@atproto/lex 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atproto/lex
2
2
 
3
+ ## 0.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix `main` export in `package.json`
8
+
9
+ - [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Re-expect everything from `@atproto/lex-client`
10
+
11
+ - [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Re-export everything from `@atproto/lex-schema`
12
+
13
+ - Updated dependencies [[`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece)]:
14
+ - @atproto/lex-client@0.0.5
15
+ - @atproto/lex-schema@0.0.5
16
+ - @atproto/lex-builder@0.0.7
17
+ - @atproto/lex-installer@0.0.7
18
+
3
19
  ## 0.0.6
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -617,23 +617,37 @@ const result = await client.xrpcSafe(com.atproto.identity.resolveHandle, {
617
617
  })
618
618
 
619
619
  if (result.success) {
620
- // Success - result is an XrpcResponse
620
+ // Handle success
621
621
  console.log(result.body)
622
622
  } else {
623
- // Failure - result is a ResponseFailure, the type depends on the method's error definitions
624
-
625
- result // ResponseFailure<"HandleNotFound">
626
-
627
- // Handle error based on type
628
- if (result.name === 'UnexpectedError') {
629
- // Network error, invalid response, etc.
630
- result.error // "unknown" type
631
- } else if (result.name === 'Unknown') {
632
- // Server returned a valid XRPC error response with an unknown error type
633
- result.error // XrpcResponseError<string>
623
+ // Handle failure
624
+ if (result.error === 'Unknown') {
625
+ // Unable to perform the request
626
+ const { reason } = result
627
+ if (reason instanceof XrpcResponseError) {
628
+ // The server returned a syntactically valid XRPC error response, but
629
+ // used an error code that is not declared for this method
630
+ reason.error // string (e.g. "AuthenticationRequired", "RateLimitExceeded", etc.)
631
+ reason.message // string
632
+ reason.status // number
633
+ reason.headers // Headers
634
+ reason.payload // { body: { error: string, message?: string }; encoding: string }
635
+ } else if (reason instanceof XrpcInvalidResponseError) {
636
+ // The response was incomplete (e.g. connection dropped), or
637
+ // invalid (e.g. malformed JSON, data does not match schema).
638
+ reason.error // "InvalidResponse"
639
+ reason.message // string
640
+ reason.response.status // number
641
+ reason.response.headers // Headers
642
+ reason.response.payload // null | { body: unknown; encoding: string }
643
+ } else {
644
+ reason // unknown (fetch failed, other?)
645
+ }
634
646
  } else {
635
- // Declared error from the method's errors list
636
- result.error // XrpcResponseError<"HandleNotFound">
647
+ // A declared error for that method
648
+ result // XrpcResponseError<"HandleNotFound">
649
+ result.error // "HandleNotFound"
650
+ result.message // string
637
651
  }
638
652
  }
639
653
  ```
@@ -660,10 +674,10 @@ The `ResponseFailure<M>` type is a union with three possible error types:
660
674
  2. **Unknown errors** - Server errors not declared in the method's schema:
661
675
 
662
676
  ```typescript
663
- // XrpcResponseFailure<'Unknown', XrpcResponseError>
677
+ // XrpcResponseFailure<'Unexpected', XrpcResponseError>
664
678
  type UnknownXrpcResponseFailure = {
665
679
  success: false
666
- name: 'Unknown'
680
+ name: 'Unexpected'
667
681
  error: XrpcResponseError<string>
668
682
  }
669
683
  ```
@@ -1202,7 +1216,7 @@ await client.call(unfollow, { followUri: uri })
1202
1216
  #### Updating Profile with Retry Logic
1203
1217
 
1204
1218
  ```typescript
1205
- import { Action } from '@atproto/lex'
1219
+ import { Action, XrpcResponseError } from '@atproto/lex'
1206
1220
  import * as app from './lexicons/app.js'
1207
1221
  import * as com from './lexicons/com.js'
1208
1222
 
@@ -1244,7 +1258,7 @@ export const updateProfile: Action<ProfileUpdate, void> = async (
1244
1258
  } catch (error) {
1245
1259
  // Retry on swap/concurrent modification errors
1246
1260
  if (
1247
- error instanceof XrpcRequestFailure &&
1261
+ error instanceof XrpcResponseError &&
1248
1262
  error.name === 'SwapError' &&
1249
1263
  attempt < maxRetries - 1
1250
1264
  ) {
@@ -0,0 +1,3 @@
1
+ export * from '@atproto/lex-schema';
2
+ export * from '@atproto/lex-client';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("@atproto/lex-schema"), exports);
5
+ tslib_1.__exportStar(require("@atproto/lex-client"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8DAAmC;AACnC,8DAAmC","sourcesContent":["export * from '@atproto/lex-schema'\nexport * from '@atproto/lex-client'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "license": "MIT",
5
5
  "description": "Lexicon tooling for AT",
6
6
  "keywords": [
@@ -15,9 +15,7 @@
15
15
  "directory": "packages/lex/lex"
16
16
  },
17
17
  "files": [
18
- "./index.cjs",
19
- "./index.mjs",
20
- "./index.d.ts",
18
+ "./dist",
21
19
  "./bin",
22
20
  "./CHANGELOG.md"
23
21
  ],
@@ -26,29 +24,30 @@
26
24
  "lex": "./bin/lex"
27
25
  },
28
26
  "sideEffects": false,
29
- "main": "./index.js",
30
- "types": "./index.d.ts",
27
+ "type": "commonjs",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
31
30
  "exports": {
32
31
  ".": {
33
- "browser": "./index.mjs",
34
- "import": "./index.mjs",
35
- "require": "./index.cjs",
36
- "types": "./index.d.ts"
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
37
34
  }
38
35
  },
39
36
  "dependencies": {
37
+ "tslib": "^2.8.1",
40
38
  "yargs": "^17.0.0",
41
- "@atproto/lex-builder": "0.0.6",
42
- "@atproto/lex-client": "0.0.4",
43
- "@atproto/lex-installer": "0.0.6",
44
- "@atproto/lex-schema": "0.0.4"
39
+ "@atproto/lex-builder": "0.0.7",
40
+ "@atproto/lex-client": "0.0.5",
41
+ "@atproto/lex-installer": "0.0.7",
42
+ "@atproto/lex-schema": "0.0.5"
45
43
  },
46
44
  "devDependencies": {
47
45
  "@types/yargs": "^17.0.33",
48
46
  "jest": "^28.1.2"
49
47
  },
50
48
  "scripts": {
51
- "build": "./bin/lex build --clear --lexicons ./lexicons --out ./tests/lexicons -- ignore additional npm args",
49
+ "prebuild": "./bin/lex build --clear --lexicons ./lexicons --out ./tests/lexicons --lib @atproto/lex-schema -- ignore additional npm args",
50
+ "build": "tsc --build tsconfig.build.json",
52
51
  "test": "jest"
53
52
  }
54
53
  }
package/index.cjs DELETED
@@ -1,11 +0,0 @@
1
- 'use strict'
2
-
3
- /* eslint-env commonjs */
4
- /* eslint-disable @typescript-eslint/no-var-requires */
5
-
6
- const { Client, buildAgent } = require('@atproto/lex-client')
7
- const { l } = require('@atproto/lex-schema')
8
-
9
- module.exports.Client = Client
10
- module.exports.buildAgent = buildAgent
11
- module.exports.l = l
package/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { Client, buildAgent } from '@atproto/lex-client'
2
- export { l } from '@atproto/lex-schema'
3
-
4
- // Type only re-exports
5
- export type * from '@atproto/lex-client'
6
- export type * from '@atproto/lex-schema'
package/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- export { Client, buildAgent } from '@atproto/lex-client'
2
- export { l } from '@atproto/lex-schema'