Skip to content

Commit 6addaaf

Browse files
authored
Merge branch 'main' into adi/feat/example
2 parents c98d970 + 89f2352 commit 6addaaf

File tree

5 files changed

+917
-92
lines changed

5 files changed

+917
-92
lines changed

README.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/client/README.md

packages/client/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<p align="center">
2+
<img src="https://raw.githubusercontent.com/tsky-dev/tsky/refs/heads/main/.github/assets/tsky-logo.png" width="200" height="200">
3+
</p>
4+
5+
<h1 align="center">tsky</h1>
6+
7+
<p align="center">
8+
A lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots.
9+
</p>
10+
11+
## ⚠️ tsky is still in development and is not ready for production use
12+
13+
tsky is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3).
14+
15+
tsky is a lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots. It's designed to be easy to use, lightweight and straightforward to use. It's built with TypeScript and has full type support.
16+
17+
It was primarily built for the [Nimbus Client](https://github.com/nimbus-town/nimbus) but can be used in any other project that requires Bluesky API integration.
18+
19+
## Installation
20+
21+
```bash
22+
# NPM
23+
npm install tsky
24+
25+
# Yarn
26+
yarn add tsky
27+
28+
# PNPM
29+
pnpm add tsky
30+
31+
# Bun
32+
bun add tsky
33+
```
34+
35+
## Usage
36+
37+
Using a Public Agent
38+
39+
```ts
40+
import { createAgent } from '@tsky/client';
41+
42+
const agent = await createAgent({
43+
options: {
44+
service: 'https://public.api.bsky.app',
45+
},
46+
});
47+
48+
// Getting a user from their handle
49+
// First, we need to get the user's DID
50+
const did = await agent.resolveDIDFromHandle(handle);
51+
// Then, we can get the user's profile
52+
const profile = await agent.actor(did);
53+
```
54+
55+
Using an Authenticated Agent
56+
57+
```ts
58+
import { createAgent } from '@tsky/client';
59+
60+
const agent = await createAgent({
61+
credentials: {
62+
identifier: "handle",
63+
password: "password"
64+
}
65+
});
66+
67+
// Getting the profile of the authenticated user
68+
const user_profile = await agent.user.profile();
69+
```
70+
71+
## Links
72+
73+
- [📚 tsky Documentation](https://tsky.dev/)
74+
- [🦋 tsky on Bluesky](https://bsky.app/profile/tsky.dev)
75+
- [📣 tsky Discord Server](https://discord.gg/KPD7XPUZn3)
76+
- [🦋 Nimbus on Bluesky](https://bsky.app/profile/nimbus.town)
77+
78+
## Contributing
79+
80+
If you want to contribute to this project, please read the [CONTRIBUTING.md](../../CONTRIBUTING.md) file.
81+
82+
## License
83+
84+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/tsky-dev/tsky/blob/main/LICENSE) file for details.

packages/client/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tsky/client",
33
"type": "module",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"license": "MIT",
66
"publishConfig": {
77
"access": "public"
@@ -31,6 +31,15 @@
3131
"test:coverage": "vitest --coverage",
3232
"test:typescript": "tsc --noEmit"
3333
},
34+
"homepage": "https://tsky.dev",
35+
"repository": {
36+
"type": "git",
37+
"url": "git+https://github.com/tsky-dev/tsky.git",
38+
"directory": "packages/client"
39+
},
40+
"bugs": {
41+
"url": "https://github.com/tsky-dev/tsky/issues"
42+
},
3443
"dependencies": {
3544
"@atcute/client": "^2.0.6"
3645
},

packages/lex-cli/src/generator/schema.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,25 @@ export const userTypeSchema = t.isOneOf([
368368

369369
export type UserTypeSchema = t.InferType<typeof userTypeSchema>;
370370

371+
/**
372+
* represents a namespace identifier (NSID)
373+
*/
374+
export type Nsid = `${string}.${string}.${string}`;
375+
371376
const NSID_RE =
372-
/^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+\.[a-z]{1,63}$/i;
373-
const nsidType = t.cascade(t.isString(), (value) => NSID_RE.test(value));
377+
/^[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\.[a-zA-Z][a-zA-Z0-9]{0,62}?$/;
378+
379+
// #__NO_SIDE_EFFECTS__
380+
export const isNsid = (input: unknown): input is Nsid => {
381+
return (
382+
typeof input === 'string' &&
383+
input.length >= 5 &&
384+
input.length <= 317 &&
385+
NSID_RE.test(input)
386+
);
387+
};
388+
389+
const nsidType = t.cascade(t.isString(), (value) => isNsid(value));
374390

375391
export const documentSchema = t.cascade(
376392
t.isObject({

0 commit comments

Comments
 (0)