@zhanglc77/bitbucket-mcp-server 1.0.11 → 1.0.13

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 (52) hide show
  1. package/build/handlers/pull-request-handlers.d.ts.map +1 -1
  2. package/build/handlers/pull-request-handlers.js +5 -2
  3. package/build/handlers/pull-request-handlers.js.map +1 -1
  4. package/build/handlers/resource-handlers.d.ts +20 -0
  5. package/build/handlers/resource-handlers.d.ts.map +1 -0
  6. package/build/handlers/resource-handlers.js +32 -0
  7. package/build/handlers/resource-handlers.js.map +1 -0
  8. package/build/index.d.ts +1245 -4
  9. package/build/index.d.ts.map +1 -1
  10. package/build/index.js +25 -86
  11. package/build/index.js.map +1 -1
  12. package/build/resources/field-schemas.d.ts +11 -108
  13. package/build/resources/field-schemas.d.ts.map +1 -1
  14. package/build/resources/field-schemas.js +169 -871
  15. package/build/resources/field-schemas.js.map +1 -1
  16. package/build/resources/resource-definitions.d.ts +19 -0
  17. package/build/resources/resource-definitions.d.ts.map +1 -0
  18. package/build/resources/resource-definitions.js +327 -0
  19. package/build/resources/resource-definitions.js.map +1 -0
  20. package/build/tools/definitions.d.ts +19 -0
  21. package/build/tools/definitions.d.ts.map +1 -1
  22. package/build/tools/definitions.js +4 -0
  23. package/build/tools/definitions.js.map +1 -1
  24. package/build/types/guards.d.ts +1 -0
  25. package/build/types/guards.d.ts.map +1 -1
  26. package/build/types/guards.js +2 -1
  27. package/build/types/guards.js.map +1 -1
  28. package/build/utils/field-filter.d.ts +42 -0
  29. package/build/utils/field-filter.d.ts.map +1 -0
  30. package/build/utils/field-filter.js +224 -0
  31. package/build/utils/field-filter.js.map +1 -0
  32. package/package.json +1 -1
  33. package/build/resources/handlers.d.ts +0 -65
  34. package/build/resources/handlers.d.ts.map +0 -1
  35. package/build/resources/handlers.js +0 -571
  36. package/build/resources/handlers.js.map +0 -1
  37. package/build/resources/schema-handlers.d.ts +0 -44
  38. package/build/resources/schema-handlers.d.ts.map +0 -1
  39. package/build/resources/schema-handlers.js +0 -183
  40. package/build/resources/schema-handlers.js.map +0 -1
  41. package/build/resources/static-resources.d.ts +0 -20
  42. package/build/resources/static-resources.d.ts.map +0 -1
  43. package/build/resources/static-resources.js +0 -73
  44. package/build/resources/static-resources.js.map +0 -1
  45. package/build/resources/templates.d.ts +0 -4
  46. package/build/resources/templates.d.ts.map +0 -1
  47. package/build/resources/templates.js +0 -306
  48. package/build/resources/templates.js.map +0 -1
  49. package/build/utils/bitbucket-uri.d.ts +0 -52
  50. package/build/utils/bitbucket-uri.d.ts.map +0 -1
  51. package/build/utils/bitbucket-uri.js +0 -139
  52. package/build/utils/bitbucket-uri.js.map +0 -1
@@ -1,893 +1,191 @@
1
1
  /**
2
- * Static field schemas and metadata for Bitbucket Cloud and Server REST API resources
3
- * Based on official Bitbucket Cloud and Server REST API documentation
4
- */
5
- /**
6
- * Repository resource field schema (Cloud and Server)
7
- */
8
- export const repositorySchema = {
9
- type: 'repository',
10
- description: 'Bitbucket repository object with complete metadata',
11
- fields: [
12
- // Common fields (both Cloud and Server)
13
- {
14
- name: 'name',
15
- type: 'string',
16
- description: 'Repository display name',
17
- required: true,
18
- example: 'My Repository'
19
- },
20
- {
21
- name: 'slug',
22
- type: 'string',
23
- description: 'URL-safe repository identifier',
24
- required: true,
25
- example: 'my-repository'
26
- },
27
- {
28
- name: 'description',
29
- type: 'string',
30
- description: 'Repository description text',
31
- example: 'This is a sample repository'
32
- },
33
- {
34
- name: 'links',
35
- type: 'object',
36
- description: 'Related links for repository resources',
37
- readonly: true,
38
- nested: true,
39
- example: { self: { href: 'https://api.bitbucket.org/2.0/repositories/...' } }
40
- },
41
- {
42
- name: 'project',
43
- type: 'object',
44
- description: 'Associated project object',
45
- nested: true,
46
- example: { name: 'Master station', key: 'PROJ' }
47
- },
48
- // Cloud-specific fields
49
- {
50
- name: 'type',
51
- type: 'string',
52
- description: 'Object type identifier, always "repository" (Cloud only)',
53
- readonly: true,
54
- example: 'repository'
55
- },
56
- {
57
- name: 'uuid',
58
- type: 'string',
59
- description: 'Unique repository identifier in UUID format with braces (Cloud only)',
60
- readonly: true,
61
- example: '{b4434b4d-6a0e-4f57-8d75-e02a824abeb0}'
62
- },
63
- {
64
- name: 'full_name',
65
- type: 'string',
66
- description: 'Full repository name in format "workspace/repo_slug" (Cloud only)',
67
- readonly: true,
68
- example: 'teamsinspace/documentation-tests'
69
- },
70
- {
71
- name: 'scm',
72
- type: 'string',
73
- description: 'Source control management type (git, hg) (Cloud only)',
74
- readonly: true,
75
- example: 'git'
76
- },
77
- {
78
- name: 'is_private',
79
- type: 'boolean',
80
- description: 'Whether the repository is private (Cloud only)',
81
- example: false
82
- },
83
- {
84
- name: 'size',
85
- type: 'number',
86
- description: 'Repository size in bytes (Cloud only)',
87
- readonly: true,
88
- example: 1172663
89
- },
90
- {
91
- name: 'language',
92
- type: 'string',
93
- description: 'Primary programming language detected (Cloud only)',
94
- readonly: true,
95
- example: 'JavaScript'
96
- },
97
- {
98
- name: 'has_issues',
99
- type: 'boolean',
100
- description: 'Whether issue tracker is enabled (Cloud only)',
101
- example: true
102
- },
103
- {
104
- name: 'has_wiki',
105
- type: 'boolean',
106
- description: 'Whether wiki is enabled (Cloud only)',
107
- example: true
108
- },
109
- {
110
- name: 'fork_policy',
111
- type: 'string',
112
- description: 'Fork permission policy (allow_forks, no_public_forks, no_forks) (Cloud only)',
113
- example: 'allow_forks'
114
- },
115
- {
116
- name: 'website',
117
- type: 'string',
118
- description: 'Repository website URL (Cloud only)',
119
- example: 'https://example.com'
120
- },
121
- {
122
- name: 'created_on',
123
- type: 'string',
124
- description: 'Repository creation timestamp in ISO 8601 format (Cloud only)',
125
- readonly: true,
126
- example: '2014-07-24T21:48:26.648365+00:00'
127
- },
128
- {
129
- name: 'updated_on',
130
- type: 'string',
131
- description: 'Last update timestamp in ISO 8601 format (Cloud only)',
132
- readonly: true,
133
- example: '2016-07-29T18:45:36.317590+00:00'
134
- },
135
- {
136
- name: 'mainbranch',
137
- type: 'object',
138
- description: 'Main branch information object (Cloud only)',
139
- nested: true,
140
- example: { name: 'main' }
141
- },
142
- {
143
- name: 'owner',
144
- type: 'object',
145
- description: 'Repository owner (user or team) object (Cloud only)',
146
- nested: true,
147
- example: { username: 'teamsinspace', type: 'team' }
148
- },
149
- {
150
- name: 'properties',
151
- type: 'object',
152
- description: 'Application-specific properties stored for this repository (Cloud only)',
153
- nested: true
154
- },
155
- // Server-specific fields
156
- {
157
- name: 'id',
158
- type: 'number',
159
- description: 'Numeric repository identifier (Server only)',
160
- readonly: true,
161
- example: 1234
162
- },
163
- {
164
- name: 'hierarchyId',
165
- type: 'string',
166
- description: 'Repository hierarchy identifier (Server only)',
167
- readonly: true,
168
- example: 'abc123def456'
169
- },
170
- {
171
- name: 'scmId',
172
- type: 'string',
173
- description: 'Source control management identifier (Server only)',
174
- readonly: true,
175
- example: 'git'
176
- },
177
- {
178
- name: 'state',
179
- type: 'string',
180
- description: 'Repository state (AVAILABLE, INITIALISING, etc.) (Server only)',
181
- readonly: true,
182
- example: 'AVAILABLE'
183
- },
184
- {
185
- name: 'statusMessage',
186
- type: 'string',
187
- description: 'Repository status message (Server only)',
188
- readonly: true,
189
- example: 'Available'
190
- },
191
- {
192
- name: 'forkable',
193
- type: 'boolean',
194
- description: 'Whether the repository can be forked (Server only)',
195
- readonly: true,
196
- example: true
197
- },
198
- {
199
- name: 'public',
200
- type: 'boolean',
201
- description: 'Whether the repository is public (Server only)',
202
- example: false
203
- },
204
- {
205
- name: 'archived',
206
- type: 'boolean',
207
- description: 'Whether the repository is archived (Server only)',
208
- example: false
209
- }
210
- ]
211
- };
212
- /**
213
- * Branch resource field schema (Cloud and Server)
214
- */
215
- export const branchSchema = {
216
- type: 'branch',
217
- description: 'Bitbucket branch reference object',
218
- fields: [
219
- // Common fields (both Cloud and Server)
220
- {
221
- name: 'type',
222
- type: 'string',
223
- description: 'Object type identifier (Server: "BRANCH", Cloud: "branch")',
224
- readonly: true,
225
- example: 'branch'
226
- },
227
- // Cloud-specific fields
228
- {
229
- name: 'name',
230
- type: 'string',
231
- description: 'Branch name (Cloud only)',
232
- example: 'main'
233
- },
234
- {
235
- name: 'target',
236
- type: 'object',
237
- description: 'Target commit object (Cloud only)',
238
- readonly: true,
239
- nested: true,
240
- example: { hash: 'abc123def456' }
241
- },
242
- {
243
- name: 'heads',
244
- type: 'array',
245
- description: 'Branch head commits (Cloud only)',
246
- readonly: true,
247
- nested: true
248
- },
249
- {
250
- name: 'links',
251
- type: 'object',
252
- description: 'Related links for branch resources (Cloud only)',
253
- readonly: true,
254
- nested: true
255
- },
256
- {
257
- name: 'default_merge_strategy',
258
- type: 'string',
259
- description: 'Default merge strategy for this branch (Cloud only)',
260
- example: 'merge_commit'
261
- },
262
- {
263
- name: 'merge_strategies',
264
- type: 'array',
265
- description: 'Available merge strategies (Cloud only)',
266
- readonly: true,
267
- example: ['merge_commit', 'squash', 'fast_forward']
268
- },
269
- // Server-specific fields
270
- {
271
- name: 'id',
272
- type: 'string',
273
- description: 'Branch identifier (Server only)',
274
- readonly: true,
275
- example: 'refs/heads/main'
276
- },
277
- {
278
- name: 'displayId',
279
- type: 'string',
280
- description: 'Display name of the branch (Server only)',
281
- readonly: true,
282
- example: 'main'
283
- },
284
- {
285
- name: 'latestCommit',
286
- type: 'string',
287
- description: 'Latest commit hash on this branch (Server only)',
288
- readonly: true,
289
- example: 'abc123def456789'
290
- },
291
- {
292
- name: 'latestChangeset',
293
- type: 'string',
294
- description: 'Latest changeset hash on this branch (Server only)',
295
- readonly: true,
296
- example: 'abc123def456789'
297
- },
298
- {
299
- name: 'isDefault',
300
- type: 'boolean',
301
- description: 'Whether this is the default branch (Server only)',
302
- readonly: true,
303
- example: true
304
- }
305
- ]
306
- };
307
- /**
308
- * Pull Request resource field schema (Cloud and Server)
309
- */
310
- export const pullRequestSchema = {
311
- type: 'pull-request',
312
- description: 'Bitbucket pull request object with complete metadata',
313
- fields: [
314
- // Common fields (both Cloud and Server)
315
- {
316
- name: 'id',
317
- type: 'number',
318
- description: 'Unique pull request identifier',
319
- required: true,
320
- readonly: true,
321
- example: 1234
322
- },
323
- {
324
- name: 'title',
325
- type: 'string',
326
- description: 'Pull request title',
327
- required: true,
328
- example: 'Add new feature'
329
- },
330
- {
331
- name: 'description',
332
- type: 'string',
333
- description: 'Pull request description',
334
- example: 'This PR adds a new feature...'
335
- },
336
- {
337
- name: 'state',
338
- type: 'string',
339
- description: 'Pull request state (OPEN, MERGED, DECLINED, SUPERSEDED)',
340
- required: true,
341
- example: 'OPEN'
342
- },
343
- // Cloud-specific fields
344
- {
345
- name: 'type',
346
- type: 'string',
347
- description: 'Object type identifier, always "pullrequest" (Cloud only)',
348
- readonly: true,
349
- example: 'pullrequest'
350
- },
351
- {
352
- name: 'draft',
353
- type: 'boolean',
354
- description: 'Whether the pull request is in draft status (Cloud only)',
355
- example: false
356
- },
357
- {
358
- name: 'author',
359
- type: 'object',
360
- description: 'Pull request author (user) object (Cloud only)',
361
- nested: true,
362
- example: { username: 'developer', display_name: 'Developer Name' }
363
- },
364
- {
365
- name: 'source',
366
- type: 'object',
367
- description: 'Source branch information (Cloud only)',
368
- nested: true,
369
- example: { branch: { name: 'feature-branch' } }
370
- },
371
- {
372
- name: 'destination',
373
- type: 'object',
374
- description: 'Destination branch information (Cloud only)',
375
- nested: true,
376
- example: { branch: { name: 'main' }, repository: { full_name: 'team/repo' } }
377
- },
378
- {
379
- name: 'merge_commit',
380
- type: 'object',
381
- description: 'Merge commit information (available after merge) (Cloud only)',
382
- nested: true,
383
- readonly: true
384
- },
385
- {
386
- name: 'close_source_branch',
387
- type: 'boolean',
388
- description: 'Whether to close source branch after merge (Cloud only)',
389
- example: true
390
- },
391
- {
392
- name: 'closed_by',
393
- type: 'object',
394
- description: 'User who closed the pull request (Cloud only)',
395
- nested: true,
396
- readonly: true
397
- },
398
- {
399
- name: 'reason',
400
- type: 'string',
401
- description: 'Reason for closing (if declined) (Cloud only)',
402
- readonly: true
403
- },
404
- {
405
- name: 'created_on',
406
- type: 'string',
407
- description: 'Creation timestamp in ISO 8601 format (Cloud only)',
408
- readonly: true,
409
- example: '2023-01-15T10:30:00.000Z'
410
- },
411
- {
412
- name: 'updated_on',
413
- type: 'string',
414
- description: 'Last update timestamp in ISO 8601 format (Cloud only)',
415
- readonly: true,
416
- example: '2023-01-16T14:20:00.000Z'
417
- },
418
- {
419
- name: 'comment_count',
420
- type: 'number',
421
- description: 'Total number of comments (Cloud only)',
422
- readonly: true,
423
- example: 5
424
- },
425
- {
426
- name: 'task_count',
427
- type: 'number',
428
- description: 'Total number of tasks (Cloud only)',
429
- readonly: true,
430
- example: 2
431
- },
432
- {
433
- name: 'reviewers',
434
- type: 'array',
435
- description: 'List of pull request reviewers (Cloud only)',
436
- nested: true,
437
- example: [{ user: { username: 'reviewer1' }, approved: true }]
438
- },
439
- {
440
- name: 'participants',
441
- type: 'array',
442
- description: 'List of pull request participants (Cloud only)',
443
- nested: true,
444
- readonly: true
445
- },
446
- {
447
- name: 'links',
448
- type: 'object',
449
- description: 'Related links for pull request resources (Cloud only)',
450
- readonly: true,
451
- nested: true
452
- },
453
- // Server-specific fields
454
- {
455
- name: 'version',
456
- type: 'number',
457
- description: 'Pull request version number for optimistic locking (Server only)',
458
- readonly: true,
459
- example: 40
460
- },
461
- {
462
- name: 'open',
463
- type: 'boolean',
464
- description: 'Whether the pull request is open (Server only)',
465
- readonly: true,
466
- example: true
467
- },
468
- {
469
- name: 'closed',
470
- type: 'boolean',
471
- description: 'Whether the pull request is closed (Server only)',
472
- readonly: true,
473
- example: false
474
- },
475
- {
476
- name: 'locked',
477
- type: 'boolean',
478
- description: 'Whether the pull request is locked from further changes (Server only)',
479
- readonly: true,
480
- example: false
481
- },
482
- {
483
- name: 'createdDate',
484
- type: 'number',
485
- description: 'Creation timestamp in milliseconds since epoch (Server only)',
486
- readonly: true,
487
- example: 1755673199103
488
- },
489
- {
490
- name: 'updatedDate',
491
- type: 'number',
492
- description: 'Last update timestamp in milliseconds since epoch (Server only)',
493
- readonly: true,
494
- example: 1755689018998
495
- },
496
- {
497
- name: 'fromRef',
498
- type: 'object',
499
- description: 'Source branch reference object with repository information (Server only)',
500
- nested: true,
501
- readonly: true,
502
- example: {
503
- displayId: 'feature-branch',
504
- latestCommit: 'abc123def456',
505
- repository: { slug: 'my-repo' }
506
- }
507
- },
508
- {
509
- name: 'toRef',
510
- type: 'object',
511
- description: 'Destination branch reference object with repository information (Server only)',
512
- nested: true,
513
- readonly: true,
514
- example: {
515
- displayId: 'main',
516
- latestCommit: 'def456abc123',
517
- repository: { slug: 'my-repo' }
518
- }
519
- },
520
- {
521
- name: 'author',
522
- type: 'object',
523
- description: 'Pull request author object with user details and approval status (Server only)',
524
- nested: true,
525
- readonly: true,
526
- example: {
527
- user: { displayName: 'John Developer', emailAddress: 'john@company.com' },
528
- role: 'AUTHOR',
529
- approved: false,
530
- status: 'UNAPPROVED'
531
- }
532
- },
533
- {
534
- name: 'reviewers',
535
- type: 'array',
536
- description: 'Array of reviewer objects with user details and approval status (Server only)',
537
- nested: true,
538
- example: [{
539
- user: { displayName: 'Jane Reviewer', emailAddress: 'jane@company.com' },
540
- role: 'REVIEWER',
541
- approved: true,
542
- status: 'APPROVED'
543
- }]
544
- },
545
- {
546
- name: 'participants',
547
- type: 'array',
548
- description: 'Array of participant objects for users involved in the pull request (Server only)',
549
- nested: true,
550
- readonly: true,
551
- example: [{
552
- user: { displayName: 'Participant Name', emailAddress: 'participant@company.com' },
553
- role: 'PARTICIPANT',
554
- approved: false,
555
- status: 'UNAPPROVED'
556
- }]
557
- },
558
- {
559
- name: 'properties',
560
- type: 'object',
561
- description: 'Additional properties including merge result, cycle time, and task counts (Server only)',
562
- nested: true,
563
- readonly: true,
564
- example: {
565
- mergeResult: { outcome: 'CLEAN', current: true },
566
- commentCount: 5,
567
- openTaskCount: 2,
568
- resolvedTaskCount: 0
2
+ * Field schema definitions for Pull Request resources
3
+ * Used for field filtering and API documentation
4
+ */
5
+ export const PULL_REQUEST_FIELDS = {
6
+ // Basic PR information
7
+ id: {
8
+ type: 'number',
9
+ description: 'Unique identifier for the pull request'
10
+ },
11
+ title: {
12
+ type: 'string',
13
+ description: 'Title of the pull request'
14
+ },
15
+ description: {
16
+ type: 'string',
17
+ description: 'Description or summary of the pull request'
18
+ },
19
+ state: {
20
+ type: 'string',
21
+ description: 'Current state of the pull request (OPEN, MERGED, DECLINED)'
22
+ },
23
+ is_open: {
24
+ type: 'boolean',
25
+ description: 'Whether the pull request is currently open'
26
+ },
27
+ is_closed: {
28
+ type: 'boolean',
29
+ description: 'Whether the pull request is closed'
30
+ },
31
+ is_locked: {
32
+ type: 'boolean',
33
+ description: 'Whether the pull request is locked for further changes'
34
+ },
35
+ // Author information
36
+ author: {
37
+ type: 'string',
38
+ description: 'Display name of the pull request author'
39
+ },
40
+ author_username: {
41
+ type: 'string',
42
+ description: 'Username of the pull request author'
43
+ },
44
+ author_email: {
45
+ type: 'string',
46
+ description: 'Email address of the pull request author',
47
+ format: 'email'
48
+ },
49
+ // Branch and commit information
50
+ source_branch: {
51
+ type: 'string',
52
+ description: 'Name of the source branch for the pull request'
53
+ },
54
+ destination_branch: {
55
+ type: 'string',
56
+ description: 'Name of the destination branch for the pull request'
57
+ },
58
+ source_commit: {
59
+ type: 'string',
60
+ description: 'Latest commit hash on the source branch'
61
+ },
62
+ destination_commit: {
63
+ type: 'string',
64
+ description: 'Latest commit hash on the destination branch'
65
+ },
66
+ // Review and participation
67
+ reviewers: {
68
+ type: 'array',
69
+ description: 'List of reviewers assigned to the pull request',
70
+ items: {
71
+ type: 'object',
72
+ properties: {
73
+ name: {
74
+ type: 'string',
75
+ description: 'Display name of the reviewer'
76
+ },
77
+ approved: {
78
+ type: 'boolean',
79
+ description: 'Whether the reviewer has approved the pull request'
80
+ },
81
+ status: {
82
+ type: 'string',
83
+ description: 'Review status (APPROVED, UNAPPROVED, NEEDS_WORK)'
84
+ }
569
85
  }
570
86
  }
571
- ]
572
- };
573
- /**
574
- * Simplified schemas for common resources - keeping existing schemas for compatibility
575
- */
576
- export const commitSchema = {
577
- type: 'commit',
578
- description: 'Bitbucket commit object with complete metadata',
579
- fields: [
580
- {
581
- name: 'type',
582
- type: 'string',
583
- description: 'Object type identifier, always "commit"',
584
- required: true,
585
- readonly: true,
586
- example: 'commit'
587
- },
588
- {
589
- name: 'hash',
590
- type: 'string',
591
- description: 'Commit SHA hash',
592
- required: true,
593
- readonly: true,
594
- example: 'abc123def456'
595
- },
596
- {
597
- name: 'message',
598
- type: 'string',
599
- description: 'Commit message',
600
- required: true,
601
- readonly: true,
602
- example: 'Fix bug in user authentication'
603
- }
604
- ]
605
- };
606
- export const fileSchema = {
607
- type: 'commit-file',
608
- description: 'File or directory in a repository at a specific commit',
609
- fields: [
610
- {
611
- name: 'type',
612
- type: 'string',
613
- description: 'Object type (commit_file or commit_directory)',
614
- required: true,
615
- readonly: true,
616
- example: 'commit_file'
617
- },
618
- {
619
- name: 'path',
620
- type: 'string',
621
- description: 'File or directory path relative to repository root',
622
- required: true,
623
- readonly: true,
624
- example: 'src/main.js'
625
- }
626
- ]
627
- };
628
- export const issueSchema = {
629
- type: 'issue',
630
- description: 'Bitbucket issue object',
631
- fields: [
632
- {
633
- name: 'type',
634
- type: 'string',
635
- description: 'Object type identifier, always "issue"',
636
- required: true,
637
- readonly: true,
638
- example: 'issue'
639
- },
640
- {
641
- name: 'id',
642
- type: 'number',
643
- description: 'Unique issue identifier',
644
- required: true,
645
- readonly: true,
646
- example: 42
647
- }
648
- ]
649
- };
650
- export const userSchema = {
651
- type: 'user',
652
- description: 'Bitbucket user or team account object',
653
- fields: [
654
- {
655
- name: 'type',
656
- type: 'string',
657
- description: 'Object type (user or team)',
658
- required: true,
659
- readonly: true,
660
- example: 'user'
661
- },
662
- {
663
- name: 'display_name',
664
- type: 'string',
665
- description: 'User display name',
666
- required: true,
667
- example: 'John Developer'
668
- }
669
- ]
670
- };
671
- export const projectSchema = {
672
- type: 'project',
673
- description: 'Bitbucket project object for organizing repositories',
674
- fields: [
675
- {
676
- name: 'type',
677
- type: 'string',
678
- description: 'Object type identifier, always "project"',
679
- required: true,
680
- readonly: true,
681
- example: 'project'
682
- },
683
- {
684
- name: 'key',
685
- type: 'string',
686
- description: 'Project key (unique within workspace)',
687
- required: true,
688
- example: 'PROJ'
689
- }
690
- ]
691
- };
692
- export const commentSchema = {
693
- type: 'comment',
694
- description: 'Comment object for pull requests, commits, or issues',
695
- fields: [
696
- {
697
- name: 'type',
698
- type: 'string',
699
- description: 'Comment type (pullrequest_comment, commit_comment, issue_comment)',
700
- required: true,
701
- readonly: true,
702
- example: 'pullrequest_comment'
703
- },
704
- {
705
- name: 'id',
706
- type: 'number',
707
- description: 'Unique comment identifier',
708
- required: true,
709
- readonly: true,
710
- example: 12345
87
+ },
88
+ participants: {
89
+ type: 'array',
90
+ description: 'List of participants in the pull request',
91
+ items: {
92
+ type: 'object',
93
+ properties: {
94
+ name: {
95
+ type: 'string',
96
+ description: 'Display name of the participant'
97
+ },
98
+ role: {
99
+ type: 'string',
100
+ description: 'Role of the participant (AUTHOR, REVIEWER, PARTICIPANT)'
101
+ },
102
+ approved: {
103
+ type: 'boolean',
104
+ description: 'Whether the participant has approved the pull request'
105
+ },
106
+ status: {
107
+ type: 'string',
108
+ description: 'Participation status'
109
+ }
110
+ }
711
111
  }
712
- ]
713
- };
714
- /**
715
- * All available resource schemas indexed by type
716
- */
717
- export const resourceSchemas = {
718
- repository: repositorySchema,
719
- pullrequest: pullRequestSchema,
720
- commit: commitSchema,
721
- branch: branchSchema,
722
- commit_file: fileSchema,
723
- commit_directory: fileSchema,
724
- issue: issueSchema,
725
- user: userSchema,
726
- team: userSchema,
727
- project: projectSchema,
728
- pullrequest_comment: commentSchema,
729
- commit_comment: commentSchema,
730
- issue_comment: commentSchema
731
- };
732
- /**
733
- * Get field schema for a specific resource type
734
- */
735
- export function getResourceSchema(resourceType) {
736
- return resourceSchemas[resourceType];
737
- }
738
- /**
739
- * Get all field names for a resource type
740
- */
741
- export function getResourceFields(resourceType) {
742
- const schema = getResourceSchema(resourceType);
743
- return schema?.fields.map(f => f.name) || [];
744
- }
745
- /**
746
- * Get field metadata for a specific field
747
- */
748
- export function getFieldMetadata(resourceType, fieldName) {
749
- const schema = getResourceSchema(resourceType);
750
- return schema?.fields.find(f => f.name === fieldName);
751
- }
752
- /**
753
- * Get commonly requested fields for different access patterns
754
- */
755
- export const commonFieldSets = {
756
- minimal: ['type', 'id', 'uuid', 'name', 'full_name'],
757
- summary: ['type', 'id', 'uuid', 'name', 'full_name', 'title', 'description', 'state', 'created_on', 'updated_on'],
758
- metadata: ['type', 'id', 'uuid', 'name', 'full_name', 'title', 'description', 'state', 'created_on', 'updated_on', 'author', 'owner'],
759
- detailed: [] // Empty means all fields
760
- };
761
- /**
762
- * Get predefined field set
763
- */
764
- export function getCommonFields(pattern) {
765
- return commonFieldSets[pattern];
766
- }
767
- /**
768
- * Resource type categories for organization and discovery
769
- */
770
- export const resourceCategories = {
771
- core: {
772
- description: 'Core Bitbucket resources essential for most operations',
773
- types: ['repository', 'pull-request', 'commit', 'branch', 'user']
774
112
  },
775
- extended: {
776
- description: 'Extended resources for advanced functionality',
777
- types: ['issue', 'project', 'pull-request-comment', 'commit-comment', 'issue-comment', 'commit-file', 'commit-directory']
113
+ // Timestamps
114
+ created_on: {
115
+ type: 'string',
116
+ description: 'Date and time when the pull request was created',
117
+ format: 'date-time'
118
+ },
119
+ updated_on: {
120
+ type: 'string',
121
+ description: 'Date and time when the pull request was last updated',
122
+ format: 'date-time'
123
+ },
124
+ // URLs and links
125
+ web_url: {
126
+ type: 'string',
127
+ description: 'Web URL to view the pull request in the browser',
128
+ format: 'uri'
129
+ },
130
+ api_url: {
131
+ type: 'string',
132
+ description: 'API URL to access the pull request programmatically',
133
+ format: 'uri'
134
+ },
135
+ // Merge information
136
+ is_merged: {
137
+ type: 'boolean',
138
+ description: 'Whether the pull request has been merged'
139
+ },
140
+ merge_commit_hash: {
141
+ type: 'string',
142
+ description: 'Hash of the merge commit if the pull request has been merged'
143
+ },
144
+ merged_by: {
145
+ type: 'string',
146
+ description: 'Name of the user who merged the pull request'
147
+ },
148
+ merged_at: {
149
+ type: 'string',
150
+ description: 'Date and time when the pull request was merged',
151
+ format: 'date-time'
152
+ },
153
+ merge_commit_message: {
154
+ type: 'string',
155
+ description: 'Commit message used for the merge commit'
778
156
  }
779
157
  };
780
158
  /**
781
- * Get all available resource types
159
+ * Get all available field names for pull requests
782
160
  */
783
- export function getAllResourceTypes() {
784
- return Object.keys(resourceSchemas);
161
+ export function getAllPullRequestFields() {
162
+ return Object.keys(PULL_REQUEST_FIELDS);
785
163
  }
786
164
  /**
787
- * Get resource types by category
165
+ * Get field definition for a specific field
788
166
  */
789
- export function getResourceTypesByCategory(category = 'all') {
790
- if (category === 'all') {
791
- return getAllResourceTypes();
792
- }
793
- return resourceCategories[category]?.types || [];
167
+ export function getFieldDefinition(fieldName) {
168
+ return PULL_REQUEST_FIELDS[fieldName];
794
169
  }
795
170
  /**
796
- * Get resource type index with metadata
797
- * Returns a static list of all available resource types
171
+ * Check if a field exists in the schema
798
172
  */
799
- export function getResourceTypeIndex() {
800
- const types = getResourceTypesByCategory('all');
801
- return types.map(type => {
802
- const schema = getResourceSchema(type);
803
- if (!schema)
804
- return null;
805
- return {
806
- type: schema.type,
807
- description: schema.description,
808
- category: resourceCategories.core.types.includes(type) ? 'core' : 'extended'
809
- };
810
- }).filter(Boolean);
173
+ export function isValidField(fieldName) {
174
+ return fieldName in PULL_REQUEST_FIELDS;
811
175
  }
812
176
  /**
813
- * Get filtered fields based on criteria
177
+ * Get all fields that can be used with dot notation (nested fields)
814
178
  */
815
- export function getFilteredFields(resourceType, filterBy) {
816
- const schema = getResourceSchema(resourceType);
817
- if (!schema)
818
- return [];
819
- if (!filterBy)
820
- return schema.fields;
821
- return schema.fields.filter(field => {
822
- switch (filterBy) {
823
- case 'required':
824
- return field.required === true;
825
- case 'optional':
826
- return !field.required;
827
- case 'readonly':
828
- return field.readonly === true;
829
- case 'nested':
830
- return field.nested === true;
831
- default:
832
- return true;
179
+ export function getNestedFields() {
180
+ const nestedFields = [];
181
+ Object.entries(PULL_REQUEST_FIELDS).forEach(([fieldName, fieldDef]) => {
182
+ if (fieldDef.type === 'array' && fieldDef.items?.properties) {
183
+ const properties = Object.keys(fieldDef.items.properties);
184
+ properties.forEach(prop => {
185
+ nestedFields.push(`${fieldName}.${prop}`);
186
+ });
833
187
  }
834
188
  });
835
- }
836
- /**
837
- * Get validation rules for a resource type
838
- */
839
- export function getValidationRules(resourceType, operation = 'read') {
840
- const schema = getResourceSchema(resourceType);
841
- if (!schema)
842
- return null;
843
- const rules = {
844
- resourceType: schema.type,
845
- operation,
846
- requiredFields: schema.fields.filter(f => f.required && !f.readonly).map(f => f.name),
847
- readonlyFields: schema.fields.filter(f => f.readonly).map(f => f.name),
848
- optionalFields: schema.fields.filter(f => !f.required && !f.readonly).map(f => f.name),
849
- nestedFields: schema.fields.filter(f => f.nested).map(f => f.name),
850
- fieldTypes: schema.fields.reduce((acc, field) => {
851
- acc[field.name] = field.type;
852
- return acc;
853
- }, {})
854
- };
855
- // Adjust rules based on operation
856
- if (operation === 'create') {
857
- // For create operations, some readonly fields might be auto-generated
858
- rules.readonlyFields = schema.fields.filter(f => f.readonly && !['type', 'created_on'].includes(f.name)).map(f => f.name);
859
- }
860
- else if (operation === 'update') {
861
- // For update operations, some required fields might become optional
862
- rules.requiredFields = schema.fields.filter(f => f.required && !f.readonly && !['type', 'id', 'uuid'].includes(f.name)).map(f => f.name);
863
- }
864
- return rules;
865
- }
866
- /**
867
- * Get field schema with detailed information
868
- */
869
- export function getDetailedFieldSchema(resourceType, fieldName, includeNested = false) {
870
- const fieldMetadata = getFieldMetadata(resourceType, fieldName);
871
- if (!fieldMetadata)
872
- return null;
873
- const result = {
874
- ...fieldMetadata,
875
- resourceType,
876
- validationRules: {
877
- required: fieldMetadata.required || false,
878
- readonly: fieldMetadata.readonly || false,
879
- type: fieldMetadata.type
880
- }
881
- };
882
- // Add nested schema information if requested and applicable
883
- if (includeNested && fieldMetadata.nested && fieldMetadata.type === 'object') {
884
- // For now, we'll indicate that nested schemas are available
885
- // In the future, this could include detailed nested field definitions
886
- result.nestedSchema = {
887
- available: true,
888
- note: `Nested schema for ${fieldName} in ${resourceType} - use specific resource type for detailed schema`
889
- };
890
- }
891
- return result;
189
+ return nestedFields;
892
190
  }
893
191
  //# sourceMappingURL=field-schemas.js.map