@stream-io/node-sdk 0.8.14 → 0.9.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.
@@ -0,0 +1,22 @@
1
+ import type { TimestampNS } from './index';
2
+ /**
3
+ * Makes `new Date(ns)` a deprecated constructor, and a compile error for a server-sent nanosecond timestamp.
4
+ *
5
+ * Any tsconfig whose `include` covers this directory picks this file up; `exclude` it to defer.
6
+ *
7
+ * The `0 extends 1 & T` guard excludes `any`. Without it this overload would capture
8
+ * every `new Date(<any>)` in the program -- `any` is assignable to the brand, and a
9
+ * merged declaration is tried before lib.es5.d.ts -- breaking each `JSON.parse` path
10
+ * and index-signature read on the next regeneration.
11
+ */
12
+ declare global {
13
+ interface DateConstructor {
14
+ /**
15
+ * @deprecated Unix nanoseconds, not milliseconds. Use SDK's provided nsToDate(t), or nsToMs(t) for arithmetic.
16
+ */
17
+ new <T extends TimestampNS>(t: 0 extends 1 & T ? never : T): {
18
+ readonly ERROR_use_SDKs_nsToDate_helper_instead: never;
19
+ };
20
+ }
21
+ }
22
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ApiClient, StreamResponse } from '../../gen-imports';
2
- import { AnalyzeRequest, AnalyzeResponse, AppealRequest, AppealResponse, BanRequest, BulkActionAppealsRequest, BulkActionAppealsResponse, BulkDeleteActionConfigRequest, BulkDeleteActionConfigResponse, BulkImageModerationRequest, BulkImageModerationResponse, BulkUpsertActionConfigRequest, BulkUpsertActionConfigResponse, BypassRequest, BypassResponse, CheckRequest, CheckResponse, CheckS3AccessRequest, CheckS3AccessResponse, CreatePolicyTestSetRequest, CreateQueueRequest, CustomCheckRequest, CustomCheckResponse, DeleteActionConfigResponse, DeleteModerationConfigResponse, DeleteModerationRuleResponse, DeleteModerationTemplateResponse, DeleteQueueRequest, FlagItemResponse, FlagRequest, GetActionConfigResponse, GetAppealResponse, GetConfigResponse, GetFlagCountRequest, GetFlagCountResponse, GetModerationRuleResponse, GetReviewQueueItemResponse, GetSetupSessionResponse, InsertActionLogRequest, InsertActionLogResponse, LabelsRequest, LabelsResponse, ListQueuesResponse, ModerationBanResponse, MuteRequest, MuteResponse, PolicyTestRunResponse, PolicyTestSetListResponse, PolicyTestSetResponse, QueryAppealsRequest, QueryAppealsResponse, QueryFeedModerationTemplatesResponse, QueryLabelResultsRequest, QueryLabelResultsResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryModerationFlagsRequest, QueryModerationFlagsResponse, QueryModerationLogsRequest, QueryModerationLogsResponse, QueryModerationRulesRequest, QueryModerationRulesResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, QueueResponse, Response, SubmitActionRequest, SubmitActionResponse, SubmitModerationFeedbackRequest, SubmitModerationFeedbackResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpdateQueueRequest, UpsertActionConfigRequest, UpsertActionConfigResponse, UpsertConfigRequest, UpsertConfigResponse, UpsertModerationRuleRequest, UpsertModerationRuleResponse, UpsertModerationTemplateRequest, UpsertModerationTemplateResponse, UpsertSetupSessionRequest, UpsertSetupSessionResponse } from '../models';
2
+ import { AnalyzeRequest, AnalyzeResponse, AppealRequest, AppealResponse, BanRequest, BulkActionAppealsRequest, BulkActionAppealsResponse, BulkDeleteActionConfigRequest, BulkDeleteActionConfigResponse, BulkImageModerationRequest, BulkImageModerationResponse, BulkUpsertActionConfigRequest, BulkUpsertActionConfigResponse, BypassRequest, BypassResponse, CheckRequest, CheckResponse, CheckS3AccessRequest, CheckS3AccessResponse, CreatePolicyTestSetRequest, CreateQueueRequest, CustomCheckRequest, CustomCheckResponse, DeleteActionConfigResponse, DeleteModerationConfigResponse, DeleteModerationRuleResponse, DeleteModerationTemplateResponse, DeleteQueueRequest, FlagItemResponse, FlagRequest, GetActionConfigResponse, GetAppealResponse, GetConfigResponse, GetFlagCountRequest, GetFlagCountResponse, GetModerationRuleResponse, GetReviewQueueItemResponse, GetSetupSessionResponse, InsertActionLogRequest, InsertActionLogResponse, LabelsRequest, LabelsResponse, ListQueuesResponse, ModerationBanResponse, MuteRequest, MuteResponse, PolicyTestRunResponse, PolicyTestSetListResponse, PolicyTestSetResponse, QueryAppealsRequest, QueryAppealsResponse, QueryFeedModerationTemplatesResponse, QueryLabelResultsRequest, QueryLabelResultsResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryModerationFeedbackRequest, QueryModerationFeedbackResponse, QueryModerationFlagsRequest, QueryModerationFlagsResponse, QueryModerationLogsRequest, QueryModerationLogsResponse, QueryModerationRulesRequest, QueryModerationRulesResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, QueueResponse, Response, RevealMediaRequest, RevealMediaResponse, SubmitActionRequest, SubmitActionResponse, SubmitModerationFeedbackRequest, SubmitModerationFeedbackResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpdateQueueRequest, UpsertActionConfigRequest, UpsertActionConfigResponse, UpsertConfigRequest, UpsertConfigResponse, UpsertModerationRuleRequest, UpsertModerationRuleResponse, UpsertModerationTemplateRequest, UpsertModerationTemplateResponse, UpsertSetupSessionRequest, UpsertSetupSessionResponse } from '../models';
3
3
  export declare class ModerationApi {
4
4
  readonly apiClient: ApiClient;
5
5
  constructor(apiClient: ApiClient);
@@ -42,7 +42,10 @@ export declare class ModerationApi {
42
42
  }): Promise<StreamResponse<GetConfigResponse>>;
43
43
  queryModerationConfigs(request?: QueryModerationConfigsRequest): Promise<StreamResponse<QueryModerationConfigsResponse>>;
44
44
  customCheck(request: CustomCheckRequest): Promise<StreamResponse<CustomCheckResponse>>;
45
- v2DeleteTemplate(): Promise<StreamResponse<DeleteModerationTemplateResponse>>;
45
+ queryModerationFeedback(request?: QueryModerationFeedbackRequest): Promise<StreamResponse<QueryModerationFeedbackResponse>>;
46
+ v2DeleteTemplate(request?: {
47
+ name?: string;
48
+ }): Promise<StreamResponse<DeleteModerationTemplateResponse>>;
46
49
  v2QueryTemplates(): Promise<StreamResponse<QueryFeedModerationTemplatesResponse>>;
47
50
  v2UpsertTemplate(request: UpsertModerationTemplateRequest): Promise<StreamResponse<UpsertModerationTemplateResponse>>;
48
51
  flag(request: FlagRequest): Promise<StreamResponse<FlagItemResponse>>;
@@ -64,7 +67,10 @@ export declare class ModerationApi {
64
67
  getPolicyTestRun(request: {
65
68
  id: string;
66
69
  }): Promise<StreamResponse<PolicyTestRunResponse>>;
67
- listPolicyTestSets(): Promise<StreamResponse<PolicyTestSetListResponse>>;
70
+ listPolicyTestSets(request?: {
71
+ limit?: number;
72
+ offset?: number;
73
+ }): Promise<StreamResponse<PolicyTestSetListResponse>>;
68
74
  createPolicyTestSet(request: CreatePolicyTestSetRequest): Promise<StreamResponse<PolicyTestSetResponse>>;
69
75
  deletePolicyTestSet(request: {
70
76
  id: string;
@@ -89,6 +95,7 @@ export declare class ModerationApi {
89
95
  deleteQueue(request: DeleteQueueRequest & {
90
96
  id: string;
91
97
  }): Promise<StreamResponse<QueueResponse>>;
98
+ revealMedia(request: RevealMediaRequest): Promise<StreamResponse<RevealMediaResponse>>;
92
99
  queryReviewQueue(request?: QueryReviewQueueRequest): Promise<StreamResponse<QueryReviewQueueResponse>>;
93
100
  getReviewQueueItem(request: {
94
101
  id: string;
@@ -96,7 +103,7 @@ export declare class ModerationApi {
96
103
  getSetupSession(): Promise<StreamResponse<GetSetupSessionResponse>>;
97
104
  upsertSetupSession(request: UpsertSetupSessionRequest): Promise<StreamResponse<UpsertSetupSessionResponse>>;
98
105
  submitAction(request: SubmitActionRequest): Promise<StreamResponse<SubmitActionResponse>>;
99
- submitModerationFeedback(request: SubmitModerationFeedbackRequest): Promise<StreamResponse<SubmitModerationFeedbackResponse>>;
106
+ submitModerationFeedback(request?: SubmitModerationFeedbackRequest): Promise<StreamResponse<SubmitModerationFeedbackResponse>>;
100
107
  unban(request: UnbanRequest & {
101
108
  target_user_id: string;
102
109
  channel_cid?: string;
@@ -1,5 +1,5 @@
1
1
  import { StreamResponse, VideoApi } from '../../gen-imports';
2
- import { BlockUserRequest, BlockUserResponse, CollectUserFeedbackRequest, CollectUserFeedbackResponse, DeleteCallRequest, DeleteCallResponse, DeleteRecordingResponse, DeleteTranscriptionResponse, EndCallResponse, GetCallParticipantSessionMetricsResponse, GetCallReportResponse, GetCallResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, KickUserRequest, KickUserResponse, ListRecordingsResponse, ListTranscriptionsResponse, MuteUsersRequest, MuteUsersResponse, PinRequest, PinResponse, QueryCallParticipantSessionsResponse, QueryCallParticipantsRequest, QueryCallParticipantsResponse, RingCallRequest, RingCallResponse, SendCallEventRequest, SendCallEventResponse, SendClosedCaptionRequest, SendClosedCaptionResponse, StartClosedCaptionsRequest, StartClosedCaptionsResponse, StartFrameRecordingRequest, StartFrameRecordingResponse, StartHLSBroadcastingResponse, StartRTMPBroadcastsRequest, StartRTMPBroadcastsResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopAllRTMPBroadcastsResponse, StopClosedCaptionsRequest, StopClosedCaptionsResponse, StopFrameRecordingResponse, StopHLSBroadcastingResponse, StopLiveRequest, StopLiveResponse, StopRTMPBroadcastsRequest, StopRTMPBroadcastsResponse, StopRecordingRequest, StopRecordingResponse, StopTranscriptionRequest, StopTranscriptionResponse, UnblockUserRequest, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from '../models';
2
+ import { BlockUserRequest, BlockUserResponse, CollectUserFeedbackRequest, CollectUserFeedbackResponse, DeleteCallRequest, DeleteCallResponse, DeleteRecordingResponse, DeleteTranscriptionResponse, EndCallResponse, GetCallParticipantSessionMetricsResponse, GetCallReportResponse, GetCallResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, KickUserRequest, KickUserResponse, ListRecordingsResponse, ListTranscriptionsResponse, MuteUsersRequest, MuteUsersResponse, PinRequest, PinResponse, QueryCallParticipantSessionsResponse, QueryCallParticipantsRequest, QueryCallParticipantsResponse, RecordingType, RingCallRequest, RingCallResponse, SendCallEventRequest, SendCallEventResponse, SendClosedCaptionRequest, SendClosedCaptionResponse, StartClosedCaptionsRequest, StartClosedCaptionsResponse, StartFrameRecordingRequest, StartFrameRecordingResponse, StartHLSBroadcastingResponse, StartRTMPBroadcastsRequest, StartRTMPBroadcastsResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopAllRTMPBroadcastsResponse, StopClosedCaptionsRequest, StopClosedCaptionsResponse, StopFrameRecordingResponse, StopHLSBroadcastingResponse, StopLiveRequest, StopLiveResponse, StopRTMPBroadcastsRequest, StopRTMPBroadcastsResponse, StopRecordingRequest, StopRecordingResponse, StopTranscriptionRequest, StopTranscriptionResponse, UnblockUserRequest, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from '../models';
3
3
  export declare class CallApi {
4
4
  protected videoApi: VideoApi;
5
5
  readonly type: string;
@@ -29,10 +29,10 @@ export declare class CallApi {
29
29
  videoPin(request: PinRequest): Promise<StreamResponse<PinResponse>>;
30
30
  listRecordings(): Promise<StreamResponse<ListRecordingsResponse>>;
31
31
  startRecording(request: StartRecordingRequest & {
32
- recording_type: string;
32
+ recording_type: RecordingType;
33
33
  }): Promise<StreamResponse<StartRecordingResponse>>;
34
34
  stopRecording(request: StopRecordingRequest & {
35
- recording_type: string;
35
+ recording_type: RecordingType;
36
36
  }): Promise<StreamResponse<StopRecordingResponse>>;
37
37
  getCallReport(request?: {
38
38
  session_id?: string;
@@ -1,5 +1,5 @@
1
1
  import { ApiClient, StreamResponse } from '../../gen-imports';
2
- import { BlockUserRequest, BlockUserResponse, CollectUserFeedbackRequest, CollectUserFeedbackResponse, CreateCallTypeRequest, CreateCallTypeResponse, CreateSIPTrunkRequest, CreateSIPTrunkResponse, DeleteCallRequest, DeleteCallResponse, DeleteRecordingResponse, DeleteSIPInboundRoutingRuleResponse, DeleteSIPTrunkResponse, DeleteTranscriptionResponse, EndCallResponse, GetActiveCallsStatusResponse, GetCallParticipantSessionMetricsResponse, GetCallReportResponse, GetCallResponse, GetCallSessionParticipantStatsDetailsResponse, GetCallTypeResponse, GetDailyDigestResponse, GetEdgesResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, KickUserRequest, KickUserResponse, ListCallTypeResponse, ListRecordingsResponse, ListSIPInboundRoutingRuleResponse, ListSIPTrunksResponse, ListTranscriptionsResponse, MuteUsersRequest, MuteUsersResponse, PinRequest, PinResponse, QueryAggregateCallStatsRequest, QueryAggregateCallStatsResponse, QueryCallMembersRequest, QueryCallMembersResponse, QueryCallParticipantSessionsResponse, QueryCallParticipantsRequest, QueryCallParticipantsResponse, QueryCallRingAttemptsRequest, QueryCallRingAttemptsResponse, QueryCallSessionParticipantStatsResponse, QueryCallSessionParticipantStatsTimelineResponse, QueryCallSessionStatsRequest, QueryCallSessionStatsResponse, QueryCallStatsMapResponse, QueryCallStatsRequest, QueryCallStatsResponse, QueryCallsRequest, QueryCallsResponse, QueryUserFeedbackRequest, QueryUserFeedbackResponse, ReportClientEventRequest, ReportClientEventResponse, ResolveSipAuthRequest, ResolveSipAuthResponse, ResolveSipInboundRequest, ResolveSipInboundResponse, Response, RingCallRequest, RingCallResponse, SIPInboundRoutingRuleRequest, SIPInboundRoutingRuleResponse, SendCallEventRequest, SendCallEventResponse, SendClosedCaptionRequest, SendClosedCaptionResponse, SortParamRequest, StartClosedCaptionsRequest, StartClosedCaptionsResponse, StartFrameRecordingRequest, StartFrameRecordingResponse, StartHLSBroadcastingResponse, StartRTMPBroadcastsRequest, StartRTMPBroadcastsResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopAllRTMPBroadcastsResponse, StopClosedCaptionsRequest, StopClosedCaptionsResponse, StopFrameRecordingResponse, StopHLSBroadcastingResponse, StopLiveRequest, StopLiveResponse, StopRTMPBroadcastsRequest, StopRTMPBroadcastsResponse, StopRecordingRequest, StopRecordingResponse, StopTranscriptionRequest, StopTranscriptionResponse, UnblockUserRequest, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateCallTypeRequest, UpdateCallTypeResponse, UpdateSIPInboundRoutingRuleRequest, UpdateSIPInboundRoutingRuleResponse, UpdateSIPTrunkRequest, UpdateSIPTrunkResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from '../models';
2
+ import { BlockUserRequest, BlockUserResponse, CollectUserFeedbackRequest, CollectUserFeedbackResponse, CreateCallTypeRequest, CreateCallTypeResponse, CreateSIPTrunkRequest, CreateSIPTrunkResponse, DeleteCallRequest, DeleteCallResponse, DeleteRecordingResponse, DeleteSIPInboundRoutingRuleResponse, DeleteSIPTrunkResponse, DeleteTranscriptionResponse, EndCallResponse, GetActiveCallsStatusResponse, GetCallParticipantSessionMetricsResponse, GetCallReportResponse, GetCallResponse, GetCallSessionParticipantStatsDetailsResponse, GetCallTypeResponse, GetDailyDigestResponse, GetEdgesResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, KickUserRequest, KickUserResponse, ListCallTypeResponse, ListRecordingsResponse, ListSIPInboundRoutingRuleResponse, ListSIPTrunksResponse, ListTranscriptionsResponse, MuteUsersRequest, MuteUsersResponse, PinRequest, PinResponse, QueryAggregateCallStatsRequest, QueryAggregateCallStatsResponse, QueryCallMembersRequest, QueryCallMembersResponse, QueryCallParticipantSessionsResponse, QueryCallParticipantsRequest, QueryCallParticipantsResponse, QueryCallRingAttemptsRequest, QueryCallRingAttemptsResponse, QueryCallSessionParticipantStatsResponse, QueryCallSessionParticipantStatsTimelineResponse, QueryCallSessionStatsRequest, QueryCallSessionStatsResponse, QueryCallStatsMapResponse, QueryCallStatsRequest, QueryCallStatsResponse, QueryCallsRequest, QueryCallsResponse, QueryUserFeedbackRequest, QueryUserFeedbackResponse, RecordingType, ReportClientEventRequest, ReportClientEventResponse, ResolveSipAuthRequest, ResolveSipAuthResponse, ResolveSipInboundRequest, ResolveSipInboundResponse, Response, RingCallRequest, RingCallResponse, SIPInboundRoutingRuleRequest, SIPInboundRoutingRuleResponse, SendCallEventRequest, SendCallEventResponse, SendClosedCaptionRequest, SendClosedCaptionResponse, SortParamRequest, StartClosedCaptionsRequest, StartClosedCaptionsResponse, StartFrameRecordingRequest, StartFrameRecordingResponse, StartHLSBroadcastingResponse, StartRTMPBroadcastsRequest, StartRTMPBroadcastsResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopAllRTMPBroadcastsResponse, StopClosedCaptionsRequest, StopClosedCaptionsResponse, StopFrameRecordingResponse, StopHLSBroadcastingResponse, StopLiveRequest, StopLiveResponse, StopRTMPBroadcastsRequest, StopRTMPBroadcastsResponse, StopRecordingRequest, StopRecordingResponse, StopTranscriptionRequest, StopTranscriptionResponse, UnblockUserRequest, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateCallTypeRequest, UpdateCallTypeResponse, UpdateSIPInboundRoutingRuleRequest, UpdateSIPInboundRoutingRuleResponse, UpdateSIPTrunkRequest, UpdateSIPTrunkResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from '../models';
3
3
  export declare class VideoApi {
4
4
  readonly apiClient: ApiClient;
5
5
  constructor(apiClient: ApiClient);
@@ -82,12 +82,12 @@ export declare class VideoApi {
82
82
  startRecording(request: StartRecordingRequest & {
83
83
  type: string;
84
84
  id: string;
85
- recording_type: string;
85
+ recording_type: RecordingType;
86
86
  }): Promise<StreamResponse<StartRecordingResponse>>;
87
87
  stopRecording(request: StopRecordingRequest & {
88
88
  type: string;
89
89
  id: string;
90
- recording_type: string;
90
+ recording_type: RecordingType;
91
91
  }): Promise<StreamResponse<StopRecordingResponse>>;
92
92
  getCallReport(request: {
93
93
  type: string;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Unit conversions between the API's timestamps and JavaScript's.
3
+ *
4
+ * **The invariant this module exists to hold:** a timestamp is a unix-**nanosecond** `number` —
5
+ * that is what the API puts on the wire and what every server-sent date field on a generated
6
+ * response or event type carries. A duration, interval or delay stays in **milliseconds**, because
7
+ * that is what `setTimeout` and `ApiConfig.timeout` speak.
8
+ *
9
+ * Two consequences make the helpers below mandatory rather than convenient:
10
+ *
11
+ * - **Every `Date`-based path is out of range.** `Date` tops out around 8.64e15 ms while a current
12
+ * nanosecond timestamp is ~1.79e18, so a bare wire number read as milliseconds lands on an
13
+ * invalid instance: `new Date(ns).toISOString()` throws `RangeError`, and a date library handed
14
+ * the same number formats it as the literal string `'Invalid Date'`. Neither is a type error.
15
+ * - **A unit mix-up between two `number`s is the silent one.** Comparing a wire timestamp against
16
+ * `Date.now()`, or adding a millisecond duration to one, produces a plausible-looking number and
17
+ * no complaint at all.
18
+ *
19
+ * Outgoing **request** date fields are unaffected: they are still typed `Date`, because
20
+ * `JSON.stringify` emits RFC3339 for a `Date` and that is the format the request spec declares.
21
+ * Use {@link nsToDate} when handing a server-sent timestamp back to the API.
22
+ *
23
+ * Precision note: nanosecond epoch values exceed `Number.MAX_SAFE_INTEGER` (~9.01e15), so they are
24
+ * quantised to roughly 256 ns steps. Ordering is unaffected; exact equality against a value that
25
+ * has round-tripped through JSON is not guaranteed.
26
+ */
27
+ /** Nanoseconds per millisecond — the only magic number in this module. */
28
+ export declare const NS_PER_MS = 1000000;
29
+ /** A wire timestamp as epoch milliseconds, for arithmetic against `Date.now()` or a `Date`. */
30
+ export declare const nsToMs: (ns: number) => number;
31
+ /** Epoch milliseconds as a wire timestamp. */
32
+ export declare const msToNs: (ms: number) => number;
33
+ /**
34
+ * The local clock as a wire-comparable timestamp, for building API-shaped objects.
35
+ *
36
+ * Millisecond resolution, so two calls within the same millisecond produce equal timestamps.
37
+ * Callers that order by timestamp must tie-break on something else.
38
+ */
39
+ export declare const nowNs: () => number;
40
+ /** A wire timestamp as a `Date`, for request payloads and date libraries. */
41
+ export declare const nsToDate: (ns: number) => Date;
42
+ /**
43
+ * A wire timestamp as a nanosecond-precision RFC3339 string, for an outgoing request date field.
44
+ * {@link nsToDate} is lossy here — `Date` holds only milliseconds.
45
+ */
46
+ export declare const nsToRfc3339: (ns: number) => string;
47
+ /** A `Date` as a wire timestamp. */
48
+ export declare const dateToNs: (date: Date) => number;
49
+ /**
50
+ * A server-sent timestamp as a `Date`, or `undefined` when there is none.
51
+ *
52
+ * The guarded companion to {@link nsToDate}, for the boundary where a wire timestamp becomes
53
+ * something a date library or a caller consumes. Use {@link nsToDate} when the value is known to
54
+ * be present; use this when it comes straight off a response, an event or persisted state.
55
+ *
56
+ * The guard is the whole point, and it covers two cases that are silent rather than loud:
57
+ *
58
+ * - **Absent.** Many timestamps are optional in practice even where the generated type marks them
59
+ * required. `nsToDate(undefined as never)` yields an `Invalid Date`, and `.toISOString()` on one
60
+ * throws `RangeError: Invalid time value`.
61
+ * - **Not finite.** A malformed payload or a hand-built fixture can produce `NaN`, which reaches
62
+ * the same `RangeError` by a different route.
63
+ *
64
+ * Returning `undefined` rather than throwing lets a caller fall back to whatever it already does
65
+ * for a missing timestamp.
66
+ */
67
+ export declare const convertTimestampToDate: (timestamp?: number | null) => Date | undefined;
package/index.ts CHANGED
@@ -11,4 +11,14 @@ export {
11
11
  InvalidWebhookErrorMessages,
12
12
  verifyAndParseWebhook,
13
13
  } from './src/utils/webhook';
14
+ export {
15
+ convertTimestampToDate,
16
+ dateToNs,
17
+ msToNs,
18
+ nowNs,
19
+ NS_PER_MS,
20
+ nsToDate,
21
+ nsToMs,
22
+ nsToRfc3339,
23
+ } from './src/utils/time';
14
24
  export { StreamError } from './src/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/node-sdk",
3
- "version": "0.8.14",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -4,6 +4,10 @@ import {
4
4
  ChannelStateResponse,
5
5
  DeleteChannelResponse,
6
6
  EventResponse,
7
+ ForkChannelRequest,
8
+ ForkChannelResponse,
9
+ ForkMessageIDsRequest,
10
+ ForkMessageIDsResponse,
7
11
  GetDraftResponse,
8
12
  GetManyMessagesResponse,
9
13
  GetPinnedMessagesResponse,
@@ -15,6 +19,8 @@ import {
15
19
  QueryChannelBansRequest,
16
20
  QueryChannelBansResponse,
17
21
  Response,
22
+ RewindChannelRequest,
23
+ RewindChannelResponse,
18
24
  SendEventRequest,
19
25
  SendMessageRequest,
20
26
  SendMessageResponse,
@@ -204,6 +210,38 @@ export class ChannelApi {
204
210
  });
205
211
  }
206
212
 
213
+ fork(
214
+ request: ForkChannelRequest,
215
+ ): Promise<StreamResponse<ForkChannelResponse>> {
216
+ if (!this.id) {
217
+ throw new Error(
218
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
219
+ );
220
+ }
221
+
222
+ return this.chatApi.forkChannel({
223
+ id: this.id,
224
+ type: this.type,
225
+ ...request,
226
+ });
227
+ }
228
+
229
+ forkMessageIDs(
230
+ request: ForkMessageIDsRequest,
231
+ ): Promise<StreamResponse<ForkMessageIDsResponse>> {
232
+ if (!this.id) {
233
+ throw new Error(
234
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
235
+ );
236
+ }
237
+
238
+ return this.chatApi.forkMessageIDs({
239
+ id: this.id,
240
+ type: this.type,
241
+ ...request,
242
+ });
243
+ }
244
+
207
245
  hide(
208
246
  request?: HideChannelRequest,
209
247
  ): Promise<StreamResponse<HideChannelResponse>> {
@@ -359,6 +397,22 @@ export class ChannelApi {
359
397
  return this.chatApi.markRead({ id: this.id, type: this.type, ...request });
360
398
  }
361
399
 
400
+ rewind(
401
+ request: RewindChannelRequest,
402
+ ): Promise<StreamResponse<RewindChannelResponse>> {
403
+ if (!this.id) {
404
+ throw new Error(
405
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
406
+ );
407
+ }
408
+
409
+ return this.chatApi.rewindChannel({
410
+ id: this.id,
411
+ type: this.type,
412
+ ...request,
413
+ });
414
+ }
415
+
362
416
  show(
363
417
  request?: ShowChannelRequest,
364
418
  ): Promise<StreamResponse<ShowChannelResponse>> {
@@ -23,6 +23,8 @@ import {
23
23
  DeleteChannelsRequest,
24
24
  DeleteChannelsResponse,
25
25
  DeleteCommandResponse,
26
+ DeleteHistoryWindowTeamsRequest,
27
+ DeleteHistoryWindowTeamsResponse,
26
28
  DeleteMessageResponse,
27
29
  DeleteReactionResponse,
28
30
  DeleteReminderResponse,
@@ -33,10 +35,15 @@ import {
33
35
  EventResponse,
34
36
  ExportChannelsRequest,
35
37
  ExportChannelsResponse,
38
+ ForkChannelRequest,
39
+ ForkChannelResponse,
40
+ ForkMessageIDsRequest,
41
+ ForkMessageIDsResponse,
36
42
  GetCampaignResponse,
37
43
  GetChannelTypeResponse,
38
44
  GetCommandResponse,
39
45
  GetDraftResponse,
46
+ GetHistoryWindowTeamsResponse,
40
47
  GetManyMessagesResponse,
41
48
  GetMessageResponse,
42
49
  GetPinnedMessagesResponse,
@@ -74,6 +81,8 @@ import {
74
81
  QueryChannelBansResponse,
75
82
  QueryChannelsRequest,
76
83
  QueryChannelsResponse,
84
+ QueryDeletedChannelsRequest,
85
+ QueryDeletedChannelsResponse,
77
86
  QueryDraftsRequest,
78
87
  QueryDraftsResponse,
79
88
  QueryFutureChannelBansPayload,
@@ -99,6 +108,8 @@ import {
99
108
  QueryThreadsRequest,
100
109
  QueryThreadsResponse,
101
110
  Response,
111
+ RewindChannelRequest,
112
+ RewindChannelResponse,
102
113
  SearchPayload,
103
114
  SearchResponse,
104
115
  SendEventRequest,
@@ -108,6 +119,8 @@ import {
108
119
  SendReactionResponse,
109
120
  SendScheduledMessageNowResponse,
110
121
  SendUserCustomEventRequest,
122
+ SetHistoryWindowTeamsRequest,
123
+ SetHistoryWindowTeamsResponse,
111
124
  SetRetentionPolicyRequest,
112
125
  SetRetentionPolicyResponse,
113
126
  ShowChannelRequest,
@@ -429,6 +442,31 @@ export class ChatApi {
429
442
  return response;
430
443
  }
431
444
 
445
+ async queryDeletedChannels(
446
+ request?: QueryDeletedChannelsRequest,
447
+ ): Promise<StreamResponse<QueryDeletedChannelsResponse>> {
448
+ const body = {
449
+ limit: request?.limit,
450
+ next: request?.next,
451
+ prev: request?.prev,
452
+ sort: request?.sort,
453
+ filter_conditions: request?.filter_conditions,
454
+ };
455
+
456
+ const response =
457
+ await this.apiClient.sendRequest<QueryDeletedChannelsResponse>(
458
+ 'POST',
459
+ '/api/v2/chat/channels/deleted',
460
+ undefined,
461
+ undefined,
462
+ body,
463
+ );
464
+
465
+ decoders['QueryDeletedChannelsResponse']?.(response);
466
+
467
+ return response;
468
+ }
469
+
432
470
  async markDelivered(
433
471
  request?: MarkDeliveredRequest & { user_id?: string },
434
472
  ): Promise<StreamResponse<MarkDeliveredResponse>> {
@@ -507,6 +545,7 @@ export class ChatApi {
507
545
  };
508
546
  const body = {
509
547
  hide_for_creator: request?.hide_for_creator,
548
+ include_scheduled_messages: request?.include_scheduled_messages,
510
549
  state: request?.state,
511
550
  thread_unread_counts: request?.thread_unread_counts,
512
551
  member_custom_include: request?.member_custom_include,
@@ -829,6 +868,60 @@ export class ChatApi {
829
868
  return response;
830
869
  }
831
870
 
871
+ async forkChannel(
872
+ request: ForkChannelRequest & { type: string; id: string },
873
+ ): Promise<StreamResponse<ForkChannelResponse>> {
874
+ const pathParams = {
875
+ type: request?.type,
876
+ id: request?.id,
877
+ };
878
+ const body = {
879
+ message_id: request?.message_id,
880
+ channel: request?.channel,
881
+ exclude_attachments: request?.exclude_attachments,
882
+ user_id: request?.user_id,
883
+ user: request?.user,
884
+ };
885
+
886
+ const response = await this.apiClient.sendRequest<ForkChannelResponse>(
887
+ 'POST',
888
+ '/api/v2/chat/channels/{type}/{id}/fork',
889
+ pathParams,
890
+ undefined,
891
+ body,
892
+ );
893
+
894
+ decoders['ForkChannelResponse']?.(response);
895
+
896
+ return response;
897
+ }
898
+
899
+ async forkMessageIDs(
900
+ request: ForkMessageIDsRequest & { type: string; id: string },
901
+ ): Promise<StreamResponse<ForkMessageIDsResponse>> {
902
+ const pathParams = {
903
+ type: request?.type,
904
+ id: request?.id,
905
+ };
906
+ const body = {
907
+ source_message_ids: request?.source_message_ids,
908
+ user_id: request?.user_id,
909
+ user: request?.user,
910
+ };
911
+
912
+ const response = await this.apiClient.sendRequest<ForkMessageIDsResponse>(
913
+ 'POST',
914
+ '/api/v2/chat/channels/{type}/{id}/fork/message_ids',
915
+ pathParams,
916
+ undefined,
917
+ body,
918
+ );
919
+
920
+ decoders['ForkMessageIDsResponse']?.(response);
921
+
922
+ return response;
923
+ }
924
+
832
925
  async hideChannel(
833
926
  request: HideChannelRequest & { type: string; id: string },
834
927
  ): Promise<StreamResponse<HideChannelResponse>> {
@@ -1063,6 +1156,7 @@ export class ChatApi {
1063
1156
  };
1064
1157
  const body = {
1065
1158
  hide_for_creator: request?.hide_for_creator,
1159
+ include_scheduled_messages: request?.include_scheduled_messages,
1066
1160
  state: request?.state,
1067
1161
  thread_unread_counts: request?.thread_unread_counts,
1068
1162
  member_custom_include: request?.member_custom_include,
@@ -1112,6 +1206,34 @@ export class ChatApi {
1112
1206
  return response;
1113
1207
  }
1114
1208
 
1209
+ async rewindChannel(
1210
+ request: RewindChannelRequest & { type: string; id: string },
1211
+ ): Promise<StreamResponse<RewindChannelResponse>> {
1212
+ const pathParams = {
1213
+ type: request?.type,
1214
+ id: request?.id,
1215
+ };
1216
+ const body = {
1217
+ expected_last_message_id: request?.expected_last_message_id,
1218
+ message_id: request?.message_id,
1219
+ inclusive: request?.inclusive,
1220
+ user_id: request?.user_id,
1221
+ user: request?.user,
1222
+ };
1223
+
1224
+ const response = await this.apiClient.sendRequest<RewindChannelResponse>(
1225
+ 'POST',
1226
+ '/api/v2/chat/channels/{type}/{id}/rewind',
1227
+ pathParams,
1228
+ undefined,
1229
+ body,
1230
+ );
1231
+
1232
+ decoders['RewindChannelResponse']?.(response);
1233
+
1234
+ return response;
1235
+ }
1236
+
1115
1237
  async showChannel(
1116
1238
  request: ShowChannelRequest & { type: string; id: string },
1117
1239
  ): Promise<StreamResponse<ShowChannelResponse>> {
@@ -1515,6 +1637,64 @@ export class ChatApi {
1515
1637
  return response;
1516
1638
  }
1517
1639
 
1640
+ async getHistoryWindowTeams(): Promise<
1641
+ StreamResponse<GetHistoryWindowTeamsResponse>
1642
+ > {
1643
+ const response =
1644
+ await this.apiClient.sendRequest<GetHistoryWindowTeamsResponse>(
1645
+ 'GET',
1646
+ '/api/v2/chat/history_window/teams',
1647
+ undefined,
1648
+ undefined,
1649
+ );
1650
+
1651
+ decoders['GetHistoryWindowTeamsResponse']?.(response);
1652
+
1653
+ return response;
1654
+ }
1655
+
1656
+ async setHistoryWindowTeams(
1657
+ request: SetHistoryWindowTeamsRequest,
1658
+ ): Promise<StreamResponse<SetHistoryWindowTeamsResponse>> {
1659
+ const body = {
1660
+ teams: request?.teams,
1661
+ };
1662
+
1663
+ const response =
1664
+ await this.apiClient.sendRequest<SetHistoryWindowTeamsResponse>(
1665
+ 'POST',
1666
+ '/api/v2/chat/history_window/teams',
1667
+ undefined,
1668
+ undefined,
1669
+ body,
1670
+ );
1671
+
1672
+ decoders['SetHistoryWindowTeamsResponse']?.(response);
1673
+
1674
+ return response;
1675
+ }
1676
+
1677
+ async deleteHistoryWindowTeams(
1678
+ request: DeleteHistoryWindowTeamsRequest,
1679
+ ): Promise<StreamResponse<DeleteHistoryWindowTeamsResponse>> {
1680
+ const body = {
1681
+ teams: request?.teams,
1682
+ };
1683
+
1684
+ const response =
1685
+ await this.apiClient.sendRequest<DeleteHistoryWindowTeamsResponse>(
1686
+ 'POST',
1687
+ '/api/v2/chat/history_window/teams/delete',
1688
+ undefined,
1689
+ undefined,
1690
+ body,
1691
+ );
1692
+
1693
+ decoders['DeleteHistoryWindowTeamsResponse']?.(response);
1694
+
1695
+ return response;
1696
+ }
1697
+
1518
1698
  async queryMembers(request?: {
1519
1699
  payload?: QueryMembersPayload;
1520
1700
  }): Promise<StreamResponse<MembersResponse>> {
@@ -2319,6 +2499,7 @@ export class ChatApi {
2319
2499
  const body = {
2320
2500
  max_age_hours: request?.max_age_hours,
2321
2501
  policy: request?.policy,
2502
+ channel_type: request?.channel_type,
2322
2503
  };
2323
2504
 
2324
2505
  const response =
@@ -2340,6 +2521,7 @@ export class ChatApi {
2340
2521
  ): Promise<StreamResponse<DeleteRetentionPolicyResponse>> {
2341
2522
  const body = {
2342
2523
  policy: request?.policy,
2524
+ channel_type: request?.channel_type,
2343
2525
  };
2344
2526
 
2345
2527
  const response =
@@ -2810,9 +2992,11 @@ export class ChatApi {
2810
2992
 
2811
2993
  async unreadCounts(request?: {
2812
2994
  user_id?: string;
2995
+ include_large_channels?: boolean;
2813
2996
  }): Promise<StreamResponse<WrappedUnreadCountsResponse>> {
2814
2997
  const queryParams = {
2815
2998
  user_id: request?.user_id,
2999
+ include_large_channels: request?.include_large_channels,
2816
3000
  };
2817
3001
 
2818
3002
  const response =
@@ -14,6 +14,8 @@ import {
14
14
  CheckSNSResponse,
15
15
  CheckSQSRequest,
16
16
  CheckSQSResponse,
17
+ ClaimGuestUserRequest,
18
+ ClaimGuestUserResponse,
17
19
  CreateBlockListRequest,
18
20
  CreateBlockListResponse,
19
21
  CreateDeviceRequest,
@@ -76,6 +78,7 @@ import {
76
78
  PollOptionResponse,
77
79
  PollResponse,
78
80
  PollVotesResponse,
81
+ PushProviderName,
79
82
  QueryPollVotesRequest,
80
83
  QueryPollsRequest,
81
84
  QueryPollsResponse,
@@ -186,6 +189,7 @@ export class CommonApi {
186
189
  sqs_key: request?.sqs_key,
187
190
  sqs_secret: request?.sqs_secret,
188
191
  sqs_url: request?.sqs_url,
192
+ two_way_block_effect_enabled: request?.two_way_block_effect_enabled,
189
193
  user_response_time_enabled: request?.user_response_time_enabled,
190
194
  video_primary_use_case: request?.video_primary_use_case,
191
195
  webhook_url: request?.webhook_url,
@@ -1430,7 +1434,7 @@ export class CommonApi {
1430
1434
  }
1431
1435
 
1432
1436
  async deletePushProvider(request: {
1433
- type: string;
1437
+ type: PushProviderName;
1434
1438
  name: string;
1435
1439
  }): Promise<StreamResponse<Response>> {
1436
1440
  const pathParams = {
@@ -1451,7 +1455,7 @@ export class CommonApi {
1451
1455
  }
1452
1456
 
1453
1457
  async getPushTemplates(request: {
1454
- push_provider_type: string;
1458
+ push_provider_type: PushProviderName;
1455
1459
  push_provider_name?: string;
1456
1460
  }): Promise<StreamResponse<GetPushTemplatesResponse>> {
1457
1461
  const queryParams = {
@@ -2008,6 +2012,27 @@ export class CommonApi {
2008
2012
  return response;
2009
2013
  }
2010
2014
 
2015
+ async claimGuestUser(
2016
+ request: ClaimGuestUserRequest,
2017
+ ): Promise<StreamResponse<ClaimGuestUserResponse>> {
2018
+ const body = {
2019
+ guest_user_id: request?.guest_user_id,
2020
+ user_id: request?.user_id,
2021
+ };
2022
+
2023
+ const response = await this.apiClient.sendRequest<ClaimGuestUserResponse>(
2024
+ 'POST',
2025
+ '/api/v2/users/claim_guest',
2026
+ undefined,
2027
+ undefined,
2028
+ body,
2029
+ );
2030
+
2031
+ decoders['ClaimGuestUserResponse']?.(response);
2032
+
2033
+ return response;
2034
+ }
2035
+
2011
2036
  async deactivateUsers(
2012
2037
  request: DeactivateUsersRequest,
2013
2038
  ): Promise<StreamResponse<DeactivateUsersResponse>> {