Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update open api to latest version #65

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions __tests__/external-storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,48 @@ describe('external storage CRUD API', () => {

expect(response).toBeDefined();
});

it('docs snippets', async () => {
const s3name = `streamnodetest-${uuidv4()}`;
await client.createExternalStorage({
name: s3name,
storage_type: 's3',
bucket: 'my-bucket',
path: 'directory_name/',
aws_s3: {
s3_api_key: 'us-east-1',
s3_region: 'my-access-key',
s3_secret: 'my-secret',
},
});

await client.deleteExternalStorage({ name: s3name });

const gcsName = `streamnodetest-${uuidv4()}`;
await client.createExternalStorage({
bucket: 'my-bucket',
name: gcsName,
storage_type: 'gcs',
path: 'directory_name/',
gcs_credentials: 'content of the service account file',
});

await client.deleteExternalStorage({ name: gcsName });

const azureName = `streamnodetest-${uuidv4()}`;
await client.createExternalStorage({
name: azureName,
storage_type: 'abs',
bucket: 'my-bucket',
path: 'directory_name/',
azure_blob: {
abs_account_name: '...',
abs_client_id: '...',
abs_client_secret: '...',
abs_tenant_id: '...',
},
});

await client.deleteExternalStorage({ name: azureName });
});
});
227 changes: 225 additions & 2 deletions src/gen/chat/ChatApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseApi } from '../../BaseApi';
import { StreamResponse } from '../../types';
import {
CampaignResponse,
CastPollVoteRequest,
ChannelGetOrCreateRequest,
ChannelStateResponse,
Expand All @@ -16,18 +17,21 @@ import {
DeleteChannelsResponse,
DeleteCommandResponse,
DeleteMessageResponse,
DeleteSegmentTargetsRequest,
EventResponse,
ExportChannelsRequest,
ExportChannelsResponse,
FileUploadRequest,
FileUploadResponse,
GetCampaignResponse,
GetChannelTypeResponse,
GetCommandResponse,
GetExportChannelsStatusResponse,
GetManyMessagesResponse,
GetMessageResponse,
GetReactionsResponse,
GetRepliesResponse,
GetSegmentResponse,
GetThreadResponse,
HideChannelRequest,
HideChannelResponse,
Expand All @@ -50,6 +54,8 @@ import {
PollVotesResponse,
QueryBannedUsersPayload,
QueryBannedUsersResponse,
QueryCampaignsRequest,
QueryCampaignsResponse,
QueryChannelsRequest,
QueryChannelsResponse,
QueryMembersPayload,
Expand All @@ -62,6 +68,10 @@ import {
QueryPollsResponse,
QueryReactionsRequest,
QueryReactionsResponse,
QuerySegmentTargetsRequest,
QuerySegmentTargetsResponse,
QuerySegmentsRequest,
QuerySegmentsResponse,
QueryThreadsRequest,
QueryThreadsResponse,
ReactionRemovalResponse,
Expand All @@ -77,6 +87,9 @@ import {
ShowChannelRequest,
ShowChannelResponse,
SortParamRequest,
StartCampaignRequest,
StartCampaignResponse,
StopCampaignRequest,
TranslateMessageRequest,
TruncateChannelRequest,
TruncateChannelResponse,
Expand Down Expand Up @@ -108,6 +121,83 @@ import {
import { decoders } from '../model-decoders';

export class ChatApi extends BaseApi {
queryCampaigns = async (
request?: QueryCampaignsRequest,
): Promise<StreamResponse<QueryCampaignsResponse>> => {
const body = {
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
filter: request?.filter,
};

const response = await this.sendRequest<
StreamResponse<QueryCampaignsResponse>
>('POST', '/api/v2/chat/campaigns/query', undefined, undefined, body);

decoders.QueryCampaignsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

getCampaign = async (request: {
id: string;
}): Promise<StreamResponse<GetCampaignResponse>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<
StreamResponse<GetCampaignResponse>
>('GET', '/api/v2/chat/campaigns/{id}', pathParams, undefined);

decoders.GetCampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

startCampaign = async (
request: StartCampaignRequest & { id: string },
): Promise<StreamResponse<StartCampaignResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {
scheduled_for: request?.scheduled_for,
stop_at: request?.stop_at,
};

const response = await this.sendRequest<
StreamResponse<StartCampaignResponse>
>('POST', '/api/v2/chat/campaigns/{id}/start', pathParams, undefined, body);

decoders.StartCampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

scheduleCampaign = async (
request: StopCampaignRequest & { id: string },
): Promise<StreamResponse<CampaignResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {};

const response = await this.sendRequest<StreamResponse<CampaignResponse>>(
'POST',
'/api/v2/chat/campaigns/{id}/stop',
pathParams,
undefined,
body,
);

decoders.CampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

queryChannels = async (
request?: QueryChannelsRequest,
): Promise<StreamResponse<QueryChannelsResponse>> => {
Expand Down Expand Up @@ -712,6 +802,8 @@ export class ChatApi extends BaseApi {
read_events: request?.read_events,
replies: request?.replies,
search: request?.search,
skip_last_msg_update_for_system_msgs:
request?.skip_last_msg_update_for_system_msgs,
typing_events: request?.typing_events,
uploads: request?.uploads,
url_enrichment: request?.url_enrichment,
Expand Down Expand Up @@ -791,6 +883,8 @@ export class ChatApi extends BaseApi {
reminders: request?.reminders,
replies: request?.replies,
search: request?.search,
skip_last_msg_update_for_system_msgs:
request?.skip_last_msg_update_for_system_msgs,
typing_events: request?.typing_events,
uploads: request?.uploads,
url_enrichment: request?.url_enrichment,
Expand Down Expand Up @@ -1758,6 +1852,137 @@ export class ChatApi extends BaseApi {
return { ...response.body, metadata: response.metadata };
};

querySegments = async (
request: QuerySegmentsRequest,
): Promise<StreamResponse<QuerySegmentsResponse>> => {
const body = {
filter: request?.filter,
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
};

const response = await this.sendRequest<
StreamResponse<QuerySegmentsResponse>
>('POST', '/api/v2/chat/segments/query', undefined, undefined, body);

decoders.QuerySegmentsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

deleteSegment = async (request: {
id: string;
}): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'DELETE',
'/api/v2/chat/segments/{id}',
pathParams,
undefined,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

getSegment = async (request: {
id: string;
}): Promise<StreamResponse<GetSegmentResponse>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<StreamResponse<GetSegmentResponse>>(
'GET',
'/api/v2/chat/segments/{id}',
pathParams,
undefined,
);

decoders.GetSegmentResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

deleteSegmentTargets = async (
request: DeleteSegmentTargetsRequest & { id: string },
): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
};
const body = {
target_ids: request?.target_ids,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'POST',
'/api/v2/chat/segments/{id}/deletetargets',
pathParams,
undefined,
body,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

segmentTargetExists = async (request: {
id: string;
target_id: string;
}): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
target_id: request?.target_id,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'GET',
'/api/v2/chat/segments/{id}/target/{target_id}',
pathParams,
undefined,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

querySegmentTargets = async (
request: QuerySegmentTargetsRequest & { id: string },
): Promise<StreamResponse<QuerySegmentTargetsResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
filter: request?.filter,
};

const response = await this.sendRequest<
StreamResponse<QuerySegmentTargetsResponse>
>(
'POST',
'/api/v2/chat/segments/{id}/targets/query',
pathParams,
undefined,
body,
);

decoders.QuerySegmentTargetsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

queryThreads = async (
request?: QueryThreadsRequest,
): Promise<StreamResponse<QueryThreadsResponse>> => {
Expand All @@ -1783,13 +2008,11 @@ export class ChatApi extends BaseApi {

getThread = async (request: {
message_id: string;
connection_id?: string;
reply_limit?: number;
participant_limit?: number;
member_limit?: number;
}): Promise<StreamResponse<GetThreadResponse>> => {
const queryParams = {
connection_id: request?.connection_id,
reply_limit: request?.reply_limit,
participant_limit: request?.participant_limit,
member_limit: request?.member_limit,
Expand Down
Loading
Loading