@atproto/lexicon-resolver 0.1.0
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 +14 -0
- package/LICENSE.txt +7 -0
- package/README.md +79 -0
- package/dist/client/index.d.ts +28 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +118 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/lexicons.d.ts +105 -0
- package/dist/client/lexicons.d.ts.map +1 -0
- package/dist/client/lexicons.js +75 -0
- package/dist/client/lexicons.js.map +1 -0
- package/dist/client/types/com/atproto/sync/getRecord.d.ts +38 -0
- package/dist/client/types/com/atproto/sync/getRecord.d.ts.map +1 -0
- package/dist/client/types/com/atproto/sync/getRecord.js +58 -0
- package/dist/client/types/com/atproto/sync/getRecord.js.map +1 -0
- package/dist/client/util.d.ts +37 -0
- package/dist/client/util.d.ts.map +1 -0
- package/dist/client/util.js +38 -0
- package/dist/client/util.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/lexicon.d.ts +43 -0
- package/dist/lexicon.d.ts.map +1 -0
- package/dist/lexicon.js +98 -0
- package/dist/lexicon.js.map +1 -0
- package/dist/record.d.ts +37 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +100 -0
- package/dist/record.js.map +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +14 -0
- package/dist/util.js.map +1 -0
- package/jest.config.js +7 -0
- package/package.json +46 -0
- package/src/client/index.ts +67 -0
- package/src/client/lexicons.ts +98 -0
- package/src/client/types/com/atproto/sync/getRecord.ts +78 -0
- package/src/client/util.ts +82 -0
- package/src/index.ts +2 -0
- package/src/lexicon.ts +147 -0
- package/src/record.ts +156 -0
- package/src/util.ts +10 -0
- package/tests/lexicon.test.ts +266 -0
- package/tests/record.test.ts +98 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +7 -0
- package/tsconfig.tests.json +8 -0
- package/tsconfig.tests.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @atproto/lexicon-resolver
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4069](https://github.com/bluesky-social/atproto/pull/4069) [`331a356ce`](https://github.com/bluesky-social/atproto/commit/331a356ce27ff1d0b24747b0c16f3b54b07a0a12) Thanks [@devinivy](https://github.com/devinivy)! - Support for Lexicon resolution and DID authority lookups.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`331a356ce`](https://github.com/bluesky-social/atproto/commit/331a356ce27ff1d0b24747b0c16f3b54b07a0a12), [`331a356ce`](https://github.com/bluesky-social/atproto/commit/331a356ce27ff1d0b24747b0c16f3b54b07a0a12)]:
|
|
12
|
+
- @atproto/repo@0.8.6
|
|
13
|
+
- @atproto/lexicon@0.4.13
|
|
14
|
+
- @atproto/xrpc@0.7.2
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Dual MIT/Apache-2.0 License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2025 Bluesky Social 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
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @atproto/lexicon-resolver
|
|
2
|
+
|
|
3
|
+
ATProto Lexicon resolution
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@atproto/lexicon-resolver)
|
|
6
|
+
[](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
This package may be used to determine the DID authority for a Lexicon based on its NSID, and to resolve a Lexicon from its NSID based on [Lexicon Resolution](https://atproto.com/specs/lexicon#lexicon-publication-and-resolution) from the network. Resolutions always verify the inclusion proof for the Lexicon schema document published to the ATProto network.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import {
|
|
14
|
+
resolveLexicon,
|
|
15
|
+
resolveLexiconDidAuthority,
|
|
16
|
+
} from '@atproto/lexicon-resolver'
|
|
17
|
+
|
|
18
|
+
// Which DID is the authority over this Lexicon?
|
|
19
|
+
const didAuthority = await resolveLexiconDidAuthority('app.bsky.feed.post')
|
|
20
|
+
// Resolve the Lexicon document with resolution details
|
|
21
|
+
const resolved = await resolveLexicon('app.bsky.feed.post')
|
|
22
|
+
/**
|
|
23
|
+
* {
|
|
24
|
+
* commit: {
|
|
25
|
+
* did: 'did:plc:4v4y5r3lwsbtmsxhile2ljac',
|
|
26
|
+
* rev: '3lnlpukgipj2c',
|
|
27
|
+
* sig: Uint8Array(64),
|
|
28
|
+
* ...
|
|
29
|
+
* },
|
|
30
|
+
* uri: AtUri(at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.feed.post),
|
|
31
|
+
* cid: CID(bafyreidgbehqwweghrrddfu6jgj7lyr6fwhzgazhirnszdb5lvr7iynkiy),
|
|
32
|
+
* nsid: NSID('app.bsky.feed.post'),
|
|
33
|
+
* lexicon: {
|
|
34
|
+
* '$type': 'com.atproto.lexicon.schema',
|
|
35
|
+
* lexicon: 1
|
|
36
|
+
* id: 'app.bsky.feed.post',
|
|
37
|
+
* defs: { main: [Object], ... },
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### With identity caching
|
|
44
|
+
|
|
45
|
+
Identity data is used in order to fetch and verify record contents. The @atproto/identity package can be used to offer more control over caching and other behaviors of identity lookups.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { IdResolver, MemoryCache } from '@atproto/identity'
|
|
49
|
+
import { buildLexiconResolver } from '@atproto/lexicon-resolver'
|
|
50
|
+
|
|
51
|
+
const resolveLexicon = buildLexiconResolver({
|
|
52
|
+
idResolver: new IdResolver({
|
|
53
|
+
didCache: new MemoryCache(),
|
|
54
|
+
}),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const resolved = await resolveLexicon('app.bsky.feed.post')
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### With DID authority override
|
|
61
|
+
|
|
62
|
+
You may specify a specific DID authority you'd like to use to perform a Lexicon resolution, overriding ATProto's DNS-based authority over Lexicons. This is described in some more detail in [Authority and Control](https://atproto.com/specs/lexicon#authority-and-control).
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { resolveLexicon } from '@atproto/lexicon-resolver'
|
|
66
|
+
|
|
67
|
+
const resolved = await resolveLexicon('app.bsky.feed.post', {
|
|
68
|
+
didAuthority: 'did:plc:...',
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
This project is dual-licensed under MIT and Apache 2.0 terms:
|
|
75
|
+
|
|
76
|
+
- MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)
|
|
77
|
+
- 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)
|
|
78
|
+
|
|
79
|
+
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.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { XrpcClient, type FetchHandler, type FetchHandlerOptions } from '@atproto/xrpc';
|
|
5
|
+
import * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js';
|
|
6
|
+
export * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js';
|
|
7
|
+
export declare class AtpBaseClient extends XrpcClient {
|
|
8
|
+
com: ComNS;
|
|
9
|
+
constructor(options: FetchHandler | FetchHandlerOptions);
|
|
10
|
+
/** @deprecated use `this` instead */
|
|
11
|
+
get xrpc(): XrpcClient;
|
|
12
|
+
}
|
|
13
|
+
export declare class ComNS {
|
|
14
|
+
_client: XrpcClient;
|
|
15
|
+
atproto: ComAtprotoNS;
|
|
16
|
+
constructor(client: XrpcClient);
|
|
17
|
+
}
|
|
18
|
+
export declare class ComAtprotoNS {
|
|
19
|
+
_client: XrpcClient;
|
|
20
|
+
sync: ComAtprotoSyncNS;
|
|
21
|
+
constructor(client: XrpcClient);
|
|
22
|
+
}
|
|
23
|
+
export declare class ComAtprotoSyncNS {
|
|
24
|
+
_client: XrpcClient;
|
|
25
|
+
constructor(client: XrpcClient);
|
|
26
|
+
getRecord(params?: ComAtprotoSyncGetRecord.QueryParams, opts?: ComAtprotoSyncGetRecord.CallOptions): Promise<ComAtprotoSyncGetRecord.Response>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,uBAAuB,MAAM,uCAAuC,CAAA;AAEhF,OAAO,KAAK,uBAAuB,MAAM,uCAAuC,CAAA;AAEhF,qBAAa,aAAc,SAAQ,UAAU;IAC3C,GAAG,EAAE,KAAK,CAAA;gBAEE,OAAO,EAAE,YAAY,GAAG,mBAAmB;IAKvD,qCAAqC;IACrC,IAAI,IAAI,IAAI,UAAU,CAErB;CACF;AAED,qBAAa,KAAK;IAChB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,YAAY,CAAA;gBAET,MAAM,EAAE,UAAU;CAI/B;AAED,qBAAa,YAAY;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,IAAI,EAAE,gBAAgB,CAAA;gBAEV,MAAM,EAAE,UAAU;CAI/B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,EAAE,UAAU,CAAA;gBAEP,MAAM,EAAE,UAAU;IAI9B,SAAS,CACP,MAAM,CAAC,EAAE,uBAAuB,CAAC,WAAW,EAC5C,IAAI,CAAC,EAAE,uBAAuB,CAAC,WAAW,GACzC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC;CAO7C"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ComAtprotoSyncNS = exports.ComAtprotoNS = exports.ComNS = exports.AtpBaseClient = exports.ComAtprotoSyncGetRecord = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
39
|
+
*/
|
|
40
|
+
const xrpc_1 = require("@atproto/xrpc");
|
|
41
|
+
const lexicons_js_1 = require("./lexicons.js");
|
|
42
|
+
const ComAtprotoSyncGetRecord = __importStar(require("./types/com/atproto/sync/getRecord.js"));
|
|
43
|
+
exports.ComAtprotoSyncGetRecord = __importStar(require("./types/com/atproto/sync/getRecord.js"));
|
|
44
|
+
class AtpBaseClient extends xrpc_1.XrpcClient {
|
|
45
|
+
constructor(options) {
|
|
46
|
+
super(options, lexicons_js_1.schemas);
|
|
47
|
+
Object.defineProperty(this, "com", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
this.com = new ComNS(this);
|
|
54
|
+
}
|
|
55
|
+
/** @deprecated use `this` instead */
|
|
56
|
+
get xrpc() {
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.AtpBaseClient = AtpBaseClient;
|
|
61
|
+
class ComNS {
|
|
62
|
+
constructor(client) {
|
|
63
|
+
Object.defineProperty(this, "_client", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(this, "atproto", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: void 0
|
|
74
|
+
});
|
|
75
|
+
this._client = client;
|
|
76
|
+
this.atproto = new ComAtprotoNS(client);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.ComNS = ComNS;
|
|
80
|
+
class ComAtprotoNS {
|
|
81
|
+
constructor(client) {
|
|
82
|
+
Object.defineProperty(this, "_client", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true,
|
|
85
|
+
writable: true,
|
|
86
|
+
value: void 0
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(this, "sync", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
this._client = client;
|
|
95
|
+
this.sync = new ComAtprotoSyncNS(client);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ComAtprotoNS = ComAtprotoNS;
|
|
99
|
+
class ComAtprotoSyncNS {
|
|
100
|
+
constructor(client) {
|
|
101
|
+
Object.defineProperty(this, "_client", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
configurable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
value: void 0
|
|
106
|
+
});
|
|
107
|
+
this._client = client;
|
|
108
|
+
}
|
|
109
|
+
getRecord(params, opts) {
|
|
110
|
+
return this._client
|
|
111
|
+
.call('com.atproto.sync.getRecord', params, undefined, opts)
|
|
112
|
+
.catch((e) => {
|
|
113
|
+
throw ComAtprotoSyncGetRecord.toKnownErr(e);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.ComAtprotoSyncNS = ComAtprotoSyncNS;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,wCAIsB;AACtB,+CAAuC;AAGvC,+FAAgF;AAEhF,iGAAgF;AAEhF,MAAa,aAAc,SAAQ,iBAAU;IAG3C,YAAY,OAA2C;QACrD,KAAK,CAAC,OAAO,EAAE,qBAAO,CAAC,CAAA;QAHzB;;;;;WAAU;QAIR,IAAI,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED,qCAAqC;IACrC,IAAI,IAAI;QACN,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAZD,sCAYC;AAED,MAAa,KAAK;IAIhB,YAAY,MAAkB;QAH9B;;;;;WAAmB;QACnB;;;;;WAAqB;QAGnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;CACF;AARD,sBAQC;AAED,MAAa,YAAY;IAIvB,YAAY,MAAkB;QAH9B;;;;;WAAmB;QACnB;;;;;WAAsB;QAGpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC1C,CAAC;CACF;AARD,oCAQC;AAED,MAAa,gBAAgB;IAG3B,YAAY,MAAkB;QAF9B;;;;;WAAmB;QAGjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,SAAS,CACP,MAA4C,EAC5C,IAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO;aAChB,IAAI,CAAC,4BAA4B,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC;aAC3D,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,uBAAuB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AAjBD,4CAiBC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Lexicons, type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
export declare const schemaDict: {
|
|
6
|
+
readonly ComAtprotoSyncGetRecord: {
|
|
7
|
+
readonly lexicon: 1;
|
|
8
|
+
readonly id: "com.atproto.sync.getRecord";
|
|
9
|
+
readonly defs: {
|
|
10
|
+
readonly main: {
|
|
11
|
+
readonly type: "query";
|
|
12
|
+
readonly description: "Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.";
|
|
13
|
+
readonly parameters: {
|
|
14
|
+
readonly type: "params";
|
|
15
|
+
readonly required: ["did", "collection", "rkey"];
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly did: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly format: "did";
|
|
20
|
+
readonly description: "The DID of the repo.";
|
|
21
|
+
};
|
|
22
|
+
readonly collection: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly format: "nsid";
|
|
25
|
+
};
|
|
26
|
+
readonly rkey: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly description: "Record Key";
|
|
29
|
+
readonly format: "record-key";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly output: {
|
|
34
|
+
readonly encoding: "application/vnd.ipld.car";
|
|
35
|
+
};
|
|
36
|
+
readonly errors: [{
|
|
37
|
+
readonly name: "RecordNotFound";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "RepoNotFound";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "RepoTakendown";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "RepoSuspended";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "RepoDeactivated";
|
|
46
|
+
}];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare const schemas: {
|
|
52
|
+
readonly lexicon: 1;
|
|
53
|
+
readonly id: "com.atproto.sync.getRecord";
|
|
54
|
+
readonly defs: {
|
|
55
|
+
readonly main: {
|
|
56
|
+
readonly type: "query";
|
|
57
|
+
readonly description: "Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.";
|
|
58
|
+
readonly parameters: {
|
|
59
|
+
readonly type: "params";
|
|
60
|
+
readonly required: ["did", "collection", "rkey"];
|
|
61
|
+
readonly properties: {
|
|
62
|
+
readonly did: {
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
readonly format: "did";
|
|
65
|
+
readonly description: "The DID of the repo.";
|
|
66
|
+
};
|
|
67
|
+
readonly collection: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly format: "nsid";
|
|
70
|
+
};
|
|
71
|
+
readonly rkey: {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
readonly description: "Record Key";
|
|
74
|
+
readonly format: "record-key";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly output: {
|
|
79
|
+
readonly encoding: "application/vnd.ipld.car";
|
|
80
|
+
};
|
|
81
|
+
readonly errors: [{
|
|
82
|
+
readonly name: "RecordNotFound";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "RepoNotFound";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "RepoTakendown";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "RepoSuspended";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "RepoDeactivated";
|
|
91
|
+
}];
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}[];
|
|
95
|
+
export declare const lexicons: Lexicons;
|
|
96
|
+
export declare function validate<T extends {
|
|
97
|
+
$type: string;
|
|
98
|
+
}>(v: unknown, id: string, hash: string, requiredType: true): ValidationResult<T>;
|
|
99
|
+
export declare function validate<T extends {
|
|
100
|
+
$type?: string;
|
|
101
|
+
}>(v: unknown, id: string, hash: string, requiredType?: false): ValidationResult<T>;
|
|
102
|
+
export declare const ids: {
|
|
103
|
+
readonly ComAtprotoSyncGetRecord: "com.atproto.sync.getRecord";
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=lexicons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicons.d.ts","sourceRoot":"","sources":["../../src/client/lexicons.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,QAAQ,EAER,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAA;AAGzB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDwB,CAAA;AAC/C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAA;AACvE,eAAO,MAAM,QAAQ,EAAE,QAAgC,CAAA;AAEvD,wBAAgB,QAAQ,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAClD,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GACjB,gBAAgB,CAAC,CAAC,CAAC,CAAA;AACtB,wBAAgB,QAAQ,CAAC,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,KAAK,GACnB,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAiBtB,eAAO,MAAM,GAAG;;CAEN,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ids = exports.lexicons = exports.schemas = exports.schemaDict = void 0;
|
|
4
|
+
exports.validate = validate;
|
|
5
|
+
/**
|
|
6
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
7
|
+
*/
|
|
8
|
+
const lexicon_1 = require("@atproto/lexicon");
|
|
9
|
+
const util_js_1 = require("./util.js");
|
|
10
|
+
exports.schemaDict = {
|
|
11
|
+
ComAtprotoSyncGetRecord: {
|
|
12
|
+
lexicon: 1,
|
|
13
|
+
id: 'com.atproto.sync.getRecord',
|
|
14
|
+
defs: {
|
|
15
|
+
main: {
|
|
16
|
+
type: 'query',
|
|
17
|
+
description: 'Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.',
|
|
18
|
+
parameters: {
|
|
19
|
+
type: 'params',
|
|
20
|
+
required: ['did', 'collection', 'rkey'],
|
|
21
|
+
properties: {
|
|
22
|
+
did: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
format: 'did',
|
|
25
|
+
description: 'The DID of the repo.',
|
|
26
|
+
},
|
|
27
|
+
collection: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
format: 'nsid',
|
|
30
|
+
},
|
|
31
|
+
rkey: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Record Key',
|
|
34
|
+
format: 'record-key',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
output: {
|
|
39
|
+
encoding: 'application/vnd.ipld.car',
|
|
40
|
+
},
|
|
41
|
+
errors: [
|
|
42
|
+
{
|
|
43
|
+
name: 'RecordNotFound',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'RepoNotFound',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'RepoTakendown',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'RepoSuspended',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'RepoDeactivated',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
exports.schemas = Object.values(exports.schemaDict);
|
|
63
|
+
exports.lexicons = new lexicon_1.Lexicons(exports.schemas);
|
|
64
|
+
function validate(v, id, hash, requiredType) {
|
|
65
|
+
return (requiredType ? util_js_1.is$typed : util_js_1.maybe$typed)(v, id, hash)
|
|
66
|
+
? exports.lexicons.validate(`${id}#${hash}`, v)
|
|
67
|
+
: {
|
|
68
|
+
success: false,
|
|
69
|
+
error: new lexicon_1.ValidationError(`Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.ids = {
|
|
73
|
+
ComAtprotoSyncGetRecord: 'com.atproto.sync.getRecord',
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=lexicons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicons.js","sourceRoot":"","sources":["../../src/client/lexicons.ts"],"names":[],"mappings":";;;AA+EA,4BAcC;AA7FD;;GAEG;AACH,8CAKyB;AACzB,uCAA8D;AAEjD,QAAA,UAAU,GAAG;IACxB,uBAAuB,EAAE;QACvB,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,4BAA4B;QAChC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,iIAAiI;gBACnI,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC;oBACvC,UAAU,EAAE;wBACV,GAAG,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B,uBAAuB,EAAE,4BAA4B;CAC7C,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { HeadersMap, XRPCError } from '@atproto/xrpc';
|
|
5
|
+
export type QueryParams = {
|
|
6
|
+
/** The DID of the repo. */
|
|
7
|
+
did: string;
|
|
8
|
+
collection: string;
|
|
9
|
+
/** Record Key */
|
|
10
|
+
rkey: string;
|
|
11
|
+
};
|
|
12
|
+
export type InputSchema = undefined;
|
|
13
|
+
export interface CallOptions {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
headers?: HeadersMap;
|
|
16
|
+
}
|
|
17
|
+
export interface Response {
|
|
18
|
+
success: boolean;
|
|
19
|
+
headers: HeadersMap;
|
|
20
|
+
data: Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
export declare class RecordNotFoundError extends XRPCError {
|
|
23
|
+
constructor(src: XRPCError);
|
|
24
|
+
}
|
|
25
|
+
export declare class RepoNotFoundError extends XRPCError {
|
|
26
|
+
constructor(src: XRPCError);
|
|
27
|
+
}
|
|
28
|
+
export declare class RepoTakendownError extends XRPCError {
|
|
29
|
+
constructor(src: XRPCError);
|
|
30
|
+
}
|
|
31
|
+
export declare class RepoSuspendedError extends XRPCError {
|
|
32
|
+
constructor(src: XRPCError);
|
|
33
|
+
}
|
|
34
|
+
export declare class RepoDeactivatedError extends XRPCError {
|
|
35
|
+
constructor(src: XRPCError);
|
|
36
|
+
}
|
|
37
|
+
export declare function toKnownErr(e: any): any;
|
|
38
|
+
//# sourceMappingURL=getRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRecord.d.ts","sourceRoot":"","sources":["../../../../../../src/client/types/com/atproto/sync/getRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAcrD,MAAM,MAAM,WAAW,GAAG;IACxB,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AACD,MAAM,MAAM,WAAW,GAAG,SAAS,CAAA;AAEnC,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,UAAU,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,GAAG,EAAE,SAAS;CAG3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,OAUhC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepoDeactivatedError = exports.RepoSuspendedError = exports.RepoTakendownError = exports.RepoNotFoundError = exports.RecordNotFoundError = void 0;
|
|
4
|
+
exports.toKnownErr = toKnownErr;
|
|
5
|
+
/**
|
|
6
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
7
|
+
*/
|
|
8
|
+
const xrpc_1 = require("@atproto/xrpc");
|
|
9
|
+
const lexicons_1 = require("../../../../lexicons");
|
|
10
|
+
const util_1 = require("../../../../util");
|
|
11
|
+
const is$typed = util_1.is$typed, validate = lexicons_1.validate;
|
|
12
|
+
const id = 'com.atproto.sync.getRecord';
|
|
13
|
+
class RecordNotFoundError extends xrpc_1.XRPCError {
|
|
14
|
+
constructor(src) {
|
|
15
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.RecordNotFoundError = RecordNotFoundError;
|
|
19
|
+
class RepoNotFoundError extends xrpc_1.XRPCError {
|
|
20
|
+
constructor(src) {
|
|
21
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.RepoNotFoundError = RepoNotFoundError;
|
|
25
|
+
class RepoTakendownError extends xrpc_1.XRPCError {
|
|
26
|
+
constructor(src) {
|
|
27
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.RepoTakendownError = RepoTakendownError;
|
|
31
|
+
class RepoSuspendedError extends xrpc_1.XRPCError {
|
|
32
|
+
constructor(src) {
|
|
33
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.RepoSuspendedError = RepoSuspendedError;
|
|
37
|
+
class RepoDeactivatedError extends xrpc_1.XRPCError {
|
|
38
|
+
constructor(src) {
|
|
39
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.RepoDeactivatedError = RepoDeactivatedError;
|
|
43
|
+
function toKnownErr(e) {
|
|
44
|
+
if (e instanceof xrpc_1.XRPCError) {
|
|
45
|
+
if (e.error === 'RecordNotFound')
|
|
46
|
+
return new RecordNotFoundError(e);
|
|
47
|
+
if (e.error === 'RepoNotFound')
|
|
48
|
+
return new RepoNotFoundError(e);
|
|
49
|
+
if (e.error === 'RepoTakendown')
|
|
50
|
+
return new RepoTakendownError(e);
|
|
51
|
+
if (e.error === 'RepoSuspended')
|
|
52
|
+
return new RepoSuspendedError(e);
|
|
53
|
+
if (e.error === 'RepoDeactivated')
|
|
54
|
+
return new RepoDeactivatedError(e);
|
|
55
|
+
}
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=getRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRecord.js","sourceRoot":"","sources":["../../../../../../src/client/types/com/atproto/sync/getRecord.ts"],"names":[],"mappings":";;;AAmEA,gCAUC;AA7ED;;GAEG;AACH,wCAAqD;AAGrD,mDAA4D;AAC5D,2CAIyB;AAEzB,MAAM,QAAQ,GAAG,eAAS,EACxB,QAAQ,GAAG,mBAAS,CAAA;AACtB,MAAM,EAAE,GAAG,4BAA4B,CAAA;AAsBvC,MAAa,mBAAoB,SAAQ,gBAAS;IAChD,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,iBAAkB,SAAQ,gBAAS;IAC9C,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAJD,8CAIC;AAED,MAAa,kBAAmB,SAAQ,gBAAS;IAC/C,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,kBAAmB,SAAQ,gBAAS;IAC/C,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,oBAAqB,SAAQ,gBAAS;IACjD,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAJD,oDAIC;AAED,SAAgB,UAAU,CAAC,CAAM;IAC/B,IAAI,CAAC,YAAY,gBAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,KAAK,KAAK,gBAAgB;YAAE,OAAO,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,CAAC,KAAK,KAAK,cAAc;YAAE,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAC/D,IAAI,CAAC,CAAC,KAAK,KAAK,eAAe;YAAE,OAAO,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAA;QACjE,IAAI,CAAC,CAAC,KAAK,KAAK,eAAe;YAAE,OAAO,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAA;QACjE,IAAI,CAAC,CAAC,KAAK,KAAK,iBAAiB;YAAE,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
export type OmitKey<T, K extends keyof T> = {
|
|
6
|
+
[K2 in keyof T as K2 extends K ? never : K2]: T[K2];
|
|
7
|
+
};
|
|
8
|
+
export type $Typed<V, T extends string = string> = V & {
|
|
9
|
+
$type: T;
|
|
10
|
+
};
|
|
11
|
+
export type Un$Typed<V extends {
|
|
12
|
+
$type?: string;
|
|
13
|
+
}> = OmitKey<V, '$type'>;
|
|
14
|
+
export type $Type<Id extends string, Hash extends string> = Hash extends 'main' ? Id : `${Id}#${Hash}`;
|
|
15
|
+
export type $TypedObject<V, Id extends string, Hash extends string> = V extends {
|
|
16
|
+
$type: $Type<Id, Hash>;
|
|
17
|
+
} ? V : V extends {
|
|
18
|
+
$type?: string;
|
|
19
|
+
} ? V extends {
|
|
20
|
+
$type?: infer T extends $Type<Id, Hash>;
|
|
21
|
+
} ? V & {
|
|
22
|
+
$type: T;
|
|
23
|
+
} : never : V & {
|
|
24
|
+
$type: $Type<Id, Hash>;
|
|
25
|
+
};
|
|
26
|
+
export declare function is$typed<V, Id extends string, Hash extends string>(v: V, id: Id, hash: Hash): v is $TypedObject<V, Id, Hash>;
|
|
27
|
+
export declare function maybe$typed<V, Id extends string, Hash extends string>(v: V, id: Id, hash: Hash): v is V & object & {
|
|
28
|
+
$type?: $Type<Id, Hash>;
|
|
29
|
+
};
|
|
30
|
+
export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>;
|
|
31
|
+
export type ValidatorParam<V extends Validator> = V extends Validator<infer R> ? R : never;
|
|
32
|
+
/**
|
|
33
|
+
* Utility function that allows to convert a "validate*" utility function into a
|
|
34
|
+
* type predicate.
|
|
35
|
+
*/
|
|
36
|
+
export declare function asPredicate<V extends Validator>(validate: V): <T>(v: T) => v is T & ValidatorParam<V>;
|
|
37
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/client/util.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAA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,EACN,IAAI,EAAE,IAAI,GACT,CAAC,IAAI,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAEhC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EACnE,CAAC,EAAE,CAAC,EACJ,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,GACT,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;CAAE,CAK/C;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,OAAO,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAA;AACxE,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,IAC5C,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,CAAC,IACzC,CAAC,EAAE,GAAG,CAAC,KAAG,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAGtD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.is$typed = is$typed;
|
|
7
|
+
exports.maybe$typed = maybe$typed;
|
|
8
|
+
exports.asPredicate = asPredicate;
|
|
9
|
+
function isObject(v) {
|
|
10
|
+
return v != null && typeof v === 'object';
|
|
11
|
+
}
|
|
12
|
+
function is$type($type, id, hash) {
|
|
13
|
+
return hash === 'main'
|
|
14
|
+
? $type === id
|
|
15
|
+
: // $type === `${id}#${hash}`
|
|
16
|
+
typeof $type === 'string' &&
|
|
17
|
+
$type.length === id.length + 1 + hash.length &&
|
|
18
|
+
$type.charCodeAt(id.length) === 35 /* '#' */ &&
|
|
19
|
+
$type.startsWith(id) &&
|
|
20
|
+
$type.endsWith(hash);
|
|
21
|
+
}
|
|
22
|
+
function is$typed(v, id, hash) {
|
|
23
|
+
return isObject(v) && '$type' in v && is$type(v.$type, id, hash);
|
|
24
|
+
}
|
|
25
|
+
function maybe$typed(v, id, hash) {
|
|
26
|
+
return (isObject(v) &&
|
|
27
|
+
('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Utility function that allows to convert a "validate*" utility function into a
|
|
31
|
+
* type predicate.
|
|
32
|
+
*/
|
|
33
|
+
function asPredicate(validate) {
|
|
34
|
+
return function (v) {
|
|
35
|
+
return validate(v).success;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/client/util.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAgDH,4BAMC;AAED,kCASC;AAUD,kCAIC;AAhED,SAAS,QAAQ,CAAI,CAAI;IACvB,OAAO,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAA;AAC3C,CAAC;AAED,SAAS,OAAO,CACd,KAAc,EACd,EAAM,EACN,IAAU;IAEV,OAAO,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC,KAAK,KAAK,EAAE;QACd,CAAC,CAAC,4BAA4B;YAC5B,OAAO,KAAK,KAAK,QAAQ;gBACvB,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM;gBAC5C,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,SAAS;gBAC5C,KAAK,CAAC,UAAU,CAAC,EAAE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