Skip to content

Commit

Permalink
Update changeset to better reflect changes (#2707)
Browse files Browse the repository at this point in the history
* Update changeset to better reflect changes

* Remove un-necessary packages from changeset

* codegen

* expose lexicons instead of schemas

* export a copy of the internal lexicon

* typo

* fix minor typos in changesets

---------

Co-authored-by: Devin Ivy <[email protected]>
  • Loading branch information
matthieusieben and devinivy authored Aug 12, 2024
1 parent b934b39 commit 2bdf75d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
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)

0 comments on commit 2bdf75d

Please sign in to comment.