Skip to content

Commit

Permalink
feat: support for SNS (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
totalimmersion authored Oct 16, 2023
1 parent 52de99c commit 9a4bdfb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
ChannelSort,
ChannelStateOptions,
CheckPushResponse,
CheckSNSResponse,
CheckSQSResponse,
Configs,
ConnectAPIResponse,
Expand Down Expand Up @@ -147,6 +148,7 @@ import {
TaskStatus,
TestCampaignResponse,
TestPushDataInput,
TestSNSDataInput,
TestSQSDataInput,
TokenOrProvider,
UnBanUserOptions,
Expand Down Expand Up @@ -715,6 +717,20 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
return await this.post<CheckSQSResponse>(this.baseURL + '/check_sqs', data);
}

/**
* testSNSSettings - Tests that the given or configured SNS configuration is valid
*
* @param {TestSNSDataInput} [data] Overrides SNS settings for testing if needed
* IE: {
sns_key: 'auth_key',
sns_secret: 'auth_secret',
sns_topic_arn: 'topic_to_publish_to',
}
*/
async testSNSSettings(data: TestSNSDataInput = {}) {
return await this.post<CheckSNSResponse>(this.baseURL + '/check_sns', data);
}

/**
* Disconnects the websocket and removes the user from client.
*
Expand Down
18 changes: 18 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ export type AppSettingsAPIResponse<StreamChatGenerics extends ExtendableGenerics
};
revoke_tokens_issued_before?: string | null;
search_backend?: 'disabled' | 'elasticsearch' | 'postgres';
sns_key?: string;
sns_secret?: string;
sns_topic_arn?: string;
sqs_key?: string;
sqs_secret?: string;
sqs_url?: string;
Expand Down Expand Up @@ -344,6 +347,12 @@ export type CheckSQSResponse = APIResponse & {
error?: string;
};

export type CheckSNSResponse = APIResponse & {
status: string;
data?: {};
error?: string;
};

export type CommandResponse<
StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
> = Partial<CreatedAtUpdatedAt> & {
Expand Down Expand Up @@ -1617,6 +1626,9 @@ export type AppSettings = {
};
reminders_interval?: number;
revoke_tokens_issued_before?: string | null;
sns_key?: string;
sns_secret?: string;
sns_topic_arn?: string;
sqs_key?: string;
sqs_secret?: string;
sqs_url?: string;
Expand Down Expand Up @@ -2240,6 +2252,12 @@ export type TestSQSDataInput = {
sqs_url?: string;
};

export type TestSNSDataInput = {
sns_key?: string;
sns_secret?: string;
sns_topic_arn?: string;
};

export type TokenOrProvider = null | string | TokenProvider | undefined;

export type TokenProvider = () => Promise<string>;
Expand Down

0 comments on commit 9a4bdfb

Please sign in to comment.