@atproto/lex-schema 0.0.4 → 0.0.6
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 +58 -0
- package/dist/core/$type.d.ts +7 -0
- package/dist/core/$type.d.ts.map +1 -1
- package/dist/core/$type.js.map +1 -1
- package/dist/core/property-key.d.ts.map +1 -0
- package/dist/core/property-key.js.map +1 -0
- package/dist/core/result.d.ts +7 -6
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/result.js +9 -8
- package/dist/core/result.js.map +1 -1
- package/dist/{validation → core}/schema.d.ts +21 -2
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/{validation → core}/schema.js +25 -2
- package/dist/core/schema.js.map +1 -0
- package/dist/core/string-format.d.ts +37 -26
- package/dist/core/string-format.d.ts.map +1 -1
- package/dist/core/string-format.js +66 -59
- package/dist/core/string-format.js.map +1 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/validation-error.d.ts +19 -0
- package/dist/core/validation-error.d.ts.map +1 -0
- package/dist/{validation → core}/validation-error.js +13 -6
- package/dist/core/validation-error.js.map +1 -0
- package/dist/{validation → core}/validation-issue.d.ts +43 -0
- package/dist/core/validation-issue.d.ts.map +1 -0
- package/dist/{validation → core}/validation-issue.js +55 -2
- package/dist/core/validation-issue.js.map +1 -0
- package/dist/{validation → core}/validator.d.ts +5 -4
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/{validation → core}/validator.js +16 -13
- package/dist/core/validator.js.map +1 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +5 -0
- package/dist/core.js.map +1 -1
- package/dist/external.d.ts +21 -21
- package/dist/external.d.ts.map +1 -1
- package/dist/external.js +39 -55
- package/dist/external.js.map +1 -1
- package/dist/helpers.d.ts +41 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +13 -0
- package/dist/helpers.js.map +1 -0
- package/dist/schema/_parameters.d.ts +1 -1
- package/dist/schema/_parameters.d.ts.map +1 -1
- package/dist/schema/_parameters.js.map +1 -1
- package/dist/schema/array.d.ts +1 -1
- package/dist/schema/array.d.ts.map +1 -1
- package/dist/schema/array.js +2 -2
- package/dist/schema/array.js.map +1 -1
- package/dist/schema/blob.d.ts +2 -1
- package/dist/schema/blob.d.ts.map +1 -1
- package/dist/schema/blob.js +34 -20
- package/dist/schema/blob.js.map +1 -1
- package/dist/schema/boolean.d.ts +1 -1
- package/dist/schema/boolean.d.ts.map +1 -1
- package/dist/schema/boolean.js +2 -2
- package/dist/schema/boolean.js.map +1 -1
- package/dist/schema/bytes.d.ts +1 -1
- package/dist/schema/bytes.d.ts.map +1 -1
- package/dist/schema/bytes.js +2 -2
- package/dist/schema/bytes.js.map +1 -1
- package/dist/schema/cid.d.ts +1 -1
- package/dist/schema/cid.d.ts.map +1 -1
- package/dist/schema/cid.js +2 -2
- package/dist/schema/cid.js.map +1 -1
- package/dist/schema/custom.d.ts +1 -1
- package/dist/schema/custom.d.ts.map +1 -1
- package/dist/schema/custom.js +3 -3
- package/dist/schema/custom.js.map +1 -1
- package/dist/schema/dict.d.ts +1 -1
- package/dist/schema/dict.d.ts.map +1 -1
- package/dist/schema/dict.js +2 -2
- package/dist/schema/dict.js.map +1 -1
- package/dist/schema/discriminated-union.d.ts +1 -1
- package/dist/schema/discriminated-union.d.ts.map +1 -1
- package/dist/schema/discriminated-union.js +2 -2
- package/dist/schema/discriminated-union.js.map +1 -1
- package/dist/schema/enum.d.ts +1 -1
- package/dist/schema/enum.d.ts.map +1 -1
- package/dist/schema/enum.js +2 -2
- package/dist/schema/enum.js.map +1 -1
- package/dist/schema/integer.d.ts +1 -1
- package/dist/schema/integer.d.ts.map +1 -1
- package/dist/schema/integer.js +4 -4
- package/dist/schema/integer.js.map +1 -1
- package/dist/schema/intersection.d.ts +1 -2
- package/dist/schema/intersection.d.ts.map +1 -1
- package/dist/schema/intersection.js +2 -2
- package/dist/schema/intersection.js.map +1 -1
- package/dist/schema/literal.d.ts +1 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +2 -2
- package/dist/schema/literal.js.map +1 -1
- package/dist/schema/never.d.ts +1 -1
- package/dist/schema/never.d.ts.map +1 -1
- package/dist/schema/never.js +2 -2
- package/dist/schema/never.js.map +1 -1
- package/dist/schema/null.d.ts +1 -1
- package/dist/schema/null.d.ts.map +1 -1
- package/dist/schema/null.js +2 -2
- package/dist/schema/null.js.map +1 -1
- package/dist/schema/nullable.d.ts +1 -1
- package/dist/schema/nullable.d.ts.map +1 -1
- package/dist/schema/nullable.js +2 -2
- package/dist/schema/nullable.js.map +1 -1
- package/dist/schema/object.d.ts +1 -2
- package/dist/schema/object.d.ts.map +1 -1
- package/dist/schema/object.js +2 -2
- package/dist/schema/object.js.map +1 -1
- package/dist/schema/optional.d.ts +1 -1
- package/dist/schema/optional.d.ts.map +1 -1
- package/dist/schema/optional.js +2 -2
- package/dist/schema/optional.js.map +1 -1
- package/dist/schema/params.d.ts +1 -3
- package/dist/schema/params.d.ts.map +1 -1
- package/dist/schema/params.js +2 -2
- package/dist/schema/params.js.map +1 -1
- package/dist/schema/payload.d.ts +17 -15
- package/dist/schema/payload.d.ts.map +1 -1
- package/dist/schema/payload.js +28 -0
- package/dist/schema/payload.js.map +1 -1
- package/dist/schema/procedure.d.ts +3 -6
- package/dist/schema/procedure.d.ts.map +1 -1
- package/dist/schema/procedure.js +1 -0
- package/dist/schema/procedure.js.map +1 -1
- package/dist/schema/query.d.ts +3 -5
- package/dist/schema/query.d.ts.map +1 -1
- package/dist/schema/query.js +1 -0
- package/dist/schema/query.js.map +1 -1
- package/dist/schema/record.d.ts +14 -14
- package/dist/schema/record.d.ts.map +1 -1
- package/dist/schema/record.js +2 -2
- package/dist/schema/record.js.map +1 -1
- package/dist/schema/ref.d.ts +1 -1
- package/dist/schema/ref.d.ts.map +1 -1
- package/dist/schema/ref.js +2 -2
- package/dist/schema/ref.js.map +1 -1
- package/dist/schema/refine.d.ts +18 -1
- package/dist/schema/refine.d.ts.map +1 -1
- package/dist/schema/refine.js +2 -2
- package/dist/schema/refine.js.map +1 -1
- package/dist/schema/regexp.d.ts +1 -1
- package/dist/schema/regexp.d.ts.map +1 -1
- package/dist/schema/regexp.js +2 -2
- package/dist/schema/regexp.js.map +1 -1
- package/dist/schema/string.d.ts +1 -2
- package/dist/schema/string.d.ts.map +1 -1
- package/dist/schema/string.js +1 -2
- package/dist/schema/string.js.map +1 -1
- package/dist/schema/subscription.d.ts +4 -8
- package/dist/schema/subscription.d.ts.map +1 -1
- package/dist/schema/subscription.js.map +1 -1
- package/dist/schema/token.d.ts +1 -1
- package/dist/schema/token.d.ts.map +1 -1
- package/dist/schema/token.js +2 -2
- package/dist/schema/token.js.map +1 -1
- package/dist/schema/typed-object.d.ts +8 -8
- package/dist/schema/typed-object.d.ts.map +1 -1
- package/dist/schema/typed-object.js +2 -2
- package/dist/schema/typed-object.js.map +1 -1
- package/dist/schema/typed-ref.d.ts +1 -1
- package/dist/schema/typed-ref.d.ts.map +1 -1
- package/dist/schema/typed-ref.js +2 -2
- package/dist/schema/typed-ref.js.map +1 -1
- package/dist/schema/typed-union.d.ts +2 -3
- package/dist/schema/typed-union.d.ts.map +1 -1
- package/dist/schema/typed-union.js +2 -2
- package/dist/schema/typed-union.js.map +1 -1
- package/dist/schema/union.d.ts +1 -1
- package/dist/schema/union.d.ts.map +1 -1
- package/dist/schema/union.js +3 -6
- package/dist/schema/union.js.map +1 -1
- package/dist/schema/unknown-object.d.ts +1 -2
- package/dist/schema/unknown-object.d.ts.map +1 -1
- package/dist/schema/unknown-object.js +2 -2
- package/dist/schema/unknown-object.js.map +1 -1
- package/dist/schema/unknown.d.ts +1 -1
- package/dist/schema/unknown.d.ts.map +1 -1
- package/dist/schema/unknown.js +2 -2
- package/dist/schema/unknown.js.map +1 -1
- package/dist/util/assertion-util.d.ts +8 -0
- package/dist/util/assertion-util.d.ts.map +1 -0
- package/dist/util/assertion-util.js +31 -0
- package/dist/util/assertion-util.js.map +1 -0
- package/dist/util/memoize.d.ts +3 -0
- package/dist/util/memoize.d.ts.map +1 -0
- package/dist/util/memoize.js +52 -0
- package/dist/util/memoize.js.map +1 -0
- package/package.json +6 -6
- package/src/core/$type.ts +4 -0
- package/src/core/result.ts +9 -8
- package/src/{validation → core}/schema.ts +29 -4
- package/src/core/string-format.ts +88 -68
- package/src/core/types.ts +4 -0
- package/src/{validation → core}/validation-error.ts +14 -6
- package/src/{validation → core}/validation-issue.ts +64 -2
- package/src/{validation → core}/validator.ts +17 -13
- package/src/core.ts +5 -0
- package/src/external.ts +75 -55
- package/src/helpers.test.ts +487 -0
- package/src/helpers.ts +75 -0
- package/src/schema/_parameters.test.ts +1 -0
- package/src/schema/_parameters.ts +1 -1
- package/src/schema/array.test.ts +1 -0
- package/src/schema/array.ts +1 -1
- package/src/schema/blob.test.ts +3 -4
- package/src/schema/blob.ts +32 -24
- package/src/schema/boolean.test.ts +1 -0
- package/src/schema/boolean.ts +1 -1
- package/src/schema/bytes.test.ts +1 -0
- package/src/schema/bytes.ts +1 -1
- package/src/schema/cid.test.ts +1 -0
- package/src/schema/cid.ts +1 -1
- package/src/schema/custom.test.ts +8 -7
- package/src/schema/custom.ts +2 -2
- package/src/schema/dict.test.ts +1 -0
- package/src/schema/dict.ts +1 -1
- package/src/schema/discriminated-union.test.ts +1 -0
- package/src/schema/discriminated-union.ts +1 -1
- package/src/schema/enum.test.ts +1 -0
- package/src/schema/enum.ts +1 -1
- package/src/schema/integer.test.ts +1 -0
- package/src/schema/integer.ts +3 -3
- package/src/schema/intersection.test.ts +1 -0
- package/src/schema/intersection.ts +2 -2
- package/src/schema/literal.test.ts +1 -0
- package/src/schema/literal.ts +1 -1
- package/src/schema/never.test.ts +1 -0
- package/src/schema/never.ts +1 -1
- package/src/schema/null.test.ts +1 -0
- package/src/schema/null.ts +1 -1
- package/src/schema/nullable.test.ts +1 -0
- package/src/schema/nullable.ts +1 -1
- package/src/schema/object.test.ts +1 -0
- package/src/schema/object.ts +3 -3
- package/src/schema/optional.test.ts +1 -0
- package/src/schema/optional.ts +1 -1
- package/src/schema/params.test.ts +1 -0
- package/src/schema/params.ts +3 -10
- package/src/schema/payload.test.ts +1 -0
- package/src/schema/payload.ts +67 -34
- package/src/schema/permission-set.test.ts +37 -36
- package/src/schema/permission.test.ts +1 -0
- package/src/schema/procedure.test.ts +2 -62
- package/src/schema/procedure.ts +8 -20
- package/src/schema/query.test.ts +23 -69
- package/src/schema/query.ts +7 -14
- package/src/schema/record.test.ts +1 -0
- package/src/schema/record.ts +13 -6
- package/src/schema/ref.test.ts +2 -1
- package/src/schema/ref.ts +1 -1
- package/src/schema/refine.test.ts +1 -0
- package/src/schema/refine.ts +19 -2
- package/src/schema/regexp.test.ts +1 -0
- package/src/schema/regexp.ts +1 -1
- package/src/schema/string.test.ts +1 -0
- package/src/schema/string.ts +8 -2
- package/src/schema/subscription.test.ts +31 -93
- package/src/schema/subscription.ts +11 -25
- package/src/schema/token.test.ts +1 -0
- package/src/schema/token.ts +1 -1
- package/src/schema/typed-object.test.ts +1 -0
- package/src/schema/typed-object.ts +10 -5
- package/src/schema/typed-ref.test.ts +1 -0
- package/src/schema/typed-ref.ts +1 -1
- package/src/schema/typed-union.test.ts +1 -0
- package/src/schema/typed-union.ts +4 -4
- package/src/schema/union.test.ts +1 -0
- package/src/schema/union.ts +2 -5
- package/src/schema/unknown-object.test.ts +1 -0
- package/src/schema/unknown-object.ts +1 -2
- package/src/schema/unknown.test.ts +1 -0
- package/src/schema/unknown.ts +1 -1
- package/src/util/array-agg.test.ts +1 -0
- package/src/util/assertion-util.ts +40 -0
- package/src/util/memoize.ts +57 -0
- package/tsconfig.tests.json +2 -2
- package/dist/validation/property-key.d.ts.map +0 -1
- package/dist/validation/property-key.js.map +0 -1
- package/dist/validation/schema.d.ts.map +0 -1
- package/dist/validation/schema.js.map +0 -1
- package/dist/validation/validation-error.d.ts +0 -9
- package/dist/validation/validation-error.d.ts.map +0 -1
- package/dist/validation/validation-error.js.map +0 -1
- package/dist/validation/validation-issue.d.ts.map +0 -1
- package/dist/validation/validation-issue.js.map +0 -1
- package/dist/validation/validator.d.ts.map +0 -1
- package/dist/validation/validator.js.map +0 -1
- package/dist/validation.d.ts +0 -6
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -9
- package/dist/validation.js.map +0 -1
- package/src/validation.ts +0 -5
- /package/dist/{validation → core}/property-key.d.ts +0 -0
- /package/dist/{validation → core}/property-key.js +0 -0
- /package/src/{validation → core}/property-key.ts +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { asNsidString } from '../core.js'
|
|
2
3
|
import { PermissionSet } from './permission-set.js'
|
|
3
4
|
import { Permission } from './permission.js'
|
|
4
5
|
|
|
5
6
|
describe('PermissionSet', () => {
|
|
6
7
|
describe('constructor', () => {
|
|
7
8
|
it('creates a PermissionSet instance with all parameters', () => {
|
|
8
|
-
const nsid =
|
|
9
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
9
10
|
const permissions = [
|
|
10
11
|
new Permission('app.bsky.feed.post:read', {}),
|
|
11
12
|
new Permission('app.bsky.feed.post:write', {}),
|
|
@@ -24,7 +25,7 @@ describe('PermissionSet', () => {
|
|
|
24
25
|
})
|
|
25
26
|
|
|
26
27
|
it('creates a PermissionSet instance with minimal options', () => {
|
|
27
|
-
const nsid =
|
|
28
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
28
29
|
const permissions = [
|
|
29
30
|
new Permission('app.bsky.feed.post:read', {}),
|
|
30
31
|
] as const
|
|
@@ -39,7 +40,7 @@ describe('PermissionSet', () => {
|
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
it('creates a PermissionSet instance with empty permissions array', () => {
|
|
42
|
-
const nsid =
|
|
43
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
43
44
|
const permissions = [] as const
|
|
44
45
|
const options = {}
|
|
45
46
|
|
|
@@ -50,7 +51,7 @@ describe('PermissionSet', () => {
|
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
it('creates a PermissionSet instance with title only', () => {
|
|
53
|
-
const nsid =
|
|
54
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
54
55
|
const permissions = [
|
|
55
56
|
new Permission('app.bsky.feed.like:read', {}),
|
|
56
57
|
] as const
|
|
@@ -65,7 +66,7 @@ describe('PermissionSet', () => {
|
|
|
65
66
|
})
|
|
66
67
|
|
|
67
68
|
it('creates a PermissionSet instance with detail only', () => {
|
|
68
|
-
const nsid =
|
|
69
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
69
70
|
const permissions = [
|
|
70
71
|
new Permission('app.bsky.feed.like:read', {}),
|
|
71
72
|
] as const
|
|
@@ -80,7 +81,7 @@ describe('PermissionSet', () => {
|
|
|
80
81
|
})
|
|
81
82
|
|
|
82
83
|
it('creates a PermissionSet instance with localized titles', () => {
|
|
83
|
-
const nsid =
|
|
84
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
84
85
|
const permissions = [
|
|
85
86
|
new Permission('app.bsky.feed.post:read', {}),
|
|
86
87
|
] as const
|
|
@@ -102,7 +103,7 @@ describe('PermissionSet', () => {
|
|
|
102
103
|
})
|
|
103
104
|
|
|
104
105
|
it('creates a PermissionSet instance with localized details', () => {
|
|
105
|
-
const nsid =
|
|
106
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
106
107
|
const permissions = [
|
|
107
108
|
new Permission('app.bsky.feed.post:read', {}),
|
|
108
109
|
] as const
|
|
@@ -124,7 +125,7 @@ describe('PermissionSet', () => {
|
|
|
124
125
|
})
|
|
125
126
|
|
|
126
127
|
it('creates a PermissionSet instance with all options including localization', () => {
|
|
127
|
-
const nsid =
|
|
128
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
128
129
|
const permissions = [
|
|
129
130
|
new Permission('app.bsky.feed.post:read', {}),
|
|
130
131
|
new Permission('app.bsky.feed.post:write', {}),
|
|
@@ -165,7 +166,7 @@ describe('PermissionSet', () => {
|
|
|
165
166
|
|
|
166
167
|
describe('property immutability', () => {
|
|
167
168
|
it('options object itself is mutable', () => {
|
|
168
|
-
const nsid =
|
|
169
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
169
170
|
const permissions = [
|
|
170
171
|
new Permission('app.bsky.feed.post:read', {}),
|
|
171
172
|
] as const
|
|
@@ -181,7 +182,7 @@ describe('PermissionSet', () => {
|
|
|
181
182
|
|
|
182
183
|
describe('with multiple permissions', () => {
|
|
183
184
|
it('creates a PermissionSet with multiple read permissions', () => {
|
|
184
|
-
const nsid =
|
|
185
|
+
const nsid = asNsidString('app.bsky.oauth.read')
|
|
185
186
|
const permissions = [
|
|
186
187
|
new Permission('app.bsky.feed.post:read', {}),
|
|
187
188
|
new Permission('app.bsky.feed.like:read', {}),
|
|
@@ -211,7 +212,7 @@ describe('PermissionSet', () => {
|
|
|
211
212
|
})
|
|
212
213
|
|
|
213
214
|
it('creates a PermissionSet with mixed read/write permissions', () => {
|
|
214
|
-
const nsid =
|
|
215
|
+
const nsid = asNsidString('app.bsky.oauth.full')
|
|
215
216
|
const permissions = [
|
|
216
217
|
new Permission('app.bsky.feed.post:read', {}),
|
|
217
218
|
new Permission('app.bsky.feed.post:write', {}),
|
|
@@ -229,7 +230,7 @@ describe('PermissionSet', () => {
|
|
|
229
230
|
})
|
|
230
231
|
|
|
231
232
|
it('creates a PermissionSet with a single permission', () => {
|
|
232
|
-
const nsid =
|
|
233
|
+
const nsid = asNsidString('app.bsky.oauth.limited')
|
|
233
234
|
const permissions = [
|
|
234
235
|
new Permission('app.bsky.actor.profile:read', {}),
|
|
235
236
|
] as const
|
|
@@ -249,7 +250,7 @@ describe('PermissionSet', () => {
|
|
|
249
250
|
|
|
250
251
|
describe('edge cases', () => {
|
|
251
252
|
it('handles very long NSID', () => {
|
|
252
|
-
const nsid =
|
|
253
|
+
const nsid = asNsidString(
|
|
253
254
|
'com.example.very.long.namespace.identifier.oauth.permissions',
|
|
254
255
|
)
|
|
255
256
|
const permissions = [new Permission('resource:action', {})] as const
|
|
@@ -261,7 +262,7 @@ describe('PermissionSet', () => {
|
|
|
261
262
|
})
|
|
262
263
|
|
|
263
264
|
it('handles long title strings', () => {
|
|
264
|
-
const nsid =
|
|
265
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
265
266
|
const permissions = [
|
|
266
267
|
new Permission('app.bsky.feed.post:read', {}),
|
|
267
268
|
] as const
|
|
@@ -277,7 +278,7 @@ describe('PermissionSet', () => {
|
|
|
277
278
|
})
|
|
278
279
|
|
|
279
280
|
it('handles long detail strings', () => {
|
|
280
|
-
const nsid =
|
|
281
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
281
282
|
const permissions = [
|
|
282
283
|
new Permission('app.bsky.feed.post:read', {}),
|
|
283
284
|
] as const
|
|
@@ -293,7 +294,7 @@ describe('PermissionSet', () => {
|
|
|
293
294
|
})
|
|
294
295
|
|
|
295
296
|
it('handles multiple language codes in title:lang', () => {
|
|
296
|
-
const nsid =
|
|
297
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
297
298
|
const permissions = [
|
|
298
299
|
new Permission('app.bsky.feed.post:read', {}),
|
|
299
300
|
] as const
|
|
@@ -319,7 +320,7 @@ describe('PermissionSet', () => {
|
|
|
319
320
|
})
|
|
320
321
|
|
|
321
322
|
it('handles undefined values in title:lang', () => {
|
|
322
|
-
const nsid =
|
|
323
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
323
324
|
const permissions = [
|
|
324
325
|
new Permission('app.bsky.feed.post:read', {}),
|
|
325
326
|
] as const
|
|
@@ -342,7 +343,7 @@ describe('PermissionSet', () => {
|
|
|
342
343
|
})
|
|
343
344
|
|
|
344
345
|
it('handles undefined values in detail:lang', () => {
|
|
345
|
-
const nsid =
|
|
346
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
346
347
|
const permissions = [
|
|
347
348
|
new Permission('app.bsky.feed.post:read', {}),
|
|
348
349
|
] as const
|
|
@@ -363,7 +364,7 @@ describe('PermissionSet', () => {
|
|
|
363
364
|
})
|
|
364
365
|
|
|
365
366
|
it('handles special characters in title', () => {
|
|
366
|
-
const nsid =
|
|
367
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
367
368
|
const permissions = [
|
|
368
369
|
new Permission('app.bsky.feed.post:read', {}),
|
|
369
370
|
] as const
|
|
@@ -379,7 +380,7 @@ describe('PermissionSet', () => {
|
|
|
379
380
|
})
|
|
380
381
|
|
|
381
382
|
it('handles special characters in detail', () => {
|
|
382
|
-
const nsid =
|
|
383
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
383
384
|
const permissions = [
|
|
384
385
|
new Permission('app.bsky.feed.post:read', {}),
|
|
385
386
|
] as const
|
|
@@ -396,7 +397,7 @@ describe('PermissionSet', () => {
|
|
|
396
397
|
})
|
|
397
398
|
|
|
398
399
|
it('handles unicode characters in title', () => {
|
|
399
|
-
const nsid =
|
|
400
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
400
401
|
const permissions = [
|
|
401
402
|
new Permission('app.bsky.feed.post:read', {}),
|
|
402
403
|
] as const
|
|
@@ -410,7 +411,7 @@ describe('PermissionSet', () => {
|
|
|
410
411
|
})
|
|
411
412
|
|
|
412
413
|
it('handles empty strings in title', () => {
|
|
413
|
-
const nsid =
|
|
414
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
414
415
|
const permissions = [
|
|
415
416
|
new Permission('app.bsky.feed.post:read', {}),
|
|
416
417
|
] as const
|
|
@@ -424,7 +425,7 @@ describe('PermissionSet', () => {
|
|
|
424
425
|
})
|
|
425
426
|
|
|
426
427
|
it('handles empty strings in detail', () => {
|
|
427
|
-
const nsid =
|
|
428
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
428
429
|
const permissions = [
|
|
429
430
|
new Permission('app.bsky.feed.post:read', {}),
|
|
430
431
|
] as const
|
|
@@ -438,7 +439,7 @@ describe('PermissionSet', () => {
|
|
|
438
439
|
})
|
|
439
440
|
|
|
440
441
|
it('handles large number of permissions', () => {
|
|
441
|
-
const nsid =
|
|
442
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
442
443
|
const permissions = Array.from(
|
|
443
444
|
{ length: 100 },
|
|
444
445
|
(_, i) => new Permission(`resource${i}:action`, {}),
|
|
@@ -453,7 +454,7 @@ describe('PermissionSet', () => {
|
|
|
453
454
|
|
|
454
455
|
describe('real-world permission set examples', () => {
|
|
455
456
|
it('creates a feed management permission set', () => {
|
|
456
|
-
const nsid =
|
|
457
|
+
const nsid = asNsidString('app.bsky.oauth.feed')
|
|
457
458
|
const permissions = [
|
|
458
459
|
new Permission('app.bsky.feed.post:read', {}),
|
|
459
460
|
new Permission('app.bsky.feed.post:write', {}),
|
|
@@ -483,7 +484,7 @@ describe('PermissionSet', () => {
|
|
|
483
484
|
})
|
|
484
485
|
|
|
485
486
|
it('creates a read-only permission set', () => {
|
|
486
|
-
const nsid =
|
|
487
|
+
const nsid = asNsidString('app.bsky.oauth.readonly')
|
|
487
488
|
const permissions = [
|
|
488
489
|
new Permission('app.bsky.feed.post:read', {}),
|
|
489
490
|
new Permission('app.bsky.feed.like:read', {}),
|
|
@@ -504,7 +505,7 @@ describe('PermissionSet', () => {
|
|
|
504
505
|
})
|
|
505
506
|
|
|
506
507
|
it('creates a profile management permission set', () => {
|
|
507
|
-
const nsid =
|
|
508
|
+
const nsid = asNsidString('app.bsky.oauth.profile')
|
|
508
509
|
const permissions = [
|
|
509
510
|
new Permission('app.bsky.actor.profile:read', {}),
|
|
510
511
|
new Permission('app.bsky.actor.profile:write', {}),
|
|
@@ -531,7 +532,7 @@ describe('PermissionSet', () => {
|
|
|
531
532
|
})
|
|
532
533
|
|
|
533
534
|
it('creates a minimal permission set', () => {
|
|
534
|
-
const nsid =
|
|
535
|
+
const nsid = asNsidString('app.bsky.oauth.minimal')
|
|
535
536
|
const permissions = [
|
|
536
537
|
new Permission('app.bsky.actor.profile:read', {}),
|
|
537
538
|
] as const
|
|
@@ -549,7 +550,7 @@ describe('PermissionSet', () => {
|
|
|
549
550
|
|
|
550
551
|
describe('permission validation', () => {
|
|
551
552
|
it('validates that permissions are Permission instances', () => {
|
|
552
|
-
const nsid =
|
|
553
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
553
554
|
const permission1 = new Permission('app.bsky.feed.post:read', {})
|
|
554
555
|
const permission2 = new Permission('app.bsky.feed.post:write', {})
|
|
555
556
|
const permissions = [permission1, permission2] as const
|
|
@@ -562,7 +563,7 @@ describe('PermissionSet', () => {
|
|
|
562
563
|
})
|
|
563
564
|
|
|
564
565
|
it('preserves permission resource strings', () => {
|
|
565
|
-
const nsid =
|
|
566
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
566
567
|
const permissions = [
|
|
567
568
|
new Permission('app.bsky.feed.post:read', {}),
|
|
568
569
|
new Permission('app.bsky.feed.like:write', {}),
|
|
@@ -584,7 +585,7 @@ describe('PermissionSet', () => {
|
|
|
584
585
|
})
|
|
585
586
|
|
|
586
587
|
it('preserves permission options', () => {
|
|
587
|
-
const nsid =
|
|
588
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
588
589
|
const permissionOptions = { custom: 'value' }
|
|
589
590
|
const permissions = [
|
|
590
591
|
new Permission('app.bsky.feed.post:read', permissionOptions),
|
|
@@ -599,7 +600,7 @@ describe('PermissionSet', () => {
|
|
|
599
600
|
|
|
600
601
|
describe('option variations', () => {
|
|
601
602
|
it('accepts title without detail', () => {
|
|
602
|
-
const nsid =
|
|
603
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
603
604
|
const permissions = [
|
|
604
605
|
new Permission('app.bsky.feed.post:read', {}),
|
|
605
606
|
] as const
|
|
@@ -616,7 +617,7 @@ describe('PermissionSet', () => {
|
|
|
616
617
|
})
|
|
617
618
|
|
|
618
619
|
it('accepts detail without title', () => {
|
|
619
|
-
const nsid =
|
|
620
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
620
621
|
const permissions = [
|
|
621
622
|
new Permission('app.bsky.feed.post:read', {}),
|
|
622
623
|
] as const
|
|
@@ -635,7 +636,7 @@ describe('PermissionSet', () => {
|
|
|
635
636
|
})
|
|
636
637
|
|
|
637
638
|
it('accepts title:lang without title', () => {
|
|
638
|
-
const nsid =
|
|
639
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
639
640
|
const permissions = [
|
|
640
641
|
new Permission('app.bsky.feed.post:read', {}),
|
|
641
642
|
] as const
|
|
@@ -656,7 +657,7 @@ describe('PermissionSet', () => {
|
|
|
656
657
|
})
|
|
657
658
|
|
|
658
659
|
it('accepts detail:lang without detail', () => {
|
|
659
|
-
const nsid =
|
|
660
|
+
const nsid = asNsidString('app.bsky.oauth.permissions')
|
|
660
661
|
const permissions = [
|
|
661
662
|
new Permission('app.bsky.feed.post:read', {}),
|
|
662
663
|
] as const
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
1
2
|
import { ObjectSchema } from './object.js'
|
|
2
3
|
import { ParamsSchema } from './params.js'
|
|
3
4
|
import { Payload } from './payload.js'
|
|
4
|
-
import {
|
|
5
|
-
InferProcedureInputBody,
|
|
6
|
-
InferProcedureOutputBody,
|
|
7
|
-
InferProcedureParameters,
|
|
8
|
-
Procedure,
|
|
9
|
-
} from './procedure.js'
|
|
5
|
+
import { Procedure } from './procedure.js'
|
|
10
6
|
import { StringSchema } from './string.js'
|
|
11
7
|
|
|
12
8
|
describe('Procedure', () => {
|
|
@@ -288,62 +284,6 @@ describe('Procedure', () => {
|
|
|
288
284
|
})
|
|
289
285
|
})
|
|
290
286
|
|
|
291
|
-
describe('type inference helpers', () => {
|
|
292
|
-
it('infers procedure parameters type', () => {
|
|
293
|
-
const parameters = new ParamsSchema({
|
|
294
|
-
limit: new StringSchema({}),
|
|
295
|
-
})
|
|
296
|
-
const procedure = new Procedure(
|
|
297
|
-
'com.example.list',
|
|
298
|
-
parameters,
|
|
299
|
-
new Payload(undefined, undefined),
|
|
300
|
-
new Payload(undefined, undefined),
|
|
301
|
-
undefined,
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
type Params = InferProcedureParameters<typeof procedure>
|
|
305
|
-
// Type test - this will fail at compile time if inference is wrong
|
|
306
|
-
const params: Params = { limit: 'test' }
|
|
307
|
-
expect(params).toBeDefined()
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
it('infers procedure input body type', () => {
|
|
311
|
-
const inputSchema = new ObjectSchema({
|
|
312
|
-
text: new StringSchema({}),
|
|
313
|
-
})
|
|
314
|
-
const procedure = new Procedure(
|
|
315
|
-
'com.example.create',
|
|
316
|
-
new ParamsSchema({}),
|
|
317
|
-
new Payload('application/json', inputSchema),
|
|
318
|
-
new Payload(undefined, undefined),
|
|
319
|
-
undefined,
|
|
320
|
-
)
|
|
321
|
-
|
|
322
|
-
type InputBody = InferProcedureInputBody<typeof procedure>
|
|
323
|
-
// Type test - this will fail at compile time if inference is wrong
|
|
324
|
-
const input: InputBody = { text: 'hello' }
|
|
325
|
-
expect(input).toBeDefined()
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
it('infers procedure output body type', () => {
|
|
329
|
-
const outputSchema = new ObjectSchema({
|
|
330
|
-
uri: new StringSchema({}),
|
|
331
|
-
})
|
|
332
|
-
const procedure = new Procedure(
|
|
333
|
-
'com.example.get',
|
|
334
|
-
new ParamsSchema({}),
|
|
335
|
-
new Payload(undefined, undefined),
|
|
336
|
-
new Payload('application/json', outputSchema),
|
|
337
|
-
undefined,
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
type OutputBody = InferProcedureOutputBody<typeof procedure>
|
|
341
|
-
// Type test - this will fail at compile time if inference is wrong
|
|
342
|
-
const output: OutputBody = { uri: 'at://did:plc:abc/post/123' }
|
|
343
|
-
expect(output).toBeDefined()
|
|
344
|
-
})
|
|
345
|
-
})
|
|
346
|
-
|
|
347
287
|
describe('property access', () => {
|
|
348
288
|
it('provides access to all properties', () => {
|
|
349
289
|
const nsid = 'com.example.test'
|
package/src/schema/procedure.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import { NsidString } from '../core.js'
|
|
2
|
-
import { Infer } from '../validation.js'
|
|
3
2
|
import { ParamsSchema } from './params.js'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export type InferProcedureParameters<Q extends Procedure> =
|
|
7
|
-
Q extends Procedure<any, infer P extends ParamsSchema, any> ? Infer<P> : never
|
|
8
|
-
|
|
9
|
-
export type InferProcedureInputBody<Q extends Procedure> =
|
|
10
|
-
Q extends Procedure<any, any, infer I extends Payload, any>
|
|
11
|
-
? InferPayloadBody<I>
|
|
12
|
-
: never
|
|
13
|
-
|
|
14
|
-
export type InferProcedureOutputBody<Q extends Procedure> =
|
|
15
|
-
Q extends Procedure<any, any, any, infer O extends Payload>
|
|
16
|
-
? InferPayloadBody<O>
|
|
17
|
-
: never
|
|
3
|
+
import { Payload } from './payload.js'
|
|
18
4
|
|
|
19
5
|
export class Procedure<
|
|
20
|
-
TNsid extends NsidString =
|
|
21
|
-
TParameters extends ParamsSchema =
|
|
22
|
-
TInputPayload extends Payload =
|
|
23
|
-
TOutputPayload extends Payload =
|
|
24
|
-
TErrors extends undefined | readonly string[] =
|
|
6
|
+
TNsid extends NsidString = NsidString,
|
|
7
|
+
TParameters extends ParamsSchema = ParamsSchema,
|
|
8
|
+
TInputPayload extends Payload = Payload,
|
|
9
|
+
TOutputPayload extends Payload = Payload,
|
|
10
|
+
TErrors extends undefined | readonly string[] = undefined | readonly string[],
|
|
25
11
|
> {
|
|
12
|
+
readonly type = 'procedure' as const
|
|
13
|
+
|
|
26
14
|
constructor(
|
|
27
15
|
readonly nsid: TNsid,
|
|
28
16
|
readonly parameters: TParameters,
|
package/src/schema/query.test.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { asNsidString } from '../core.js'
|
|
2
3
|
import { IntegerSchema } from './integer.js'
|
|
3
4
|
import { ObjectSchema } from './object.js'
|
|
4
5
|
import { OptionalSchema } from './optional.js'
|
|
5
6
|
import { ParamsSchema } from './params.js'
|
|
6
7
|
import { Payload } from './payload.js'
|
|
7
|
-
import {
|
|
8
|
+
import { Query } from './query.js'
|
|
8
9
|
import { StringSchema } from './string.js'
|
|
9
10
|
|
|
10
11
|
describe('Query', () => {
|
|
11
12
|
describe('constructor', () => {
|
|
12
13
|
it('creates a Query instance with all parameters', () => {
|
|
13
|
-
const nsid =
|
|
14
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
14
15
|
const parameters = new ParamsSchema({
|
|
15
16
|
feed: new StringSchema({ format: 'at-uri' }),
|
|
16
17
|
limit: new OptionalSchema(
|
|
@@ -35,7 +36,7 @@ describe('Query', () => {
|
|
|
35
36
|
})
|
|
36
37
|
|
|
37
38
|
it('creates a Query instance without errors', () => {
|
|
38
|
-
const nsid =
|
|
39
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
39
40
|
const parameters = new ParamsSchema({
|
|
40
41
|
feed: new StringSchema({ format: 'at-uri' }),
|
|
41
42
|
})
|
|
@@ -56,7 +57,7 @@ describe('Query', () => {
|
|
|
56
57
|
})
|
|
57
58
|
|
|
58
59
|
it('creates a Query instance with empty parameters', () => {
|
|
59
|
-
const nsid =
|
|
60
|
+
const nsid = asNsidString('app.bsky.actor.getProfile')
|
|
60
61
|
const parameters = new ParamsSchema({})
|
|
61
62
|
const output = new Payload(
|
|
62
63
|
'application/json',
|
|
@@ -74,7 +75,7 @@ describe('Query', () => {
|
|
|
74
75
|
|
|
75
76
|
describe('properties', () => {
|
|
76
77
|
it('has nsid property', () => {
|
|
77
|
-
const nsid =
|
|
78
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
78
79
|
const parameters = new ParamsSchema({})
|
|
79
80
|
const output = new Payload('application/json', undefined)
|
|
80
81
|
|
|
@@ -85,7 +86,7 @@ describe('Query', () => {
|
|
|
85
86
|
})
|
|
86
87
|
|
|
87
88
|
it('has parameters property', () => {
|
|
88
|
-
const nsid =
|
|
89
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
89
90
|
const parameters = new ParamsSchema({
|
|
90
91
|
feed: new StringSchema({ format: 'at-uri' }),
|
|
91
92
|
})
|
|
@@ -98,7 +99,7 @@ describe('Query', () => {
|
|
|
98
99
|
})
|
|
99
100
|
|
|
100
101
|
it('has output property', () => {
|
|
101
|
-
const nsid =
|
|
102
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
102
103
|
const parameters = new ParamsSchema({})
|
|
103
104
|
const output = new Payload('application/json', undefined)
|
|
104
105
|
|
|
@@ -109,7 +110,7 @@ describe('Query', () => {
|
|
|
109
110
|
})
|
|
110
111
|
|
|
111
112
|
it('has errors property', () => {
|
|
112
|
-
const nsid =
|
|
113
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
113
114
|
const parameters = new ParamsSchema({})
|
|
114
115
|
const output = new Payload('application/json', undefined)
|
|
115
116
|
const errors = ['NotFound', 'RateLimitExceeded'] as const
|
|
@@ -123,7 +124,7 @@ describe('Query', () => {
|
|
|
123
124
|
|
|
124
125
|
describe('with complex parameters', () => {
|
|
125
126
|
it('creates a Query with multiple parameter types', () => {
|
|
126
|
-
const nsid =
|
|
127
|
+
const nsid = asNsidString('app.bsky.feed.searchPosts')
|
|
127
128
|
const parameters = new ParamsSchema({
|
|
128
129
|
q: new StringSchema({ minLength: 1 }),
|
|
129
130
|
limit: new OptionalSchema(
|
|
@@ -151,7 +152,7 @@ describe('Query', () => {
|
|
|
151
152
|
|
|
152
153
|
describe('with various output payloads', () => {
|
|
153
154
|
it('creates a Query with undefined output payload', () => {
|
|
154
|
-
const nsid =
|
|
155
|
+
const nsid = asNsidString('app.bsky.actor.getProfile')
|
|
155
156
|
const parameters = new ParamsSchema({
|
|
156
157
|
actor: new StringSchema({ format: 'at-identifier' }),
|
|
157
158
|
})
|
|
@@ -165,7 +166,7 @@ describe('Query', () => {
|
|
|
165
166
|
})
|
|
166
167
|
|
|
167
168
|
it('creates a Query with JSON payload', () => {
|
|
168
|
-
const nsid =
|
|
169
|
+
const nsid = asNsidString('app.bsky.actor.getProfile')
|
|
169
170
|
const parameters = new ParamsSchema({
|
|
170
171
|
actor: new StringSchema({ format: 'at-identifier' }),
|
|
171
172
|
})
|
|
@@ -185,7 +186,7 @@ describe('Query', () => {
|
|
|
185
186
|
})
|
|
186
187
|
|
|
187
188
|
it('creates a Query with text payload', () => {
|
|
188
|
-
const nsid =
|
|
189
|
+
const nsid = asNsidString('app.bsky.feed.getPost')
|
|
189
190
|
const parameters = new ParamsSchema({
|
|
190
191
|
uri: new StringSchema({ format: 'at-uri' }),
|
|
191
192
|
})
|
|
@@ -200,7 +201,7 @@ describe('Query', () => {
|
|
|
200
201
|
|
|
201
202
|
describe('with different error configurations', () => {
|
|
202
203
|
it('creates a Query with a single error', () => {
|
|
203
|
-
const nsid =
|
|
204
|
+
const nsid = asNsidString('app.bsky.feed.getPost')
|
|
204
205
|
const parameters = new ParamsSchema({})
|
|
205
206
|
const output = new Payload('application/json', undefined)
|
|
206
207
|
const errors = ['NotFound'] as const
|
|
@@ -211,7 +212,7 @@ describe('Query', () => {
|
|
|
211
212
|
})
|
|
212
213
|
|
|
213
214
|
it('creates a Query with multiple errors', () => {
|
|
214
|
-
const nsid =
|
|
215
|
+
const nsid = asNsidString('app.bsky.feed.getPost')
|
|
215
216
|
const parameters = new ParamsSchema({})
|
|
216
217
|
const output = new Payload('application/json', undefined)
|
|
217
218
|
const errors = ['NotFound', 'Unauthorized', 'RateLimitExceeded'] as const
|
|
@@ -226,7 +227,7 @@ describe('Query', () => {
|
|
|
226
227
|
})
|
|
227
228
|
|
|
228
229
|
it('creates a Query with empty errors array', () => {
|
|
229
|
-
const nsid =
|
|
230
|
+
const nsid = asNsidString('app.bsky.feed.getPost')
|
|
230
231
|
const parameters = new ParamsSchema({})
|
|
231
232
|
const output = new Payload('application/json', undefined)
|
|
232
233
|
const errors = [] as const
|
|
@@ -237,56 +238,9 @@ describe('Query', () => {
|
|
|
237
238
|
})
|
|
238
239
|
})
|
|
239
240
|
|
|
240
|
-
describe('type inference', () => {
|
|
241
|
-
it('InferQueryParameters correctly infers parameter types', () => {
|
|
242
|
-
const nsid = asNsid('app.bsky.feed.getFeedSkeleton')
|
|
243
|
-
const parameters = new ParamsSchema({
|
|
244
|
-
feed: new StringSchema({ format: 'at-uri' }),
|
|
245
|
-
limit: new OptionalSchema(new IntegerSchema({})),
|
|
246
|
-
})
|
|
247
|
-
const output = new Payload('application/json', undefined)
|
|
248
|
-
|
|
249
|
-
const query = new Query(nsid, parameters, output, undefined)
|
|
250
|
-
|
|
251
|
-
type Params = InferQueryParameters<typeof query>
|
|
252
|
-
|
|
253
|
-
// Type-level test - this should compile without errors
|
|
254
|
-
const params: Params = {
|
|
255
|
-
feed: 'at://did:plc:abc123/app.bsky.feed.post/xyz',
|
|
256
|
-
limit: 50,
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
expect(params.feed).toBeDefined()
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
it('InferQueryOutputBody correctly infers output body type', () => {
|
|
263
|
-
const nsid = asNsid('app.bsky.feed.getFeedSkeleton')
|
|
264
|
-
const parameters = new ParamsSchema({})
|
|
265
|
-
const output = new Payload(
|
|
266
|
-
'application/json',
|
|
267
|
-
new ObjectSchema({
|
|
268
|
-
cursor: new OptionalSchema(new StringSchema({})),
|
|
269
|
-
feed: new StringSchema({ format: 'at-uri' }),
|
|
270
|
-
}),
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
const query = new Query(nsid, parameters, output, undefined)
|
|
274
|
-
|
|
275
|
-
type OutputBody = InferQueryOutputBody<typeof query>
|
|
276
|
-
|
|
277
|
-
// Type-level test - this should compile without errors
|
|
278
|
-
const outputBody: OutputBody = {
|
|
279
|
-
cursor: 'abc123',
|
|
280
|
-
feed: 'at://did:plc:abc123/app.bsky.feed.post/xyz',
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
expect(outputBody.feed).toBeDefined()
|
|
284
|
-
})
|
|
285
|
-
})
|
|
286
|
-
|
|
287
241
|
describe('edge cases', () => {
|
|
288
242
|
it('handles very long NSID', () => {
|
|
289
|
-
const nsid =
|
|
243
|
+
const nsid = asNsidString(
|
|
290
244
|
'com.example.very.long.namespace.identifier.method.name',
|
|
291
245
|
)
|
|
292
246
|
const parameters = new ParamsSchema({})
|
|
@@ -298,7 +252,7 @@ describe('Query', () => {
|
|
|
298
252
|
})
|
|
299
253
|
|
|
300
254
|
it('handles query with all optional parameters', () => {
|
|
301
|
-
const nsid =
|
|
255
|
+
const nsid = asNsidString('app.bsky.feed.search')
|
|
302
256
|
const parameters = new ParamsSchema({
|
|
303
257
|
q: new OptionalSchema(new StringSchema({})),
|
|
304
258
|
limit: new OptionalSchema(new IntegerSchema({})),
|
|
@@ -312,7 +266,7 @@ describe('Query', () => {
|
|
|
312
266
|
})
|
|
313
267
|
|
|
314
268
|
it('handles query with complex nested output schema', () => {
|
|
315
|
-
const nsid =
|
|
269
|
+
const nsid = asNsidString('app.bsky.feed.getTimeline')
|
|
316
270
|
const parameters = new ParamsSchema({})
|
|
317
271
|
const output = new Payload(
|
|
318
272
|
'application/json',
|
|
@@ -335,7 +289,7 @@ describe('Query', () => {
|
|
|
335
289
|
|
|
336
290
|
describe('real-world query examples', () => {
|
|
337
291
|
it('creates a getFeedSkeleton query', () => {
|
|
338
|
-
const nsid =
|
|
292
|
+
const nsid = asNsidString('app.bsky.feed.getFeedSkeleton')
|
|
339
293
|
const parameters = new ParamsSchema({
|
|
340
294
|
feed: new StringSchema({ format: 'at-uri' }),
|
|
341
295
|
limit: new OptionalSchema(
|
|
@@ -357,7 +311,7 @@ describe('Query', () => {
|
|
|
357
311
|
})
|
|
358
312
|
|
|
359
313
|
it('creates a searchPosts query', () => {
|
|
360
|
-
const nsid =
|
|
314
|
+
const nsid = asNsidString('app.bsky.feed.searchPosts')
|
|
361
315
|
const parameters = new ParamsSchema({
|
|
362
316
|
q: new StringSchema({ minLength: 1, maxLength: 300 }),
|
|
363
317
|
limit: new OptionalSchema(
|
|
@@ -382,7 +336,7 @@ describe('Query', () => {
|
|
|
382
336
|
})
|
|
383
337
|
|
|
384
338
|
it('creates a getProfile query', () => {
|
|
385
|
-
const nsid =
|
|
339
|
+
const nsid = asNsidString('app.bsky.actor.getProfile')
|
|
386
340
|
const parameters = new ParamsSchema({
|
|
387
341
|
actor: new StringSchema({ format: 'at-identifier' }),
|
|
388
342
|
})
|