@atproto/lexicon 0.2.0 → 0.2.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 +8 -0
- package/LICENSE +21 -0
- package/build.js +0 -8
- package/dist/blob-refs.d.ts +2 -2
- package/dist/index.js +905 -2044
- package/dist/index.js.map +4 -4
- package/dist/types.d.ts +396 -396
- package/package.json +14 -24
- package/src/types.ts +1 -1
- package/src/validators/formats.ts +6 -3
- package/tsconfig.build.json +1 -1
- package/tsconfig.json +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/lexicons.d.ts +0 -15
- package/dist/src/record/index.d.ts +0 -4
- package/dist/src/record/schema.d.ts +0 -9
- package/dist/src/record/schemas.d.ts +0 -10
- package/dist/src/record/util.d.ts +0 -1
- package/dist/src/record/validation.d.ts +0 -24
- package/dist/src/record/validator.d.ts +0 -17
- package/dist/src/types.d.ts +0 -30268
- package/dist/src/util.d.ts +0 -6
- package/dist/src/validation.d.ts +0 -6
- package/dist/src/validators/blob.d.ts +0 -6
- package/dist/src/validators/complex.d.ts +0 -5
- package/dist/src/validators/primitives.d.ts +0 -9
- package/dist/src/validators/xrpc.d.ts +0 -3
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/update-pkg.js +0 -14
package/package.json
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lexicon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "jest",
|
|
7
|
-
"prettier": "prettier --check src/ tests/",
|
|
8
|
-
"prettier:fix": "prettier --write src/ tests/",
|
|
9
|
-
"lint": "eslint . --ext .ts,.tsx",
|
|
10
|
-
"lint:fix": "yarn lint --fix",
|
|
11
|
-
"verify": "run-p prettier lint",
|
|
12
|
-
"verify:fix": "yarn prettier:fix && yarn lint:fix",
|
|
13
|
-
"build": "node ./build.js",
|
|
14
|
-
"postbuild": "tsc --build tsconfig.build.json",
|
|
15
|
-
"update-main-to-dist": "node ./update-pkg.js --update-main-to-dist",
|
|
16
|
-
"update-main-to-src": "node ./update-pkg.js --update-main-to-src",
|
|
17
|
-
"prepublish": "npm run update-main-to-dist",
|
|
18
|
-
"postpublish": "npm run update-main-to-src"
|
|
19
|
-
},
|
|
20
5
|
"license": "MIT",
|
|
21
6
|
"repository": {
|
|
22
7
|
"type": "git",
|
|
@@ -24,12 +9,17 @@
|
|
|
24
9
|
"directory": "packages/lexicon"
|
|
25
10
|
},
|
|
26
11
|
"dependencies": {
|
|
27
|
-
"@atproto/common-web": "*",
|
|
28
|
-
"@atproto/identifier": "*",
|
|
29
|
-
"@atproto/nsid": "*",
|
|
30
|
-
"@atproto/uri": "*",
|
|
31
12
|
"iso-datestring-validator": "^2.2.2",
|
|
32
|
-
"multiformats": "^9.
|
|
33
|
-
"zod": "^3.21.4"
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
"multiformats": "^9.9.0",
|
|
14
|
+
"zod": "^3.21.4",
|
|
15
|
+
"@atproto/common-web": "^0.2.0",
|
|
16
|
+
"@atproto/syntax": "^0.1.1"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"build": "node ./build.js",
|
|
21
|
+
"postbuild": "tsc --build tsconfig.build.json",
|
|
22
|
+
"update-main-to-dist": "node ../../update-main-to-dist.js packages/lexicon"
|
|
23
|
+
},
|
|
24
|
+
"types": "dist/index.d.ts"
|
|
25
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { ensureValidAtUri } from '@atproto/uri'
|
|
2
1
|
import { isValidISODateString } from 'iso-datestring-validator'
|
|
3
2
|
import { CID } from 'multiformats/cid'
|
|
4
3
|
import { ValidationResult, ValidationError } from '../types'
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
ensureValidDid,
|
|
6
|
+
ensureValidHandle,
|
|
7
|
+
ensureValidNsid,
|
|
8
|
+
ensureValidAtUri,
|
|
9
|
+
} from '@atproto/syntax'
|
|
7
10
|
import { validateLanguage } from '@atproto/common-web'
|
|
8
11
|
|
|
9
12
|
export function datetime(path: string, value: string): ValidationResult {
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
package/dist/src/index.d.ts
DELETED
package/dist/src/lexicons.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LexiconDoc, LexUserType } from './types';
|
|
2
|
-
export declare class Lexicons {
|
|
3
|
-
docs: Map<string, LexiconDoc>;
|
|
4
|
-
defs: Map<string, LexUserType>;
|
|
5
|
-
constructor(docs?: unknown[]);
|
|
6
|
-
add(doc: unknown): void;
|
|
7
|
-
remove(uri: string): void;
|
|
8
|
-
get(uri: string): LexiconDoc | undefined;
|
|
9
|
-
getDef(uri: string): LexUserType | undefined;
|
|
10
|
-
getDefOrThrow(uri: string, types?: string[]): LexUserType;
|
|
11
|
-
assertValidRecord(lexUri: string, value: unknown): void;
|
|
12
|
-
assertValidXrpcParams(lexUri: string, value: unknown): void;
|
|
13
|
-
assertValidXrpcInput(lexUri: string, value: unknown): void;
|
|
14
|
-
assertValidXrpcOutput(lexUri: string, value: unknown): void;
|
|
15
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ValidateFunction } from 'ajv';
|
|
2
|
-
import { RecordSchema } from '../types';
|
|
3
|
-
export declare class CompiledRecordSchema {
|
|
4
|
-
def: RecordSchema;
|
|
5
|
-
id: string;
|
|
6
|
-
validate?: ValidateFunction;
|
|
7
|
-
constructor(def: RecordSchema);
|
|
8
|
-
}
|
|
9
|
-
export default CompiledRecordSchema;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import CompiledRecordSchema from './schema';
|
|
2
|
-
import RecordValidator, { RecordValidatorDescription } from './validator';
|
|
3
|
-
export declare class RecordSchemas {
|
|
4
|
-
schemas: Map<string, CompiledRecordSchema>;
|
|
5
|
-
add(schemaDef: unknown): void;
|
|
6
|
-
remove(key: string): void;
|
|
7
|
-
get(key: string): CompiledRecordSchema | undefined;
|
|
8
|
-
createRecordValidator(desc: string | string[] | RecordValidatorDescription): RecordValidator;
|
|
9
|
-
}
|
|
10
|
-
export default RecordSchemas;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isRecord: (obj: unknown) => obj is Record<string, unknown>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ValidateFunction } from 'ajv';
|
|
2
|
-
import CompiledRecordSchema from './schema';
|
|
3
|
-
export declare class ValidationError extends Error {
|
|
4
|
-
code: ValidationResultCode;
|
|
5
|
-
messages: string[];
|
|
6
|
-
constructor(res: ValidationResult);
|
|
7
|
-
}
|
|
8
|
-
export declare enum ValidationResultCode {
|
|
9
|
-
Full = "full",
|
|
10
|
-
Partial = "partial",
|
|
11
|
-
Incompatible = "incompatible",
|
|
12
|
-
Invalid = "invalid"
|
|
13
|
-
}
|
|
14
|
-
export declare class ValidationResult {
|
|
15
|
-
code: ValidationResultCode;
|
|
16
|
-
error: string | undefined;
|
|
17
|
-
fallbacks: string[];
|
|
18
|
-
messages: string[];
|
|
19
|
-
get valid(): boolean;
|
|
20
|
-
get fullySupported(): boolean;
|
|
21
|
-
get compatible(): boolean;
|
|
22
|
-
_t(to: ValidationResultCode, message?: string): void;
|
|
23
|
-
_fail(schema: CompiledRecordSchema, validator: ValidateFunction): void;
|
|
24
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CompiledRecordSchema from './schema';
|
|
2
|
-
import RecordSchemas from './schemas';
|
|
3
|
-
import { ValidationResult } from './validation';
|
|
4
|
-
export interface RecordValidatorDescription {
|
|
5
|
-
type: string | string[];
|
|
6
|
-
ext?: string | string[];
|
|
7
|
-
}
|
|
8
|
-
export declare class RecordValidator {
|
|
9
|
-
private schemas;
|
|
10
|
-
type: CompiledRecordSchema[];
|
|
11
|
-
ext: CompiledRecordSchema[];
|
|
12
|
-
constructor(schemas: RecordSchemas, type: CompiledRecordSchema[], ext: CompiledRecordSchema[]);
|
|
13
|
-
validate(value: unknown): ValidationResult;
|
|
14
|
-
isValid(value: unknown): boolean;
|
|
15
|
-
assertValid(value: unknown): ValidationResult;
|
|
16
|
-
}
|
|
17
|
-
export default RecordValidator;
|