@felixgeelhaar/jira-sdk 0.2.0 → 0.3.0

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.
@@ -13062,6 +13062,30 @@ var DoTransitionInputSchema = external_exports.object({
13062
13062
  historyMetadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
13063
13063
  properties: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional()
13064
13064
  });
13065
+ var AttachmentSchema = external_exports.object({
13066
+ self: external_exports.url(),
13067
+ id: external_exports.string(),
13068
+ filename: external_exports.string(),
13069
+ author: schemas.UserRefSchema.optional(),
13070
+ created: schemas.OptionalJiraDateTimeSchema,
13071
+ size: external_exports.number().int().min(0),
13072
+ mimeType: external_exports.string(),
13073
+ content: external_exports.url(),
13074
+ thumbnail: external_exports.url().optional()
13075
+ });
13076
+ var AttachmentMetadataSchema = external_exports.object({
13077
+ id: external_exports.number(),
13078
+ self: external_exports.url(),
13079
+ filename: external_exports.string(),
13080
+ author: schemas.UserRefSchema,
13081
+ created: schemas.OptionalJiraDateTimeSchema,
13082
+ size: external_exports.number(),
13083
+ mimeType: external_exports.string(),
13084
+ properties: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
13085
+ content: external_exports.url().optional(),
13086
+ thumbnail: external_exports.url().optional()
13087
+ });
13088
+ var AddAttachmentResponseSchema = external_exports.array(AttachmentSchema);
13065
13089
  var WorklogVisibilitySchema = external_exports.object({
13066
13090
  type: external_exports.enum(["group", "role"]),
13067
13091
  value: external_exports.string(),
@@ -13099,6 +13123,52 @@ var WorklogsPageSchema = external_exports.object({
13099
13123
  total: external_exports.number(),
13100
13124
  worklogs: external_exports.array(WorklogSchema)
13101
13125
  });
13126
+
13127
+ // src/schemas/issue/link.ts
13128
+ var IssueLinkTypeSchema = external_exports.object({
13129
+ id: external_exports.string(),
13130
+ name: external_exports.string(),
13131
+ inward: external_exports.string(),
13132
+ outward: external_exports.string(),
13133
+ self: external_exports.url().optional()
13134
+ });
13135
+ var LinkedIssueFieldsSchema = external_exports.object({
13136
+ summary: external_exports.string().optional(),
13137
+ status: IssueStatusSchema.optional(),
13138
+ priority: IssuePrioritySchema.nullable().optional(),
13139
+ issuetype: IssueTypeSchema.optional()
13140
+ });
13141
+ var LinkedIssueSchema = external_exports.object({
13142
+ id: external_exports.string(),
13143
+ key: external_exports.string(),
13144
+ self: external_exports.url().optional(),
13145
+ fields: LinkedIssueFieldsSchema.optional()
13146
+ });
13147
+ var IssueLinkSchema = external_exports.object({
13148
+ id: external_exports.string(),
13149
+ self: external_exports.url().optional(),
13150
+ type: IssueLinkTypeSchema,
13151
+ inwardIssue: LinkedIssueSchema.optional(),
13152
+ outwardIssue: LinkedIssueSchema.optional()
13153
+ });
13154
+ var CreateIssueLinkInputSchema = external_exports.object({
13155
+ type: external_exports.object({
13156
+ name: external_exports.string().optional(),
13157
+ id: external_exports.string().optional()
13158
+ }),
13159
+ inwardIssue: external_exports.object({ key: external_exports.string() }).optional(),
13160
+ outwardIssue: external_exports.object({ key: external_exports.string() }).optional(),
13161
+ comment: external_exports.object({
13162
+ body: external_exports.unknown(),
13163
+ visibility: external_exports.object({
13164
+ type: external_exports.enum(["group", "role"]),
13165
+ value: external_exports.string()
13166
+ }).optional()
13167
+ }).optional()
13168
+ });
13169
+ var IssueLinkTypesResponseSchema = external_exports.object({
13170
+ issueLinkTypes: external_exports.array(IssueLinkTypeSchema)
13171
+ });
13102
13172
  var WatchersSchema = external_exports.object({
13103
13173
  self: external_exports.url(),
13104
13174
  watchCount: external_exports.number().int().min(0),
@@ -13467,6 +13537,139 @@ var IssueService = class extends BaseService {
13467
13537
  async removeVote(issueIdOrKey) {
13468
13538
  await this.deleteMethod(`/issue/${issueIdOrKey}/votes`);
13469
13539
  }
13540
+ // Attachments
13541
+ /**
13542
+ * Add an attachment to an issue
13543
+ *
13544
+ * @param issueIdOrKey - Issue ID or key
13545
+ * @param file - File or Blob to upload
13546
+ * @param filename - Optional filename (defaults to File.name or 'attachment')
13547
+ * @returns Array of created attachments
13548
+ *
13549
+ * @example
13550
+ * ```typescript
13551
+ * const file = new File(['content'], 'document.txt', { type: 'text/plain' });
13552
+ * const attachments = await client.issues.addAttachment('PROJECT-123', file);
13553
+ * ```
13554
+ */
13555
+ async addAttachment(issueIdOrKey, file2, filename) {
13556
+ const formData = new FormData();
13557
+ const name = filename ?? (file2 instanceof File ? file2.name : "attachment");
13558
+ formData.append("file", file2, name);
13559
+ const response = await this.http.post(
13560
+ this.buildPath(`/issue/${issueIdOrKey}/attachments`),
13561
+ formData,
13562
+ {
13563
+ headers: {
13564
+ "X-Atlassian-Token": "no-check"
13565
+ }
13566
+ }
13567
+ );
13568
+ return this.validateResponse(response, AddAttachmentResponseSchema);
13569
+ }
13570
+ /**
13571
+ * Get attachment metadata by ID
13572
+ *
13573
+ * @param attachmentId - Attachment ID
13574
+ * @returns Attachment metadata
13575
+ */
13576
+ async getAttachment(attachmentId) {
13577
+ return this.getMethod(`/attachment/${attachmentId}`, AttachmentMetadataSchema);
13578
+ }
13579
+ /**
13580
+ * Download attachment content
13581
+ *
13582
+ * @param attachmentId - Attachment ID
13583
+ * @returns Blob containing the attachment content
13584
+ */
13585
+ async downloadAttachment(attachmentId) {
13586
+ const response = await this.http.request({
13587
+ method: "GET",
13588
+ url: this.buildPath(`/attachment/content/${attachmentId}`),
13589
+ headers: {
13590
+ Accept: "*/*"
13591
+ },
13592
+ metadata: { rawResponse: true }
13593
+ });
13594
+ return response.data;
13595
+ }
13596
+ /**
13597
+ * Delete an attachment
13598
+ *
13599
+ * @param attachmentId - Attachment ID
13600
+ */
13601
+ async deleteAttachment(attachmentId) {
13602
+ await this.deleteMethod(`/attachment/${attachmentId}`);
13603
+ }
13604
+ // Issue Links
13605
+ /**
13606
+ * Get all links for an issue
13607
+ *
13608
+ * @param issueIdOrKey - Issue ID or key
13609
+ * @returns Array of issue links
13610
+ */
13611
+ async getIssueLinks(issueIdOrKey) {
13612
+ const issue2 = await this.get(issueIdOrKey, {
13613
+ fields: ["issuelinks"]
13614
+ });
13615
+ const links = issue2.fields["issuelinks"];
13616
+ if (!links || !Array.isArray(links)) {
13617
+ return [];
13618
+ }
13619
+ return links.map((link) => IssueLinkSchema.parse(link));
13620
+ }
13621
+ /**
13622
+ * Create a link between two issues
13623
+ *
13624
+ * @param input - Issue link creation input
13625
+ *
13626
+ * @example
13627
+ * ```typescript
13628
+ * await client.issues.createIssueLink({
13629
+ * type: { name: 'Blocks' },
13630
+ * inwardIssue: { key: 'PROJECT-123' },
13631
+ * outwardIssue: { key: 'PROJECT-456' },
13632
+ * });
13633
+ * ```
13634
+ */
13635
+ async createIssueLink(input) {
13636
+ const validatedInput = CreateIssueLinkInputSchema.parse(input);
13637
+ await this.postMethodRaw("/issueLink", validatedInput);
13638
+ }
13639
+ /**
13640
+ * Get an issue link by ID
13641
+ *
13642
+ * @param linkId - Issue link ID
13643
+ * @returns Issue link
13644
+ */
13645
+ async getIssueLink(linkId) {
13646
+ return this.getMethod(`/issueLink/${linkId}`, IssueLinkSchema);
13647
+ }
13648
+ /**
13649
+ * Delete an issue link
13650
+ *
13651
+ * @param linkId - Issue link ID
13652
+ */
13653
+ async deleteIssueLink(linkId) {
13654
+ await this.deleteMethod(`/issueLink/${linkId}`);
13655
+ }
13656
+ /**
13657
+ * List all available issue link types
13658
+ *
13659
+ * @returns Issue link types response
13660
+ */
13661
+ async listIssueLinkTypes() {
13662
+ return this.getMethod("/issueLinkType", IssueLinkTypesResponseSchema);
13663
+ }
13664
+ /**
13665
+ * Get a specific issue link type
13666
+ *
13667
+ * @param linkTypeId - Issue link type ID
13668
+ * @returns Issue link type
13669
+ */
13670
+ async getIssueLinkType(linkTypeId) {
13671
+ return this.getMethod(`/issueLinkType/${linkTypeId}`, IssueLinkTypeSchema);
13672
+ }
13470
13673
  };
13471
13674
 
13472
13675
  // src/services/project.service.ts