-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client/ts): Add support for changing user name, user first and l…
…ast name, retrieving users by keys, and more to TypeScript client
- Loading branch information
Showing
8 changed files
with
556 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Synnax Labs, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License included in the file | ||
// licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with the Business Source | ||
// License, use of this software will be governed by the Apache License, Version 2.0, | ||
// included in the file licenses/APL.txt. | ||
|
||
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter"; | ||
import { z } from "zod"; | ||
|
||
import { keyZ, type User, userZ } from "@/user/payload"; | ||
import { nullableArrayZ } from "@/util/zod"; | ||
|
||
const reqZ = z.object({ | ||
keys: keyZ.array().optional(), | ||
usernames: z.string().array().optional(), | ||
}); | ||
type Request = z.infer<typeof reqZ>; | ||
const resZ = z.object({ users: nullableArrayZ(userZ) }); | ||
const RETRIEVE_ENDPOINT = "/user/retrieve"; | ||
|
||
export class Retriever { | ||
private readonly client: UnaryClient; | ||
|
||
constructor(client: UnaryClient) { | ||
this.client = client; | ||
} | ||
|
||
async retrieve(req: Request): Promise<User[]> { | ||
const res = await sendRequired<typeof reqZ, typeof resZ>( | ||
this.client, | ||
RETRIEVE_ENDPOINT, | ||
req, | ||
reqZ, | ||
resZ, | ||
); | ||
return res.users; | ||
} | ||
} |
Oops, something went wrong.