@atproto/lexicon-resolver 0.2.6 → 0.3.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 +23 -0
- package/dist/lexicon.d.ts +13 -13
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +46 -20
- package/dist/lexicon.js.map +1 -1
- package/dist/lexicons/com/atproto/lexicon/schema.d.ts +3 -0
- package/dist/lexicons/com/atproto/lexicon/schema.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts +50 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.js +15 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.js +45 -0
- package/dist/lexicons/com/atproto/lexicon/schema.js.map +1 -0
- package/dist/lexicons/com/atproto/lexicon.d.ts +2 -0
- package/dist/lexicons/com/atproto/lexicon.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon.js +41 -0
- package/dist/lexicons/com/atproto/lexicon.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/sync/getRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts +31 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.js +24 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.js +45 -0
- package/dist/lexicons/com/atproto/sync/getRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/sync.d.ts +2 -0
- package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync.js +41 -0
- package/dist/lexicons/com/atproto/sync.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +3 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -0
- package/dist/lexicons/com/atproto.js +42 -0
- package/dist/lexicons/com/atproto.js.map +1 -0
- package/dist/lexicons/com.d.ts +2 -0
- package/dist/lexicons/com.d.ts.map +1 -0
- package/dist/lexicons/com.js +41 -0
- package/dist/lexicons/com.js.map +1 -0
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +41 -0
- package/dist/lexicons/index.js.map +1 -0
- package/dist/record.d.ts +9 -10
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +10 -13
- package/dist/record.js.map +1 -1
- package/package.json +8 -10
- package/src/lexicon.ts +29 -37
- package/src/lexicons/com/atproto/lexicon/schema.defs.ts +43 -0
- package/src/lexicons/com/atproto/lexicon/schema.ts +6 -0
- package/src/lexicons/com/atproto/lexicon.ts +5 -0
- package/src/lexicons/com/atproto/sync/getRecord.defs.ts +39 -0
- package/src/lexicons/com/atproto/sync/getRecord.ts +6 -0
- package/src/lexicons/com/atproto/sync.ts +5 -0
- package/src/lexicons/com/atproto.ts +6 -0
- package/src/lexicons/com.ts +5 -0
- package/src/lexicons/index.ts +5 -0
- package/src/record.ts +42 -25
- package/tests/lexicon.test.ts +4 -3
- package/tests/record.test.ts +8 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/client/index.d.ts +0 -28
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -118
- package/dist/client/index.js.map +0 -1
- package/dist/client/lexicons.d.ts +0 -105
- package/dist/client/lexicons.d.ts.map +0 -1
- package/dist/client/lexicons.js +0 -75
- package/dist/client/lexicons.js.map +0 -1
- package/dist/client/types/com/atproto/sync/getRecord.d.ts +0 -38
- package/dist/client/types/com/atproto/sync/getRecord.d.ts.map +0 -1
- package/dist/client/types/com/atproto/sync/getRecord.js +0 -58
- package/dist/client/types/com/atproto/sync/getRecord.js.map +0 -1
- package/dist/client/util.d.ts +0 -37
- package/dist/client/util.d.ts.map +0 -1
- package/dist/client/util.js +0 -38
- package/dist/client/util.js.map +0 -1
- package/src/client/index.ts +0 -67
- package/src/client/lexicons.ts +0 -98
- package/src/client/types/com/atproto/sync/getRecord.ts +0 -78
- package/src/client/util.ts +0 -82
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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","sourcesContent":["/**\n * GENERATED CODE - DO NOT MODIFY\n */\nimport { HeadersMap, XRPCError } from '@atproto/xrpc'\nimport { type ValidationResult, BlobRef } from '@atproto/lexicon'\nimport { CID } from 'multiformats/cid'\nimport { validate as _validate } from '../../../../lexicons'\nimport {\n type $Typed,\n is$typed as _is$typed,\n type OmitKey,\n} from '../../../../util'\n\nconst is$typed = _is$typed,\n validate = _validate\nconst id = 'com.atproto.sync.getRecord'\n\nexport type QueryParams = {\n /** The DID of the repo. */\n did: string\n collection: string\n /** Record Key */\n rkey: string\n}\nexport type InputSchema = undefined\n\nexport interface CallOptions {\n signal?: AbortSignal\n headers?: HeadersMap\n}\n\nexport interface Response {\n success: boolean\n headers: HeadersMap\n data: Uint8Array\n}\n\nexport class RecordNotFoundError extends XRPCError {\n constructor(src: XRPCError) {\n super(src.status, src.error, src.message, src.headers, { cause: src })\n }\n}\n\nexport class RepoNotFoundError extends XRPCError {\n constructor(src: XRPCError) {\n super(src.status, src.error, src.message, src.headers, { cause: src })\n }\n}\n\nexport class RepoTakendownError extends XRPCError {\n constructor(src: XRPCError) {\n super(src.status, src.error, src.message, src.headers, { cause: src })\n }\n}\n\nexport class RepoSuspendedError extends XRPCError {\n constructor(src: XRPCError) {\n super(src.status, src.error, src.message, src.headers, { cause: src })\n }\n}\n\nexport class RepoDeactivatedError extends XRPCError {\n constructor(src: XRPCError) {\n super(src.status, src.error, src.message, src.headers, { cause: src })\n }\n}\n\nexport function toKnownErr(e: any) {\n if (e instanceof XRPCError) {\n if (e.error === 'RecordNotFound') return new RecordNotFoundError(e)\n if (e.error === 'RepoNotFound') return new RepoNotFoundError(e)\n if (e.error === 'RepoTakendown') return new RepoTakendownError(e)\n if (e.error === 'RepoSuspended') return new RepoSuspendedError(e)\n if (e.error === 'RepoDeactivated') return new RepoDeactivatedError(e)\n }\n\n return e\n}\n"]}
|
package/dist/client/util.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI;KACzC,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;CACpD,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AACnE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,IAAI,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAExE,MAAM,MAAM,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,MAAM,GAC3E,EAAE,GACF,GAAG,EAAE,IAAI,IAAI,EAAE,CAAA;AAqBnB,MAAM,MAAM,YAAY,CACtB,CAAC,EACD,EAAE,SAAS,MAAM,EACjB,IAAI,SAAS,MAAM,IACjB,CAAC,SAAS;IACZ,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;CACvB,GACG,CAAC,GACD,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;CAAE,GACnD,CAAC,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAChB,KAAK,GACP,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;CAAE,CAAA;AAEpC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EAChE,CAAC,EAAE,CAAC,EACJ,EAAE,EAAE,EAAE,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"}
|
package/dist/client/util.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
package/dist/client/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;gBACpB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAgBD,SAAgB,QAAQ,CACtB,CAAI,EACJ,EAAM,EACN,IAAU;IAEV,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAA;AAClE,CAAC;AAED,SAAgB,WAAW,CACzB,CAAI,EACJ,EAAM,EACN,IAAU;IAEV,OAAO,CACL,QAAQ,CAAC,CAAC,CAAC;QACX,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAC5E,CAAA;AACH,CAAC;AAMD;;;GAGG;AACH,SAAgB,WAAW,CAAsB,QAAW;IAC1D,OAAO,UAAa,CAAI;QACtB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IAC5B,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * GENERATED CODE - DO NOT MODIFY\n */\n\nimport { type ValidationResult } from '@atproto/lexicon'\n\nexport type OmitKey<T, K extends keyof T> = {\n [K2 in keyof T as K2 extends K ? never : K2]: T[K2]\n}\n\nexport type $Typed<V, T extends string = string> = V & { $type: T }\nexport type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>\n\nexport type $Type<Id extends string, Hash extends string> = Hash extends 'main'\n ? Id\n : `${Id}#${Hash}`\n\nfunction isObject<V>(v: V): v is V & object {\n return v != null && typeof v === 'object'\n}\n\nfunction is$type<Id extends string, Hash extends string>(\n $type: unknown,\n id: Id,\n hash: Hash,\n): $type is $Type<Id, Hash> {\n return hash === 'main'\n ? $type === id\n : // $type === `${id}#${hash}`\n typeof $type === 'string' &&\n $type.length === id.length + 1 + hash.length &&\n $type.charCodeAt(id.length) === 35 /* '#' */ &&\n $type.startsWith(id) &&\n $type.endsWith(hash)\n}\n\nexport type $TypedObject<\n V,\n Id extends string,\n Hash extends string,\n> = V extends {\n $type: $Type<Id, Hash>\n}\n ? V\n : V extends { $type?: string }\n ? V extends { $type?: infer T extends $Type<Id, Hash> }\n ? V & { $type: T }\n : never\n : V & { $type: $Type<Id, Hash> }\n\nexport function is$typed<V, Id extends string, Hash extends string>(\n v: V,\n id: Id,\n hash: Hash,\n): v is $TypedObject<V, Id, Hash> {\n return isObject(v) && '$type' in v && is$type(v.$type, id, hash)\n}\n\nexport function maybe$typed<V, Id extends string, Hash extends string>(\n v: V,\n id: Id,\n hash: Hash,\n): v is V & object & { $type?: $Type<Id, Hash> } {\n return (\n isObject(v) &&\n ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)\n )\n}\n\nexport type Validator<R = unknown> = (v: unknown) => ValidationResult<R>\nexport type ValidatorParam<V extends Validator> =\n V extends Validator<infer R> ? R : never\n\n/**\n * Utility function that allows to convert a \"validate*\" utility function into a\n * type predicate.\n */\nexport function asPredicate<V extends Validator>(validate: V) {\n return function <T>(v: T): v is T & ValidatorParam<V> {\n return validate(v).success\n }\n}\n"]}
|
package/src/client/index.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
XrpcClient,
|
|
6
|
-
type FetchHandler,
|
|
7
|
-
type FetchHandlerOptions,
|
|
8
|
-
} from '@atproto/xrpc'
|
|
9
|
-
import { schemas } from './lexicons.js'
|
|
10
|
-
import { CID } from 'multiformats/cid'
|
|
11
|
-
import { type OmitKey, type Un$Typed } from './util.js'
|
|
12
|
-
import * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js'
|
|
13
|
-
|
|
14
|
-
export * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js'
|
|
15
|
-
|
|
16
|
-
export class AtpBaseClient extends XrpcClient {
|
|
17
|
-
com: ComNS
|
|
18
|
-
|
|
19
|
-
constructor(options: FetchHandler | FetchHandlerOptions) {
|
|
20
|
-
super(options, schemas)
|
|
21
|
-
this.com = new ComNS(this)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** @deprecated use `this` instead */
|
|
25
|
-
get xrpc(): XrpcClient {
|
|
26
|
-
return this
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class ComNS {
|
|
31
|
-
_client: XrpcClient
|
|
32
|
-
atproto: ComAtprotoNS
|
|
33
|
-
|
|
34
|
-
constructor(client: XrpcClient) {
|
|
35
|
-
this._client = client
|
|
36
|
-
this.atproto = new ComAtprotoNS(client)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class ComAtprotoNS {
|
|
41
|
-
_client: XrpcClient
|
|
42
|
-
sync: ComAtprotoSyncNS
|
|
43
|
-
|
|
44
|
-
constructor(client: XrpcClient) {
|
|
45
|
-
this._client = client
|
|
46
|
-
this.sync = new ComAtprotoSyncNS(client)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class ComAtprotoSyncNS {
|
|
51
|
-
_client: XrpcClient
|
|
52
|
-
|
|
53
|
-
constructor(client: XrpcClient) {
|
|
54
|
-
this._client = client
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
getRecord(
|
|
58
|
-
params?: ComAtprotoSyncGetRecord.QueryParams,
|
|
59
|
-
opts?: ComAtprotoSyncGetRecord.CallOptions,
|
|
60
|
-
): Promise<ComAtprotoSyncGetRecord.Response> {
|
|
61
|
-
return this._client
|
|
62
|
-
.call('com.atproto.sync.getRecord', params, undefined, opts)
|
|
63
|
-
.catch((e) => {
|
|
64
|
-
throw ComAtprotoSyncGetRecord.toKnownErr(e)
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/client/lexicons.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
type LexiconDoc,
|
|
6
|
-
Lexicons,
|
|
7
|
-
ValidationError,
|
|
8
|
-
type ValidationResult,
|
|
9
|
-
} from '@atproto/lexicon'
|
|
10
|
-
import { type $Typed, is$typed, maybe$typed } from './util.js'
|
|
11
|
-
|
|
12
|
-
export const schemaDict = {
|
|
13
|
-
ComAtprotoSyncGetRecord: {
|
|
14
|
-
lexicon: 1,
|
|
15
|
-
id: 'com.atproto.sync.getRecord',
|
|
16
|
-
defs: {
|
|
17
|
-
main: {
|
|
18
|
-
type: 'query',
|
|
19
|
-
description:
|
|
20
|
-
'Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.',
|
|
21
|
-
parameters: {
|
|
22
|
-
type: 'params',
|
|
23
|
-
required: ['did', 'collection', 'rkey'],
|
|
24
|
-
properties: {
|
|
25
|
-
did: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
format: 'did',
|
|
28
|
-
description: 'The DID of the repo.',
|
|
29
|
-
},
|
|
30
|
-
collection: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
format: 'nsid',
|
|
33
|
-
},
|
|
34
|
-
rkey: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
description: 'Record Key',
|
|
37
|
-
format: 'record-key',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
output: {
|
|
42
|
-
encoding: 'application/vnd.ipld.car',
|
|
43
|
-
},
|
|
44
|
-
errors: [
|
|
45
|
-
{
|
|
46
|
-
name: 'RecordNotFound',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'RepoNotFound',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'RepoTakendown',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'RepoSuspended',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'RepoDeactivated',
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
} as const satisfies Record<string, LexiconDoc>
|
|
65
|
-
export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]
|
|
66
|
-
export const lexicons: Lexicons = new Lexicons(schemas)
|
|
67
|
-
|
|
68
|
-
export function validate<T extends { $type: string }>(
|
|
69
|
-
v: unknown,
|
|
70
|
-
id: string,
|
|
71
|
-
hash: string,
|
|
72
|
-
requiredType: true,
|
|
73
|
-
): ValidationResult<T>
|
|
74
|
-
export function validate<T extends { $type?: string }>(
|
|
75
|
-
v: unknown,
|
|
76
|
-
id: string,
|
|
77
|
-
hash: string,
|
|
78
|
-
requiredType?: false,
|
|
79
|
-
): ValidationResult<T>
|
|
80
|
-
export function validate(
|
|
81
|
-
v: unknown,
|
|
82
|
-
id: string,
|
|
83
|
-
hash: string,
|
|
84
|
-
requiredType?: boolean,
|
|
85
|
-
): ValidationResult {
|
|
86
|
-
return (requiredType ? is$typed : maybe$typed)(v, id, hash)
|
|
87
|
-
? lexicons.validate(`${id}#${hash}`, v)
|
|
88
|
-
: {
|
|
89
|
-
success: false,
|
|
90
|
-
error: new ValidationError(
|
|
91
|
-
`Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`,
|
|
92
|
-
),
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const ids = {
|
|
97
|
-
ComAtprotoSyncGetRecord: 'com.atproto.sync.getRecord',
|
|
98
|
-
} as const
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
-
*/
|
|
4
|
-
import { HeadersMap, XRPCError } from '@atproto/xrpc'
|
|
5
|
-
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
-
import { CID } from 'multiformats/cid'
|
|
7
|
-
import { validate as _validate } from '../../../../lexicons'
|
|
8
|
-
import {
|
|
9
|
-
type $Typed,
|
|
10
|
-
is$typed as _is$typed,
|
|
11
|
-
type OmitKey,
|
|
12
|
-
} from '../../../../util'
|
|
13
|
-
|
|
14
|
-
const is$typed = _is$typed,
|
|
15
|
-
validate = _validate
|
|
16
|
-
const id = 'com.atproto.sync.getRecord'
|
|
17
|
-
|
|
18
|
-
export type QueryParams = {
|
|
19
|
-
/** The DID of the repo. */
|
|
20
|
-
did: string
|
|
21
|
-
collection: string
|
|
22
|
-
/** Record Key */
|
|
23
|
-
rkey: string
|
|
24
|
-
}
|
|
25
|
-
export type InputSchema = undefined
|
|
26
|
-
|
|
27
|
-
export interface CallOptions {
|
|
28
|
-
signal?: AbortSignal
|
|
29
|
-
headers?: HeadersMap
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface Response {
|
|
33
|
-
success: boolean
|
|
34
|
-
headers: HeadersMap
|
|
35
|
-
data: Uint8Array
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class RecordNotFoundError extends XRPCError {
|
|
39
|
-
constructor(src: XRPCError) {
|
|
40
|
-
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export class RepoNotFoundError extends XRPCError {
|
|
45
|
-
constructor(src: XRPCError) {
|
|
46
|
-
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class RepoTakendownError extends XRPCError {
|
|
51
|
-
constructor(src: XRPCError) {
|
|
52
|
-
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class RepoSuspendedError extends XRPCError {
|
|
57
|
-
constructor(src: XRPCError) {
|
|
58
|
-
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class RepoDeactivatedError extends XRPCError {
|
|
63
|
-
constructor(src: XRPCError) {
|
|
64
|
-
super(src.status, src.error, src.message, src.headers, { cause: src })
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function toKnownErr(e: any) {
|
|
69
|
-
if (e instanceof XRPCError) {
|
|
70
|
-
if (e.error === 'RecordNotFound') return new RecordNotFoundError(e)
|
|
71
|
-
if (e.error === 'RepoNotFound') return new RepoNotFoundError(e)
|
|
72
|
-
if (e.error === 'RepoTakendown') return new RepoTakendownError(e)
|
|
73
|
-
if (e.error === 'RepoSuspended') return new RepoSuspendedError(e)
|
|
74
|
-
if (e.error === 'RepoDeactivated') return new RepoDeactivatedError(e)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return e
|
|
78
|
-
}
|
package/src/client/util.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { type ValidationResult } from '@atproto/lexicon'
|
|
6
|
-
|
|
7
|
-
export type OmitKey<T, K extends keyof T> = {
|
|
8
|
-
[K2 in keyof T as K2 extends K ? never : K2]: T[K2]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type $Typed<V, T extends string = string> = V & { $type: T }
|
|
12
|
-
export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>
|
|
13
|
-
|
|
14
|
-
export type $Type<Id extends string, Hash extends string> = Hash extends 'main'
|
|
15
|
-
? Id
|
|
16
|
-
: `${Id}#${Hash}`
|
|
17
|
-
|
|
18
|
-
function isObject<V>(v: V): v is V & object {
|
|
19
|
-
return v != null && typeof v === 'object'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function is$type<Id extends string, Hash extends string>(
|
|
23
|
-
$type: unknown,
|
|
24
|
-
id: Id,
|
|
25
|
-
hash: Hash,
|
|
26
|
-
): $type is $Type<Id, Hash> {
|
|
27
|
-
return hash === 'main'
|
|
28
|
-
? $type === id
|
|
29
|
-
: // $type === `${id}#${hash}`
|
|
30
|
-
typeof $type === 'string' &&
|
|
31
|
-
$type.length === id.length + 1 + hash.length &&
|
|
32
|
-
$type.charCodeAt(id.length) === 35 /* '#' */ &&
|
|
33
|
-
$type.startsWith(id) &&
|
|
34
|
-
$type.endsWith(hash)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type $TypedObject<
|
|
38
|
-
V,
|
|
39
|
-
Id extends string,
|
|
40
|
-
Hash extends string,
|
|
41
|
-
> = V extends {
|
|
42
|
-
$type: $Type<Id, Hash>
|
|
43
|
-
}
|
|
44
|
-
? V
|
|
45
|
-
: V extends { $type?: string }
|
|
46
|
-
? V extends { $type?: infer T extends $Type<Id, Hash> }
|
|
47
|
-
? V & { $type: T }
|
|
48
|
-
: never
|
|
49
|
-
: V & { $type: $Type<Id, Hash> }
|
|
50
|
-
|
|
51
|
-
export function is$typed<V, Id extends string, Hash extends string>(
|
|
52
|
-
v: V,
|
|
53
|
-
id: Id,
|
|
54
|
-
hash: Hash,
|
|
55
|
-
): v is $TypedObject<V, Id, Hash> {
|
|
56
|
-
return isObject(v) && '$type' in v && is$type(v.$type, id, hash)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function maybe$typed<V, Id extends string, Hash extends string>(
|
|
60
|
-
v: V,
|
|
61
|
-
id: Id,
|
|
62
|
-
hash: Hash,
|
|
63
|
-
): v is V & object & { $type?: $Type<Id, Hash> } {
|
|
64
|
-
return (
|
|
65
|
-
isObject(v) &&
|
|
66
|
-
('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>
|
|
71
|
-
export type ValidatorParam<V extends Validator> =
|
|
72
|
-
V extends Validator<infer R> ? R : never
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Utility function that allows to convert a "validate*" utility function into a
|
|
76
|
-
* type predicate.
|
|
77
|
-
*/
|
|
78
|
-
export function asPredicate<V extends Validator>(validate: V) {
|
|
79
|
-
return function <T>(v: T): v is T & ValidatorParam<V> {
|
|
80
|
-
return validate(v).success
|
|
81
|
-
}
|
|
82
|
-
}
|