@atproto/lexicon 0.6.2 → 0.7.0-next.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/blob-refs.d.ts +4 -4
  3. package/dist/blob-refs.js +20 -45
  4. package/dist/blob-refs.js.map +1 -1
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +4 -20
  8. package/dist/index.js.map +1 -1
  9. package/dist/lexicons.d.ts +1 -1
  10. package/dist/lexicons.d.ts.map +1 -1
  11. package/dist/lexicons.js +40 -54
  12. package/dist/lexicons.js.map +1 -1
  13. package/dist/serialize.js +22 -31
  14. package/dist/serialize.js.map +1 -1
  15. package/dist/types.js +193 -203
  16. package/dist/types.js.map +1 -1
  17. package/dist/util.js +6 -10
  18. package/dist/util.js.map +1 -1
  19. package/dist/validation.d.ts +2 -2
  20. package/dist/validation.d.ts.map +1 -1
  21. package/dist/validation.js +10 -17
  22. package/dist/validation.js.map +1 -1
  23. package/dist/validators/blob.d.ts +2 -2
  24. package/dist/validators/blob.d.ts.map +1 -1
  25. package/dist/validators/blob.js +5 -8
  26. package/dist/validators/blob.js.map +1 -1
  27. package/dist/validators/complex.d.ts +2 -2
  28. package/dist/validators/complex.d.ts.map +1 -1
  29. package/dist/validators/complex.js +20 -26
  30. package/dist/validators/complex.js.map +1 -1
  31. package/dist/validators/formats.d.ts +1 -1
  32. package/dist/validators/formats.d.ts.map +1 -1
  33. package/dist/validators/formats.js +38 -50
  34. package/dist/validators/formats.js.map +1 -1
  35. package/dist/validators/primitives.d.ts +2 -2
  36. package/dist/validators/primitives.d.ts.map +1 -1
  37. package/dist/validators/primitives.js +33 -69
  38. package/dist/validators/primitives.js.map +1 -1
  39. package/dist/validators/xrpc.d.ts +2 -2
  40. package/dist/validators/xrpc.d.ts.map +1 -1
  41. package/dist/validators/xrpc.js +6 -42
  42. package/dist/validators/xrpc.js.map +1 -1
  43. package/{jest.config.js → jest.config.cjs} +8 -1
  44. package/package.json +17 -9
  45. package/src/index.ts +4 -4
  46. package/src/lexicons.ts +4 -4
  47. package/src/serialize.ts +1 -1
  48. package/src/types.ts +1 -1
  49. package/src/validation.ts +4 -4
  50. package/src/validators/blob.ts +3 -3
  51. package/src/validators/complex.ts +5 -5
  52. package/src/validators/formats.ts +3 -2
  53. package/src/validators/primitives.ts +3 -3
  54. package/src/validators/xrpc.ts +8 -4
  55. package/tests/_scaffolds/lexicons.ts +1 -1
  56. package/tests/general.test.ts +5 -5
  57. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,43 +1,7 @@
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.params = params;
37
- const types_1 = require("../types");
38
- const complex_1 = require("./complex");
39
- const PrimitiveValidators = __importStar(require("./primitives"));
40
- function params(lexicons, path, def, val) {
1
+ import { ValidationError, } from '../types.js';
2
+ import { array } from './complex.js';
3
+ import * as PrimitiveValidators from './primitives.js';
4
+ export function params(lexicons, path, def, val) {
41
5
  // type
42
6
  const value = val && typeof val === 'object' ? val : {};
43
7
  const requiredProps = new Set(def.required ?? []);
@@ -47,7 +11,7 @@ function params(lexicons, path, def, val) {
47
11
  for (const key in def.properties) {
48
12
  const propDef = def.properties[key];
49
13
  const validated = propDef.type === 'array'
50
- ? (0, complex_1.array)(lexicons, key, propDef, value[key])
14
+ ? array(lexicons, key, propDef, value[key])
51
15
  : PrimitiveValidators.validate(lexicons, key, propDef, value[key]);
52
16
  const propValue = validated.success ? validated.value : value[key];
53
17
  const propIsUndefined = typeof propValue === 'undefined';
@@ -55,7 +19,7 @@ function params(lexicons, path, def, val) {
55
19
  if (propIsUndefined && requiredProps.has(key)) {
56
20
  return {
57
21
  success: false,
58
- error: new types_1.ValidationError(`${path} must have the property "${key}"`),
22
+ error: new ValidationError(`${path} must have the property "${key}"`),
59
23
  };
60
24
  }
61
25
  else if (!propIsUndefined && !validated.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"xrpc.js","sourceRoot":"","sources":["../../src/validators/xrpc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBA2CC;AA/CD,oCAA+E;AAC/E,uCAAiC;AACjC,kEAAmD;AAEnD,SAAgB,MAAM,CACpB,QAAkB,EAClB,IAAY,EACZ,GAAsB,EACtB,GAAY;IAEZ,OAAO;IACP,MAAM,KAAK,GAAG,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAEvD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,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AAE,CAAA;gBAC5B,CAAC;gBACD,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;AAC9C,CAAC","sourcesContent":["import { Lexicons } from '../lexicons'\nimport { LexXrpcParameters, ValidationError, ValidationResult } from '../types'\nimport { array } from './complex'\nimport * as PrimitiveValidators from './primitives'\n\nexport function params(\n lexicons: Lexicons,\n path: string,\n def: LexXrpcParameters,\n val: unknown,\n): ValidationResult<Record<string, unknown>> {\n // type\n const value = val && typeof val === 'object' ? val : {}\n\n const requiredProps = new Set(def.required ?? [])\n\n // properties\n let resultValue = value as Record<string, unknown>\n if (typeof def.properties === 'object') {\n for (const key in def.properties) {\n const propDef = def.properties[key]\n const validated =\n propDef.type === 'array'\n ? array(lexicons, key, propDef, value[key])\n : PrimitiveValidators.validate(lexicons, key, propDef, value[key])\n const propValue = validated.success ? validated.value : value[key]\n const propIsUndefined = typeof propValue === 'undefined'\n // Return error for bad validation, giving required rule precedence\n if (propIsUndefined && requiredProps.has(key)) {\n return {\n success: false,\n error: new ValidationError(`${path} must have the property \"${key}\"`),\n }\n } else if (!propIsUndefined && !validated.success) {\n return validated\n }\n // Adjust value based on e.g. applied defaults, cloning shallowly if there was a changed value\n if (propValue !== value[key]) {\n if (resultValue === value) {\n // Lazy shallow clone\n resultValue = { ...value }\n }\n resultValue[key] = propValue\n }\n }\n }\n\n return { success: true, value: resultValue }\n}\n"]}
1
+ {"version":3,"file":"xrpc.js","sourceRoot":"","sources":["../../src/validators/xrpc.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,KAAK,mBAAmB,MAAM,iBAAiB,CAAA;AAEtD,MAAM,UAAU,MAAM,CACpB,QAAkB,EAClB,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D,OAAO,SAAS,CAAA;YAClB,CAAC;YACD,8FAA8F;YAC9F,IAAI,SAAS,KAAK,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC7B,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;oBAC1B,qBAAqB;oBACrB,WAAW,GAAG,EAAE,GAAG,KAAK,EAAE,CAAA;gBAC5B,CAAC;gBACD,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;AAC9C,CAAC","sourcesContent":["import { Lexicons } from '../lexicons.js'\nimport {\n LexXrpcParameters,\n ValidationError,\n ValidationResult,\n} from '../types.js'\nimport { array } from './complex.js'\nimport * as PrimitiveValidators from './primitives.js'\n\nexport function params(\n lexicons: Lexicons,\n path: string,\n def: LexXrpcParameters,\n val: unknown,\n): ValidationResult<Record<string, unknown>> {\n // type\n const value = val && typeof val === 'object' ? val : {}\n\n const requiredProps = new Set(def.required ?? [])\n\n // properties\n let resultValue = value as Record<string, unknown>\n if (typeof def.properties === 'object') {\n for (const key in def.properties) {\n const propDef = def.properties[key]\n const validated =\n propDef.type === 'array'\n ? array(lexicons, key, propDef, value[key])\n : PrimitiveValidators.validate(lexicons, key, propDef, value[key])\n const propValue = validated.success ? validated.value : value[key]\n const propIsUndefined = typeof propValue === 'undefined'\n // Return error for bad validation, giving required rule precedence\n if (propIsUndefined && requiredProps.has(key)) {\n return {\n success: false,\n error: new ValidationError(`${path} must have the property \"${key}\"`),\n }\n } else if (!propIsUndefined && !validated.success) {\n return validated\n }\n // Adjust value based on e.g. applied defaults, cloning shallowly if there was a changed value\n if (propValue !== value[key]) {\n if (resultValue === value) {\n // Lazy shallow clone\n resultValue = { ...value }\n }\n resultValue[key] = propValue\n }\n }\n }\n\n return { success: true, value: resultValue }\n}\n"]}
@@ -1,7 +1,14 @@
1
1
  /** @type {import('jest').Config} */
2
2
  module.exports = {
3
3
  displayName: 'Lexicon',
4
- transform: { '^.+\\.ts$': '@swc/jest' },
4
+ transform: {
5
+ '^.+\\.(t|j)s$': [
6
+ '@swc/jest',
7
+ { jsc: { transform: {} }, module: { type: 'es6' } },
8
+ ],
9
+ },
10
+ extensionsToTreatAsEsm: ['.ts'],
11
+ transformIgnorePatterns: [],
5
12
  setupFiles: ['<rootDir>/../../jest.setup.ts'],
6
13
  moduleNameMapper: { '^(\\.\\.?\\/.+)\\.js$': ['$1.ts', '$1.js'] },
7
14
  }
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@atproto/lexicon",
3
- "version": "0.6.2",
3
+ "version": "0.7.0-next.0",
4
+ "engines": {
5
+ "node": ">=22"
6
+ },
4
7
  "license": "MIT",
5
8
  "description": "atproto Lexicon schema language library",
6
9
  "keywords": [
@@ -13,21 +16,26 @@
13
16
  "url": "https://github.com/bluesky-social/atproto",
14
17
  "directory": "packages/lexicon"
15
18
  },
16
- "main": "dist/index.js",
17
- "types": "dist/index.d.ts",
18
19
  "dependencies": {
19
20
  "iso-datestring-validator": "^2.2.2",
20
- "multiformats": "^9.9.0",
21
+ "multiformats": "^13.0.0",
21
22
  "zod": "^3.23.8",
22
- "@atproto/common-web": "^0.4.18",
23
- "@atproto/syntax": "^0.5.0"
23
+ "@atproto/syntax": "^0.6.0-next.0",
24
+ "@atproto/common-web": "^0.5.0-next.0"
24
25
  },
25
26
  "devDependencies": {
26
- "jest": "^28.1.2",
27
- "typescript": "^5.6.3"
27
+ "jest": "^30.0.0",
28
+ "typescript": "^6.0.3"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ }
28
36
  },
29
37
  "scripts": {
30
- "test": "jest",
38
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
31
39
  "build": "tsc --build tsconfig.build.json"
32
40
  }
33
41
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './types'
2
- export * from './lexicons'
3
- export * from './blob-refs'
4
- export * from './serialize'
1
+ export * from './types.js'
2
+ export * from './lexicons.js'
3
+ export * from './blob-refs.js'
4
+ export * from './serialize.js'
package/src/lexicons.ts CHANGED
@@ -7,16 +7,16 @@ import {
7
7
  ValidationError,
8
8
  ValidationResult,
9
9
  isObj,
10
- } from './types'
11
- import { toLexUri } from './util'
10
+ } from './types.js'
11
+ import { toLexUri } from './util.js'
12
12
  import {
13
13
  assertValidRecord,
14
14
  assertValidXrpcInput,
15
15
  assertValidXrpcMessage,
16
16
  assertValidXrpcOutput,
17
17
  assertValidXrpcParams,
18
- } from './validation'
19
- import { object as validateObject } from './validators/complex'
18
+ } from './validation.js'
19
+ import { object as validateObject } from './validators/complex.js'
20
20
 
21
21
  /**
22
22
  * A collection of compiled lexicons.
package/src/serialize.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  ipldToJson,
7
7
  jsonToIpld,
8
8
  } from '@atproto/common-web'
9
- import { BlobRef, jsonBlobRef } from './blob-refs'
9
+ import { BlobRef, jsonBlobRef } from './blob-refs.js'
10
10
 
11
11
  /**
12
12
  * @note this is equivalent to `unknown` because of {@link IpldValue} being `unknown`.
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod'
2
2
  import { validateLanguage } from '@atproto/common-web'
3
3
  import { isValidNsid } from '@atproto/syntax'
4
- import { requiredPropertiesRefinement } from './util'
4
+ import { requiredPropertiesRefinement } from './util.js'
5
5
 
6
6
  export const languageSchema = z
7
7
  .string()
package/src/validation.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Lexicons } from './lexicons'
1
+ import { Lexicons } from './lexicons.js'
2
2
  import {
3
3
  LexRecord,
4
4
  LexRefVariant,
@@ -6,9 +6,9 @@ import {
6
6
  LexXrpcProcedure,
7
7
  LexXrpcQuery,
8
8
  LexXrpcSubscription,
9
- } from './types'
10
- import { object, validateOneOf } from './validators/complex'
11
- import { params } from './validators/xrpc'
9
+ } from './types.js'
10
+ import { object, validateOneOf } from './validators/complex.js'
11
+ import { params } from './validators/xrpc.js'
12
12
 
13
13
  export function assertValidRecord(
14
14
  lexicons: Lexicons,
@@ -1,6 +1,6 @@
1
- import { BlobRef } from '../blob-refs'
2
- import { Lexicons } from '../lexicons'
3
- import { LexUserType, ValidationError, ValidationResult } from '../types'
1
+ import { BlobRef } from '../blob-refs.js'
2
+ import { Lexicons } from '../lexicons.js'
3
+ import { LexUserType, ValidationError, ValidationResult } from '../types.js'
4
4
 
5
5
  export function blob(
6
6
  lexicons: Lexicons,
@@ -1,4 +1,4 @@
1
- import { Lexicons } from '../lexicons'
1
+ import { Lexicons } from '../lexicons.js'
2
2
  import {
3
3
  LexArray,
4
4
  LexRefVariant,
@@ -7,10 +7,10 @@ import {
7
7
  ValidationResult,
8
8
  isDiscriminatedObject,
9
9
  isObj,
10
- } from '../types'
11
- import { toLexUri } from '../util'
12
- import { blob } from './blob'
13
- import { validate as validatePrimitive } from './primitives'
10
+ } from '../types.js'
11
+ import { toLexUri } from '../util.js'
12
+ import { blob } from './blob.js'
13
+ import { validate as validatePrimitive } from './primitives.js'
14
14
 
15
15
  export function validate(
16
16
  lexicons: Lexicons,
@@ -1,4 +1,5 @@
1
- import { isValidISODateString } from 'iso-datestring-validator'
1
+ import isoDatestringValidator from 'iso-datestring-validator'
2
+ const { isValidISODateString } = isoDatestringValidator
2
3
  import { CID } from 'multiformats/cid'
3
4
  import { validateLanguage } from '@atproto/common-web'
4
5
  import {
@@ -10,7 +11,7 @@ import {
10
11
  isValidTid,
11
12
  isValidUri,
12
13
  } from '@atproto/syntax'
13
- import { ValidationError, ValidationResult } from '../types'
14
+ import { ValidationError, ValidationResult } from '../types.js'
14
15
 
15
16
  export function datetime(path: string, value: string): ValidationResult {
16
17
  try {
@@ -1,6 +1,6 @@
1
1
  import { CID } from 'multiformats/cid'
2
2
  import { graphemeLen, utf8Len } from '@atproto/common-web'
3
- import { Lexicons } from '../lexicons'
3
+ import { Lexicons } from '../lexicons.js'
4
4
  import {
5
5
  LexBoolean,
6
6
  LexBytes,
@@ -9,8 +9,8 @@ import {
9
9
  LexUserType,
10
10
  ValidationError,
11
11
  ValidationResult,
12
- } from '../types'
13
- import * as formats from './formats'
12
+ } from '../types.js'
13
+ import * as formats from './formats.js'
14
14
 
15
15
  export function validate(
16
16
  lexicons: Lexicons,
@@ -1,7 +1,11 @@
1
- import { Lexicons } from '../lexicons'
2
- import { LexXrpcParameters, ValidationError, ValidationResult } from '../types'
3
- import { array } from './complex'
4
- import * as PrimitiveValidators from './primitives'
1
+ import { Lexicons } from '../lexicons.js'
2
+ import {
3
+ LexXrpcParameters,
4
+ ValidationError,
5
+ ValidationResult,
6
+ } from '../types.js'
7
+ import { array } from './complex.js'
8
+ import * as PrimitiveValidators from './primitives.js'
5
9
 
6
10
  export function params(
7
11
  lexicons: Lexicons,
@@ -1,4 +1,4 @@
1
- import { LexiconDoc } from '../../src/index'
1
+ import { LexiconDoc } from '../../src/index.js'
2
2
 
3
3
  const lexicons: LexiconDoc[] = [
4
4
  {
@@ -1,6 +1,7 @@
1
+ import assert from 'node:assert'
1
2
  import { CID } from 'multiformats/cid'
2
- import { LexiconDoc, Lexicons, parseLexiconDoc } from '../src/index'
3
- import LexiconDocs from './_scaffolds/lexicons'
3
+ import { LexiconDoc, Lexicons, parseLexiconDoc } from '../src/index.js'
4
+ import LexiconDocs from './_scaffolds/lexicons.js'
4
5
 
5
6
  describe('Lexicons collection', () => {
6
7
  const lex = new Lexicons(LexiconDocs)
@@ -79,9 +80,8 @@ describe('General validation', () => {
79
80
  }
80
81
  {
81
82
  const res = lex.validate('com.example.kitchenSink#object', {})
82
- expect(res.success).toBe(false)
83
- if (res.success) throw new Error('Asserted')
84
- expect(res.error?.message).toBe('Object must have the property "object"')
83
+ assert(!res.success)
84
+ expect(res.error.message).toBe('Object must have the property "object"')
85
85
  }
86
86
  })
87
87
  it('fails when a required property is missing', () => {
@@ -1 +1 @@
1
- {"root":["./src/blob-refs.ts","./src/index.ts","./src/lexicons.ts","./src/serialize.ts","./src/types.ts","./src/util.ts","./src/validation.ts","./src/validators/blob.ts","./src/validators/complex.ts","./src/validators/formats.ts","./src/validators/primitives.ts","./src/validators/xrpc.ts"],"version":"5.8.2"}
1
+ {"root":["./src/blob-refs.ts","./src/index.ts","./src/lexicons.ts","./src/serialize.ts","./src/types.ts","./src/util.ts","./src/validation.ts","./src/validators/blob.ts","./src/validators/complex.ts","./src/validators/formats.ts","./src/validators/primitives.ts","./src/validators/xrpc.ts"],"version":"6.0.3"}