@atproto/syntax 0.6.1 → 0.6.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atproto/syntax
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#5151](https://github.com/bluesky-social/atproto/pull/5151) [`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update dependencies
8
+
9
+ ## 0.6.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
14
+
3
15
  ## 0.6.1
4
16
 
5
17
  ### Patch Changes
package/dist/aturi.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare class AtUri {
14
14
  constructor(uri: string, base?: string | AtUri);
15
15
  static make(handleOrDid: string, collection?: string, rkey?: string): AtUri;
16
16
  get protocol(): string;
17
- get origin(): `at://did:${string}:${string}` | `at://${string}.${string}`;
17
+ get origin(): `at://${string}.${string}` | `at://did:${string}:${string}`;
18
18
  get did(): DidString;
19
19
  get hostname(): AtIdentifierString;
20
20
  set hostname(v: string);
@@ -1 +1 @@
1
- {"version":3,"file":"aturi.d.ts","sourceRoot":"","sources":["../src/aturi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAmB,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,eAAe,EAAwB,MAAM,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AE,CAAC,GACP,KAAK,IAAI,CAAC,GAAG,UAAU,CAIzB;AAKD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAiC5D;AA4BD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU,CAG7E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAgBnE;AAED,qBAAa,gBAAiB,SAAQ,KAAK;CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/syntax",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -23,7 +23,6 @@
23
23
  "tslib": "^2.8.1"
24
24
  },
25
25
  "devDependencies": {
26
- "typescript": "^6.0.3",
27
26
  "vitest": "^4.0.16"
28
27
  },
29
28
  "browser": {
@@ -38,6 +37,6 @@
38
37
  },
39
38
  "scripts": {
40
39
  "test": "vitest run",
41
- "build": "tsc --build tsconfig.build.json"
40
+ "build": "tsgo --build tsconfig.build.json"
42
41
  }
43
42
  }
@@ -7,19 +7,27 @@ import {
7
7
  } from '../src/index.js'
8
8
 
9
9
  describe('valid interop', () => {
10
- for (const value of readLines(
11
- `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_valid.txt`,
12
- )) {
13
- testValid(value)
14
- }
10
+ test.each(
11
+ readLines(
12
+ `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_valid.txt`,
13
+ ),
14
+ )('%s', (value) => {
15
+ expect(isAtUriString(value)).toBe(true)
16
+ expect(isAtUriString(value, { strict: false })).toBe(true)
17
+ expect(() => assertAtUriString(value)).not.toThrow()
18
+ expect(() => assertAtUriString(value, { strict: false })).not.toThrow()
19
+ })
15
20
  })
16
21
 
17
22
  describe('invalid interop', () => {
18
- for (const value of readLines(
19
- `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_invalid.txt`,
20
- )) {
21
- testInvalid(value)
22
- }
23
+ test.each(
24
+ readLines(
25
+ `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_invalid.txt`,
26
+ ),
27
+ )('%s', (value) => {
28
+ expect(isAtUriString(value)).toBe(false)
29
+ expect(() => assertAtUriString(value)).toThrow(InvalidAtUriError)
30
+ })
23
31
  })
24
32
 
25
33
  describe('custom cases', () => {
@@ -4,13 +4,13 @@ import { AtUri } from '../src/index.js'
4
4
 
5
5
  describe(AtUri, () => {
6
6
  describe('parses valid interop', () => {
7
- for (const value of readLines(
8
- `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_valid.txt`,
9
- )) {
10
- test(value, () => {
11
- expect(() => new AtUri(value)).not.toThrow()
12
- })
13
- }
7
+ test.each(
8
+ readLines(
9
+ `${__dirname}/../../../interop-test-files/syntax/aturi_syntax_valid.txt`,
10
+ ),
11
+ )('%s', (value) => {
12
+ expect(() => new AtUri(value)).not.toThrow()
13
+ })
14
14
  })
15
15
 
16
16
  describe('valid at uris', () => {
@@ -260,18 +260,16 @@ describe(AtUri, () => {
260
260
  '',
261
261
  ],
262
262
  ]
263
- for (const [input, host, path, search, hash] of TESTS) {
264
- test(input, () => {
265
- const urip = new AtUri(input)
266
- expect(urip.protocol).toBe('at:')
267
- expect(urip.host).toBe(host)
268
- expect(urip.hostname).toBe(host)
269
- expect(urip.origin).toBe(`at://${host}`)
270
- expect(urip.pathname).toBe(path)
271
- expect(urip.search).toBe(search)
272
- expect(urip.hash).toBe(hash)
273
- })
274
- }
263
+ test.each(TESTS)('%s', (input, host, path, search, hash) => {
264
+ const urip = new AtUri(input)
265
+ expect(urip.protocol).toBe('at:')
266
+ expect(urip.host).toBe(host)
267
+ expect(urip.hostname).toBe(host)
268
+ expect(urip.origin).toBe(`at://${host}`)
269
+ expect(urip.pathname).toBe(path)
270
+ expect(urip.search).toBe(search)
271
+ expect(urip.hash).toBe(hash)
272
+ })
275
273
  })
276
274
 
277
275
  it('handles ATP-specific parsing', () => {
@@ -360,23 +358,19 @@ describe(AtUri, () => {
360
358
  'at://did:web:localhost%3A1234/foo/bar?foo=bar&baz=buux#hash',
361
359
  ]
362
360
 
363
- for (const base of BASES) {
364
- describe(base, () => {
365
- for (const [input, path, search, hash] of TESTS) {
366
- test(input, () => {
367
- const baseUri = new AtUri(base)
368
- const uri = new AtUri(input, base)
369
- expect(uri.protocol).toBe('at:')
370
- expect(uri.host).toBe(baseUri.host)
371
- expect(uri.hostname).toBe(baseUri.hostname)
372
- expect(uri.origin).toBe(baseUri.origin)
373
- expect(uri.pathname).toBe(path)
374
- expect(uri.search).toBe(search)
375
- expect(uri.hash).toBe(hash)
376
- })
377
- }
361
+ describe.each(BASES)('%s', (base) => {
362
+ test.each(TESTS)('%s', (input, path, search, hash) => {
363
+ const baseUri = new AtUri(base)
364
+ const uri = new AtUri(input, base)
365
+ expect(uri.protocol).toBe('at:')
366
+ expect(uri.host).toBe(baseUri.host)
367
+ expect(uri.hostname).toBe(baseUri.hostname)
368
+ expect(uri.origin).toBe(baseUri.origin)
369
+ expect(uri.pathname).toBe(path)
370
+ expect(uri.search).toBe(search)
371
+ expect(uri.hash).toBe(hash)
378
372
  })
379
- }
373
+ })
380
374
  })
381
375
 
382
376
  it('properly checks that the did property is a valid did', () => {
@@ -1,5 +1,5 @@
1
1
  import * as fs from 'node:fs'
2
- import { describe, expect, it } from 'vitest'
2
+ import { describe, expect, it, test } from 'vitest'
3
3
  import {
4
4
  InvalidNsidError,
5
5
  NSID,
@@ -92,7 +92,7 @@ describe('NSID validation', () => {
92
92
  })
93
93
 
94
94
  describe('valid NSIDs', () => {
95
- for (const validNsid of [
95
+ test.each([
96
96
  'com.example.foo',
97
97
  'o'.repeat(63) + '.foo.bar',
98
98
  'com.' + 'o'.repeat(63) + '.foo',
@@ -119,15 +119,11 @@ describe('NSID validation', () => {
119
119
  'org.4chan.lex.getThing',
120
120
  'test.12345.record',
121
121
  'xn--fiqs8s.xn--fiqa61au8b7zsevnm8ak20mc4a87e.record.two',
122
- ]) {
123
- it(validNsid, () => {
124
- expectValid(validNsid)
125
- })
126
- }
122
+ ])('%s', expectValid)
127
123
  })
128
124
 
129
125
  describe('invalid NSIDs', () => {
130
- for (const invalidNsid of [
126
+ test.each([
131
127
  'o'.repeat(64) + '.foo.bar',
132
128
  'com.' + 'o'.repeat(64) + '.foo',
133
129
  'com.example.' + 'o'.repeat(64),
@@ -157,43 +153,22 @@ describe('NSID validation', () => {
157
153
  'com.-example.foo',
158
154
  'com.example.0foo',
159
155
  'com.example.f-o',
160
- ]) {
161
- it(invalidNsid, () => {
162
- expect(validateNsid(invalidNsid)).toMatchObject({
163
- success: false,
164
- message: expect.any(String),
165
- })
166
- })
167
- }
156
+ ])('%s', expectInvalid)
168
157
  })
169
158
 
170
159
  describe('conforms to interop valid NSIDs', () => {
171
- for (const line of fs
172
- .readFileSync(`${__dirname}/interop-files/nsid_syntax_valid.txt`)
173
- .toString()
174
- .split('\n')) {
175
- if (line.startsWith('#') || line.length === 0) {
176
- continue
177
- }
178
-
179
- it(line, () => {
180
- expectValid(line)
181
- })
182
- }
160
+ test.each(readInteropLines('nsid_syntax_valid.txt'))('%s', expectValid)
183
161
  })
184
162
 
185
163
  describe('conforms to interop invalid NSIDs', () => {
186
- for (const line of fs
187
- .readFileSync(`${__dirname}/interop-files/nsid_syntax_invalid.txt`)
188
- .toString()
189
- .split('\n')) {
190
- if (line.startsWith('#') || line.length === 0) {
191
- continue
192
- }
193
-
194
- it(line, () => {
195
- expectInvalid(line)
196
- })
197
- }
164
+ test.each(readInteropLines('nsid_syntax_invalid.txt'))('%s', expectInvalid)
198
165
  })
199
166
  })
167
+
168
+ function readInteropLines(filename: string): string[] {
169
+ return fs
170
+ .readFileSync(`${__dirname}/interop-files/${filename}`)
171
+ .toString()
172
+ .split('\n')
173
+ .filter((line) => line.length > 0 && !line.startsWith('#'))
174
+ }
@@ -7,6 +7,6 @@
7
7
  "importHelpers": true,
8
8
  "target": "ES2023",
9
9
  "rootDir": "./src",
10
- "outDir": "./dist"
11
- }
10
+ "outDir": "./dist",
11
+ },
12
12
  }
@@ -1 +1 @@
1
- {"root":["./src/at-identifier.ts","./src/aturi.ts","./src/aturi_validation.ts","./src/datetime.ts","./src/did.ts","./src/handle.ts","./src/index.ts","./src/language.ts","./src/nsid.ts","./src/recordkey.ts","./src/tid.ts","./src/uri.ts","./src/lib/result.ts"],"version":"6.0.3"}
1
+ {"version":"7.0.0-dev.20260614.1","root":["./src/at-identifier.ts","./src/aturi.ts","./src/aturi_validation.ts","./src/datetime.ts","./src/did.ts","./src/handle.ts","./src/index.ts","./src/language.ts","./src/nsid.ts","./src/recordkey.ts","./src/tid.ts","./src/uri.ts","./src/lib/result.ts"]}
package/tsconfig.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "include": [],
3
3
  "references": [
4
4
  { "path": "./tsconfig.build.json" },
5
- { "path": "./tsconfig.tests.json" }
6
- ]
5
+ { "path": "./tsconfig.tests.json" },
6
+ ],
7
7
  }
@@ -4,6 +4,5 @@
4
4
  "compilerOptions": {
5
5
  "noImplicitAny": true,
6
6
  "rootDir": "./",
7
- "baseUrl": "./"
8
- }
7
+ },
9
8
  }