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

Update changeset to better reflect changes #2707

Merged
merged 7 commits into from
Aug 12, 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
5 changes: 5 additions & 0 deletions .changeset/new-olives-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lexicon": patch
---

Remove internal circular dependency.
18 changes: 4 additions & 14 deletions .changeset/purple-pans-shout.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
---
"@atproto/lex-cli": minor
"@atproto/xrpc": minor
"@atproto/api": minor
"@atproto/dev-env": patch
"@atproto/lexicon": patch
"@atproto/ozone": patch
"@atproto/bsky": patch
"@atproto/pds": patch
"@atproto/xrpc-server": patch
---

## Motivation
Expand Down Expand Up @@ -177,10 +170,7 @@ baseClient.xrpc.lex.assertValidXrpcMessage('io.example.doStuff', {
<td>

```ts
import { schemas } from '@atproto/api'
import { Lexicons } from '@atproto/lexicon'

const lexicons = new Lexicons(schemas)
import { lexicons } from '@atproto/api'

lexicons.assertValidXrpcMessage('io.example.doStuff', {
// ...
Expand All @@ -206,7 +196,7 @@ import { BskyAgent } from '@atproto/api'
class MyAgent extends BskyAgent {
private accessToken?: string

async createOrRefleshSession(identifier: string, password: string) {
async createOrRefreshSession(identifier: string, password: string) {
// custom logic here

this.accessToken = 'my-access-jwt'
Expand Down Expand Up @@ -263,7 +253,7 @@ class MyAgent extends Agent {
</table>


If you are monkey patching the the `xrpc` service client to perform client-side rate limiting, you can now do this in the `FetchHandler` function:
If you are monkey patching the `xrpc` service client to perform client-side rate limiting, you can now do this in the `FetchHandler` function:

<table>
<tr>
Expand Down Expand Up @@ -416,7 +406,7 @@ future version.
Since its use has completely changed, the `FetchHandler` type has also
completely changed. The new `FetchHandler` type is now a function that receives
a `url` pathname and a `RequestInit` object and returns a `Promise<Response>`.
This function is responsible from making the actual request to the server.
This function is responsible for making the actual request to the server.

```ts
export type FetchHandler = (
Expand Down
5 changes: 5 additions & 0 deletions .changeset/silver-buckets-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": minor
---

The generated client implementation uses the new `XrpcClient` class from `@atproto/xrpc`, instead of the deprecated `Client` and `ServiceClient` class.
11 changes: 5 additions & 6 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,12 +1073,11 @@ export class ComAtprotoServerNS {
params?: ComAtprotoServerGetServiceAuth.QueryParams,
opts?: ComAtprotoServerGetServiceAuth.CallOptions,
): Promise<ComAtprotoServerGetServiceAuth.Response> {
return this._client.call(
'com.atproto.server.getServiceAuth',
params,
undefined,
opts,
)
return this._client
.call('com.atproto.server.getServiceAuth', params, undefined, opts)
.catch((e) => {
throw ComAtprotoServerGetServiceAuth.toKnownErr(e)
})
}

getSession(
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11673,9 +11673,7 @@ export const schemaDict = {
},
},
}
export const schemas = Object.freeze(
Object.values(schemaDict),
) as readonly LexiconDoc[]
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ export interface Response {

export class BadExpirationError extends XRPCError {
constructor(src: XRPCError) {
super(src.status, src.error, src.message, src.headers)
super(src.status, src.error, src.message, src.headers, { cause: src })
}
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
if (e.error === 'BadExpiration') return new BadExpirationError(e)
}

return e
}
8 changes: 7 additions & 1 deletion packages/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Lexicons } from '@atproto/lexicon'
import { lexicons as internalLexicons } from './client/lexicons'

export { AtUri } from '@atproto/syntax'
export {
BlobRef,
Expand All @@ -11,7 +14,6 @@ export * from './types'
export * from './const'
export * from './util'
export * from './client'
export { schemas } from './client/lexicons'
export * from './rich-text/rich-text'
export * from './rich-text/sanitization'
export * from './rich-text/unicode'
Expand All @@ -27,3 +29,7 @@ export { BskyAgent } from './bsky-agent'

/** @deprecated */
export { AtpAgent as default } from './atp-agent'

// Expose a copy to prevent alteration of the internal Lexicon instance used by
// the AtpBaseClient class.
export const lexicons = new Lexicons(internalLexicons)