Skip to content

Commit

Permalink
Merge branch 'main' into feat/apiKey-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulati09 committed Nov 21, 2024
2 parents 8423b97 + 83cbad5 commit c9581d2
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "portkey-ai",
"version": "1.5.1",
"version": "1.5.2",
"description": "Node client library for the Portkey API",
"types": "dist/src/index.d.ts",
"main": "dist/src/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export { VectorStores } from './vectorStores';
export { BetaChat } from './betaChat';
export { Uploads } from './uploads';
export { ApiKeys } from './apiKeys';
export { Logs } from './logsExport';
228 changes: 228 additions & 0 deletions src/apis/logsExport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
import { ApiResource } from '../apiResource';
import { APIResponseType, ApiClientInterface } from '../_types/generalTypes';
import { APIPromise, RequestOptions } from '../baseClient';
import { createHeaders } from './createHeaders';
import { toQueryParams } from '../utils';

export interface LogsExportCreateParams {
filters?: Record<string, any>;
workspaceId?: string;
description?: string;
requestedData?: string[];
}
export interface LogsExportCreateResponse extends APIResponseType {
id?: string;
total?: number;
object?: string;
}
export interface LogsExportListParams {
workspaceId?: string;
}
export interface LogsExportListResponse extends APIResponseType {
object?: string;
total?: number;
data?: Record<string, any>[];
}
export interface LogsExportUpdateParams {
exportId?: string;
workspaceId?: string;
filters?: Record<string, any>;
requestedData?: string[];
}
export interface LogsExportUpdateResponse extends APIResponseType {
id?: string;
total?: number;
object?: string;
}
export interface LogsExportCancelParams {
exportId?: string;
}
export interface LogsExportCancelResponse extends APIResponseType {
message?: string;
object?: string;
}
export interface LogsExportRetrieveParams {
exportId: string;
}
export interface LogsExportRetrieveResponse extends APIResponseType {
id?: string;
organisation_id?: string;
filters?: Record<string, any>;
requested_data?: string[];
status?: string;
description?: string;
created_at?: Date;
last_updated_at?: Date;
created_by?: string;
workspace_id?: string;
total_records?: number;
object?: string;
}
export interface LogsExportStartParams {
exportId?: string;
}
export interface LogsExportStartResponse extends APIResponseType {
message?: string;
object?: string;
}
export interface LogsExportDownloadParams {
exportId?: string;
}
export interface LogsExportDownloadResponse extends APIResponseType {
signed_url?: string;
}
export class Logs extends ApiResource {
exports: Exports;
constructor(client: any) {
super(client);
this.exports = new Exports(client);
}
}
export class Exports extends ApiResource {
create(
_body: LogsExportCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportCreateResponse> {
const { workspaceId, requestedData, ...rest } = _body;
const body = {
...rest,
workspace_id: workspaceId,
requested_data: requestedData,
};
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.post<LogsExportCreateResponse>('/logs/exports', {
body,
...opts,
});
return response;
}
retrieve(
_body: LogsExportRetrieveParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportRetrieveResponse> {
const body = _body;
const exportId = body.exportId;
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.getMethod<LogsExportRetrieveResponse>(
`/logs/exports/${exportId}`,
{ ...opts }
);
return response;
}
list(
_body: LogsExportListParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportListResponse> {
const { workspaceId, ...rest } = _body;
const body = {
...rest,
workspace_id: workspaceId,
};
const query = toQueryParams(body);
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.getMethod<LogsExportListResponse>(
`/logs/exports${query}`,
{ ...opts }
);
return response;
}
update(
_body: LogsExportUpdateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportUpdateResponse> {
const { workspaceId, requestedData, ...rest } = _body;
const body = {
...rest,
workspace_id: workspaceId,
requested_data: requestedData,
};
const exportId = body.exportId;
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.put<LogsExportUpdateResponse>(
`/logs/exports/${exportId}`,
{ body, ...opts }
);
return response;
}
start(
_body: LogsExportStartParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportStartResponse> {
const body = _body;
const exportId = body.exportId;
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.post<LogsExportStartResponse>(
`/logs/exports/${exportId}/start`,
{ body, ...opts }
);
return response;
}
cancel(
_body: LogsExportCancelParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportCancelResponse> {
const body = _body;
const exportId = body.exportId;
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.post<LogsExportCancelResponse>(
`/logs/exports/${exportId}/cancel`,
{ body, ...opts }
);
return response;
}
download(
_body: LogsExportDownloadParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<LogsExportDownloadResponse> {
const body = _body;
const exportId = body.exportId;
if (params) {
this.client.customHeaders = {
...this.client.customHeaders,
...createHeaders({ ...params }),
};
}
const response = this.getMethod<LogsExportDownloadResponse>(
`/logs/exports/${exportId}/download`,
{ body, ...opts }
);
return response;
}
}
2 changes: 1 addition & 1 deletion src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
if (contentType?.includes('application/json')) {
const headers = defaultParseHeaders(props);
const json = {
...(await response.json()),
...(await response.json() as any),
getHeaders: () => headers,
};

Expand Down
1 change: 1 addition & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class Portkey extends ApiClient {
virtualKeys = new API.VirtualKeys(this);
apiKeys = new API.ApiKeys(this);
configs = new API.Configs(this);
logs = new API.Logs(this);
beta = {
assistants: new API.Assistants(this),
threads: new API.Threads(this),
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { VirtualKeysListParams } from './apis/virtualKeys';
import { ApiKeysListParams } from './apis/apiKeys';
import { CongfigsListParams } from './apis/configs';
import { LogsExportListParams } from './apis/logsExport';

type PlatformProperties = {
'x-portkey-runtime'?: string;
Expand Down Expand Up @@ -162,6 +163,7 @@ export function toQueryParams(
| VirtualKeysListParams
| ApiKeysListParams
| CongfigsListParams
| LogsExportListParams|any
): string {
if (!params) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.5.1';
export const VERSION = '1.5.2';

0 comments on commit c9581d2

Please sign in to comment.