@rnsk/toolkits 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +29 -1
- package/dist/toolkits/bitbucket/icon.d.ts +5 -0
- package/dist/toolkits/bitbucket/icon.js +6 -0
- package/dist/toolkits/bitbucket/manifest.d.ts +3 -0
- package/dist/toolkits/bitbucket/manifest.js +56 -0
- package/dist/toolkits/bitbucket/tools/client.d.ts +38 -0
- package/dist/toolkits/bitbucket/tools/client.js +87 -0
- package/dist/toolkits/bitbucket/tools/commits.d.ts +149 -0
- package/dist/toolkits/bitbucket/tools/commits.js +444 -0
- package/dist/toolkits/bitbucket/tools/index.d.ts +1093 -0
- package/dist/toolkits/bitbucket/tools/index.js +770 -0
- package/dist/toolkits/bitbucket/tools/issues.d.ts +73 -0
- package/dist/toolkits/bitbucket/tools/issues.js +234 -0
- package/dist/toolkits/bitbucket/tools/pipelines.d.ts +124 -0
- package/dist/toolkits/bitbucket/tools/pipelines.js +446 -0
- package/dist/toolkits/bitbucket/tools/pull-requests.d.ts +174 -0
- package/dist/toolkits/bitbucket/tools/pull-requests.js +541 -0
- package/dist/toolkits/bitbucket/tools/reports.d.ts +84 -0
- package/dist/toolkits/bitbucket/tools/reports.js +213 -0
- package/dist/toolkits/bitbucket/tools/repositories.d.ts +156 -0
- package/dist/toolkits/bitbucket/tools/repositories.js +531 -0
- package/dist/toolkits/bitbucket/tools/search.d.ts +17 -0
- package/dist/toolkits/bitbucket/tools/search.js +67 -0
- package/dist/toolkits/bitbucket/tools/snippets.d.ts +34 -0
- package/dist/toolkits/bitbucket/tools/snippets.js +122 -0
- package/dist/toolkits/bitbucket/tools/users-workspaces.d.ts +65 -0
- package/dist/toolkits/bitbucket/tools/users-workspaces.js +294 -0
- package/dist/toolkits/discord/icon.d.ts +5 -0
- package/dist/toolkits/discord/icon.js +12 -0
- package/dist/toolkits/discord/manifest.d.ts +3 -0
- package/dist/toolkits/discord/manifest.js +52 -0
- package/dist/toolkits/discord/tools/applications.d.ts +79 -0
- package/dist/toolkits/discord/tools/applications.js +216 -0
- package/dist/toolkits/discord/tools/client.d.ts +22 -0
- package/dist/toolkits/discord/tools/client.js +69 -0
- package/dist/toolkits/discord/tools/guilds.d.ts +39 -0
- package/dist/toolkits/discord/tools/guilds.js +123 -0
- package/dist/toolkits/discord/tools/index.d.ts +222 -0
- package/dist/toolkits/discord/tools/index.js +170 -0
- package/dist/toolkits/discord/tools/misc.d.ts +7 -0
- package/dist/toolkits/discord/tools/misc.js +40 -0
- package/dist/toolkits/discord/tools/users.d.ts +28 -0
- package/dist/toolkits/discord/tools/users.js +128 -0
- package/dist/toolkits/figma/tools/index.d.ts +1 -1
- package/dist/toolkits/figma/tools/render-images-of-file-nodes.d.ts +1 -1
- package/dist/toolkits/gitlab/icon.d.ts +5 -0
- package/dist/toolkits/gitlab/icon.js +6 -0
- package/dist/toolkits/gitlab/manifest.d.ts +3 -0
- package/dist/toolkits/gitlab/manifest.js +36 -0
- package/dist/toolkits/gitlab/tools/client.d.ts +7 -0
- package/dist/toolkits/gitlab/tools/client.js +45 -0
- package/dist/toolkits/gitlab/tools/index.d.ts +306 -0
- package/dist/toolkits/gitlab/tools/index.js +36 -0
- package/dist/toolkits/gitlab/tools/issues.d.ts +45 -0
- package/dist/toolkits/gitlab/tools/issues.js +103 -0
- package/dist/toolkits/gitlab/tools/merge-requests.d.ts +35 -0
- package/dist/toolkits/gitlab/tools/merge-requests.js +91 -0
- package/dist/toolkits/gitlab/tools/pipelines.d.ts +30 -0
- package/dist/toolkits/gitlab/tools/pipelines.js +66 -0
- package/dist/toolkits/gitlab/tools/projects.d.ts +36 -0
- package/dist/toolkits/gitlab/tools/projects.js +94 -0
- package/dist/toolkits/gitlab/tools/repository.d.ts +21 -0
- package/dist/toolkits/gitlab/tools/repository.js +53 -0
- package/dist/toolkits/gitlab/tools/users-groups.d.ts +11 -0
- package/dist/toolkits/gitlab/tools/users-groups.js +30 -0
- package/dist/toolkits/google-ads/tools/get-rmf-report.d.ts +2 -2
- package/dist/toolkits/google-ads/tools/index.d.ts +2 -2
- package/dist/toolkits/google-analytics/icon.d.ts +5 -0
- package/dist/toolkits/google-analytics/icon.js +11 -0
- package/dist/toolkits/google-analytics/manifest.d.ts +3 -0
- package/dist/toolkits/google-analytics/manifest.js +48 -0
- package/dist/toolkits/google-analytics/tools/admin.d.ts +73 -0
- package/dist/toolkits/google-analytics/tools/admin.js +238 -0
- package/dist/toolkits/google-analytics/tools/audiences.d.ts +81 -0
- package/dist/toolkits/google-analytics/tools/audiences.js +190 -0
- package/dist/toolkits/google-analytics/tools/client.d.ts +47 -0
- package/dist/toolkits/google-analytics/tools/client.js +74 -0
- package/dist/toolkits/google-analytics/tools/custom-definitions.d.ts +62 -0
- package/dist/toolkits/google-analytics/tools/custom-definitions.js +106 -0
- package/dist/toolkits/google-analytics/tools/index.d.ts +16 -0
- package/dist/toolkits/google-analytics/tools/index.js +88 -0
- package/dist/toolkits/google-analytics/tools/links.d.ts +22 -0
- package/dist/toolkits/google-analytics/tools/links.js +56 -0
- package/dist/toolkits/google-analytics/tools/measurement.d.ts +3 -0
- package/dist/toolkits/google-analytics/tools/measurement.js +55 -0
- package/dist/toolkits/google-analytics/tools/reports.d.ts +136 -0
- package/dist/toolkits/google-analytics/tools/reports.js +200 -0
- package/dist/toolkits/google-contacts/icon.d.ts +5 -0
- package/dist/toolkits/google-contacts/icon.js +6 -0
- package/dist/toolkits/google-contacts/manifest.d.ts +3 -0
- package/dist/toolkits/google-contacts/manifest.js +48 -0
- package/dist/toolkits/google-contacts/tools/client.d.ts +19 -0
- package/dist/toolkits/google-contacts/tools/client.js +44 -0
- package/dist/toolkits/google-contacts/tools/contacts.d.ts +94 -0
- package/dist/toolkits/google-contacts/tools/contacts.js +273 -0
- package/dist/toolkits/google-contacts/tools/directory.d.ts +36 -0
- package/dist/toolkits/google-contacts/tools/directory.js +99 -0
- package/dist/toolkits/google-contacts/tools/groups.d.ts +68 -0
- package/dist/toolkits/google-contacts/tools/groups.js +169 -0
- package/dist/toolkits/google-contacts/tools/index.d.ts +347 -0
- package/dist/toolkits/google-contacts/tools/index.js +34 -0
- package/dist/toolkits/google-contacts/tools/photos.d.ts +26 -0
- package/dist/toolkits/google-contacts/tools/photos.js +52 -0
- package/dist/toolkits/google-maps/icon.d.ts +5 -0
- package/dist/toolkits/google-maps/icon.js +39 -0
- package/dist/toolkits/google-maps/manifest.d.ts +3 -0
- package/dist/toolkits/google-maps/manifest.js +55 -0
- package/dist/toolkits/google-maps/tools/client.d.ts +27 -0
- package/dist/toolkits/google-maps/tools/client.js +72 -0
- package/dist/toolkits/google-maps/tools/geocode.d.ts +49 -0
- package/dist/toolkits/google-maps/tools/geocode.js +168 -0
- package/dist/toolkits/google-maps/tools/index.d.ts +432 -0
- package/dist/toolkits/google-maps/tools/index.js +31 -0
- package/dist/toolkits/google-maps/tools/misc.d.ts +70 -0
- package/dist/toolkits/google-maps/tools/misc.js +158 -0
- package/dist/toolkits/google-maps/tools/places.d.ts +112 -0
- package/dist/toolkits/google-maps/tools/places.js +185 -0
- package/dist/toolkits/google-maps/tools/routes.d.ts +48 -0
- package/dist/toolkits/google-maps/tools/routes.js +97 -0
- package/dist/toolkits/google-maps/tools/tiles.d.ts +51 -0
- package/dist/toolkits/google-maps/tools/tiles.js +84 -0
- package/dist/toolkits/google-photos/icon.d.ts +5 -0
- package/dist/toolkits/google-photos/icon.js +6 -0
- package/dist/toolkits/google-photos/manifest.d.ts +3 -0
- package/dist/toolkits/google-photos/manifest.js +47 -0
- package/dist/toolkits/google-photos/tools/albums.d.ts +83 -0
- package/dist/toolkits/google-photos/tools/albums.js +180 -0
- package/dist/toolkits/google-photos/tools/client.d.ts +24 -0
- package/dist/toolkits/google-photos/tools/client.js +77 -0
- package/dist/toolkits/google-photos/tools/index.d.ts +261 -0
- package/dist/toolkits/google-photos/tools/index.js +22 -0
- package/dist/toolkits/google-photos/tools/media.d.ts +52 -0
- package/dist/toolkits/google-photos/tools/media.js +142 -0
- package/dist/toolkits/google-photos/tools/uploads.d.ts +58 -0
- package/dist/toolkits/google-photos/tools/uploads.js +107 -0
- package/dist/toolkits/google-tasks/tools/index.d.ts +1 -1
- package/dist/toolkits/google-tasks/tools/update-task-full.d.ts +1 -1
- package/dist/toolkits/groww/tools/index.d.ts +1 -1
- package/dist/toolkits/groww/tools/instruments.d.ts +1 -1
- package/dist/toolkits/hacker-news/icon.d.ts +5 -0
- package/dist/toolkits/hacker-news/icon.js +9 -0
- package/dist/toolkits/hacker-news/manifest.d.ts +3 -0
- package/dist/toolkits/hacker-news/manifest.js +25 -0
- package/dist/toolkits/hacker-news/tools/client.d.ts +8 -0
- package/dist/toolkits/hacker-news/tools/client.js +51 -0
- package/dist/toolkits/hacker-news/tools/index.d.ts +89 -0
- package/dist/toolkits/hacker-news/tools/index.js +22 -0
- package/dist/toolkits/hacker-news/tools/items.d.ts +42 -0
- package/dist/toolkits/hacker-news/tools/items.js +126 -0
- package/dist/toolkits/hacker-news/tools/search.d.ts +12 -0
- package/dist/toolkits/hacker-news/tools/search.js +40 -0
- package/dist/toolkits/hacker-news/tools/stories.d.ts +25 -0
- package/dist/toolkits/hacker-news/tools/stories.js +98 -0
- package/dist/toolkits/hostinger/icon.d.ts +5 -0
- package/dist/toolkits/hostinger/icon.js +6 -0
- package/dist/toolkits/hostinger/manifest.d.ts +3 -0
- package/dist/toolkits/hostinger/manifest.js +36 -0
- package/dist/toolkits/hostinger/tools/billing.d.ts +12 -0
- package/dist/toolkits/hostinger/tools/billing.js +35 -0
- package/dist/toolkits/hostinger/tools/client.d.ts +6 -0
- package/dist/toolkits/hostinger/tools/client.js +57 -0
- package/dist/toolkits/hostinger/tools/dns.d.ts +22 -0
- package/dist/toolkits/hostinger/tools/dns.js +47 -0
- package/dist/toolkits/hostinger/tools/domains.d.ts +21 -0
- package/dist/toolkits/hostinger/tools/domains.js +62 -0
- package/dist/toolkits/hostinger/tools/hosting.d.ts +17 -0
- package/dist/toolkits/hostinger/tools/hosting.js +38 -0
- package/dist/toolkits/hostinger/tools/index.d.ts +179 -0
- package/dist/toolkits/hostinger/tools/index.js +35 -0
- package/dist/toolkits/hostinger/tools/vps.d.ts +27 -0
- package/dist/toolkits/hostinger/tools/vps.js +77 -0
- package/dist/toolkits/hostinger/tools/whois.d.ts +33 -0
- package/dist/toolkits/hostinger/tools/whois.js +85 -0
- package/dist/toolkits/hugging-face/icon.d.ts +5 -0
- package/dist/toolkits/hugging-face/icon.js +6 -0
- package/dist/toolkits/hugging-face/manifest.d.ts +3 -0
- package/dist/toolkits/hugging-face/manifest.js +42 -0
- package/dist/toolkits/hugging-face/tools/client.d.ts +93 -0
- package/dist/toolkits/hugging-face/tools/client.js +192 -0
- package/dist/toolkits/hugging-face/tools/datasets-viewer.d.ts +65 -0
- package/dist/toolkits/hugging-face/tools/datasets-viewer.js +150 -0
- package/dist/toolkits/hugging-face/tools/datasets.d.ts +160 -0
- package/dist/toolkits/hugging-face/tools/datasets.js +383 -0
- package/dist/toolkits/hugging-face/tools/discussions.d.ts +68 -0
- package/dist/toolkits/hugging-face/tools/discussions.js +144 -0
- package/dist/toolkits/hugging-face/tools/index.d.ts +523 -0
- package/dist/toolkits/hugging-face/tools/index.js +163 -0
- package/dist/toolkits/hugging-face/tools/inference.d.ts +42 -0
- package/dist/toolkits/hugging-face/tools/inference.js +86 -0
- package/dist/toolkits/hugging-face/tools/models.d.ts +117 -0
- package/dist/toolkits/hugging-face/tools/models.js +273 -0
- package/dist/toolkits/hugging-face/tools/papers.d.ts +37 -0
- package/dist/toolkits/hugging-face/tools/papers.js +91 -0
- package/dist/toolkits/hugging-face/tools/repos.d.ts +96 -0
- package/dist/toolkits/hugging-face/tools/repos.js +201 -0
- package/dist/toolkits/hugging-face/tools/settings.d.ts +53 -0
- package/dist/toolkits/hugging-face/tools/settings.js +88 -0
- package/dist/toolkits/hugging-face/tools/spaces.d.ts +245 -0
- package/dist/toolkits/hugging-face/tools/spaces.js +468 -0
- package/dist/toolkits/hugging-face/tools/sql.d.ts +21 -0
- package/dist/toolkits/hugging-face/tools/sql.js +47 -0
- package/dist/toolkits/hugging-face/tools/users.d.ts +60 -0
- package/dist/toolkits/hugging-face/tools/users.js +132 -0
- package/dist/toolkits/hugging-face/tools/webhooks.d.ts +35 -0
- package/dist/toolkits/hugging-face/tools/webhooks.js +87 -0
- package/dist/toolkits/jira/icon.d.ts +5 -0
- package/dist/toolkits/jira/icon.js +6 -0
- package/dist/toolkits/jira/manifest.d.ts +3 -0
- package/dist/toolkits/jira/manifest.js +53 -0
- package/dist/toolkits/jira/tools/boards.d.ts +52 -0
- package/dist/toolkits/jira/tools/boards.js +104 -0
- package/dist/toolkits/jira/tools/client.d.ts +23 -0
- package/dist/toolkits/jira/tools/client.js +270 -0
- package/dist/toolkits/jira/tools/index.d.ts +1280 -0
- package/dist/toolkits/jira/tools/index.js +119 -0
- package/dist/toolkits/jira/tools/issue-fields.d.ts +10 -0
- package/dist/toolkits/jira/tools/issue-fields.js +111 -0
- package/dist/toolkits/jira/tools/issues.d.ts +304 -0
- package/dist/toolkits/jira/tools/issues.js +593 -0
- package/dist/toolkits/jira/tools/meta.d.ts +212 -0
- package/dist/toolkits/jira/tools/meta.js +369 -0
- package/dist/toolkits/jira/tools/projects.d.ts +130 -0
- package/dist/toolkits/jira/tools/projects.js +263 -0
- package/dist/toolkits/jira/tools/search.d.ts +90 -0
- package/dist/toolkits/jira/tools/search.js +181 -0
- package/dist/toolkits/jira/tools/users.d.ts +114 -0
- package/dist/toolkits/jira/tools/users.js +221 -0
- package/dist/toolkits/neo4j/icon.d.ts +5 -0
- package/dist/toolkits/neo4j/icon.js +6 -0
- package/dist/toolkits/neo4j/manifest.d.ts +3 -0
- package/dist/toolkits/neo4j/manifest.js +33 -0
- package/dist/toolkits/neo4j/tools/analytics.d.ts +21 -0
- package/dist/toolkits/neo4j/tools/analytics.js +91 -0
- package/dist/toolkits/neo4j/tools/client.d.ts +6 -0
- package/dist/toolkits/neo4j/tools/client.js +105 -0
- package/dist/toolkits/neo4j/tools/index.d.ts +198 -0
- package/dist/toolkits/neo4j/tools/index.js +30 -0
- package/dist/toolkits/neo4j/tools/instances.d.ts +47 -0
- package/dist/toolkits/neo4j/tools/instances.js +127 -0
- package/dist/toolkits/neo4j/tools/projects.d.ts +44 -0
- package/dist/toolkits/neo4j/tools/projects.js +110 -0
- package/dist/toolkits/neo4j/tools/snapshots.d.ts +20 -0
- package/dist/toolkits/neo4j/tools/snapshots.js +57 -0
- package/dist/toolkits/neon/icon.d.ts +5 -0
- package/dist/toolkits/neon/icon.js +8 -0
- package/dist/toolkits/neon/manifest.d.ts +3 -0
- package/dist/toolkits/neon/manifest.js +36 -0
- package/dist/toolkits/neon/tools/auth.d.ts +115 -0
- package/dist/toolkits/neon/tools/auth.js +286 -0
- package/dist/toolkits/neon/tools/branches.d.ts +189 -0
- package/dist/toolkits/neon/tools/branches.js +465 -0
- package/dist/toolkits/neon/tools/client.d.ts +10 -0
- package/dist/toolkits/neon/tools/client.js +69 -0
- package/dist/toolkits/neon/tools/dataapi.d.ts +42 -0
- package/dist/toolkits/neon/tools/dataapi.js +111 -0
- package/dist/toolkits/neon/tools/endpoints.d.ts +59 -0
- package/dist/toolkits/neon/tools/endpoints.js +163 -0
- package/dist/toolkits/neon/tools/index.d.ts +976 -0
- package/dist/toolkits/neon/tools/index.js +130 -0
- package/dist/toolkits/neon/tools/meta.d.ts +4 -0
- package/dist/toolkits/neon/tools/meta.js +16 -0
- package/dist/toolkits/neon/tools/orgs.d.ts +112 -0
- package/dist/toolkits/neon/tools/orgs.js +303 -0
- package/dist/toolkits/neon/tools/projects.d.ts +177 -0
- package/dist/toolkits/neon/tools/projects.js +468 -0
- package/dist/toolkits/neon/tools/snapshots.d.ts +24 -0
- package/dist/toolkits/neon/tools/snapshots.js +67 -0
- package/dist/toolkits/reddit/tools/index.d.ts +1 -1
- package/dist/toolkits/reddit/tools/search-across-subreddits.d.ts +1 -1
- package/dist/toolkits/slack/icon.d.ts +5 -0
- package/dist/toolkits/slack/icon.js +20 -0
- package/dist/toolkits/slack/manifest.d.ts +3 -0
- package/dist/toolkits/slack/manifest.js +93 -0
- package/dist/toolkits/slack/tools/admin-apps.d.ts +32 -0
- package/dist/toolkits/slack/tools/admin-apps.js +116 -0
- package/dist/toolkits/slack/tools/admin-conversations.d.ts +62 -0
- package/dist/toolkits/slack/tools/admin-conversations.js +246 -0
- package/dist/toolkits/slack/tools/admin-invites.d.ts +19 -0
- package/dist/toolkits/slack/tools/admin-invites.js +75 -0
- package/dist/toolkits/slack/tools/admin-users.d.ts +52 -0
- package/dist/toolkits/slack/tools/admin-users.js +182 -0
- package/dist/toolkits/slack/tools/audit.d.ts +20 -0
- package/dist/toolkits/slack/tools/audit.js +81 -0
- package/dist/toolkits/slack/tools/calls.d.ts +38 -0
- package/dist/toolkits/slack/tools/calls.js +141 -0
- package/dist/toolkits/slack/tools/canvas.d.ts +24 -0
- package/dist/toolkits/slack/tools/canvas.js +102 -0
- package/dist/toolkits/slack/tools/client.d.ts +22 -0
- package/dist/toolkits/slack/tools/client.js +73 -0
- package/dist/toolkits/slack/tools/conversations.d.ts +131 -0
- package/dist/toolkits/slack/tools/conversations.js +463 -0
- package/dist/toolkits/slack/tools/emoji.d.ts +29 -0
- package/dist/toolkits/slack/tools/emoji.js +118 -0
- package/dist/toolkits/slack/tools/files.d.ts +113 -0
- package/dist/toolkits/slack/tools/files.js +368 -0
- package/dist/toolkits/slack/tools/index.d.ts +28 -0
- package/dist/toolkits/slack/tools/index.js +187 -0
- package/dist/toolkits/slack/tools/messages.d.ts +106 -0
- package/dist/toolkits/slack/tools/messages.js +340 -0
- package/dist/toolkits/slack/tools/misc.d.ts +42 -0
- package/dist/toolkits/slack/tools/misc.js +127 -0
- package/dist/toolkits/slack/tools/reactions-stars-pins.d.ts +69 -0
- package/dist/toolkits/slack/tools/reactions-stars-pins.js +236 -0
- package/dist/toolkits/slack/tools/reminders.d.ts +22 -0
- package/dist/toolkits/slack/tools/reminders.js +83 -0
- package/dist/toolkits/slack/tools/search.d.ts +49 -0
- package/dist/toolkits/slack/tools/search.js +155 -0
- package/dist/toolkits/slack/tools/slack-lists.d.ts +65 -0
- package/dist/toolkits/slack/tools/slack-lists.js +282 -0
- package/dist/toolkits/slack/tools/teams.d.ts +75 -0
- package/dist/toolkits/slack/tools/teams.js +285 -0
- package/dist/toolkits/slack/tools/usergroups.d.ts +56 -0
- package/dist/toolkits/slack/tools/usergroups.js +194 -0
- package/dist/toolkits/slack/tools/users.d.ts +87 -0
- package/dist/toolkits/slack/tools/users.js +396 -0
- package/dist/toolkits/youtube/tools/add-video-to-playlist.d.ts +1 -1
- package/dist/toolkits/youtube/tools/delete-video.d.ts +1 -1
- package/dist/toolkits/youtube/tools/index.d.ts +10 -10
- package/dist/toolkits/youtube/tools/list-caption-track.d.ts +1 -1
- package/dist/toolkits/youtube/tools/list-playlist-items.d.ts +1 -1
- package/dist/toolkits/youtube/tools/list-video-categories.d.ts +1 -1
- package/dist/toolkits/youtube/tools/post-comment.d.ts +1 -1
- package/dist/toolkits/youtube/tools/report-video-abuse.d.ts +1 -1
- package/dist/toolkits/youtube/tools/search-youtube.d.ts +1 -1
- package/dist/toolkits/youtube/tools/update-thumbnail.d.ts +1 -1
- package/dist/toolkits/youtube/tools/update-video.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const ATLASSIAN_API = 'https://api.atlassian.com';
|
|
3
|
+
const cloudCache = new Map();
|
|
4
|
+
export async function getCloudId(token, hint) {
|
|
5
|
+
if (hint)
|
|
6
|
+
return hint;
|
|
7
|
+
if (cloudCache.has(token))
|
|
8
|
+
return cloudCache.get(token);
|
|
9
|
+
const response = await fetch(`${ATLASSIAN_API}/oauth/token/accessible-resources`, {
|
|
10
|
+
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
|
|
11
|
+
});
|
|
12
|
+
if (!response.ok)
|
|
13
|
+
return null;
|
|
14
|
+
const sites = await response.json().catch(() => []);
|
|
15
|
+
const id = Array.isArray(sites) && sites.length > 0 ? sites[0].id : null;
|
|
16
|
+
if (id)
|
|
17
|
+
cloudCache.set(token, id);
|
|
18
|
+
return id;
|
|
19
|
+
}
|
|
20
|
+
function withQuery(url, query = {}) {
|
|
21
|
+
const params = new URLSearchParams();
|
|
22
|
+
for (const [key, value] of Object.entries(query)) {
|
|
23
|
+
if (value === undefined || value === null || value === '')
|
|
24
|
+
continue;
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
if (value.length === 0)
|
|
27
|
+
continue;
|
|
28
|
+
params.append(key, value.join(','));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
params.append(key, String(value));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const qs = params.toString();
|
|
35
|
+
return qs ? `${url}?${qs}` : url;
|
|
36
|
+
}
|
|
37
|
+
async function parseBody(response) {
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
if (!text)
|
|
40
|
+
return { success: true };
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(text);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return { raw: text };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function jira(token, { cloudId, api = 'api/3', path, method = 'GET', query, body, headers = {} }) {
|
|
49
|
+
if (!token)
|
|
50
|
+
return { error: 'Jira token is required. Connect Jira first.' };
|
|
51
|
+
const cid = await getCloudId(token, cloudId);
|
|
52
|
+
if (!cid)
|
|
53
|
+
return { error: 'Could not determine your Jira Cloud site. Reconnect Jira and try again.' };
|
|
54
|
+
const url = withQuery(`${ATLASSIAN_API}/ex/jira/${cid}/rest/${api}${path}`, query);
|
|
55
|
+
try {
|
|
56
|
+
const response = await fetch(url, {
|
|
57
|
+
method,
|
|
58
|
+
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', Accept: 'application/json', ...headers },
|
|
59
|
+
body: body !== undefined ? (typeof body === 'string' ? body : JSON.stringify(body)) : undefined,
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
const details = await parseBody(response).catch(() => ({}));
|
|
63
|
+
return { error: `Jira API request failed with status ${response.status}`, details };
|
|
64
|
+
}
|
|
65
|
+
if (response.status === 204)
|
|
66
|
+
return { success: true };
|
|
67
|
+
return await parseBody(response);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return { error: 'Error calling Jira API', message: error instanceof Error ? error.message : 'Unknown error' };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// --- Markdown subset to Atlassian Document Format ---
|
|
74
|
+
function inlineNodes(text) {
|
|
75
|
+
const nodes = [];
|
|
76
|
+
const pattern = /(\*\*.+?\*\*|__.+?__|\*[^*]+?\*|_[^_]+?_|`[^`]+?`|\[[^\]]+?\]\([^)]+?\))/g;
|
|
77
|
+
let last = 0;
|
|
78
|
+
let match;
|
|
79
|
+
const pushText = (t) => {
|
|
80
|
+
if (t)
|
|
81
|
+
nodes.push({ type: 'text', text: t });
|
|
82
|
+
};
|
|
83
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
84
|
+
pushText(text.slice(last, match.index));
|
|
85
|
+
const tok = match[0];
|
|
86
|
+
if (tok.startsWith('**') || tok.startsWith('__')) {
|
|
87
|
+
nodes.push({ type: 'text', text: tok.slice(2, -2), marks: [{ type: 'strong' }] });
|
|
88
|
+
}
|
|
89
|
+
else if (tok.startsWith('*') || tok.startsWith('_')) {
|
|
90
|
+
nodes.push({ type: 'text', text: tok.slice(1, -1), marks: [{ type: 'em' }] });
|
|
91
|
+
}
|
|
92
|
+
else if (tok.startsWith('`')) {
|
|
93
|
+
nodes.push({ type: 'text', text: tok.slice(1, -1), marks: [{ type: 'code' }] });
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const m = /^\[([^\]]+?)\]\(([^)]+?)\)$/.exec(tok);
|
|
97
|
+
if (m)
|
|
98
|
+
nodes.push({ type: 'text', text: m[1], marks: [{ type: 'link', attrs: { href: m[2] } }] });
|
|
99
|
+
else
|
|
100
|
+
pushText(tok);
|
|
101
|
+
}
|
|
102
|
+
last = match.index + tok.length;
|
|
103
|
+
}
|
|
104
|
+
pushText(text.slice(last));
|
|
105
|
+
return nodes.length > 0 ? nodes : [{ type: 'text', text }];
|
|
106
|
+
}
|
|
107
|
+
export function mdToAdf(input) {
|
|
108
|
+
if (input === undefined || input === null)
|
|
109
|
+
return undefined;
|
|
110
|
+
if (typeof input !== 'string')
|
|
111
|
+
return input;
|
|
112
|
+
const lines = input.split('\n');
|
|
113
|
+
const content = [];
|
|
114
|
+
let i = 0;
|
|
115
|
+
const para = (t) => ({ type: 'paragraph', content: inlineNodes(t) });
|
|
116
|
+
while (i < lines.length) {
|
|
117
|
+
const line = lines[i];
|
|
118
|
+
if (/^\s*$/.test(line)) {
|
|
119
|
+
i++;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const fence = /^```(\w*)\s*$/.exec(line);
|
|
123
|
+
if (fence) {
|
|
124
|
+
const buf = [];
|
|
125
|
+
i++;
|
|
126
|
+
while (i < lines.length && !/^```\s*$/.test(lines[i]))
|
|
127
|
+
buf.push(lines[i++]);
|
|
128
|
+
i++;
|
|
129
|
+
content.push({ type: 'codeBlock', attrs: fence[1] ? { language: fence[1] } : {}, content: [{ type: 'text', text: buf.join('\n') }] });
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const heading = /^(#{1,6})\s+(.*)$/.exec(line);
|
|
133
|
+
if (heading) {
|
|
134
|
+
content.push({ type: 'heading', attrs: { level: heading[1].length }, content: inlineNodes(heading[2]) });
|
|
135
|
+
i++;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const quote = /^>\s?(.*)$/.exec(line);
|
|
139
|
+
if (quote) {
|
|
140
|
+
const buf = [quote[1]];
|
|
141
|
+
i++;
|
|
142
|
+
while (i < lines.length && /^>\s?(.*)$/.test(lines[i]))
|
|
143
|
+
buf.push(/^>\s?(.*)$/.exec(lines[i])[1]), i++;
|
|
144
|
+
content.push({ type: 'blockquote', content: buf.map((t) => para(t)) });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const bullet = /^\s*[-*+]\s+(.*)$/.exec(line);
|
|
148
|
+
if (bullet) {
|
|
149
|
+
const items = [];
|
|
150
|
+
while (i < lines.length) {
|
|
151
|
+
const m = /^\s*[-*+]\s+(.*)$/.exec(lines[i]);
|
|
152
|
+
if (!m)
|
|
153
|
+
break;
|
|
154
|
+
items.push({ type: 'listItem', content: [para(m[1])] });
|
|
155
|
+
i++;
|
|
156
|
+
}
|
|
157
|
+
content.push({ type: 'bulletList', content: items });
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const ordered = /^\s*\d+[.)]\s+(.*)$/.exec(line);
|
|
161
|
+
if (ordered) {
|
|
162
|
+
const items = [];
|
|
163
|
+
while (i < lines.length) {
|
|
164
|
+
const m = /^\s*\d+[.)]\s+(.*)$/.exec(lines[i]);
|
|
165
|
+
if (!m)
|
|
166
|
+
break;
|
|
167
|
+
items.push({ type: 'listItem', content: [para(m[1])] });
|
|
168
|
+
i++;
|
|
169
|
+
}
|
|
170
|
+
content.push({ type: 'orderedList', content: items });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
content.push(para(line));
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
return { type: 'doc', version: 1, content: content.length > 0 ? content : [para('')] };
|
|
177
|
+
}
|
|
178
|
+
// --- lookups ---
|
|
179
|
+
export async function findAccountId(token, cloudId, nameOrEmail) {
|
|
180
|
+
if (!nameOrEmail)
|
|
181
|
+
return null;
|
|
182
|
+
const users = await jira(token, { cloudId, path: '/user/search', query: { query: nameOrEmail, maxResults: 5 } });
|
|
183
|
+
if (!Array.isArray(users) || users.length === 0)
|
|
184
|
+
return null;
|
|
185
|
+
const human = users.find((u) => u.accountType !== 'app') ?? users[0];
|
|
186
|
+
return human?.accountId ?? null;
|
|
187
|
+
}
|
|
188
|
+
export async function resolveAssignee(token, cloudId, accountId, nameOrEmail) {
|
|
189
|
+
if (accountId)
|
|
190
|
+
return accountId;
|
|
191
|
+
if (!nameOrEmail)
|
|
192
|
+
return undefined;
|
|
193
|
+
return (await findAccountId(token, cloudId, nameOrEmail)) ?? undefined;
|
|
194
|
+
}
|
|
195
|
+
export async function getTransitionId(token, cloudId, issueIdOrKey, idOrName) {
|
|
196
|
+
if (/^\d+$/.test(String(idOrName)))
|
|
197
|
+
return String(idOrName);
|
|
198
|
+
const data = await jira(token, { cloudId, path: `/issue/${encodeURIComponent(issueIdOrKey)}/transitions` });
|
|
199
|
+
const list = data?.transitions ?? [];
|
|
200
|
+
const hit = list.find((t) => t.name?.toLowerCase() === String(idOrName).toLowerCase());
|
|
201
|
+
return hit ? String(hit.id) : null;
|
|
202
|
+
}
|
|
203
|
+
export async function uploadAttachment(token, cloudId, issueKey, { fileName, fileContent, mimeType }) {
|
|
204
|
+
if (!token)
|
|
205
|
+
return { error: 'Jira token is required. Connect Jira first.' };
|
|
206
|
+
const cid = await getCloudId(token, cloudId);
|
|
207
|
+
if (!cid)
|
|
208
|
+
return { error: 'Could not determine your Jira Cloud site. Reconnect Jira and try again.' };
|
|
209
|
+
try {
|
|
210
|
+
const bytes = Buffer.from(fileContent, 'base64');
|
|
211
|
+
const form = new FormData();
|
|
212
|
+
form.append('file', new Blob([bytes], { type: mimeType ?? 'application/octet-stream' }), fileName);
|
|
213
|
+
const response = await fetch(`${ATLASSIAN_API}/ex/jira/${cid}/rest/api/3/issue/${encodeURIComponent(issueKey)}/attachments`, {
|
|
214
|
+
method: 'POST',
|
|
215
|
+
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json', 'X-Atlassian-Token': 'no-check' },
|
|
216
|
+
body: form,
|
|
217
|
+
});
|
|
218
|
+
if (!response.ok) {
|
|
219
|
+
const details = await parseBody(response).catch(() => ({}));
|
|
220
|
+
return { error: `Jira API request failed with status ${response.status}`, details };
|
|
221
|
+
}
|
|
222
|
+
return await parseBody(response);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
return { error: 'Error uploading attachment to Jira', message: error instanceof Error ? error.message : 'Unknown error' };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// --- structured-filter search to JQL ---
|
|
229
|
+
function qv(value, numeric = false) {
|
|
230
|
+
if (value === undefined || value === null)
|
|
231
|
+
return null;
|
|
232
|
+
if (numeric && /^-?\d+$/.test(String(value)))
|
|
233
|
+
return String(value);
|
|
234
|
+
return `"${String(value).replace(/"/g, '\\"')}"`;
|
|
235
|
+
}
|
|
236
|
+
export function buildSearchJql(f) {
|
|
237
|
+
const clauses = [];
|
|
238
|
+
if (f.projectKey)
|
|
239
|
+
clauses.push(`project = ${qv(f.projectKey)}`);
|
|
240
|
+
if (f.assignee) {
|
|
241
|
+
if (f.assignee === 'unassigned')
|
|
242
|
+
clauses.push('assignee is EMPTY');
|
|
243
|
+
else
|
|
244
|
+
clauses.push(`assignee = ${qv(f.assignee)}`);
|
|
245
|
+
}
|
|
246
|
+
if (f.statusIdOrName)
|
|
247
|
+
clauses.push(`status = ${qv(f.statusIdOrName, true)}`);
|
|
248
|
+
if (f.priorityIdOrName)
|
|
249
|
+
clauses.push(`priority = ${qv(f.priorityIdOrName, true)}`);
|
|
250
|
+
if (f.issueTypeIdOrName)
|
|
251
|
+
clauses.push(`issuetype = ${qv(f.issueTypeIdOrName, true)}`);
|
|
252
|
+
if (f.labels && f.labels.length > 0)
|
|
253
|
+
clauses.push(`labels in (${f.labels.map((l) => qv(l)).join(', ')})`);
|
|
254
|
+
if (f.textSearch)
|
|
255
|
+
clauses.push(`text ~ ${qv(f.textSearch)}`);
|
|
256
|
+
if (f.sprintIdOrName)
|
|
257
|
+
clauses.push(`sprint = ${qv(f.sprintIdOrName, true)}`);
|
|
258
|
+
const date = (field, v) => (v ? `${field} >= ${qv(v)}` : null);
|
|
259
|
+
const dateBefore = (field, v) => (v ? `${field} <= ${qv(v)}` : null);
|
|
260
|
+
for (const c of [date('created', f.createdAfter), date('updated', f.updatedAfter), dateBefore('created', f.createdBefore), dateBefore('updated', f.updatedBefore)]) {
|
|
261
|
+
if (c)
|
|
262
|
+
clauses.push(c);
|
|
263
|
+
}
|
|
264
|
+
let jql = clauses.join(' AND ');
|
|
265
|
+
if (f.preservedOrderBy)
|
|
266
|
+
jql += (jql ? ' ' : '') + f.preservedOrderBy;
|
|
267
|
+
return jql;
|
|
268
|
+
}
|
|
269
|
+
export { ATLASSIAN_API };
|
|
270
|
+
//# sourceMappingURL=client.js.map
|