@imbue-ai/detent 1.0.1

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 (104) hide show
  1. package/README.md +246 -0
  2. package/dist/src/builtinPatterns/any.json +3 -0
  3. package/dist/src/builtinPatterns/builtinPatterns/any.json +3 -0
  4. package/dist/src/builtinPatterns.d.ts +5 -0
  5. package/dist/src/builtinPatterns.d.ts.map +1 -0
  6. package/dist/src/builtinPatterns.js +50 -0
  7. package/dist/src/builtinPatterns.js.map +1 -0
  8. package/dist/src/check.d.ts +2 -0
  9. package/dist/src/check.d.ts.map +1 -0
  10. package/dist/src/check.js +8 -0
  11. package/dist/src/check.js.map +1 -0
  12. package/dist/src/cli.d.ts +3 -0
  13. package/dist/src/cli.d.ts.map +1 -0
  14. package/dist/src/cli.js +64 -0
  15. package/dist/src/cli.js.map +1 -0
  16. package/dist/src/config.d.ts +18 -0
  17. package/dist/src/config.d.ts.map +1 -0
  18. package/dist/src/config.js +157 -0
  19. package/dist/src/config.js.map +1 -0
  20. package/dist/src/curl.d.ts +5 -0
  21. package/dist/src/curl.d.ts.map +1 -0
  22. package/dist/src/curl.js +394 -0
  23. package/dist/src/curl.js.map +1 -0
  24. package/dist/src/decomposedRequest.d.ts +24 -0
  25. package/dist/src/decomposedRequest.d.ts.map +1 -0
  26. package/dist/src/decomposedRequest.js +51 -0
  27. package/dist/src/decomposedRequest.js.map +1 -0
  28. package/dist/src/detentConfig.d.ts +15 -0
  29. package/dist/src/detentConfig.d.ts.map +1 -0
  30. package/dist/src/detentConfig.js +169 -0
  31. package/dist/src/detentConfig.js.map +1 -0
  32. package/dist/src/dump.d.ts +6 -0
  33. package/dist/src/dump.d.ts.map +1 -0
  34. package/dist/src/dump.js +14 -0
  35. package/dist/src/dump.js.map +1 -0
  36. package/dist/src/environment.d.ts +3 -0
  37. package/dist/src/environment.d.ts.map +1 -0
  38. package/dist/src/environment.js +15 -0
  39. package/dist/src/environment.js.map +1 -0
  40. package/dist/src/index.d.ts +9 -0
  41. package/dist/src/index.d.ts.map +1 -0
  42. package/dist/src/index.js +7 -0
  43. package/dist/src/index.js.map +1 -0
  44. package/dist/src/patterns/builtin/any.json +3 -0
  45. package/dist/src/patterns/builtin/builtin/any.json +3 -0
  46. package/dist/src/patterns/builtin/builtin/aws.json +326 -0
  47. package/dist/src/patterns/builtin/builtin/calendly.json +274 -0
  48. package/dist/src/patterns/builtin/builtin/coolify.json +238 -0
  49. package/dist/src/patterns/builtin/builtin/discord.json +157 -0
  50. package/dist/src/patterns/builtin/builtin/dropbox.json +115 -0
  51. package/dist/src/patterns/builtin/builtin/figma.json +228 -0
  52. package/dist/src/patterns/builtin/builtin/github.json +248 -0
  53. package/dist/src/patterns/builtin/builtin/gitlab.json +262 -0
  54. package/dist/src/patterns/builtin/builtin/google-analytics.json +155 -0
  55. package/dist/src/patterns/builtin/builtin/google-calendar.json +227 -0
  56. package/dist/src/patterns/builtin/builtin/google-directions.json +67 -0
  57. package/dist/src/patterns/builtin/builtin/google-docs.json +102 -0
  58. package/dist/src/patterns/builtin/builtin/google-drive.json +162 -0
  59. package/dist/src/patterns/builtin/builtin/google-gmail.json +257 -0
  60. package/dist/src/patterns/builtin/builtin/google-people.json +142 -0
  61. package/dist/src/patterns/builtin/builtin/google-sheets.json +115 -0
  62. package/dist/src/patterns/builtin/builtin/linear.json +12 -0
  63. package/dist/src/patterns/builtin/builtin/mailchimp.json +263 -0
  64. package/dist/src/patterns/builtin/builtin/notion.json +230 -0
  65. package/dist/src/patterns/builtin/builtin/sentry.json +172 -0
  66. package/dist/src/patterns/builtin/builtin/slack.json +221 -0
  67. package/dist/src/patterns/builtin/builtin/stripe.json +347 -0
  68. package/dist/src/patterns/builtin/builtin/telegram.json +89 -0
  69. package/dist/src/patterns/builtin/builtin/umami.json +172 -0
  70. package/dist/src/patterns/builtin/builtin/yelp.json +147 -0
  71. package/dist/src/patterns/builtin/builtin/zoom.json +192 -0
  72. package/dist/src/patterns/requestPattern.d.ts +33 -0
  73. package/dist/src/patterns/requestPattern.d.ts.map +1 -0
  74. package/dist/src/patterns/requestPattern.js +157 -0
  75. package/dist/src/patterns/requestPattern.js.map +1 -0
  76. package/dist/src/requestPattern.d.ts +15 -0
  77. package/dist/src/requestPattern.d.ts.map +1 -0
  78. package/dist/src/requestPattern.js +35 -0
  79. package/dist/src/requestPattern.js.map +1 -0
  80. package/dist/tests/builtinPatterns.test.d.ts +2 -0
  81. package/dist/tests/builtinPatterns.test.d.ts.map +1 -0
  82. package/dist/tests/builtinPatterns.test.js +1293 -0
  83. package/dist/tests/builtinPatterns.test.js.map +1 -0
  84. package/dist/tests/check.test.d.ts +2 -0
  85. package/dist/tests/check.test.d.ts.map +1 -0
  86. package/dist/tests/check.test.js +671 -0
  87. package/dist/tests/check.test.js.map +1 -0
  88. package/dist/tests/cli.test.d.ts +2 -0
  89. package/dist/tests/cli.test.d.ts.map +1 -0
  90. package/dist/tests/cli.test.js +77 -0
  91. package/dist/tests/cli.test.js.map +1 -0
  92. package/dist/tests/codeQuality.test.d.ts +2 -0
  93. package/dist/tests/codeQuality.test.d.ts.map +1 -0
  94. package/dist/tests/codeQuality.test.js +15 -0
  95. package/dist/tests/codeQuality.test.js.map +1 -0
  96. package/dist/tests/curl.test.d.ts +2 -0
  97. package/dist/tests/curl.test.d.ts.map +1 -0
  98. package/dist/tests/curl.test.js +241 -0
  99. package/dist/tests/curl.test.js.map +1 -0
  100. package/dist/tests/dump.test.d.ts +2 -0
  101. package/dist/tests/dump.test.d.ts.map +1 -0
  102. package/dist/tests/dump.test.js +154 -0
  103. package/dist/tests/dump.test.js.map +1 -0
  104. package/package.json +67 -0
@@ -0,0 +1,1293 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { PatternRegistry, getAllBuiltinSchemas } from '../src/patterns/requestPattern.js';
3
+ const builtinRegistry = new PatternRegistry(getAllBuiltinSchemas());
4
+ function makeRequest(overrides = {}) {
5
+ return {
6
+ protocol: 'https',
7
+ domain: 'example.com',
8
+ port: 443,
9
+ path: '/',
10
+ method: 'GET',
11
+ headers: {},
12
+ queryParams: {},
13
+ body: undefined,
14
+ ...overrides,
15
+ };
16
+ }
17
+ function expectPatternExists(name) {
18
+ expect(builtinRegistry.get(name), `Expected builtin pattern "${name}" to exist`).toBeDefined();
19
+ }
20
+ describe('builtin patterns: aws', () => {
21
+ it('aws scope matches regional endpoints', () => {
22
+ expectPatternExists('aws');
23
+ expect(builtinRegistry.get('aws').match(makeRequest({ domain: 'ec2.us-east-1.amazonaws.com' }))).toBe(true);
24
+ expect(builtinRegistry.get('aws').match(makeRequest({ domain: 's3.us-west-2.amazonaws.com' }))).toBe(true);
25
+ });
26
+ it('aws scope matches global endpoints without region', () => {
27
+ expect(builtinRegistry.get('aws').match(makeRequest({ domain: 'ec2.amazonaws.com' }))).toBe(true);
28
+ expect(builtinRegistry.get('aws').match(makeRequest({ domain: 'iam.amazonaws.com' }))).toBe(true);
29
+ });
30
+ it('aws scope rejects unrelated domains', () => {
31
+ expect(builtinRegistry.get('aws').match(makeRequest({ domain: 'amazonaws.example.com' }))).toBe(false);
32
+ });
33
+ it('service-specific patterns match regional endpoints', () => {
34
+ const regionalEndpoints = {
35
+ 'aws-ec2': 'ec2.us-east-1.amazonaws.com',
36
+ 'aws-lambda': 'lambda.us-west-2.amazonaws.com',
37
+ 'aws-dynamodb': 'dynamodb.eu-west-1.amazonaws.com',
38
+ 'aws-cloudformation': 'cloudformation.us-east-1.amazonaws.com',
39
+ 'aws-logs': 'logs.us-east-1.amazonaws.com',
40
+ 'aws-cloudwatch': 'monitoring.us-east-1.amazonaws.com',
41
+ 'aws-sns': 'sns.us-east-1.amazonaws.com',
42
+ 'aws-sqs': 'sqs.us-east-1.amazonaws.com',
43
+ 'aws-ssm': 'ssm.us-east-1.amazonaws.com',
44
+ 'aws-secretsmanager': 'secretsmanager.us-east-1.amazonaws.com',
45
+ 'aws-ecs': 'ecs.us-east-1.amazonaws.com',
46
+ 'aws-ecr': 'ecr.us-east-1.amazonaws.com',
47
+ 'aws-eks': 'eks.us-east-1.amazonaws.com',
48
+ 'aws-bedrock': 'bedrock.us-east-1.amazonaws.com',
49
+ 'aws-rds': 'rds.us-east-1.amazonaws.com',
50
+ 'aws-kms': 'kms.us-east-1.amazonaws.com',
51
+ 'aws-elb': 'elasticloadbalancing.us-east-1.amazonaws.com',
52
+ 'aws-cloudtrail': 'cloudtrail.us-east-1.amazonaws.com',
53
+ 'aws-eventbridge': 'events.us-east-1.amazonaws.com',
54
+ 'aws-kinesis': 'kinesis.us-east-1.amazonaws.com',
55
+ 'aws-s3': 's3.us-east-1.amazonaws.com',
56
+ 'aws-iam': 'iam.us-east-1.amazonaws.com',
57
+ 'aws-sts': 'sts.us-east-1.amazonaws.com',
58
+ 'aws-route53': 'route53.us-east-1.amazonaws.com',
59
+ 'aws-cloudfront': 'cloudfront.us-east-1.amazonaws.com',
60
+ };
61
+ for (const [pattern, domain] of Object.entries(regionalEndpoints)) {
62
+ expectPatternExists(pattern);
63
+ expect(builtinRegistry.get(pattern).match(makeRequest({ domain })), `Expected "${pattern}" to match regional domain "${domain}"`).toBe(true);
64
+ }
65
+ });
66
+ it('service-specific patterns match global endpoints without region', () => {
67
+ const globalEndpoints = {
68
+ 'aws-ec2': 'ec2.amazonaws.com',
69
+ 'aws-lambda': 'lambda.amazonaws.com',
70
+ 'aws-dynamodb': 'dynamodb.amazonaws.com',
71
+ 'aws-cloudformation': 'cloudformation.amazonaws.com',
72
+ 'aws-logs': 'logs.amazonaws.com',
73
+ 'aws-cloudwatch': 'monitoring.amazonaws.com',
74
+ 'aws-sns': 'sns.amazonaws.com',
75
+ 'aws-sqs': 'sqs.amazonaws.com',
76
+ 'aws-ssm': 'ssm.amazonaws.com',
77
+ 'aws-secretsmanager': 'secretsmanager.amazonaws.com',
78
+ 'aws-ecs': 'ecs.amazonaws.com',
79
+ 'aws-ecr': 'ecr.amazonaws.com',
80
+ 'aws-eks': 'eks.amazonaws.com',
81
+ 'aws-bedrock': 'bedrock.amazonaws.com',
82
+ 'aws-rds': 'rds.amazonaws.com',
83
+ 'aws-kms': 'kms.amazonaws.com',
84
+ 'aws-elb': 'elasticloadbalancing.amazonaws.com',
85
+ 'aws-cloudtrail': 'cloudtrail.amazonaws.com',
86
+ 'aws-eventbridge': 'events.amazonaws.com',
87
+ 'aws-kinesis': 'kinesis.amazonaws.com',
88
+ 'aws-s3': 's3.amazonaws.com',
89
+ 'aws-iam': 'iam.amazonaws.com',
90
+ 'aws-sts': 'sts.amazonaws.com',
91
+ 'aws-route53': 'route53.amazonaws.com',
92
+ 'aws-cloudfront': 'cloudfront.amazonaws.com',
93
+ };
94
+ for (const [pattern, domain] of Object.entries(globalEndpoints)) {
95
+ expectPatternExists(pattern);
96
+ expect(builtinRegistry.get(pattern).match(makeRequest({ domain })), `Expected "${pattern}" to match global domain "${domain}"`).toBe(true);
97
+ }
98
+ });
99
+ it('service-specific patterns match FIPS endpoints', () => {
100
+ expectPatternExists('aws-ec2');
101
+ expect(builtinRegistry
102
+ .get('aws-ec2')
103
+ .match(makeRequest({ domain: 'ec2-fips.us-east-1.amazonaws.com' }))).toBe(true);
104
+ expectPatternExists('aws-s3');
105
+ expect(builtinRegistry
106
+ .get('aws-s3')
107
+ .match(makeRequest({ domain: 's3-fips.us-east-1.amazonaws.com' }))).toBe(true);
108
+ });
109
+ it('service-specific patterns reject unrelated services', () => {
110
+ expect(builtinRegistry
111
+ .get('aws-ec2')
112
+ .match(makeRequest({ domain: 'lambda.us-east-1.amazonaws.com' }))).toBe(false);
113
+ expect(builtinRegistry
114
+ .get('aws-lambda')
115
+ .match(makeRequest({ domain: 'ec2.us-east-1.amazonaws.com' }))).toBe(false);
116
+ });
117
+ it('aws-s3 matches bucket-style domains', () => {
118
+ expectPatternExists('aws-s3');
119
+ expect(builtinRegistry
120
+ .get('aws-s3')
121
+ .match(makeRequest({ domain: 'my-bucket.s3.us-east-1.amazonaws.com' }))).toBe(true);
122
+ expect(builtinRegistry.get('aws-s3').match(makeRequest({ domain: 'my-bucket.s3.amazonaws.com' }))).toBe(true);
123
+ });
124
+ it('aws-s3-read matches GET to S3 and rejects POST', () => {
125
+ expectPatternExists('aws-s3-read');
126
+ expect(builtinRegistry
127
+ .get('aws-s3-read')
128
+ .match(makeRequest({ domain: 's3.us-east-1.amazonaws.com', method: 'GET' }))).toBe(true);
129
+ expect(builtinRegistry
130
+ .get('aws-s3-read')
131
+ .match(makeRequest({ domain: 's3.us-east-1.amazonaws.com', method: 'POST' }))).toBe(false);
132
+ });
133
+ it('aws-s3-write matches POST to S3 and rejects GET', () => {
134
+ expectPatternExists('aws-s3-write');
135
+ expect(builtinRegistry
136
+ .get('aws-s3-write')
137
+ .match(makeRequest({ domain: 's3.us-east-1.amazonaws.com', method: 'PUT' }))).toBe(true);
138
+ expect(builtinRegistry
139
+ .get('aws-s3-write')
140
+ .match(makeRequest({ domain: 's3.us-east-1.amazonaws.com', method: 'GET' }))).toBe(false);
141
+ });
142
+ it('aws-ecr matches prefixed domains', () => {
143
+ expectPatternExists('aws-ecr');
144
+ expect(builtinRegistry
145
+ .get('aws-ecr')
146
+ .match(makeRequest({ domain: 'api.ecr.us-east-1.amazonaws.com' }))).toBe(true);
147
+ expect(builtinRegistry
148
+ .get('aws-ecr')
149
+ .match(makeRequest({ domain: 'dkr.ecr.us-east-1.amazonaws.com' }))).toBe(true);
150
+ });
151
+ it('aws-bedrock matches runtime subdomain', () => {
152
+ expectPatternExists('aws-bedrock');
153
+ expect(builtinRegistry
154
+ .get('aws-bedrock')
155
+ .match(makeRequest({ domain: 'bedrock-runtime.us-east-1.amazonaws.com' }))).toBe(true);
156
+ });
157
+ });
158
+ describe('builtin patterns: calendly', () => {
159
+ it('calendly scope matches api.calendly.com', () => {
160
+ expectPatternExists('calendly-api');
161
+ const request = makeRequest({ domain: 'api.calendly.com', path: '/users/me' });
162
+ expect(builtinRegistry.get('calendly-api').match(request)).toBe(true);
163
+ });
164
+ it('calendly scope rejects unrelated domains', () => {
165
+ const request = makeRequest({ domain: 'calendly.example.com' });
166
+ expect(builtinRegistry.get('calendly-api').match(request)).toBe(false);
167
+ });
168
+ it('calendly-read-event-types matches GET to /event_types path', () => {
169
+ expectPatternExists('calendly-read-event-types');
170
+ expect(builtinRegistry
171
+ .get('calendly-read-event-types')
172
+ .match(makeRequest({ method: 'GET', path: '/event_types' }))).toBe(true);
173
+ expect(builtinRegistry
174
+ .get('calendly-read-event-types')
175
+ .match(makeRequest({ method: 'GET', path: '/scheduled_events' }))).toBe(false);
176
+ });
177
+ it('calendly-write-webhooks matches POST to /webhook_subscriptions path', () => {
178
+ expectPatternExists('calendly-write-webhooks');
179
+ expect(builtinRegistry
180
+ .get('calendly-write-webhooks')
181
+ .match(makeRequest({ method: 'POST', path: '/webhook_subscriptions' }))).toBe(true);
182
+ expect(builtinRegistry
183
+ .get('calendly-write-webhooks')
184
+ .match(makeRequest({ method: 'POST', path: '/event_types' }))).toBe(false);
185
+ });
186
+ });
187
+ describe('builtin patterns: coolify', () => {
188
+ it('coolify scope matches the coolify API domain', () => {
189
+ expectPatternExists('coolify-api');
190
+ const request = makeRequest({ domain: 'app.coolify.io', path: '/api/v1/servers' });
191
+ expect(builtinRegistry.get('coolify-api').match(request)).toBe(true);
192
+ });
193
+ it('coolify-read-all matches GET requests', () => {
194
+ expectPatternExists('coolify-read-all');
195
+ const get = makeRequest({ method: 'GET' });
196
+ expect(builtinRegistry.get('coolify-read-all').match(get)).toBe(true);
197
+ });
198
+ it('coolify-write-all rejects GET requests', () => {
199
+ expectPatternExists('coolify-write-all');
200
+ const get = makeRequest({ method: 'GET' });
201
+ expect(builtinRegistry.get('coolify-write-all').match(get)).toBe(false);
202
+ });
203
+ it('coolify-deployments matches deployment-related paths', () => {
204
+ expectPatternExists('coolify-deployments');
205
+ const request = makeRequest({ path: '/api/v1/deployments' });
206
+ expect(builtinRegistry.get('coolify-deployments').match(request)).toBe(true);
207
+ });
208
+ });
209
+ describe('builtin patterns: discord', () => {
210
+ it('discord scope matches discord.com', () => {
211
+ expectPatternExists('discord-api');
212
+ const request = makeRequest({ domain: 'discord.com', path: '/api/v10/channels/123' });
213
+ expect(builtinRegistry.get('discord-api').match(request)).toBe(true);
214
+ });
215
+ it('discord scope rejects unrelated domains', () => {
216
+ const request = makeRequest({ domain: 'discordapp.example.com' });
217
+ expect(builtinRegistry.get('discord-api').match(request)).toBe(false);
218
+ });
219
+ it('discord-read-guilds matches GET to guilds path', () => {
220
+ expectPatternExists('discord-read-guilds');
221
+ expect(builtinRegistry
222
+ .get('discord-read-guilds')
223
+ .match(makeRequest({ method: 'GET', path: '/api/v10/guilds/123456' }))).toBe(true);
224
+ expect(builtinRegistry
225
+ .get('discord-read-guilds')
226
+ .match(makeRequest({ method: 'GET', path: '/api/v10/channels/123' }))).toBe(false);
227
+ });
228
+ it('discord-write-messages matches POST to channel messages path', () => {
229
+ expectPatternExists('discord-write-messages');
230
+ expect(builtinRegistry
231
+ .get('discord-write-messages')
232
+ .match(makeRequest({ method: 'POST', path: '/api/v10/channels/123/messages' }))).toBe(true);
233
+ expect(builtinRegistry
234
+ .get('discord-write-messages')
235
+ .match(makeRequest({ method: 'POST', path: '/api/v10/guilds/456' }))).toBe(false);
236
+ });
237
+ });
238
+ describe('builtin patterns: dropbox', () => {
239
+ it('dropbox scope matches api.dropboxapi.com', () => {
240
+ expectPatternExists('dropbox-api');
241
+ const request = makeRequest({ domain: 'api.dropboxapi.com', path: '/2/files/list_folder' });
242
+ expect(builtinRegistry.get('dropbox-api').match(request)).toBe(true);
243
+ });
244
+ it('dropbox scope rejects unrelated domains', () => {
245
+ const request = makeRequest({ domain: 'dropbox.example.com' });
246
+ expect(builtinRegistry.get('dropbox-api').match(request)).toBe(false);
247
+ });
248
+ it('dropbox-files-read matches read paths like list_folder', () => {
249
+ expectPatternExists('dropbox-files-read');
250
+ expect(builtinRegistry
251
+ .get('dropbox-files-read')
252
+ .match(makeRequest({ path: '/2/files/list_folder' }))).toBe(true);
253
+ expect(builtinRegistry.get('dropbox-files-read').match(makeRequest({ path: '/2/files/upload' }))).toBe(false);
254
+ });
255
+ it('dropbox-sharing-read matches sharing read paths', () => {
256
+ expectPatternExists('dropbox-sharing-read');
257
+ expect(builtinRegistry
258
+ .get('dropbox-sharing-read')
259
+ .match(makeRequest({ path: '/2/sharing/list_folders' }))).toBe(true);
260
+ expect(builtinRegistry
261
+ .get('dropbox-sharing-read')
262
+ .match(makeRequest({ path: '/2/sharing/add_folder_member' }))).toBe(false);
263
+ });
264
+ });
265
+ describe('builtin patterns: figma', () => {
266
+ it('figma scope matches api.figma.com', () => {
267
+ expectPatternExists('figma-api');
268
+ const request = makeRequest({ domain: 'api.figma.com', path: '/v1/files/abc123' });
269
+ expect(builtinRegistry.get('figma-api').match(request)).toBe(true);
270
+ });
271
+ it('figma scope rejects unrelated domains', () => {
272
+ const request = makeRequest({ domain: 'figma.example.com' });
273
+ expect(builtinRegistry.get('figma-api').match(request)).toBe(false);
274
+ });
275
+ it('figma-read-files matches GET to /v1/files path', () => {
276
+ expectPatternExists('figma-read-files');
277
+ expect(builtinRegistry
278
+ .get('figma-read-files')
279
+ .match(makeRequest({ method: 'GET', path: '/v1/files/abc123' }))).toBe(true);
280
+ expect(builtinRegistry
281
+ .get('figma-read-files')
282
+ .match(makeRequest({ method: 'GET', path: '/v1/projects/456' }))).toBe(false);
283
+ });
284
+ it('figma-write-comments matches POST to comments path', () => {
285
+ expectPatternExists('figma-write-comments');
286
+ expect(builtinRegistry
287
+ .get('figma-write-comments')
288
+ .match(makeRequest({ method: 'POST', path: '/v1/files/abc123/comments' }))).toBe(true);
289
+ });
290
+ });
291
+ describe('builtin patterns: github', () => {
292
+ it('github scope matches api.github.com', () => {
293
+ expectPatternExists('github-rest-api');
294
+ const request = makeRequest({ domain: 'api.github.com', path: '/repos/octocat/hello' });
295
+ expect(builtinRegistry.get('github-rest-api').match(request)).toBe(true);
296
+ });
297
+ it('github scope rejects unrelated domains', () => {
298
+ const request = makeRequest({ domain: 'github.example.com' });
299
+ expect(builtinRegistry.get('github-rest-api').match(request)).toBe(false);
300
+ });
301
+ it('github scope rejects graphql endpoint', () => {
302
+ const request = makeRequest({ domain: 'api.github.com', path: '/graphql' });
303
+ expect(builtinRegistry.get('github-rest-api').match(request)).toBe(false);
304
+ });
305
+ it('github scope allows paths that contain graphql as a substring', () => {
306
+ const request = makeRequest({ domain: 'api.github.com', path: '/repos/owner/graphql-tools' });
307
+ expect(builtinRegistry.get('github-rest-api').match(request)).toBe(true);
308
+ });
309
+ it('github-read-issues matches issues path but not pulls', () => {
310
+ expectPatternExists('github-read-issues');
311
+ expect(builtinRegistry
312
+ .get('github-read-issues')
313
+ .match(makeRequest({ method: 'GET', path: '/repos/octocat/Hello-World/issues' }))).toBe(true);
314
+ expect(builtinRegistry
315
+ .get('github-read-issues')
316
+ .match(makeRequest({ method: 'GET', path: '/repos/octocat/Hello-World/pulls' }))).toBe(false);
317
+ });
318
+ it('github-search matches /search paths', () => {
319
+ expectPatternExists('github-search');
320
+ expect(builtinRegistry
321
+ .get('github-search')
322
+ .match(makeRequest({ method: 'GET', path: '/search/repositories' }))).toBe(true);
323
+ expect(builtinRegistry
324
+ .get('github-search')
325
+ .match(makeRequest({ method: 'GET', path: '/repos/octocat/Hello-World' }))).toBe(false);
326
+ });
327
+ });
328
+ describe('builtin patterns: gitlab', () => {
329
+ it('gitlab scope matches gitlab.com', () => {
330
+ expectPatternExists('gitlab-api');
331
+ const request = makeRequest({ domain: 'gitlab.com', path: '/api/v4/projects' });
332
+ expect(builtinRegistry.get('gitlab-api').match(request)).toBe(true);
333
+ });
334
+ it('gitlab scope rejects unrelated domains', () => {
335
+ const request = makeRequest({ domain: 'gitlab.example.com' });
336
+ expect(builtinRegistry.get('gitlab-api').match(request)).toBe(false);
337
+ });
338
+ it('gitlab-read-merge-requests matches merge_requests path', () => {
339
+ expectPatternExists('gitlab-read-merge-requests');
340
+ expect(builtinRegistry
341
+ .get('gitlab-read-merge-requests')
342
+ .match(makeRequest({ method: 'GET', path: '/api/v4/projects/42/merge_requests' }))).toBe(true);
343
+ expect(builtinRegistry
344
+ .get('gitlab-read-merge-requests')
345
+ .match(makeRequest({ method: 'GET', path: '/api/v4/projects/42/issues' }))).toBe(false);
346
+ });
347
+ it('gitlab-write-issues matches POST to issues path', () => {
348
+ expectPatternExists('gitlab-write-issues');
349
+ expect(builtinRegistry
350
+ .get('gitlab-write-issues')
351
+ .match(makeRequest({ method: 'POST', path: '/api/v4/projects/42/issues' }))).toBe(true);
352
+ expect(builtinRegistry
353
+ .get('gitlab-write-issues')
354
+ .match(makeRequest({ method: 'POST', path: '/api/v4/projects/42/merge_requests' }))).toBe(false);
355
+ });
356
+ });
357
+ describe('builtin patterns: google-analytics', () => {
358
+ it('google-analytics scope matches analyticsadmin.googleapis.com', () => {
359
+ expectPatternExists('google-analytics-api');
360
+ const request = makeRequest({
361
+ domain: 'analyticsadmin.googleapis.com',
362
+ path: '/v1beta/accounts',
363
+ });
364
+ expect(builtinRegistry.get('google-analytics-api').match(request)).toBe(true);
365
+ });
366
+ it('google-analytics-run-reports matches POST to runReport path', () => {
367
+ expectPatternExists('google-analytics-run-reports');
368
+ expect(builtinRegistry
369
+ .get('google-analytics-run-reports')
370
+ .match(makeRequest({ method: 'POST', path: '/v1beta/properties/12345:runReport' }))).toBe(true);
371
+ });
372
+ it('google-analytics-read-properties matches GET to properties path', () => {
373
+ expectPatternExists('google-analytics-read-properties');
374
+ expect(builtinRegistry
375
+ .get('google-analytics-read-properties')
376
+ .match(makeRequest({ method: 'GET', path: '/v1beta/properties' }))).toBe(true);
377
+ expect(builtinRegistry
378
+ .get('google-analytics-read-properties')
379
+ .match(makeRequest({ method: 'GET', path: '/v1beta/accounts' }))).toBe(false);
380
+ });
381
+ });
382
+ describe('builtin patterns: google-calendar', () => {
383
+ it('google-calendar scope matches www.googleapis.com with calendar path', () => {
384
+ expectPatternExists('google-calendar-api');
385
+ const request = makeRequest({
386
+ domain: 'www.googleapis.com',
387
+ path: '/calendar/v3/calendars/primary/events',
388
+ });
389
+ expect(builtinRegistry.get('google-calendar-api').match(request)).toBe(true);
390
+ });
391
+ it('google-calendar scope rejects www.googleapis.com with non-calendar path', () => {
392
+ const request = makeRequest({
393
+ domain: 'www.googleapis.com',
394
+ path: '/drive/v3/files',
395
+ });
396
+ expect(builtinRegistry.get('google-calendar-api').match(request)).toBe(false);
397
+ });
398
+ it('google-calendar-read-events matches GET with events path', () => {
399
+ expectPatternExists('google-calendar-read-events');
400
+ expect(builtinRegistry
401
+ .get('google-calendar-read-events')
402
+ .match(makeRequest({ method: 'GET', path: '/calendar/v3/calendars/primary/events' }))).toBe(true);
403
+ expect(builtinRegistry
404
+ .get('google-calendar-read-events')
405
+ .match(makeRequest({ method: 'GET', path: '/calendar/v3/users/me/calendarList' }))).toBe(false);
406
+ });
407
+ it('google-calendar-query-freebusy matches POST to freeBusy endpoint', () => {
408
+ expectPatternExists('google-calendar-query-freebusy');
409
+ expect(builtinRegistry
410
+ .get('google-calendar-query-freebusy')
411
+ .match(makeRequest({ method: 'POST', path: '/calendar/v3/freeBusy' }))).toBe(true);
412
+ });
413
+ });
414
+ describe('builtin patterns: google-directions', () => {
415
+ it('google-directions scope matches routes.googleapis.com', () => {
416
+ expectPatternExists('google-directions-api');
417
+ const request = makeRequest({
418
+ domain: 'routes.googleapis.com',
419
+ path: '/directions/v2:computeRoutes',
420
+ });
421
+ expect(builtinRegistry.get('google-directions-api').match(request)).toBe(true);
422
+ });
423
+ it('google-directions scope rejects unrelated domains', () => {
424
+ const request = makeRequest({ domain: 'maps.googleapis.com' });
425
+ expect(builtinRegistry.get('google-directions-api').match(request)).toBe(false);
426
+ });
427
+ it('google-directions-compute-routes matches POST to the correct path', () => {
428
+ expectPatternExists('google-directions-compute-routes');
429
+ const request = makeRequest({
430
+ method: 'POST',
431
+ path: '/directions/v2:computeRoutes',
432
+ });
433
+ expect(builtinRegistry.get('google-directions-compute-routes').match(request)).toBe(true);
434
+ });
435
+ it('google-directions-compute-route-matrix rejects GET', () => {
436
+ expectPatternExists('google-directions-compute-route-matrix');
437
+ const request = makeRequest({
438
+ method: 'GET',
439
+ path: '/distanceMatrix/v2:computeRouteMatrix',
440
+ });
441
+ expect(builtinRegistry.get('google-directions-compute-route-matrix').match(request)).toBe(false);
442
+ });
443
+ });
444
+ describe('builtin patterns: google-docs', () => {
445
+ it('google-docs scope matches docs.googleapis.com', () => {
446
+ expectPatternExists('google-docs-api');
447
+ const request = makeRequest({
448
+ domain: 'docs.googleapis.com',
449
+ path: '/v1/documents/abc123',
450
+ });
451
+ expect(builtinRegistry.get('google-docs-api').match(request)).toBe(true);
452
+ });
453
+ it('google-docs scope rejects unrelated domains', () => {
454
+ const request = makeRequest({ domain: 'sheets.googleapis.com' });
455
+ expect(builtinRegistry.get('google-docs-api').match(request)).toBe(false);
456
+ });
457
+ it('google-docs-read-documents matches GET to /v1/documents path', () => {
458
+ expectPatternExists('google-docs-read-documents');
459
+ expect(builtinRegistry
460
+ .get('google-docs-read-documents')
461
+ .match(makeRequest({ method: 'GET', path: '/v1/documents/abc123' }))).toBe(true);
462
+ });
463
+ it('google-docs-create-documents matches POST to /v1/documents', () => {
464
+ expectPatternExists('google-docs-create-documents');
465
+ expect(builtinRegistry
466
+ .get('google-docs-create-documents')
467
+ .match(makeRequest({ method: 'POST', path: '/v1/documents' }))).toBe(true);
468
+ });
469
+ });
470
+ describe('builtin patterns: google-drive', () => {
471
+ it('google-drive scope matches www.googleapis.com with drive path', () => {
472
+ expectPatternExists('google-drive-api');
473
+ const request = makeRequest({
474
+ domain: 'www.googleapis.com',
475
+ path: '/drive/v3/files',
476
+ });
477
+ expect(builtinRegistry.get('google-drive-api').match(request)).toBe(true);
478
+ });
479
+ it('google-drive scope rejects www.googleapis.com with non-drive path', () => {
480
+ const request = makeRequest({
481
+ domain: 'www.googleapis.com',
482
+ path: '/calendar/v3/calendars',
483
+ });
484
+ expect(builtinRegistry.get('google-drive-api').match(request)).toBe(false);
485
+ });
486
+ it('google-drive-read-files matches GET to files path', () => {
487
+ expectPatternExists('google-drive-read-files');
488
+ expect(builtinRegistry
489
+ .get('google-drive-read-files')
490
+ .match(makeRequest({ method: 'GET', path: '/drive/v3/files' }))).toBe(true);
491
+ expect(builtinRegistry
492
+ .get('google-drive-read-files')
493
+ .match(makeRequest({ method: 'GET', path: '/drive/v3/about' }))).toBe(false);
494
+ });
495
+ it('google-drive-write-comments matches POST to comments path', () => {
496
+ expectPatternExists('google-drive-write-comments');
497
+ expect(builtinRegistry
498
+ .get('google-drive-write-comments')
499
+ .match(makeRequest({ method: 'POST', path: '/drive/v3/files/abc123/comments' }))).toBe(true);
500
+ });
501
+ });
502
+ describe('builtin patterns: google-gmail', () => {
503
+ it('google-gmail scope matches gmail.googleapis.com', () => {
504
+ expectPatternExists('google-gmail-api');
505
+ const request = makeRequest({
506
+ domain: 'gmail.googleapis.com',
507
+ path: '/gmail/v1/users/me/messages',
508
+ });
509
+ expect(builtinRegistry.get('google-gmail-api').match(request)).toBe(true);
510
+ });
511
+ it('google-gmail scope rejects unrelated domains', () => {
512
+ const request = makeRequest({ domain: 'mail.google.com' });
513
+ expect(builtinRegistry.get('google-gmail-api').match(request)).toBe(false);
514
+ });
515
+ it('google-gmail-read-messages matches GET with messages path', () => {
516
+ expectPatternExists('google-gmail-read-messages');
517
+ expect(builtinRegistry
518
+ .get('google-gmail-read-messages')
519
+ .match(makeRequest({ method: 'GET', path: '/gmail/v1/users/me/messages' }))).toBe(true);
520
+ expect(builtinRegistry
521
+ .get('google-gmail-read-messages')
522
+ .match(makeRequest({ method: 'GET', path: '/gmail/v1/users/me/labels' }))).toBe(false);
523
+ });
524
+ it('google-gmail-send-messages matches POST to messages/send path', () => {
525
+ expectPatternExists('google-gmail-send-messages');
526
+ expect(builtinRegistry
527
+ .get('google-gmail-send-messages')
528
+ .match(makeRequest({ method: 'POST', path: '/gmail/v1/users/me/messages/send' }))).toBe(true);
529
+ });
530
+ it('google-gmail-send-messages matches upload variant', () => {
531
+ expect(builtinRegistry
532
+ .get('google-gmail-send-messages')
533
+ .match(makeRequest({ method: 'POST', path: '/upload/gmail/v1/users/me/messages/send' }))).toBe(true);
534
+ });
535
+ it('google-gmail-write-messages matches upload variant', () => {
536
+ expectPatternExists('google-gmail-write-messages');
537
+ expect(builtinRegistry
538
+ .get('google-gmail-write-messages')
539
+ .match(makeRequest({ method: 'POST', path: '/upload/gmail/v1/users/me/messages' }))).toBe(true);
540
+ });
541
+ it('google-gmail-write-drafts matches upload variant', () => {
542
+ expectPatternExists('google-gmail-write-drafts');
543
+ expect(builtinRegistry
544
+ .get('google-gmail-write-drafts')
545
+ .match(makeRequest({ method: 'POST', path: '/upload/gmail/v1/users/me/drafts' }))).toBe(true);
546
+ expect(builtinRegistry
547
+ .get('google-gmail-write-drafts')
548
+ .match(makeRequest({ method: 'PUT', path: '/upload/gmail/v1/users/me/drafts/abc123' }))).toBe(true);
549
+ });
550
+ });
551
+ describe('builtin patterns: google-people', () => {
552
+ it('google-people scope matches people.googleapis.com', () => {
553
+ expectPatternExists('google-people-api');
554
+ const request = makeRequest({
555
+ domain: 'people.googleapis.com',
556
+ path: '/v1/people/me',
557
+ });
558
+ expect(builtinRegistry.get('google-people-api').match(request)).toBe(true);
559
+ });
560
+ it('google-people scope rejects unrelated domains', () => {
561
+ const request = makeRequest({ domain: 'contacts.googleapis.com' });
562
+ expect(builtinRegistry.get('google-people-api').match(request)).toBe(false);
563
+ });
564
+ it('google-people-read-contacts matches GET to people path', () => {
565
+ expectPatternExists('google-people-read-contacts');
566
+ expect(builtinRegistry
567
+ .get('google-people-read-contacts')
568
+ .match(makeRequest({ method: 'GET', path: '/v1/people/me/connections' }))).toBe(true);
569
+ expect(builtinRegistry
570
+ .get('google-people-read-contacts')
571
+ .match(makeRequest({ method: 'GET', path: '/v1/contactGroups' }))).toBe(false);
572
+ });
573
+ it('google-people-read-contacts matches GET to colon-method paths', () => {
574
+ expect(builtinRegistry
575
+ .get('google-people-read-contacts')
576
+ .match(makeRequest({ method: 'GET', path: '/v1/people:batchGet' }))).toBe(true);
577
+ expect(builtinRegistry
578
+ .get('google-people-read-contacts')
579
+ .match(makeRequest({ method: 'GET', path: '/v1/people:searchContacts' }))).toBe(true);
580
+ });
581
+ it('google-people-write-contacts matches POST to colon-method paths', () => {
582
+ expectPatternExists('google-people-write-contacts');
583
+ expect(builtinRegistry
584
+ .get('google-people-write-contacts')
585
+ .match(makeRequest({ method: 'POST', path: '/v1/people:createContact' }))).toBe(true);
586
+ expect(builtinRegistry
587
+ .get('google-people-write-contacts')
588
+ .match(makeRequest({ method: 'POST', path: '/v1/people:batchDeleteContacts' }))).toBe(true);
589
+ });
590
+ it('google-people-read-contact-groups matches GET to colon-method paths', () => {
591
+ expectPatternExists('google-people-read-contact-groups');
592
+ expect(builtinRegistry
593
+ .get('google-people-read-contact-groups')
594
+ .match(makeRequest({ method: 'GET', path: '/v1/contactGroups:batchGet' }))).toBe(true);
595
+ });
596
+ it('google-people-read-other-contacts matches GET to colon-method paths', () => {
597
+ expectPatternExists('google-people-read-other-contacts');
598
+ expect(builtinRegistry
599
+ .get('google-people-read-other-contacts')
600
+ .match(makeRequest({ method: 'GET', path: '/v1/otherContacts:search' }))).toBe(true);
601
+ });
602
+ });
603
+ describe('builtin patterns: google-sheets', () => {
604
+ it('google-sheets scope matches sheets.googleapis.com', () => {
605
+ expectPatternExists('google-sheets-api');
606
+ const request = makeRequest({
607
+ domain: 'sheets.googleapis.com',
608
+ path: '/v4/spreadsheets/abc123',
609
+ });
610
+ expect(builtinRegistry.get('google-sheets-api').match(request)).toBe(true);
611
+ });
612
+ it('google-sheets scope rejects unrelated domains', () => {
613
+ const request = makeRequest({ domain: 'docs.googleapis.com' });
614
+ expect(builtinRegistry.get('google-sheets-api').match(request)).toBe(false);
615
+ });
616
+ it('google-sheets-read-values matches GET with values path', () => {
617
+ expectPatternExists('google-sheets-read-values');
618
+ expect(builtinRegistry
619
+ .get('google-sheets-read-values')
620
+ .match(makeRequest({ method: 'GET', path: '/v4/spreadsheets/abc123/values/Sheet1!A1:B10' }))).toBe(true);
621
+ });
622
+ it('google-sheets-create-spreadsheets matches POST to spreadsheets', () => {
623
+ expectPatternExists('google-sheets-create-spreadsheets');
624
+ expect(builtinRegistry
625
+ .get('google-sheets-create-spreadsheets')
626
+ .match(makeRequest({ method: 'POST', path: '/v4/spreadsheets' }))).toBe(true);
627
+ });
628
+ });
629
+ describe('builtin patterns: linear', () => {
630
+ it('linear scope matches api.linear.app', () => {
631
+ expectPatternExists('linear-api');
632
+ const request = makeRequest({ domain: 'api.linear.app', path: '/graphql' });
633
+ expect(builtinRegistry.get('linear-api').match(request)).toBe(true);
634
+ });
635
+ it('linear scope rejects unrelated domains', () => {
636
+ const request = makeRequest({ domain: 'linear.example.com' });
637
+ expect(builtinRegistry.get('linear-api').match(request)).toBe(false);
638
+ });
639
+ });
640
+ describe('builtin patterns: mailchimp', () => {
641
+ it('mailchimp scope matches the mailchimp API domain', () => {
642
+ expectPatternExists('mailchimp-api');
643
+ const request = makeRequest({
644
+ domain: 'server.api.mailchimp.com',
645
+ path: '/3.0/campaigns',
646
+ });
647
+ expect(builtinRegistry.get('mailchimp-api').match(request)).toBe(true);
648
+ });
649
+ it('mailchimp-read-campaigns matches GET to campaigns path', () => {
650
+ expectPatternExists('mailchimp-read-campaigns');
651
+ expect(builtinRegistry
652
+ .get('mailchimp-read-campaigns')
653
+ .match(makeRequest({ method: 'GET', path: '/3.0/campaigns' }))).toBe(true);
654
+ expect(builtinRegistry
655
+ .get('mailchimp-read-campaigns')
656
+ .match(makeRequest({ method: 'GET', path: '/3.0/lists' }))).toBe(false);
657
+ });
658
+ it('mailchimp-write-lists matches POST to lists path', () => {
659
+ expectPatternExists('mailchimp-write-lists');
660
+ expect(builtinRegistry
661
+ .get('mailchimp-write-lists')
662
+ .match(makeRequest({ method: 'POST', path: '/3.0/lists' }))).toBe(true);
663
+ expect(builtinRegistry
664
+ .get('mailchimp-write-lists')
665
+ .match(makeRequest({ method: 'POST', path: '/3.0/campaigns' }))).toBe(false);
666
+ });
667
+ });
668
+ describe('builtin patterns: notion', () => {
669
+ it('notion scope matches api.notion.com', () => {
670
+ expectPatternExists('notion-api');
671
+ const request = makeRequest({ domain: 'api.notion.com', path: '/v1/pages' });
672
+ expect(builtinRegistry.get('notion-api').match(request)).toBe(true);
673
+ });
674
+ it('notion scope rejects unrelated domains', () => {
675
+ const request = makeRequest({ domain: 'notion.example.com' });
676
+ expect(builtinRegistry.get('notion-api').match(request)).toBe(false);
677
+ });
678
+ it('notion-read-pages matches GET to /v1/pages path', () => {
679
+ expectPatternExists('notion-read-pages');
680
+ expect(builtinRegistry
681
+ .get('notion-read-pages')
682
+ .match(makeRequest({ method: 'GET', path: '/v1/pages/abc123' }))).toBe(true);
683
+ expect(builtinRegistry
684
+ .get('notion-read-pages')
685
+ .match(makeRequest({ method: 'GET', path: '/v1/databases/abc123' }))).toBe(false);
686
+ });
687
+ it('notion-write-databases matches create and update but not query', () => {
688
+ expectPatternExists('notion-write-databases');
689
+ expect(builtinRegistry
690
+ .get('notion-write-databases')
691
+ .match(makeRequest({ method: 'POST', path: '/v1/databases' }))).toBe(true);
692
+ expect(builtinRegistry
693
+ .get('notion-write-databases')
694
+ .match(makeRequest({ method: 'PATCH', path: '/v1/databases/abc123' }))).toBe(true);
695
+ expect(builtinRegistry
696
+ .get('notion-write-databases')
697
+ .match(makeRequest({ method: 'POST', path: '/v1/databases/abc123/query' }))).toBe(false);
698
+ });
699
+ it('notion-query-databases matches only the query endpoint', () => {
700
+ expectPatternExists('notion-query-databases');
701
+ expect(builtinRegistry
702
+ .get('notion-query-databases')
703
+ .match(makeRequest({ method: 'POST', path: '/v1/databases/abc123/query' }))).toBe(true);
704
+ expect(builtinRegistry
705
+ .get('notion-query-databases')
706
+ .match(makeRequest({ method: 'POST', path: '/v1/databases' }))).toBe(false);
707
+ });
708
+ it('notion-read-all matches GET requests', () => {
709
+ expectPatternExists('notion-read-all');
710
+ expect(builtinRegistry
711
+ .get('notion-read-all')
712
+ .match(makeRequest({ method: 'GET', path: '/v1/pages/abc123' }))).toBe(true);
713
+ });
714
+ it('notion-read-all matches POST to /v1/search', () => {
715
+ expect(builtinRegistry
716
+ .get('notion-read-all')
717
+ .match(makeRequest({ method: 'POST', path: '/v1/search' }))).toBe(true);
718
+ });
719
+ it('notion-read-all rejects POST to other paths', () => {
720
+ expect(builtinRegistry
721
+ .get('notion-read-all')
722
+ .match(makeRequest({ method: 'POST', path: '/v1/pages' }))).toBe(false);
723
+ });
724
+ it('notion-search matches POST to /v1/search', () => {
725
+ expectPatternExists('notion-search');
726
+ expect(builtinRegistry
727
+ .get('notion-search')
728
+ .match(makeRequest({ method: 'POST', path: '/v1/search' }))).toBe(true);
729
+ expect(builtinRegistry
730
+ .get('notion-search')
731
+ .match(makeRequest({ method: 'POST', path: '/v1/pages' }))).toBe(false);
732
+ });
733
+ });
734
+ describe('builtin patterns: sentry', () => {
735
+ it('sentry scope matches sentry.io', () => {
736
+ expectPatternExists('sentry-api');
737
+ const request = makeRequest({
738
+ domain: 'sentry.io',
739
+ path: '/api/0/organizations/my-org/issues/',
740
+ });
741
+ expect(builtinRegistry.get('sentry-api').match(request)).toBe(true);
742
+ });
743
+ it('sentry scope rejects unrelated domains', () => {
744
+ const request = makeRequest({ domain: 'sentry.example.com' });
745
+ expect(builtinRegistry.get('sentry-api').match(request)).toBe(false);
746
+ });
747
+ it('sentry-read-issues matches GET with issues path', () => {
748
+ expectPatternExists('sentry-read-issues');
749
+ expect(builtinRegistry
750
+ .get('sentry-read-issues')
751
+ .match(makeRequest({ method: 'GET', path: '/api/0/organizations/my-org/issues/' }))).toBe(true);
752
+ expect(builtinRegistry
753
+ .get('sentry-read-issues')
754
+ .match(makeRequest({ method: 'GET', path: '/api/0/organizations/my-org/releases/' }))).toBe(false);
755
+ });
756
+ it('sentry-write-projects matches POST to projects path', () => {
757
+ expectPatternExists('sentry-write-projects');
758
+ expect(builtinRegistry
759
+ .get('sentry-write-projects')
760
+ .match(makeRequest({ method: 'POST', path: '/api/0/teams/my-org/my-team/projects/' }))).toBe(true);
761
+ });
762
+ });
763
+ describe('builtin patterns: slack', () => {
764
+ it('slack scope matches slack.com', () => {
765
+ expectPatternExists('slack-api');
766
+ const request = makeRequest({
767
+ domain: 'slack.com',
768
+ path: '/api/chat.postMessage',
769
+ });
770
+ expect(builtinRegistry.get('slack-api').match(request)).toBe(true);
771
+ });
772
+ it('slack scope rejects unrelated domains', () => {
773
+ const request = makeRequest({ domain: 'slack.example.com' });
774
+ expect(builtinRegistry.get('slack-api').match(request)).toBe(false);
775
+ });
776
+ it('slack-read-all matches known read methods across all families', () => {
777
+ expectPatternExists('slack-read-all');
778
+ const readMethods = [
779
+ '/api/chat.getPermalink',
780
+ '/api/chat.scheduledMessages.list',
781
+ '/api/conversations.history',
782
+ '/api/conversations.info',
783
+ '/api/conversations.list',
784
+ '/api/conversations.listConnectInvites',
785
+ '/api/conversations.members',
786
+ '/api/conversations.replies',
787
+ '/api/conversations.requestSharedInvite.list',
788
+ '/api/users.conversations',
789
+ '/api/users.getPresence',
790
+ '/api/users.identity',
791
+ '/api/users.info',
792
+ '/api/users.list',
793
+ '/api/users.lookupByEmail',
794
+ '/api/users.profile.get',
795
+ '/api/files.info',
796
+ '/api/files.list',
797
+ '/api/files.remote.info',
798
+ '/api/files.remote.list',
799
+ '/api/reactions.get',
800
+ '/api/reactions.list',
801
+ '/api/search.all',
802
+ '/api/search.files',
803
+ '/api/search.messages',
804
+ '/api/pins.list',
805
+ '/api/bookmarks.list',
806
+ '/api/reminders.info',
807
+ '/api/reminders.list',
808
+ ];
809
+ for (const path of readMethods) {
810
+ expect(builtinRegistry.get('slack-read-all').match(makeRequest({ path })), `Expected slack-read-all to match "${path}"`).toBe(true);
811
+ }
812
+ });
813
+ it('slack-read-all rejects known write methods', () => {
814
+ const writeMethods = [
815
+ '/api/chat.postMessage',
816
+ '/api/chat.delete',
817
+ '/api/conversations.kick',
818
+ '/api/conversations.archive',
819
+ '/api/users.setPresence',
820
+ '/api/files.getUploadURLExternal',
821
+ '/api/files.delete',
822
+ '/api/reactions.add',
823
+ '/api/pins.add',
824
+ '/api/bookmarks.add',
825
+ '/api/reminders.add',
826
+ ];
827
+ for (const path of writeMethods) {
828
+ expect(builtinRegistry.get('slack-read-all').match(makeRequest({ path })), `Expected slack-read-all to reject "${path}"`).toBe(false);
829
+ }
830
+ });
831
+ it('slack-write-all matches known write methods across all families', () => {
832
+ expectPatternExists('slack-write-all');
833
+ const writeMethods = [
834
+ '/api/chat.appendStream',
835
+ '/api/chat.delete',
836
+ '/api/chat.deleteScheduledMessage',
837
+ '/api/chat.meMessage',
838
+ '/api/chat.postEphemeral',
839
+ '/api/chat.postMessage',
840
+ '/api/chat.scheduleMessage',
841
+ '/api/chat.startStream',
842
+ '/api/chat.stopStream',
843
+ '/api/chat.unfurl',
844
+ '/api/chat.update',
845
+ '/api/conversations.acceptSharedInvite',
846
+ '/api/conversations.approveSharedInvite',
847
+ '/api/conversations.archive',
848
+ '/api/conversations.canvasCreate',
849
+ '/api/conversations.close',
850
+ '/api/conversations.create',
851
+ '/api/conversations.declineSharedInvite',
852
+ '/api/conversations.externalInvitePermissions.set',
853
+ '/api/conversations.invite',
854
+ '/api/conversations.inviteShared',
855
+ '/api/conversations.join',
856
+ '/api/conversations.kick',
857
+ '/api/conversations.leave',
858
+ '/api/conversations.mark',
859
+ '/api/conversations.open',
860
+ '/api/conversations.rename',
861
+ '/api/conversations.requestSharedInvite.approve',
862
+ '/api/conversations.requestSharedInvite.deny',
863
+ '/api/conversations.setPurpose',
864
+ '/api/conversations.setTopic',
865
+ '/api/conversations.unarchive',
866
+ '/api/users.setPresence',
867
+ '/api/users.profile.set',
868
+ '/api/files.completeUploadExternal',
869
+ '/api/files.delete',
870
+ '/api/files.getUploadURLExternal',
871
+ '/api/files.remote.add',
872
+ '/api/files.remote.remove',
873
+ '/api/files.remote.share',
874
+ '/api/files.remote.update',
875
+ '/api/files.revokePublicURL',
876
+ '/api/files.sharedPublicURL',
877
+ '/api/reactions.add',
878
+ '/api/reactions.remove',
879
+ '/api/pins.add',
880
+ '/api/pins.remove',
881
+ '/api/bookmarks.add',
882
+ '/api/bookmarks.edit',
883
+ '/api/bookmarks.remove',
884
+ '/api/reminders.add',
885
+ '/api/reminders.complete',
886
+ '/api/reminders.delete',
887
+ ];
888
+ for (const path of writeMethods) {
889
+ expect(builtinRegistry.get('slack-write-all').match(makeRequest({ path })), `Expected slack-write-all to match "${path}"`).toBe(true);
890
+ }
891
+ });
892
+ it('slack-write-all rejects known read methods', () => {
893
+ const readMethods = [
894
+ '/api/chat.getPermalink',
895
+ '/api/conversations.list',
896
+ '/api/conversations.history',
897
+ '/api/users.info',
898
+ '/api/users.list',
899
+ '/api/files.info',
900
+ '/api/reactions.list',
901
+ '/api/search.messages',
902
+ '/api/pins.list',
903
+ '/api/bookmarks.list',
904
+ '/api/reminders.list',
905
+ ];
906
+ for (const path of readMethods) {
907
+ expect(builtinRegistry.get('slack-write-all').match(makeRequest({ path })), `Expected slack-write-all to reject "${path}"`).toBe(false);
908
+ }
909
+ });
910
+ it('slack-chat-read matches read chat methods but not write', () => {
911
+ expectPatternExists('slack-chat-read');
912
+ expect(builtinRegistry.get('slack-chat-read').match(makeRequest({ path: '/api/chat.getPermalink' }))).toBe(true);
913
+ expect(builtinRegistry
914
+ .get('slack-chat-read')
915
+ .match(makeRequest({ path: '/api/chat.scheduledMessages.list' }))).toBe(true);
916
+ expect(builtinRegistry.get('slack-chat-read').match(makeRequest({ path: '/api/chat.postMessage' }))).toBe(false);
917
+ expect(builtinRegistry.get('slack-chat-read').match(makeRequest({ path: '/api/chat.delete' }))).toBe(false);
918
+ });
919
+ it('slack-chat-write matches write chat methods but not read', () => {
920
+ expectPatternExists('slack-chat-write');
921
+ expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.postMessage' }))).toBe(true);
922
+ expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.delete' }))).toBe(true);
923
+ expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.update' }))).toBe(true);
924
+ expect(builtinRegistry
925
+ .get('slack-chat-write')
926
+ .match(makeRequest({ path: '/api/chat.appendStream' }))).toBe(true);
927
+ expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.startStream' }))).toBe(true);
928
+ expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.stopStream' }))).toBe(true);
929
+ expect(builtinRegistry
930
+ .get('slack-chat-write')
931
+ .match(makeRequest({ path: '/api/chat.getPermalink' }))).toBe(false);
932
+ });
933
+ it('slack-conversations-read matches read conversation methods but not write', () => {
934
+ expectPatternExists('slack-conversations-read');
935
+ expect(builtinRegistry
936
+ .get('slack-conversations-read')
937
+ .match(makeRequest({ path: '/api/conversations.list' }))).toBe(true);
938
+ expect(builtinRegistry
939
+ .get('slack-conversations-read')
940
+ .match(makeRequest({ path: '/api/conversations.history' }))).toBe(true);
941
+ expect(builtinRegistry
942
+ .get('slack-conversations-read')
943
+ .match(makeRequest({ path: '/api/conversations.listConnectInvites' }))).toBe(true);
944
+ expect(builtinRegistry
945
+ .get('slack-conversations-read')
946
+ .match(makeRequest({ path: '/api/conversations.requestSharedInvite.list' }))).toBe(true);
947
+ expect(builtinRegistry
948
+ .get('slack-conversations-read')
949
+ .match(makeRequest({ path: '/api/conversations.kick' }))).toBe(false);
950
+ expect(builtinRegistry
951
+ .get('slack-conversations-read')
952
+ .match(makeRequest({ path: '/api/conversations.archive' }))).toBe(false);
953
+ });
954
+ it('slack-conversations-write matches write conversation methods but not read', () => {
955
+ expectPatternExists('slack-conversations-write');
956
+ expect(builtinRegistry
957
+ .get('slack-conversations-write')
958
+ .match(makeRequest({ path: '/api/conversations.kick' }))).toBe(true);
959
+ expect(builtinRegistry
960
+ .get('slack-conversations-write')
961
+ .match(makeRequest({ path: '/api/conversations.archive' }))).toBe(true);
962
+ expect(builtinRegistry
963
+ .get('slack-conversations-write')
964
+ .match(makeRequest({ path: '/api/conversations.create' }))).toBe(true);
965
+ expect(builtinRegistry
966
+ .get('slack-conversations-write')
967
+ .match(makeRequest({ path: '/api/conversations.acceptSharedInvite' }))).toBe(true);
968
+ expect(builtinRegistry
969
+ .get('slack-conversations-write')
970
+ .match(makeRequest({ path: '/api/conversations.canvasCreate' }))).toBe(true);
971
+ expect(builtinRegistry
972
+ .get('slack-conversations-write')
973
+ .match(makeRequest({ path: '/api/conversations.inviteShared' }))).toBe(true);
974
+ expect(builtinRegistry
975
+ .get('slack-conversations-write')
976
+ .match(makeRequest({ path: '/api/conversations.externalInvitePermissions.set' }))).toBe(true);
977
+ expect(builtinRegistry
978
+ .get('slack-conversations-write')
979
+ .match(makeRequest({ path: '/api/conversations.requestSharedInvite.approve' }))).toBe(true);
980
+ expect(builtinRegistry
981
+ .get('slack-conversations-write')
982
+ .match(makeRequest({ path: '/api/conversations.requestSharedInvite.deny' }))).toBe(true);
983
+ expect(builtinRegistry
984
+ .get('slack-conversations-write')
985
+ .match(makeRequest({ path: '/api/conversations.list' }))).toBe(false);
986
+ expect(builtinRegistry
987
+ .get('slack-conversations-write')
988
+ .match(makeRequest({ path: '/api/conversations.history' }))).toBe(false);
989
+ });
990
+ it('slack-users-read matches read user methods but not write', () => {
991
+ expectPatternExists('slack-users-read');
992
+ expect(builtinRegistry.get('slack-users-read').match(makeRequest({ path: '/api/users.list' }))).toBe(true);
993
+ expect(builtinRegistry.get('slack-users-read').match(makeRequest({ path: '/api/users.info' }))).toBe(true);
994
+ expect(builtinRegistry
995
+ .get('slack-users-read')
996
+ .match(makeRequest({ path: '/api/users.profile.get' }))).toBe(true);
997
+ expect(builtinRegistry
998
+ .get('slack-users-read')
999
+ .match(makeRequest({ path: '/api/users.setPresence' }))).toBe(false);
1000
+ expect(builtinRegistry
1001
+ .get('slack-users-read')
1002
+ .match(makeRequest({ path: '/api/users.profile.set' }))).toBe(false);
1003
+ });
1004
+ it('slack-users-write matches write user methods but not read', () => {
1005
+ expectPatternExists('slack-users-write');
1006
+ expect(builtinRegistry
1007
+ .get('slack-users-write')
1008
+ .match(makeRequest({ path: '/api/users.setPresence' }))).toBe(true);
1009
+ expect(builtinRegistry
1010
+ .get('slack-users-write')
1011
+ .match(makeRequest({ path: '/api/users.profile.set' }))).toBe(true);
1012
+ expect(builtinRegistry.get('slack-users-write').match(makeRequest({ path: '/api/users.list' }))).toBe(false);
1013
+ });
1014
+ it('slack-files-read matches read file methods but not write', () => {
1015
+ expectPatternExists('slack-files-read');
1016
+ expect(builtinRegistry.get('slack-files-read').match(makeRequest({ path: '/api/files.info' }))).toBe(true);
1017
+ expect(builtinRegistry.get('slack-files-read').match(makeRequest({ path: '/api/files.list' }))).toBe(true);
1018
+ expect(builtinRegistry
1019
+ .get('slack-files-read')
1020
+ .match(makeRequest({ path: '/api/files.remote.info' }))).toBe(true);
1021
+ expect(builtinRegistry
1022
+ .get('slack-files-read')
1023
+ .match(makeRequest({ path: '/api/files.getUploadURLExternal' }))).toBe(false);
1024
+ expect(builtinRegistry.get('slack-files-read').match(makeRequest({ path: '/api/files.delete' }))).toBe(false);
1025
+ });
1026
+ it('slack-files-write matches write file methods but not read', () => {
1027
+ expectPatternExists('slack-files-write');
1028
+ expect(builtinRegistry
1029
+ .get('slack-files-write')
1030
+ .match(makeRequest({ path: '/api/files.getUploadURLExternal' }))).toBe(true);
1031
+ expect(builtinRegistry
1032
+ .get('slack-files-write')
1033
+ .match(makeRequest({ path: '/api/files.completeUploadExternal' }))).toBe(true);
1034
+ expect(builtinRegistry.get('slack-files-write').match(makeRequest({ path: '/api/files.delete' }))).toBe(true);
1035
+ expect(builtinRegistry
1036
+ .get('slack-files-write')
1037
+ .match(makeRequest({ path: '/api/files.remote.remove' }))).toBe(true);
1038
+ expect(builtinRegistry.get('slack-files-write').match(makeRequest({ path: '/api/files.info' }))).toBe(false);
1039
+ expect(builtinRegistry.get('slack-files-write').match(makeRequest({ path: '/api/files.list' }))).toBe(false);
1040
+ });
1041
+ it('slack-reactions-read matches read reaction methods but not write', () => {
1042
+ expectPatternExists('slack-reactions-read');
1043
+ expect(builtinRegistry
1044
+ .get('slack-reactions-read')
1045
+ .match(makeRequest({ path: '/api/reactions.get' }))).toBe(true);
1046
+ expect(builtinRegistry
1047
+ .get('slack-reactions-read')
1048
+ .match(makeRequest({ path: '/api/reactions.list' }))).toBe(true);
1049
+ expect(builtinRegistry
1050
+ .get('slack-reactions-read')
1051
+ .match(makeRequest({ path: '/api/reactions.add' }))).toBe(false);
1052
+ });
1053
+ it('slack-reactions-write matches write reaction methods but not read', () => {
1054
+ expectPatternExists('slack-reactions-write');
1055
+ expect(builtinRegistry
1056
+ .get('slack-reactions-write')
1057
+ .match(makeRequest({ path: '/api/reactions.add' }))).toBe(true);
1058
+ expect(builtinRegistry
1059
+ .get('slack-reactions-write')
1060
+ .match(makeRequest({ path: '/api/reactions.remove' }))).toBe(true);
1061
+ expect(builtinRegistry
1062
+ .get('slack-reactions-write')
1063
+ .match(makeRequest({ path: '/api/reactions.get' }))).toBe(false);
1064
+ });
1065
+ it('slack-search matches search methods', () => {
1066
+ expectPatternExists('slack-search');
1067
+ expect(builtinRegistry.get('slack-search').match(makeRequest({ path: '/api/search.messages' }))).toBe(true);
1068
+ expect(builtinRegistry.get('slack-search').match(makeRequest({ path: '/api/search.files' }))).toBe(true);
1069
+ expect(builtinRegistry.get('slack-search').match(makeRequest({ path: '/api/search.all' }))).toBe(true);
1070
+ expect(builtinRegistry.get('slack-search').match(makeRequest({ path: '/api/chat.postMessage' }))).toBe(false);
1071
+ });
1072
+ it('slack-pins-read matches pins.list but not pins.add', () => {
1073
+ expectPatternExists('slack-pins-read');
1074
+ expect(builtinRegistry.get('slack-pins-read').match(makeRequest({ path: '/api/pins.list' }))).toBe(true);
1075
+ expect(builtinRegistry.get('slack-pins-read').match(makeRequest({ path: '/api/pins.add' }))).toBe(false);
1076
+ });
1077
+ it('slack-pins-write matches pins.add and pins.remove but not pins.list', () => {
1078
+ expectPatternExists('slack-pins-write');
1079
+ expect(builtinRegistry.get('slack-pins-write').match(makeRequest({ path: '/api/pins.add' }))).toBe(true);
1080
+ expect(builtinRegistry.get('slack-pins-write').match(makeRequest({ path: '/api/pins.remove' }))).toBe(true);
1081
+ expect(builtinRegistry.get('slack-pins-write').match(makeRequest({ path: '/api/pins.list' }))).toBe(false);
1082
+ });
1083
+ it('slack-bookmarks-read matches bookmarks.list but not bookmarks.add', () => {
1084
+ expectPatternExists('slack-bookmarks-read');
1085
+ expect(builtinRegistry
1086
+ .get('slack-bookmarks-read')
1087
+ .match(makeRequest({ path: '/api/bookmarks.list' }))).toBe(true);
1088
+ expect(builtinRegistry
1089
+ .get('slack-bookmarks-read')
1090
+ .match(makeRequest({ path: '/api/bookmarks.add' }))).toBe(false);
1091
+ });
1092
+ it('slack-bookmarks-write matches bookmarks.add and bookmarks.edit but not bookmarks.list', () => {
1093
+ expectPatternExists('slack-bookmarks-write');
1094
+ expect(builtinRegistry
1095
+ .get('slack-bookmarks-write')
1096
+ .match(makeRequest({ path: '/api/bookmarks.add' }))).toBe(true);
1097
+ expect(builtinRegistry
1098
+ .get('slack-bookmarks-write')
1099
+ .match(makeRequest({ path: '/api/bookmarks.edit' }))).toBe(true);
1100
+ expect(builtinRegistry
1101
+ .get('slack-bookmarks-write')
1102
+ .match(makeRequest({ path: '/api/bookmarks.list' }))).toBe(false);
1103
+ });
1104
+ it('slack-reminders-read matches reminders.info and reminders.list but not reminders.add', () => {
1105
+ expectPatternExists('slack-reminders-read');
1106
+ expect(builtinRegistry
1107
+ .get('slack-reminders-read')
1108
+ .match(makeRequest({ path: '/api/reminders.info' }))).toBe(true);
1109
+ expect(builtinRegistry
1110
+ .get('slack-reminders-read')
1111
+ .match(makeRequest({ path: '/api/reminders.list' }))).toBe(true);
1112
+ expect(builtinRegistry
1113
+ .get('slack-reminders-read')
1114
+ .match(makeRequest({ path: '/api/reminders.add' }))).toBe(false);
1115
+ });
1116
+ it('slack-reminders-write matches reminders.add and reminders.delete but not reminders.list', () => {
1117
+ expectPatternExists('slack-reminders-write');
1118
+ expect(builtinRegistry
1119
+ .get('slack-reminders-write')
1120
+ .match(makeRequest({ path: '/api/reminders.add' }))).toBe(true);
1121
+ expect(builtinRegistry
1122
+ .get('slack-reminders-write')
1123
+ .match(makeRequest({ path: '/api/reminders.delete' }))).toBe(true);
1124
+ expect(builtinRegistry
1125
+ .get('slack-reminders-write')
1126
+ .match(makeRequest({ path: '/api/reminders.list' }))).toBe(false);
1127
+ });
1128
+ });
1129
+ describe('builtin patterns: stripe', () => {
1130
+ it('stripe scope matches api.stripe.com', () => {
1131
+ expectPatternExists('stripe-api');
1132
+ const request = makeRequest({
1133
+ domain: 'api.stripe.com',
1134
+ path: '/v1/charges',
1135
+ });
1136
+ expect(builtinRegistry.get('stripe-api').match(request)).toBe(true);
1137
+ });
1138
+ it('stripe scope rejects unrelated domains', () => {
1139
+ const request = makeRequest({ domain: 'stripe.example.com' });
1140
+ expect(builtinRegistry.get('stripe-api').match(request)).toBe(false);
1141
+ });
1142
+ it('stripe-read-customers matches GET to /v1/customers path', () => {
1143
+ expectPatternExists('stripe-read-customers');
1144
+ expect(builtinRegistry
1145
+ .get('stripe-read-customers')
1146
+ .match(makeRequest({ method: 'GET', path: '/v1/customers' }))).toBe(true);
1147
+ expect(builtinRegistry
1148
+ .get('stripe-read-customers')
1149
+ .match(makeRequest({ method: 'GET', path: '/v1/products' }))).toBe(false);
1150
+ });
1151
+ it('stripe-write-payments matches POST to payment_intents path', () => {
1152
+ expectPatternExists('stripe-write-payments');
1153
+ expect(builtinRegistry
1154
+ .get('stripe-write-payments')
1155
+ .match(makeRequest({ method: 'POST', path: '/v1/payment_intents' }))).toBe(true);
1156
+ expect(builtinRegistry
1157
+ .get('stripe-write-payments')
1158
+ .match(makeRequest({ method: 'POST', path: '/v1/customers' }))).toBe(false);
1159
+ });
1160
+ });
1161
+ describe('builtin patterns: telegram', () => {
1162
+ it('telegram scope matches api.telegram.org', () => {
1163
+ expectPatternExists('telegram-api');
1164
+ const request = makeRequest({
1165
+ domain: 'api.telegram.org',
1166
+ path: '/bot123456:ABC-DEF/sendMessage',
1167
+ });
1168
+ expect(builtinRegistry.get('telegram-api').match(request)).toBe(true);
1169
+ });
1170
+ it('telegram scope rejects unrelated domains', () => {
1171
+ const request = makeRequest({ domain: 'telegram.example.com' });
1172
+ expect(builtinRegistry.get('telegram-api').match(request)).toBe(false);
1173
+ });
1174
+ it('telegram-send-messages matches sendMessage paths', () => {
1175
+ expectPatternExists('telegram-send-messages');
1176
+ const request = makeRequest({ path: '/bot123456:ABC-DEF/sendMessage' });
1177
+ expect(builtinRegistry.get('telegram-send-messages').match(request)).toBe(true);
1178
+ });
1179
+ it('telegram-updates matches getUpdates path', () => {
1180
+ expectPatternExists('telegram-updates');
1181
+ expect(builtinRegistry
1182
+ .get('telegram-updates')
1183
+ .match(makeRequest({ path: '/bot123456:ABC-DEF/getUpdates' }))).toBe(true);
1184
+ expect(builtinRegistry
1185
+ .get('telegram-updates')
1186
+ .match(makeRequest({ path: '/bot123456:ABC-DEF/sendMessage' }))).toBe(false);
1187
+ });
1188
+ });
1189
+ describe('builtin patterns: umami', () => {
1190
+ it('umami scope matches the umami API domain', () => {
1191
+ expectPatternExists('umami-api');
1192
+ const request = makeRequest({
1193
+ domain: 'api.umami.is',
1194
+ path: '/api/websites',
1195
+ });
1196
+ expect(builtinRegistry.get('umami-api').match(request)).toBe(true);
1197
+ });
1198
+ it('umami-read-websites matches cloud /v1/websites path', () => {
1199
+ expectPatternExists('umami-read-websites');
1200
+ expect(builtinRegistry
1201
+ .get('umami-read-websites')
1202
+ .match(makeRequest({ method: 'GET', path: '/v1/websites' }))).toBe(true);
1203
+ expect(builtinRegistry
1204
+ .get('umami-read-websites')
1205
+ .match(makeRequest({ method: 'GET', path: '/v1/teams' }))).toBe(false);
1206
+ });
1207
+ it('umami-read-websites matches self-hosted /api/websites path', () => {
1208
+ expectPatternExists('umami-read-websites');
1209
+ expect(builtinRegistry
1210
+ .get('umami-read-websites')
1211
+ .match(makeRequest({ method: 'GET', path: '/api/websites' }))).toBe(true);
1212
+ expect(builtinRegistry
1213
+ .get('umami-read-websites')
1214
+ .match(makeRequest({ method: 'GET', path: '/api/teams' }))).toBe(false);
1215
+ });
1216
+ it('umami-write-teams matches both cloud and self-hosted paths', () => {
1217
+ expectPatternExists('umami-write-teams');
1218
+ expect(builtinRegistry
1219
+ .get('umami-write-teams')
1220
+ .match(makeRequest({ method: 'POST', path: '/v1/teams' }))).toBe(true);
1221
+ expect(builtinRegistry
1222
+ .get('umami-write-teams')
1223
+ .match(makeRequest({ method: 'POST', path: '/api/teams' }))).toBe(true);
1224
+ expect(builtinRegistry
1225
+ .get('umami-write-teams')
1226
+ .match(makeRequest({ method: 'POST', path: '/api/websites' }))).toBe(false);
1227
+ });
1228
+ });
1229
+ describe('builtin patterns: yelp', () => {
1230
+ it('yelp scope matches api.yelp.com', () => {
1231
+ expectPatternExists('yelp-api');
1232
+ const request = makeRequest({
1233
+ domain: 'api.yelp.com',
1234
+ path: '/v3/businesses/search',
1235
+ });
1236
+ expect(builtinRegistry.get('yelp-api').match(request)).toBe(true);
1237
+ });
1238
+ it('yelp scope rejects unrelated domains', () => {
1239
+ const request = makeRequest({ domain: 'yelp.example.com' });
1240
+ expect(builtinRegistry.get('yelp-api').match(request)).toBe(false);
1241
+ });
1242
+ it('yelp-read-businesses matches GET to /v3/businesses path', () => {
1243
+ expectPatternExists('yelp-read-businesses');
1244
+ expect(builtinRegistry
1245
+ .get('yelp-read-businesses')
1246
+ .match(makeRequest({ method: 'GET', path: '/v3/businesses/search' }))).toBe(true);
1247
+ expect(builtinRegistry
1248
+ .get('yelp-read-businesses')
1249
+ .match(makeRequest({ method: 'GET', path: '/v3/events' }))).toBe(false);
1250
+ });
1251
+ it('yelp-autocomplete matches /v3/autocomplete path', () => {
1252
+ expectPatternExists('yelp-autocomplete');
1253
+ expect(builtinRegistry
1254
+ .get('yelp-autocomplete')
1255
+ .match(makeRequest({ method: 'GET', path: '/v3/autocomplete' }))).toBe(true);
1256
+ expect(builtinRegistry
1257
+ .get('yelp-autocomplete')
1258
+ .match(makeRequest({ method: 'GET', path: '/v3/businesses/search' }))).toBe(false);
1259
+ });
1260
+ });
1261
+ describe('builtin patterns: zoom', () => {
1262
+ it('zoom scope matches api.zoom.us', () => {
1263
+ expectPatternExists('zoom-api');
1264
+ const request = makeRequest({
1265
+ domain: 'api.zoom.us',
1266
+ path: '/v2/users/me/meetings',
1267
+ });
1268
+ expect(builtinRegistry.get('zoom-api').match(request)).toBe(true);
1269
+ });
1270
+ it('zoom scope rejects unrelated domains', () => {
1271
+ const request = makeRequest({ domain: 'zoom.example.com' });
1272
+ expect(builtinRegistry.get('zoom-api').match(request)).toBe(false);
1273
+ });
1274
+ it('zoom-read-meetings matches GET to meetings path', () => {
1275
+ expectPatternExists('zoom-read-meetings');
1276
+ expect(builtinRegistry
1277
+ .get('zoom-read-meetings')
1278
+ .match(makeRequest({ method: 'GET', path: '/v2/meetings/123456' }))).toBe(true);
1279
+ expect(builtinRegistry
1280
+ .get('zoom-read-meetings')
1281
+ .match(makeRequest({ method: 'GET', path: '/v2/users/me' }))).toBe(false);
1282
+ });
1283
+ it('zoom-write-recordings matches DELETE to recordings path', () => {
1284
+ expectPatternExists('zoom-write-recordings');
1285
+ expect(builtinRegistry
1286
+ .get('zoom-write-recordings')
1287
+ .match(makeRequest({ method: 'DELETE', path: '/v2/meetings/123456/recordings' }))).toBe(true);
1288
+ expect(builtinRegistry
1289
+ .get('zoom-write-recordings')
1290
+ .match(makeRequest({ method: 'DELETE', path: '/v2/meetings/123456' }))).toBe(false);
1291
+ });
1292
+ });
1293
+ //# sourceMappingURL=builtinPatterns.test.js.map