@atproto/xrpc 0.3.3 → 0.4.1
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 +20 -0
- package/LICENSE.txt +7 -0
- package/README.md +13 -5
- package/dist/client.d.ts +3 -3
- package/dist/index.js +10 -29
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
- package/src/client.ts +3 -3
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atproto/xrpc
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atproto/lexicon@0.3.1
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#1801](https://github.com/bluesky-social/atproto/pull/1801) [`ce49743d`](https://github.com/bluesky-social/atproto/commit/ce49743d7f8800d33116b88001d7b512553c2c89) Thanks [@gaearon](https://github.com/gaearon)! - Methods that accepts lexicons now take `LexiconDoc` type instead of `unknown`
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1788](https://github.com/bluesky-social/atproto/pull/1788) [`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423) Thanks [@bnewbold](https://github.com/bnewbold)! - update license to "MIT or Apache2"
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`ce49743d`](https://github.com/bluesky-social/atproto/commit/ce49743d7f8800d33116b88001d7b512553c2c89), [`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423)]:
|
|
21
|
+
- @atproto/lexicon@0.3.0
|
|
22
|
+
|
|
3
23
|
## 0.3.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Dual MIT/Apache-2.0 License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2023 Bluesky PBC, and Contributors
|
|
4
|
+
|
|
5
|
+
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
|
+
|
|
7
|
+
Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
|
package/README.md
CHANGED
|
@@ -8,9 +8,10 @@ TypeScript client library for talking to [atproto](https://atproto.com) services
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
10
|
```typescript
|
|
11
|
+
import { LexiconDoc } from '@atproto/lexicon'
|
|
11
12
|
import xrpc from '@atproto/xrpc'
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const pingLexicon: LexiconDoc = {
|
|
14
15
|
lexicon: 1,
|
|
15
16
|
id: 'io.example.ping',
|
|
16
17
|
defs: {
|
|
@@ -31,7 +32,8 @@ xrpc.addLexicon({
|
|
|
31
32
|
},
|
|
32
33
|
},
|
|
33
34
|
},
|
|
34
|
-
}
|
|
35
|
+
}
|
|
36
|
+
xrpc.addLexicon(pingLexicon)
|
|
35
37
|
|
|
36
38
|
const res1 = await xrpc.call('https://example.com', 'io.example.ping', {
|
|
37
39
|
message: 'hello world',
|
|
@@ -44,7 +46,7 @@ const res2 = await xrpc
|
|
|
44
46
|
res2.encoding // => 'application/json'
|
|
45
47
|
res2.body // => {message: 'hello world'}
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
const writeJsonLexicon: LexiconDoc = {
|
|
48
50
|
lexicon: 1,
|
|
49
51
|
id: 'io.example.writeJsonFile',
|
|
50
52
|
defs: {
|
|
@@ -60,7 +62,8 @@ xrpc.addLexicon({
|
|
|
60
62
|
},
|
|
61
63
|
},
|
|
62
64
|
},
|
|
63
|
-
}
|
|
65
|
+
}
|
|
66
|
+
xrpc.addLexicon(writeJsonLexicon)
|
|
64
67
|
|
|
65
68
|
const res3 = await xrpc.service('https://example.com').call(
|
|
66
69
|
'io.example.writeJsonFile',
|
|
@@ -71,4 +74,9 @@ const res3 = await xrpc.service('https://example.com').call(
|
|
|
71
74
|
|
|
72
75
|
## License
|
|
73
76
|
|
|
74
|
-
MIT
|
|
77
|
+
This project is dual-licensed under MIT and Apache 2.0 terms:
|
|
78
|
+
|
|
79
|
+
- MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)
|
|
80
|
+
- Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
81
|
+
|
|
82
|
+
Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Lexicons } from '@atproto/lexicon';
|
|
1
|
+
import { LexiconDoc, Lexicons } from '@atproto/lexicon';
|
|
2
2
|
import { FetchHandler, FetchHandlerResponse, Headers, CallOptions, QueryParams, XRPCResponse } from './types';
|
|
3
3
|
export declare class Client {
|
|
4
4
|
fetch: FetchHandler;
|
|
5
5
|
lex: Lexicons;
|
|
6
6
|
call(serviceUri: string | URL, methodNsid: string, params?: QueryParams, data?: unknown, opts?: CallOptions): Promise<XRPCResponse>;
|
|
7
7
|
service(serviceUri: string | URL): ServiceClient;
|
|
8
|
-
addLexicon(doc:
|
|
9
|
-
addLexicons(docs:
|
|
8
|
+
addLexicon(doc: LexiconDoc): void;
|
|
9
|
+
addLexicons(docs: LexiconDoc[]): void;
|
|
10
10
|
removeLexicon(uri: string): void;
|
|
11
11
|
}
|
|
12
12
|
export declare class ServiceClient {
|
package/dist/index.js
CHANGED
|
@@ -12688,13 +12688,13 @@ var ensureValidAtUri = (uri2) => {
|
|
|
12688
12688
|
throw new Error("ATURI requires at least method and authority sections");
|
|
12689
12689
|
}
|
|
12690
12690
|
try {
|
|
12691
|
-
|
|
12692
|
-
} catch {
|
|
12693
|
-
try {
|
|
12691
|
+
if (parts[2].startsWith("did:")) {
|
|
12694
12692
|
ensureValidDid(parts[2]);
|
|
12695
|
-
}
|
|
12696
|
-
|
|
12693
|
+
} else {
|
|
12694
|
+
ensureValidHandle(parts[2]);
|
|
12697
12695
|
}
|
|
12696
|
+
} catch {
|
|
12697
|
+
throw new Error("ATURI authority must be a valid handle or DID");
|
|
12698
12698
|
}
|
|
12699
12699
|
if (parts.length >= 4) {
|
|
12700
12700
|
if (parts[3].length == 0) {
|
|
@@ -13989,7 +13989,7 @@ function datetime(path, value) {
|
|
|
13989
13989
|
} catch {
|
|
13990
13990
|
return {
|
|
13991
13991
|
success: false,
|
|
13992
|
-
error: new ValidationError(`${path} must be an
|
|
13992
|
+
error: new ValidationError(`${path} must be an valid atproto datetime (both RFC-3339 and ISO-8601)`)
|
|
13993
13993
|
};
|
|
13994
13994
|
}
|
|
13995
13995
|
return { success: true, value };
|
|
@@ -14824,15 +14824,6 @@ var discriminatedObject = z.object({ $type: z.string() });
|
|
|
14824
14824
|
function isDiscriminatedObject(value) {
|
|
14825
14825
|
return discriminatedObject.safeParse(value).success;
|
|
14826
14826
|
}
|
|
14827
|
-
var LexiconDocMalformedError = class extends Error {
|
|
14828
|
-
constructor(message, schemaDef, issues) {
|
|
14829
|
-
super(message);
|
|
14830
|
-
this.schemaDef = schemaDef;
|
|
14831
|
-
this.issues = issues;
|
|
14832
|
-
this.schemaDef = schemaDef;
|
|
14833
|
-
this.issues = issues;
|
|
14834
|
-
}
|
|
14835
|
-
};
|
|
14836
14827
|
var ValidationError = class extends Error {
|
|
14837
14828
|
};
|
|
14838
14829
|
var InvalidLexiconError = class extends Error {
|
|
@@ -14913,23 +14904,13 @@ var Lexicons = class {
|
|
|
14913
14904
|
}
|
|
14914
14905
|
}
|
|
14915
14906
|
add(doc) {
|
|
14916
|
-
|
|
14917
|
-
lexiconDoc.parse(doc);
|
|
14918
|
-
} catch (e) {
|
|
14919
|
-
if (e instanceof ZodError) {
|
|
14920
|
-
throw new LexiconDocMalformedError(`Failed to parse schema definition ${doc.id}`, doc, e.issues);
|
|
14921
|
-
} else {
|
|
14922
|
-
throw e;
|
|
14923
|
-
}
|
|
14924
|
-
}
|
|
14925
|
-
const validatedDoc = doc;
|
|
14926
|
-
const uri2 = toLexUri(validatedDoc.id);
|
|
14907
|
+
const uri2 = toLexUri(doc.id);
|
|
14927
14908
|
if (this.docs.has(uri2)) {
|
|
14928
14909
|
throw new Error(`${uri2} has already been registered`);
|
|
14929
14910
|
}
|
|
14930
|
-
resolveRefUris(
|
|
14931
|
-
this.docs.set(uri2,
|
|
14932
|
-
for (const [defUri, def2] of iterDefs(
|
|
14911
|
+
resolveRefUris(doc, uri2);
|
|
14912
|
+
this.docs.set(uri2, doc);
|
|
14913
|
+
for (const [defUri, def2] of iterDefs(doc)) {
|
|
14933
14914
|
this.defs.set(defUri, def2);
|
|
14934
14915
|
}
|
|
14935
14916
|
}
|