chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
import { requestJson } from '@/lib/api/client/request'
|
||||
import * as selectorContracts from '@/lib/api/contracts/selectors'
|
||||
import { fetchOAuthToken } from '@/hooks/selectors/helpers'
|
||||
import { ensureCredential, ensureDomain, SELECTOR_STALE } from '@/hooks/selectors/providers/shared'
|
||||
import type { SelectorDefinition, SelectorKey, SelectorQueryArgs } from '@/hooks/selectors/types'
|
||||
|
||||
export const jiraSelectors = {
|
||||
'jira.projects': {
|
||||
key: 'jira.projects',
|
||||
contracts: [
|
||||
selectorContracts.jiraProjectsSelectorContract,
|
||||
selectorContracts.jiraProjectSelectorContract,
|
||||
],
|
||||
staleTime: SELECTOR_STALE,
|
||||
getQueryKey: ({ context, search }: SelectorQueryArgs) => [
|
||||
'selectors',
|
||||
'jira.projects',
|
||||
context.oauthCredential ?? 'none',
|
||||
context.domain ?? 'none',
|
||||
search ?? '',
|
||||
],
|
||||
enabled: ({ context }) => Boolean(context.oauthCredential && context.domain),
|
||||
fetchList: async ({ context, search, signal }: SelectorQueryArgs) => {
|
||||
const credentialId = ensureCredential(context, 'jira.projects')
|
||||
const domain = ensureDomain(context, 'jira.projects')
|
||||
const bundle = await fetchOAuthToken(credentialId, context.workflowId)
|
||||
if (!bundle) {
|
||||
throw new Error('Missing Jira access token')
|
||||
}
|
||||
const data = await requestJson(selectorContracts.jiraProjectsSelectorContract, {
|
||||
query: {
|
||||
domain,
|
||||
accessToken: bundle.accessToken,
|
||||
cloudId: bundle.cloudId,
|
||||
query: search,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
return (data.projects || []).map((project) => ({
|
||||
id: project.id,
|
||||
label: project.name,
|
||||
}))
|
||||
},
|
||||
fetchById: async ({ context, detailId, signal }: SelectorQueryArgs) => {
|
||||
if (!detailId) return null
|
||||
const credentialId = ensureCredential(context, 'jira.projects')
|
||||
const domain = ensureDomain(context, 'jira.projects')
|
||||
const bundle = await fetchOAuthToken(credentialId, context.workflowId)
|
||||
if (!bundle) {
|
||||
throw new Error('Missing Jira access token')
|
||||
}
|
||||
const data = await requestJson(selectorContracts.jiraProjectSelectorContract, {
|
||||
body: {
|
||||
domain,
|
||||
accessToken: bundle.accessToken,
|
||||
cloudId: bundle.cloudId,
|
||||
projectId: detailId,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
if (!data.project) return null
|
||||
return {
|
||||
id: data.project.id,
|
||||
label: data.project.name,
|
||||
}
|
||||
},
|
||||
},
|
||||
'jira.issues': {
|
||||
key: 'jira.issues',
|
||||
contracts: [
|
||||
selectorContracts.jiraIssuesSelectorContract,
|
||||
selectorContracts.jiraIssueSelectorContract,
|
||||
],
|
||||
staleTime: 15 * 1000,
|
||||
getQueryKey: ({ context, search }: SelectorQueryArgs) => [
|
||||
'selectors',
|
||||
'jira.issues',
|
||||
context.oauthCredential ?? 'none',
|
||||
context.domain ?? 'none',
|
||||
context.projectId ?? 'none',
|
||||
search ?? '',
|
||||
],
|
||||
enabled: ({ context }) => Boolean(context.oauthCredential && context.domain),
|
||||
fetchList: async ({ context, search, signal }: SelectorQueryArgs) => {
|
||||
const credentialId = ensureCredential(context, 'jira.issues')
|
||||
const domain = ensureDomain(context, 'jira.issues')
|
||||
const bundle = await fetchOAuthToken(credentialId, context.workflowId)
|
||||
if (!bundle) {
|
||||
throw new Error('Missing Jira access token')
|
||||
}
|
||||
const data = await requestJson(selectorContracts.jiraIssuesSelectorContract, {
|
||||
query: {
|
||||
domain,
|
||||
accessToken: bundle.accessToken,
|
||||
cloudId: bundle.cloudId,
|
||||
projectId: context.projectId,
|
||||
query: search,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
const issues =
|
||||
data.sections?.flatMap((section) =>
|
||||
(section.issues || []).map((issue) => ({
|
||||
id: issue.id || issue.key || '',
|
||||
name: issue.summary || issue.key || '',
|
||||
}))
|
||||
) || []
|
||||
return issues
|
||||
.filter((issue) => issue.id)
|
||||
.map((issue) => ({ id: issue.id, label: issue.name || issue.id }))
|
||||
},
|
||||
fetchById: async ({ context, detailId, signal }: SelectorQueryArgs) => {
|
||||
if (!detailId) return null
|
||||
const credentialId = ensureCredential(context, 'jira.issues')
|
||||
const domain = ensureDomain(context, 'jira.issues')
|
||||
const bundle = await fetchOAuthToken(credentialId, context.workflowId)
|
||||
if (!bundle) {
|
||||
throw new Error('Missing Jira access token')
|
||||
}
|
||||
const data = await requestJson(selectorContracts.jiraIssueSelectorContract, {
|
||||
body: {
|
||||
domain,
|
||||
accessToken: bundle.accessToken,
|
||||
cloudId: bundle.cloudId,
|
||||
issueKeys: [detailId],
|
||||
},
|
||||
signal,
|
||||
})
|
||||
const issue = data.issues?.[0]
|
||||
if (!issue) return null
|
||||
return { id: issue.id, label: issue.name }
|
||||
},
|
||||
},
|
||||
} satisfies Record<Extract<SelectorKey, 'jira.projects' | 'jira.issues'>, SelectorDefinition>
|
||||
Reference in New Issue
Block a user