6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
154 lines
4.6 KiB
TypeScript
154 lines
4.6 KiB
TypeScript
import type { JiraGetFieldsParams, JiraGetFieldsResponse } from '@/tools/jira/types'
|
|
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
|
|
import { getJiraCloudId, parseAtlassianErrorMessage } from '@/tools/jira/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
function buildFieldsUrl(cloudId: string): string {
|
|
return `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/field`
|
|
}
|
|
|
|
export const jiraGetFieldsTool: ToolConfig<JiraGetFieldsParams, JiraGetFieldsResponse> = {
|
|
id: 'jira_get_fields',
|
|
name: 'Jira Get Fields',
|
|
description:
|
|
'Get all system and custom fields defined in the Jira instance. Useful for discovering custom field IDs (e.g., customfield_10001) to use when writing or updating issues.',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'jira',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'OAuth access token for Jira',
|
|
},
|
|
domain: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Your Jira domain (e.g., yourcompany.atlassian.net)',
|
|
},
|
|
cloudId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'hidden',
|
|
description:
|
|
'Jira Cloud ID for the instance. If not provided, it will be fetched using the domain.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params: JiraGetFieldsParams) => {
|
|
if (params.cloudId) {
|
|
return buildFieldsUrl(params.cloudId)
|
|
}
|
|
return 'https://api.atlassian.com/oauth/token/accessible-resources'
|
|
},
|
|
method: 'GET',
|
|
headers: (params: JiraGetFieldsParams) => ({
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response, params?: JiraGetFieldsParams) => {
|
|
const fetchFields = async (cloudId: string) => {
|
|
const fieldsResponse = await fetch(buildFieldsUrl(cloudId), {
|
|
method: 'GET',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${params!.accessToken}`,
|
|
},
|
|
})
|
|
|
|
if (!fieldsResponse.ok) {
|
|
const errorText = await fieldsResponse.text()
|
|
throw new Error(
|
|
parseAtlassianErrorMessage(fieldsResponse.status, fieldsResponse.statusText, errorText)
|
|
)
|
|
}
|
|
|
|
return fieldsResponse.json()
|
|
}
|
|
|
|
let data: any
|
|
|
|
if (!params?.cloudId) {
|
|
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
|
|
data = await fetchFields(cloudId)
|
|
} else {
|
|
if (!response.ok) {
|
|
const errorText = await response.text()
|
|
throw new Error(parseAtlassianErrorMessage(response.status, response.statusText, errorText))
|
|
}
|
|
data = await response.json()
|
|
}
|
|
|
|
const fields = Array.isArray(data) ? data : []
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
ts: new Date().toISOString(),
|
|
fields: fields.map((f: any) => ({
|
|
id: f?.id ?? '',
|
|
key: f?.key ?? null,
|
|
name: f?.name ?? '',
|
|
custom: f?.custom ?? null,
|
|
navigable: f?.navigable ?? null,
|
|
searchable: f?.searchable ?? null,
|
|
schemaType: f?.schema?.type ?? null,
|
|
customType: f?.schema?.custom ?? null,
|
|
})),
|
|
total: fields.length,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
ts: TIMESTAMP_OUTPUT,
|
|
fields: {
|
|
type: 'array',
|
|
description: 'Array of Jira fields (system and custom)',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'Field ID (e.g., summary, customfield_10001)' },
|
|
key: { type: 'string', description: 'Field key', optional: true },
|
|
name: { type: 'string', description: 'Human-readable field name' },
|
|
custom: {
|
|
type: 'boolean',
|
|
description: 'Whether this is a custom field',
|
|
optional: true,
|
|
},
|
|
navigable: {
|
|
type: 'boolean',
|
|
description: 'Whether the field is navigable in issue views',
|
|
optional: true,
|
|
},
|
|
searchable: {
|
|
type: 'boolean',
|
|
description: 'Whether the field can be used in JQL searches',
|
|
optional: true,
|
|
},
|
|
schemaType: {
|
|
type: 'string',
|
|
description: 'Field value type (e.g., string, number, array, user)',
|
|
optional: true,
|
|
},
|
|
customType: {
|
|
type: 'string',
|
|
description: 'Custom field type identifier (only for custom fields)',
|
|
optional: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
total: { type: 'number', description: 'Number of fields returned' },
|
|
},
|
|
}
|