Skip to content

Commit

Permalink
fix: types for list apps
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniAkash committed Feb 28, 2024
1 parent 8ab1276 commit d77df11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/client/lister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class Lister extends BaseClient {
while (true) {
// Prepare request data
// @ts-expect-error - TS doesn't know that the method exists
requestData["page"] = page;
requestData.setPage(page);
if (perPage) {
// @ts-expect-error - TS doesn't know that the method exists
requestData["per_page"] = perPage;
requestData.setPerPage(perPage);
}

// Perform gRPC request
Expand Down
16 changes: 13 additions & 3 deletions src/client/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// import { StatusCode } from "clarifai-nodejs-grpc/proto/clarifai/api/status/status_code_pb";
import { Lister } from "./lister";
import { KWArgs } from "../utils/types";
import { ListAppsRequest } from "clarifai-nodejs-grpc/proto/clarifai/api/service_pb";
import {
ListAppsRequest,
MultiAppResponse,
} from "clarifai-nodejs-grpc/proto/clarifai/api/service_pb";
import { mapParamsToRequest, promisifyGrpcCall } from "../utils/misc";

// interface UserAppID {
Expand Down Expand Up @@ -36,12 +39,19 @@ export class User extends Lister {
| Record<string, never>;
pageNo?: number;
perPage?: number;
}) {
}): AsyncGenerator<MultiAppResponse, void, unknown> {
const listApps = promisifyGrpcCall(this.STUB.client.listApps);
const request = new ListAppsRequest();
mapParamsToRequest(params, request);

yield this.listPagesGenerator(listApps, request, pageNo, perPage);
for await (const item of this.listPagesGenerator(
listApps,
request,
pageNo,
perPage,
)) {
yield item;
}
}

// async listRunners(
Expand Down

0 comments on commit d77df11

Please sign in to comment.