@atproto/lexicon 0.4.1 → 0.4.3
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 +18 -0
- package/dist/types.d.ts +6282 -6282
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +53 -9
- package/dist/types.js.map +1 -1
- package/dist/util.js +3 -4
- package/dist/util.js.map +1 -1
- package/dist/validation.js +5 -6
- package/dist/validation.js.map +1 -1
- package/dist/validators/blob.js +1 -2
- package/dist/validators/blob.js.map +1 -1
- package/dist/validators/complex.js +4 -5
- package/dist/validators/complex.js.map +1 -1
- package/dist/validators/formats.d.ts.map +1 -1
- package/dist/validators/formats.js +25 -22
- package/dist/validators/formats.js.map +1 -1
- package/dist/validators/primitives.d.ts.map +1 -1
- package/dist/validators/primitives.js +70 -38
- package/dist/validators/primitives.js.map +1 -1
- package/dist/validators/xrpc.js +1 -2
- package/dist/validators/xrpc.js.map +1 -1
- package/jest.config.js +1 -2
- package/package.json +5 -4
- package/src/types.ts +52 -3
- package/src/validators/formats.ts +15 -10
- package/src/validators/primitives.ts +74 -34
- package/tests/general.test.ts +80 -3
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.tests.tsbuildinfo +1 -0
package/tests/general.test.ts
CHANGED
|
@@ -592,20 +592,97 @@ describe('Record validation', () => {
|
|
|
592
592
|
})
|
|
593
593
|
|
|
594
594
|
it('Applies grapheme string length constraint', () => {
|
|
595
|
+
// Shorter than two graphemes
|
|
596
|
+
expect(() =>
|
|
597
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
598
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
599
|
+
string: '',
|
|
600
|
+
}),
|
|
601
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
602
|
+
expect(() =>
|
|
603
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
604
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
605
|
+
string: '\u0301\u0301\u0301', // Three combining acute accents
|
|
606
|
+
}),
|
|
607
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
608
|
+
expect(() =>
|
|
609
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
610
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
611
|
+
string: 'a',
|
|
612
|
+
}),
|
|
613
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
614
|
+
expect(() =>
|
|
615
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
616
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
617
|
+
string: 'a\u0301\u0301\u0301\u0301', // 'á́́́' ('a' with four combining acute accents)
|
|
618
|
+
}),
|
|
619
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
620
|
+
expect(() =>
|
|
621
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
622
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
623
|
+
string: '5\uFE0F', // '5️' with emoji presentation
|
|
624
|
+
}),
|
|
625
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
626
|
+
expect(() =>
|
|
627
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
628
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
629
|
+
string: '👨👩👧👧',
|
|
630
|
+
}),
|
|
631
|
+
).toThrow('Record/string must not be shorter than 2 graphemes')
|
|
632
|
+
|
|
633
|
+
// Two to four graphemes
|
|
634
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
635
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
636
|
+
string: 'ab',
|
|
637
|
+
})
|
|
638
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
639
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
640
|
+
string: 'a\u0301b', // 'áb' with combining accent
|
|
641
|
+
})
|
|
642
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
643
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
644
|
+
string: 'a\u0301b\u0301', // 'áb́'
|
|
645
|
+
})
|
|
646
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
647
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
648
|
+
string: '😀😀',
|
|
649
|
+
})
|
|
595
650
|
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
596
651
|
$type: 'com.example.stringLengthGrapheme',
|
|
597
652
|
string: '12👨👩👧👧',
|
|
598
653
|
})
|
|
654
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
655
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
656
|
+
string: 'abcd',
|
|
657
|
+
})
|
|
658
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
659
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
660
|
+
string: 'a\u0301b\u0301c\u0301d\u0301', // 'áb́ćd́'
|
|
661
|
+
})
|
|
662
|
+
|
|
663
|
+
// Longer than four graphemes
|
|
599
664
|
expect(() =>
|
|
600
665
|
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
601
666
|
$type: 'com.example.stringLengthGrapheme',
|
|
602
|
-
string: '
|
|
667
|
+
string: 'abcde',
|
|
603
668
|
}),
|
|
604
|
-
).toThrow('Record/string must not be
|
|
669
|
+
).toThrow('Record/string must not be longer than 4 graphemes')
|
|
605
670
|
expect(() =>
|
|
606
671
|
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
607
672
|
$type: 'com.example.stringLengthGrapheme',
|
|
608
|
-
string: '
|
|
673
|
+
string: 'a\u0301b\u0301c\u0301d\u0301e\u0301', // 'áb́ćd́é'
|
|
674
|
+
}),
|
|
675
|
+
).toThrow('Record/string must not be longer than 4 graphemes')
|
|
676
|
+
expect(() =>
|
|
677
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
678
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
679
|
+
string: '😀😀😀😀😀',
|
|
680
|
+
}),
|
|
681
|
+
).toThrow('Record/string must not be longer than 4 graphemes')
|
|
682
|
+
expect(() =>
|
|
683
|
+
lex.assertValidRecord('com.example.stringLengthGrapheme', {
|
|
684
|
+
$type: 'com.example.stringLengthGrapheme',
|
|
685
|
+
string: 'ab😀de',
|
|
609
686
|
}),
|
|
610
687
|
).toThrow('Record/string must not be longer than 4 graphemes')
|
|
611
688
|
})
|
|
@@ -0,0 +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.6.3"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./tests/general.test.ts","./tests/_scaffolds/lexicons.ts"],"version":"5.6.3"}
|