@atproto/lexicon 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,35 +1,31 @@
1
1
  {
2
2
  "name": "@atproto/lexicon",
3
- "version": "0.2.0",
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
- },
3
+ "version": "0.2.2",
20
4
  "license": "MIT",
5
+ "description": "atproto Lexicon schema language library",
6
+ "keywords": [
7
+ "atproto",
8
+ "lexicon"
9
+ ],
10
+ "homepage": "https://atproto.com",
21
11
  "repository": {
22
12
  "type": "git",
23
- "url": "https://github.com/bluesky-social/atproto.git",
13
+ "url": "https://github.com/bluesky-social/atproto",
24
14
  "directory": "packages/lexicon"
25
15
  },
16
+ "main": "dist/index.js",
26
17
  "dependencies": {
27
- "@atproto/common-web": "*",
28
- "@atproto/identifier": "*",
29
- "@atproto/nsid": "*",
30
- "@atproto/uri": "*",
31
18
  "iso-datestring-validator": "^2.2.2",
32
- "multiformats": "^9.6.4",
33
- "zod": "^3.21.4"
34
- }
35
- }
19
+ "multiformats": "^9.9.0",
20
+ "zod": "^3.21.4",
21
+ "@atproto/common-web": "^0.2.1",
22
+ "@atproto/syntax": "^0.1.2"
23
+ },
24
+ "scripts": {
25
+ "test": "jest",
26
+ "build": "node ./build.js",
27
+ "postbuild": "tsc --build tsconfig.build.json",
28
+ "update-main-to-dist": "node ../../update-main-to-dist.js packages/lexicon"
29
+ },
30
+ "types": "dist/index.d.ts"
31
+ }
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod'
2
- import { NSID } from '@atproto/nsid'
2
+ import { NSID } from '@atproto/syntax'
3
3
  import { requiredPropertiesRefinement } from './util'
4
4
 
5
5
  // primitives
@@ -173,11 +173,9 @@ export const lexObject = z
173
173
  description: z.string().optional(),
174
174
  required: z.string().array().optional(),
175
175
  nullable: z.string().array().optional(),
176
- properties: z
177
- .record(
178
- z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]),
179
- )
180
- .optional(),
176
+ properties: z.record(
177
+ z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]),
178
+ ),
181
179
  })
182
180
  .strict()
183
181
  .superRefine(requiredPropertiesRefinement)
@@ -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 { ensureValidDid, ensureValidHandle } from '@atproto/identifier'
6
- import { ensureValidNsid } from '@atproto/nsid'
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 {
@@ -1,6 +1,5 @@
1
1
  import { CID } from 'multiformats/cid'
2
2
  import { lexiconDoc, Lexicons } from '../src/index'
3
- import { object } from '../src/validators/complex'
4
3
  import LexiconDocs from './_scaffolds/lexicons'
5
4
 
6
5
  describe('Lexicons collection', () => {
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "exclude": ["**/*.spec.ts", "**/*.test.ts"]
4
- }
4
+ }
package/tsconfig.json CHANGED
@@ -11,4 +11,4 @@
11
11
  { "path": "../nsid/tsconfig.build.json" },
12
12
  { "path": "../uri/tsconfig.build.json" }
13
13
  ]
14
- }
14
+ }
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './lexicons';
@@ -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,4 +0,0 @@
1
- export * from './schema';
2
- export * from './schemas';
3
- export * from './validator';
4
- export * from './validation';
@@ -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;