@trycomp/compound-sdk
v0.1.4
Published
TypeScript SDK for the Comp AI API.
Readme
@trycomp/compound-sdk
Developer-friendly & type-safe Typescript SDK specifically catered to leverage @trycomp/compound-sdk API.
[!IMPORTANT] This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Summary
Table of Contents
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add @trycomp/compound-sdkPNPM
pnpm add @trycomp/compound-sdkBun
bun add @trycomp/compound-sdkYarn
yarn add @trycomp/compound-sdk[!NOTE] This package is published as an ES Module (ESM) only. For applications using CommonJS, use
await import("@trycomp/compound-sdk")to import and use this package.
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
Example
import { Compai } from "@trycomp/compound-sdk";
const compai = new Compai({
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
});
console.log(result);
}
run();
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
| ------------ | ---- | ----------- | --------------------- |
| bearerAuth | http | HTTP Bearer | COMP_AI_BEARER_AUTH |
To authenticate with the API the bearerAuth parameter must be set when initializing the SDK client instance. For example:
import { Compai } from "@trycomp/compound-sdk";
const compai = new Compai({
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
});
console.log(result);
}
run();
Available Resources and Operations
Activity
- addComment - Calls a mutation at the path activity.js:addComment
- listForSubject - Calls a query at the path activity.js:listForSubject
- listForSubjectLatest - Calls a query at the path activity.js:listForSubjectLatest
Admin
- listOrganizations - Calls a query at the path admin.js:listOrganizations
- getOrgById - Calls a query at the path admin.js:getOrgById
- listInvoicesForOrg - Calls a action at the path admin.js:listInvoicesForOrg
- disableEntitlement - Calls a action at the path admin.js:disableEntitlement
- isCurrentUserAdmin - Calls a query at the path admin.js:isCurrentUserAdmin
ApiKeys
- listForOrg - Calls a query at the path modules/apiKeys.js:listForOrg
Auth
- getCurrentUser - Calls a query at the path auth.js:getCurrentUser
- getActiveOrg - Calls a query at the path auth.js:getActiveOrg
CloudInfrastructure.Connections
- disconnectAll - Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectAll
- disconnectAws - Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectAws
- disconnectConnection - Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectConnection
- getById - Calls a query at the path modules/cloudInfrastructure/connections.js:getById
- getForOrg - Calls a query at the path modules/cloudInfrastructure/connections.js:getForOrg
- listForOrg - Calls a query at the path modules/cloudInfrastructure/connections.js:listForOrg
- listForOrgWithStats - Calls a query at the path modules/cloudInfrastructure/connections.js:listForOrgWithStats
- setGithubScope - Calls a mutation at the path modules/cloudInfrastructure/connections.js:setGithubScope
- setLabel - Calls a mutation at the path modules/cloudInfrastructure/connections.js:setLabel
CloudInfrastructure.Mutelist
- listForConnection - Calls a query at the path modules/cloudInfrastructure/mutelist.js:listForConnection
- listForOrg - Calls a query at the path modules/cloudInfrastructure/mutelist.js:listForOrg
- listSuppressionOptions - Calls a query at the path modules/cloudInfrastructure/mutelist.js:listSuppressionOptions
- removeEntry - Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:removeEntry
- setEnabled - Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:setEnabled
- upsertEntry - Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:upsertEntry
CloudInfrastructure.Profiles
- create - Calls a mutation at the path modules/cloudInfrastructure/profiles.js:create
- getById - Calls a query at the path modules/cloudInfrastructure/profiles.js:getById
- listForConnection - Calls a query at the path modules/cloudInfrastructure/profiles.js:listForConnection
- listForOrg - Calls a query at the path modules/cloudInfrastructure/profiles.js:listForOrg
- remove - Calls a mutation at the path modules/cloudInfrastructure/profiles.js:remove
- setEnabled - Calls a mutation at the path modules/cloudInfrastructure/profiles.js:setEnabled
- update - Calls a mutation at the path modules/cloudInfrastructure/profiles.js:update
CloudInfrastructure.Settings
- getForOrg - Calls a query at the path modules/cloudInfrastructure/settings.js:getForOrg
- update - Calls a mutation at the path modules/cloudInfrastructure/settings.js:update
CloudInfrastructure.Verify
- verifyAndSaveAwsConnection - Calls a action at the path modules/cloudInfrastructure/verify.js:verifyAndSaveAwsConnection
CloudInfrastructure.VerifyGithub
- listAvailableInstallations - Calls a query at the path modules/cloudInfrastructure/verifyGithub.js:listAvailableInstallations
- verifyAndSaveGithubConnection - Calls a action at the path modules/cloudInfrastructure/verifyGithub.js:verifyAndSaveGithubConnection
- listInstallationReposForConnection - Calls a action at the path modules/cloudInfrastructure/verifyGithub.js:listInstallationReposForConnection
CloudInfrastructure.VerifyKubernetes
- verifyAndSaveKubernetesConnection - Calls a action at the path modules/cloudInfrastructure/verifyKubernetes.js:verifyAndSaveKubernetesConnection
CloudTests.Findings
- getById - Calls a query at the path modules/cloudTests/findings.js:getById
- listForConnection - Calls a query at the path modules/cloudTests/findings.js:listForConnection
- listForOrg - Calls a query at the path modules/cloudTests/findings.js:listForOrg
- listOpenChecks - Calls a query at the path modules/cloudTests/findings.js:listOpenChecks
- setAssignee - Calls a mutation at the path modules/cloudTests/findings.js:setAssignee
- setStatus - Calls a mutation at the path modules/cloudTests/findings.js:setStatus
CloudTests.Metrics
- getOverview - Calls a query at the path modules/cloudTests/metrics.js:getOverview
CloudTests.Remediation
- generateForFinding - Calls a action at the path modules/cloudTests/remediation.js:generateForFinding
CloudTests.Scans
- listRunsForOrg - Calls a query at the path modules/cloudTests/scans.js:listRunsForOrg
- listRunsForConnection - Calls a query at the path modules/cloudTests/scans.js:listRunsForConnection
- getRunById - Calls a query at the path modules/cloudTests/scans.js:getRunById
- listEventsForRun - Calls a query at the path modules/cloudTests/scans.js:listEventsForRun
- runForConnection - Calls a mutation at the path modules/cloudTests/scans.js:runForConnection
CodeSecurity.AiPentests
- listProjects - Calls a query at the path modules/codeSecurity/aiPentests.js:listProjects
- getProject - Calls a query at the path modules/codeSecurity/aiPentests.js:getProject
- listRunsForProject - Calls a query at the path modules/codeSecurity/aiPentests.js:listRunsForProject
- listEventsForRun - Calls a query at the path modules/codeSecurity/aiPentests.js:listEventsForRun
- listFindingsForRun - Calls a query at the path modules/codeSecurity/aiPentests.js:listFindingsForRun
- listSecretsForProject - Calls a query at the path modules/codeSecurity/aiPentests.js:listSecretsForProject
- createProject - Calls a mutation at the path modules/codeSecurity/aiPentests.js:createProject
- saveDraft - Calls a mutation at the path modules/codeSecurity/aiPentests.js:saveDraft
- createRunFromDraft - Calls a mutation at the path modules/codeSecurity/aiPentests.js:createRunFromDraft
- restartFailedRun - Calls a mutation at the path modules/codeSecurity/aiPentests.js:restartFailedRun
- generateUploadUrl - Calls a mutation at the path modules/codeSecurity/aiPentests.js:generateUploadUrl
- checkConnectivity - Calls a action at the path modules/codeSecurity/aiPentests.js:checkConnectivity
CodeSecurity.Autofix
- createFixPullRequest - Calls a action at the path modules/codeSecurity/autofix.js:createFixPullRequest
- getRegenStatus - Calls a query at the path modules/codeSecurity/autofix.js:getRegenStatus
CodeSecurity.DeepSecurityAudit
- queueAudit - Calls a action at the path modules/codeSecurity/deepSecurityAudit.js:queueAudit
- latestForRepo - Calls a query at the path modules/codeSecurity/deepSecurityAudit.js:latestForRepo
- listEventsForRun - Calls a query at the path modules/codeSecurity/deepSecurityAudit.js:listEventsForRun
CodeSecurity.DepScanner
- latestForRepo - Calls a query at the path modules/codeSecurity/depScanner.js:latestForRepo
- listEventsForRun - Calls a query at the path modules/codeSecurity/depScanner.js:listEventsForRun
- queueDepScan - Calls a action at the path modules/codeSecurity/depScanner.js:queueDepScan
CodeSecurity.Findings
- getById - Calls a query at the path modules/codeSecurity/findings.js:getById
- listForRepo - Calls a query at the path modules/codeSecurity/findings.js:listForRepo
- listOpenForOrg - Calls a query at the path modules/codeSecurity/findings.js:listOpenForOrg
- setAssignee - Calls a mutation at the path modules/codeSecurity/findings.js:setAssignee
- setStatus - Calls a mutation at the path modules/codeSecurity/findings.js:setStatus
CodeSecurity.Metrics
- getOverview - Calls a query at the path modules/codeSecurity/metrics.js:getOverview
CodeSecurity.Repositories
- listForOrg - Calls a query at the path modules/codeSecurity/repositories.js:listForOrg
- listForOrgWithStats - Calls a query at the path modules/codeSecurity/repositories.js:listForOrgWithStats
- getById - Calls a query at the path modules/codeSecurity/repositories.js:getById
- setContextNotes - Calls a mutation at the path modules/codeSecurity/repositories.js:setContextNotes
- updateScanSettings - Calls a mutation at the path modules/codeSecurity/repositories.js:updateScanSettings
CodeSecurity.Reviewer
- listForOrg - Calls a query at the path modules/codeSecurity/reviewer.js:listForOrg
- getById - Calls a query at the path modules/codeSecurity/reviewer.js:getById
- getRunBySha - Calls a query at the path modules/codeSecurity/reviewer.js:getRunBySha
- getFindingById - Calls a query at the path modules/codeSecurity/reviewer.js:getFindingById
- setFindingStatus - Calls a mutation at the path modules/codeSecurity/reviewer.js:setFindingStatus
- listEvents - Calls a query at the path modules/codeSecurity/reviewer.js:listEvents
- listStepStates - Calls a query at the path modules/codeSecurity/reviewer.js:listStepStates
- rerunReview - Calls a action at the path modules/codeSecurity/reviewer.js:rerunReview
CodeSecurity.ReviewRules
- listForOrg - Calls a query at the path modules/codeSecurity/reviewRules.js:listForOrg
- listForRepo - Calls a query at the path modules/codeSecurity/reviewRules.js:listForRepo
- create - Calls a mutation at the path modules/codeSecurity/reviewRules.js:create
- update - Calls a mutation at the path modules/codeSecurity/reviewRules.js:update
- setEnabled - Calls a mutation at the path modules/codeSecurity/reviewRules.js:setEnabled
- remove - Calls a mutation at the path modules/codeSecurity/reviewRules.js:remove
- setOrgRuleDisabledForRepo - Calls a mutation at the path modules/codeSecurity/reviewRules.js:setOrgRuleDisabledForRepo
CodeSecurity.Scan
- scanRepository - Calls a action at the path modules/codeSecurity/scan.js:scanRepository
- enqueueInitialScans - Calls a action at the path modules/codeSecurity/scan.js:enqueueInitialScans
Compliance.Library
- listFrameworks - Calls a query at the path compliance/library.js:listFrameworks
- getFrameworkBySlug - Calls a query at the path compliance/library.js:getFrameworkBySlug
- listRequirementsForFramework - Calls a query at the path compliance/library.js:listRequirementsForFramework
- listControlsForRequirement - Calls a query at the path compliance/library.js:listControlsForRequirement
- listSatisfiersForControlTemplate - Calls a query at the path compliance/library.js:listSatisfiersForControlTemplate
- getTaskTemplateBySlug - Calls a query at the path compliance/library.js:getTaskTemplateBySlug
- getPolicyTemplateBySlug - Calls a query at the path compliance/library.js:getPolicyTemplateBySlug
Compliance.OrgControls
- listForOrg - Calls a query at the path compliance/orgControls.js:listForOrg
- getById - Calls a query at the path compliance/orgControls.js:getById
- countByStatus - Calls a query at the path compliance/orgControls.js:countByStatus
Compliance.OrgFrameworks
- listForOrg - Calls a query at the path compliance/orgFrameworks.js:listForOrg
- adopt - Calls a mutation at the path compliance/orgFrameworks.js:adopt
Devices.Devices
- listForOrg - Calls a query at the path modules/devices/devices.js:listForOrg
- orderDevice - Calls a mutation at the path modules/devices/devices.js:orderDevice
Devices.Policies
- listForOrg - Calls a query at the path modules/devices/policies.js:listForOrg
- upsert - Calls a mutation at the path modules/devices/policies.js:upsert
Entitlements
- getMyMembership - Calls a query at the path entitlements.js:getMyMembership
- getForOrg - Calls a query at the path entitlements.js:getForOrg
- hasModuleForOrg - Calls a query at the path entitlements.js:hasModuleForOrg
- grantManual - Calls a mutation at the path entitlements.js:grantManual
Evidence.Evidence
- listForOrg - Calls a query at the path evidence/evidence.js:listForOrg
- generateUploadUrl - Calls a mutation at the path evidence/evidence.js:generateUploadUrl
- attach - Calls a mutation at the path evidence/evidence.js:attach
Integrations.Github.Actions
- setRepositoryScope - Calls a action at the path integrations/github/actions.js:setRepositoryScope
- listInstallationRepos - Calls a action at the path integrations/github/actions.js:listInstallationRepos
Integrations.Github.Connect
- buildInstallUrl - Calls a action at the path integrations/github/connect.js:buildInstallUrl
- getOrgSlugByInstallation - Calls a query at the path integrations/github/connect.js:getOrgSlugByInstallation
- completeInstall - Calls a action at the path integrations/github/connect.js:completeInstall
Integrations.Github.DispatchWebhook
- verifyAndDispatch - Calls a action at the path integrations/github/dispatchWebhook.js:verifyAndDispatch
Integrations.Github.Mutations
- updateConfig - Calls a mutation at the path integrations/github/mutations.js:updateConfig
- disconnect - Calls a mutation at the path integrations/github/mutations.js:disconnect
- clearRepositories - Calls a mutation at the path integrations/github/mutations.js:clearRepositories
Integrations.Github.Queries
- getForOrg - Calls a query at the path integrations/github/queries.js:getForOrg
Integrations.GoogleWorkspace.Connect
- startOAuth - Calls a action at the path integrations/googleWorkspace/connect.js:startOAuth
- completeCallback - Calls a action at the path integrations/googleWorkspace/connect.js:completeCallback
Integrations.GoogleWorkspace.Queries
- getForOrg - Calls a query at the path integrations/googleWorkspace/queries.js:getForOrg
Integrations.List
- listForOrg - Calls a query at the path integrations/list.js:listForOrg
Onboarding
- getForOrg - Calls a query at the path onboarding.js:getForOrg
- markDone - Calls a mutation at the path onboarding.js:markDone
- undo - Calls a mutation at the path onboarding.js:undo
- dismiss - Calls a mutation at the path onboarding.js:dismiss
- restore - Calls a mutation at the path onboarding.js:restore
- isModuleOnboarded - Calls a query at the path onboarding.js:isModuleOnboarded
- modulesOnboardedForOrg - Calls a query at the path onboarding.js:modulesOnboardedForOrg
Orgs
- listMine - Calls a query at the path orgs.js:listMine
- getBySlug - Calls a query at the path orgs.js:getBySlug
- listMembers - Calls a query at the path orgs.js:listMembers
- listPendingInvitations - Calls a query at the path orgs.js:listPendingInvitations
- listMyPendingInvitations - Calls a query at the path orgs.js:listMyPendingInvitations
- getInvitationForMe - Calls a query at the path orgs.js:getInvitationForMe
Policies.Policies
- listForOrg - Calls a query at the path policies/policies.js:listForOrg
- getById - Calls a query at the path policies/policies.js:getById
- saveVersion - Calls a mutation at the path policies/policies.js:saveVersion
- publish - Calls a mutation at the path policies/policies.js:publish
- retire - Calls a mutation at the path policies/policies.js:retire
Policies.Versions
- listForPolicy - Calls a query at the path policies/versions.js:listForPolicy
Portal
- getTrainingBySlug - Calls a query at the path portal.js:getTrainingBySlug
- getPolicyBySlug - Calls a query at the path portal.js:getPolicyBySlug
Quotes
- listForOrg - Calls a query at the path quotes.js:listForOrg
- getById - Calls a query at the path quotes.js:getById
- adminListForOrg - Calls a query at the path quotes.js:adminListForOrg
- create - Calls a action at the path quotes.js:create
- startCheckout - Calls a action at the path quotes.js:startCheckout
- cancel - Calls a mutation at the path quotes.js:cancel
Stripe
- listInvoicesForWorkspace - Calls a action at the path stripe.js:listInvoicesForWorkspace
Tasks.Tasks
- listForOrg - Calls a query at the path tasks/tasks.js:listForOrg
- getById - Calls a query at the path tasks/tasks.js:getById
- markComplete - Calls a mutation at the path tasks/tasks.js:markComplete
- reopen - Calls a mutation at the path tasks/tasks.js:reopen
- assign - Calls a mutation at the path tasks/tasks.js:assign
Standalone functions
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
activityAddComment- Calls a mutation at the path activity.js:addCommentactivityListForSubject- Calls a query at the path activity.js:listForSubjectactivityListForSubjectLatest- Calls a query at the path activity.js:listForSubjectLatestadminDisableEntitlement- Calls a action at the path admin.js:disableEntitlementadminGetOrgById- Calls a query at the path admin.js:getOrgByIdadminIsCurrentUserAdmin- Calls a query at the path admin.js:isCurrentUserAdminadminListInvoicesForOrg- Calls a action at the path admin.js:listInvoicesForOrgadminListOrganizations- Calls a query at the path admin.js:listOrganizationsapiKeysListForOrg- Calls a query at the path modules/apiKeys.js:listForOrgauthGetActiveOrg- Calls a query at the path auth.js:getActiveOrgauthGetCurrentUser- Calls a query at the path auth.js:getCurrentUsercloudInfrastructureConnectionsDisconnectAll- Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectAllcloudInfrastructureConnectionsDisconnectAws- Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectAwscloudInfrastructureConnectionsDisconnectConnection- Calls a mutation at the path modules/cloudInfrastructure/connections.js:disconnectConnectioncloudInfrastructureConnectionsGetById- Calls a query at the path modules/cloudInfrastructure/connections.js:getByIdcloudInfrastructureConnectionsGetForOrg- Calls a query at the path modules/cloudInfrastructure/connections.js:getForOrgcloudInfrastructureConnectionsListForOrg- Calls a query at the path modules/cloudInfrastructure/connections.js:listForOrgcloudInfrastructureConnectionsListForOrgWithStats- Calls a query at the path modules/cloudInfrastructure/connections.js:listForOrgWithStatscloudInfrastructureConnectionsSetGithubScope- Calls a mutation at the path modules/cloudInfrastructure/connections.js:setGithubScopecloudInfrastructureConnectionsSetLabel- Calls a mutation at the path modules/cloudInfrastructure/connections.js:setLabelcloudInfrastructureMutelistListForConnection- Calls a query at the path modules/cloudInfrastructure/mutelist.js:listForConnectioncloudInfrastructureMutelistListForOrg- Calls a query at the path modules/cloudInfrastructure/mutelist.js:listForOrgcloudInfrastructureMutelistListSuppressionOptions- Calls a query at the path modules/cloudInfrastructure/mutelist.js:listSuppressionOptionscloudInfrastructureMutelistRemoveEntry- Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:removeEntrycloudInfrastructureMutelistSetEnabled- Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:setEnabledcloudInfrastructureMutelistUpsertEntry- Calls a mutation at the path modules/cloudInfrastructure/mutelist.js:upsertEntrycloudInfrastructureProfilesCreate- Calls a mutation at the path modules/cloudInfrastructure/profiles.js:createcloudInfrastructureProfilesGetById- Calls a query at the path modules/cloudInfrastructure/profiles.js:getByIdcloudInfrastructureProfilesListForConnection- Calls a query at the path modules/cloudInfrastructure/profiles.js:listForConnectioncloudInfrastructureProfilesListForOrg- Calls a query at the path modules/cloudInfrastructure/profiles.js:listForOrgcloudInfrastructureProfilesRemove- Calls a mutation at the path modules/cloudInfrastructure/profiles.js:removecloudInfrastructureProfilesSetEnabled- Calls a mutation at the path modules/cloudInfrastructure/profiles.js:setEnabledcloudInfrastructureProfilesUpdate- Calls a mutation at the path modules/cloudInfrastructure/profiles.js:updatecloudInfrastructureSettingsGetForOrg- Calls a query at the path modules/cloudInfrastructure/settings.js:getForOrgcloudInfrastructureSettingsUpdate- Calls a mutation at the path modules/cloudInfrastructure/settings.js:updatecloudInfrastructureVerifyGithubListAvailableInstallations- Calls a query at the path modules/cloudInfrastructure/verifyGithub.js:listAvailableInstallationscloudInfrastructureVerifyGithubListInstallationReposForConnection- Calls a action at the path modules/cloudInfrastructure/verifyGithub.js:listInstallationReposForConnectioncloudInfrastructureVerifyGithubVerifyAndSaveGithubConnection- Calls a action at the path modules/cloudInfrastructure/verifyGithub.js:verifyAndSaveGithubConnectioncloudInfrastructureVerifyKubernetesVerifyAndSaveKubernetesConnection- Calls a action at the path modules/cloudInfrastructure/verifyKubernetes.js:verifyAndSaveKubernetesConnectioncloudInfrastructureVerifyVerifyAndSaveAwsConnection- Calls a action at the path modules/cloudInfrastructure/verify.js:verifyAndSaveAwsConnectioncloudTestsFindingsGetById- Calls a query at the path modules/cloudTests/findings.js:getByIdcloudTestsFindingsListForConnection- Calls a query at the path modules/cloudTests/findings.js:listForConnectioncloudTestsFindingsListForOrg- Calls a query at the path modules/cloudTests/findings.js:listForOrgcloudTestsFindingsListOpenChecks- Calls a query at the path modules/cloudTests/findings.js:listOpenCheckscloudTestsFindingsSetAssignee- Calls a mutation at the path modules/cloudTests/findings.js:setAssigneecloudTestsFindingsSetStatus- Calls a mutation at the path modules/cloudTests/findings.js:setStatuscloudTestsMetricsGetOverview- Calls a query at the path modules/cloudTests/metrics.js:getOverviewcloudTestsRemediationGenerateForFinding- Calls a action at the path modules/cloudTests/remediation.js:generateForFindingcloudTestsScansGetRunById- Calls a query at the path modules/cloudTests/scans.js:getRunByIdcloudTestsScansListEventsForRun- Calls a query at the path modules/cloudTests/scans.js:listEventsForRuncloudTestsScansListRunsForConnection- Calls a query at the path modules/cloudTests/scans.js:listRunsForConnectioncloudTestsScansListRunsForOrg- Calls a query at the path modules/cloudTests/scans.js:listRunsForOrgcloudTestsScansRunForConnection- Calls a mutation at the path modules/cloudTests/scans.js:runForConnectioncodeSecurityAiPentestsCheckConnectivity- Calls a action at the path modules/codeSecurity/aiPentests.js:checkConnectivitycodeSecurityAiPentestsCreateProject- Calls a mutation at the path modules/codeSecurity/aiPentests.js:createProjectcodeSecurityAiPentestsCreateRunFromDraft- Calls a mutation at the path modules/codeSecurity/aiPentests.js:createRunFromDraftcodeSecurityAiPentestsGenerateUploadUrl- Calls a mutation at the path modules/codeSecurity/aiPentests.js:generateUploadUrlcodeSecurityAiPentestsGetProject- Calls a query at the path modules/codeSecurity/aiPentests.js:getProjectcodeSecurityAiPentestsListEventsForRun- Calls a query at the path modules/codeSecurity/aiPentests.js:listEventsForRuncodeSecurityAiPentestsListFindingsForRun- Calls a query at the path modules/codeSecurity/aiPentests.js:listFindingsForRuncodeSecurityAiPentestsListProjects- Calls a query at the path modules/codeSecurity/aiPentests.js:listProjectscodeSecurityAiPentestsListRunsForProject- Calls a query at the path modules/codeSecurity/aiPentests.js:listRunsForProjectcodeSecurityAiPentestsListSecretsForProject- Calls a query at the path modules/codeSecurity/aiPentests.js:listSecretsForProjectcodeSecurityAiPentestsRestartFailedRun- Calls a mutation at the path modules/codeSecurity/aiPentests.js:restartFailedRuncodeSecurityAiPentestsSaveDraft- Calls a mutation at the path modules/codeSecurity/aiPentests.js:saveDraftcodeSecurityAutofixCreateFixPullRequest- Calls a action at the path modules/codeSecurity/autofix.js:createFixPullRequestcodeSecurityAutofixGetRegenStatus- Calls a query at the path modules/codeSecurity/autofix.js:getRegenStatuscodeSecurityDeepSecurityAuditLatestForRepo- Calls a query at the path modules/codeSecurity/deepSecurityAudit.js:latestForRepocodeSecurityDeepSecurityAuditListEventsForRun- Calls a query at the path modules/codeSecurity/deepSecurityAudit.js:listEventsForRuncodeSecurityDeepSecurityAuditQueueAudit- Calls a action at the path modules/codeSecurity/deepSecurityAudit.js:queueAuditcodeSecurityDepScannerLatestForRepo- Calls a query at the path modules/codeSecurity/depScanner.js:latestForRepocodeSecurityDepScannerListEventsForRun- Calls a query at the path modules/codeSecurity/depScanner.js:listEventsForRuncodeSecurityDepScannerQueueDepScan- Calls a action at the path modules/codeSecurity/depScanner.js:queueDepScancodeSecurityFindingsGetById- Calls a query at the path modules/codeSecurity/findings.js:getByIdcodeSecurityFindingsListForRepo- Calls a query at the path modules/codeSecurity/findings.js:listForRepocodeSecurityFindingsListOpenForOrg- Calls a query at the path modules/codeSecurity/findings.js:listOpenForOrgcodeSecurityFindingsSetAssignee- Calls a mutation at the path modules/codeSecurity/findings.js:setAssigneecodeSecurityFindingsSetStatus- Calls a mutation at the path modules/codeSecurity/findings.js:setStatuscodeSecurityMetricsGetOverview- Calls a query at the path modules/codeSecurity/metrics.js:getOverviewcodeSecurityRepositoriesGetById- Calls a query at the path modules/codeSecurity/repositories.js:getByIdcodeSecurityRepositoriesListForOrg- Calls a query at the path modules/codeSecurity/repositories.js:listForOrgcodeSecurityRepositoriesListForOrgWithStats- Calls a query at the path modules/codeSecurity/repositories.js:listForOrgWithStatscodeSecurityRepositoriesSetContextNotes- Calls a mutation at the path modules/codeSecurity/repositories.js:setContextNotescodeSecurityRepositoriesUpdateScanSettings- Calls a mutation at the path modules/codeSecurity/repositories.js:updateScanSettingscodeSecurityReviewerGetById- Calls a query at the path modules/codeSecurity/reviewer.js:getByIdcodeSecurityReviewerGetFindingById- Calls a query at the path modules/codeSecurity/reviewer.js:getFindingByIdcodeSecurityReviewerGetRunBySha- Calls a query at the path modules/codeSecurity/reviewer.js:getRunByShacodeSecurityReviewerListEvents- Calls a query at the path modules/codeSecurity/reviewer.js:listEventscodeSecurityReviewerListForOrg- Calls a query at the path modules/codeSecurity/reviewer.js:listForOrgcodeSecurityReviewerListStepStates- Calls a query at the path modules/codeSecurity/reviewer.js:listStepStatescodeSecurityReviewerRerunReview- Calls a action at the path modules/codeSecurity/reviewer.js:rerunReviewcodeSecurityReviewerSetFindingStatus- Calls a mutation at the path modules/codeSecurity/reviewer.js:setFindingStatuscodeSecurityReviewRulesCreate- Calls a mutation at the path modules/codeSecurity/reviewRules.js:createcodeSecurityReviewRulesListForOrg- Calls a query at the path modules/codeSecurity/reviewRules.js:listForOrgcodeSecurityReviewRulesListForRepo- Calls a query at the path modules/codeSecurity/reviewRules.js:listForRepocodeSecurityReviewRulesRemove- Calls a mutation at the path modules/codeSecurity/reviewRules.js:removecodeSecurityReviewRulesSetEnabled- Calls a mutation at the path modules/codeSecurity/reviewRules.js:setEnabledcodeSecurityReviewRulesSetOrgRuleDisabledForRepo- Calls a mutation at the path modules/codeSecurity/reviewRules.js:setOrgRuleDisabledForRepocodeSecurityReviewRulesUpdate- Calls a mutation at the path modules/codeSecurity/reviewRules.js:updatecodeSecurityScanEnqueueInitialScans- Calls a action at the path modules/codeSecurity/scan.js:enqueueInitialScanscodeSecurityScanScanRepository- Calls a action at the path modules/codeSecurity/scan.js:scanRepositorycomplianceLibraryGetFrameworkBySlug- Calls a query at the path compliance/library.js:getFrameworkBySlugcomplianceLibraryGetPolicyTemplateBySlug- Calls a query at the path compliance/library.js:getPolicyTemplateBySlugcomplianceLibraryGetTaskTemplateBySlug- Calls a query at the path compliance/library.js:getTaskTemplateBySlugcomplianceLibraryListControlsForRequirement- Calls a query at the path compliance/library.js:listControlsForRequirementcomplianceLibraryListFrameworks- Calls a query at the path compliance/library.js:listFrameworkscomplianceLibraryListRequirementsForFramework- Calls a query at the path compliance/library.js:listRequirementsForFrameworkcomplianceLibraryListSatisfiersForControlTemplate- Calls a query at the path compliance/library.js:listSatisfiersForControlTemplatecomplianceOrgControlsCountByStatus- Calls a query at the path compliance/orgControls.js:countByStatuscomplianceOrgControlsGetById- Calls a query at the path compliance/orgControls.js:getByIdcomplianceOrgControlsListForOrg- Calls a query at the path compliance/orgControls.js:listForOrgcomplianceOrgFrameworksAdopt- Calls a mutation at the path compliance/orgFrameworks.js:adoptcomplianceOrgFrameworksListForOrg- Calls a query at the path compliance/orgFrameworks.js:listForOrgdevicesDevicesListForOrg- Calls a query at the path modules/devices/devices.js:listForOrgdevicesDevicesOrderDevice- Calls a mutation at the path modules/devices/devices.js:orderDevicedevicesPoliciesListForOrg- Calls a query at the path modules/devices/policies.js:listForOrgdevicesPoliciesUpsert- Calls a mutation at the path modules/devices/policies.js:upsertentitlementsGetForOrg- Calls a query at the path entitlements.js:getForOrgentitlementsGetMyMembership- Calls a query at the path entitlements.js:getMyMembershipentitlementsGrantManual- Calls a mutation at the path entitlements.js:grantManualentitlementsHasModuleForOrg- Calls a query at the path entitlements.js:hasModuleForOrgevidenceEvidenceAttach- Calls a mutation at the path evidence/evidence.js:attachevidenceEvidenceGenerateUploadUrl- Calls a mutation at the path evidence/evidence.js:generateUploadUrlevidenceEvidenceListForOrg- Calls a query at the path evidence/evidence.js:listForOrgintegrationsGithubActionsListInstallationRepos- Calls a action at the path integrations/github/actions.js:listInstallationReposintegrationsGithubActionsSetRepositoryScope- Calls a action at the path integrations/github/actions.js:setRepositoryScopeintegrationsGithubConnectBuildInstallUrl- Calls a action at the path integrations/github/connect.js:buildInstallUrlintegrationsGithubConnectCompleteInstall- Calls a action at the path integrations/github/connect.js:completeInstallintegrationsGithubConnectGetOrgSlugByInstallation- Calls a query at the path integrations/github/connect.js:getOrgSlugByInstallationintegrationsGithubDispatchWebhookVerifyAndDispatch- Calls a action at the path integrations/github/dispatchWebhook.js:verifyAndDispatchintegrationsGithubMutationsClearRepositories- Calls a mutation at the path integrations/github/mutations.js:clearRepositoriesintegrationsGithubMutationsDisconnect- Calls a mutation at the path integrations/github/mutations.js:disconnectintegrationsGithubMutationsUpdateConfig- Calls a mutation at the path integrations/github/mutations.js:updateConfigintegrationsGithubQueriesGetForOrg- Calls a query at the path integrations/github/queries.js:getForOrgintegrationsGoogleWorkspaceConnectCompleteCallback- Calls a action at the path integrations/googleWorkspace/connect.js:completeCallbackintegrationsGoogleWorkspaceConnectStartOAuth- Calls a action at the path integrations/googleWorkspace/connect.js:startOAuthintegrationsGoogleWorkspaceQueriesGetForOrg- Calls a query at the path integrations/googleWorkspace/queries.js:getForOrgintegrationsListListForOrg- Calls a query at the path integrations/list.js:listForOrgonboardingDismiss- Calls a mutation at the path onboarding.js:dismissonboardingGetForOrg- Calls a query at the path onboarding.js:getForOrgonboardingIsModuleOnboarded- Calls a query at the path onboarding.js:isModuleOnboardedonboardingMarkDone- Calls a mutation at the path onboarding.js:markDoneonboardingModulesOnboardedForOrg- Calls a query at the path onboarding.js:modulesOnboardedForOrgonboardingRestore- Calls a mutation at the path onboarding.js:restoreonboardingUndo- Calls a mutation at the path onboarding.js:undoorgsGetBySlug- Calls a query at the path orgs.js:getBySlugorgsGetInvitationForMe- Calls a query at the path orgs.js:getInvitationForMeorgsListMembers- Calls a query at the path orgs.js:listMembersorgsListMine- Calls a query at the path orgs.js:listMineorgsListMyPendingInvitations- Calls a query at the path orgs.js:listMyPendingInvitationsorgsListPendingInvitations- Calls a query at the path orgs.js:listPendingInvitationspoliciesPoliciesGetById- Calls a query at the path policies/policies.js:getByIdpoliciesPoliciesListForOrg- Calls a query at the path policies/policies.js:listForOrgpoliciesPoliciesPublish- Calls a mutation at the path policies/policies.js:publishpoliciesPoliciesRetire- Calls a mutation at the path policies/policies.js:retirepoliciesPoliciesSaveVersion- Calls a mutation at the path policies/policies.js:saveVersionpoliciesVersionsListForPolicy- Calls a query at the path policies/versions.js:listForPolicyportalGetPolicyBySlug- Calls a query at the path portal.js:getPolicyBySlugportalGetTrainingBySlug- Calls a query at the path portal.js:getTrainingBySlugquotesAdminListForOrg- Calls a query at the path quotes.js:adminListForOrgquotesCancel- Calls a mutation at the path quotes.js:cancelquotesCreate- Calls a action at the path quotes.js:createquotesGetById- Calls a query at the path quotes.js:getByIdquotesListForOrg- Calls a query at the path quotes.js:listForOrgquotesStartCheckout- Calls a action at the path quotes.js:startCheckoutstripeListInvoicesForWorkspace- Calls a action at the path stripe.js:listInvoicesForWorkspacetasksTasksAssign- Calls a mutation at the path tasks/tasks.js:assigntasksTasksGetById- Calls a query at the path tasks/tasks.js:getByIdtasksTasksListForOrg- Calls a query at the path tasks/tasks.js:listForOrgtasksTasksMarkComplete- Calls a mutation at the path tasks/tasks.js:markCompletetasksTasksReopen- Calls a mutation at the path tasks/tasks.js:reopen
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { Compai } from "@trycomp/compound-sdk";
const compai = new Compai({
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { Compai } from "@trycomp/compound-sdk";
const compai = new Compai({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
});
console.log(result);
}
run();
Error Handling
CompaiError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.statusCode | number | HTTP response status code eg 404 |
| error.headers | Headers | HTTP response headers |
| error.body | string | HTTP body. Can be empty string if no body is returned. |
| error.rawResponse | Response | Raw HTTP response |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { Compai } from "@trycomp/compound-sdk";
import * as errors from "@trycomp/compound-sdk/models/errors";
const compai = new Compai({
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
try {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.CompaiError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.FailedResponseError) {
}
}
}
}
run();
Error Classes
Primary errors:
CompaiError: The base class for HTTP error responses.FailedResponseError: Failed operation.
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from CompaiError:
ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { Compai } from "@trycomp/compound-sdk";
const compai = new Compai({
serverURL: "https://fleet-sparrow-75.convex.cloud",
bearerAuth: process.env["COMP_AI_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await compai.activity.addComment({
args: {
body: "<value>",
orgId: "<id>",
subjectId: "<id>",
subjectType: "repository",
},
});
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to:
- route requests through a proxy server using undici's ProxyAgent
- use the
"beforeRequest"hook to add a custom header and a timeout to requests - use the
"requestError"hook to log errors
import { Compai } from "@trycomp/compound-sdk";
import { ProxyAgent } from "undici";
import { HTTPClient } from "@trycomp/compound-sdk/lib/http";
const dispatcher = new ProxyAgent("http://proxy.example.com:8080");
const httpClient = new HTTPClient({
// 'fetcher' takes a function that has the same signature as native 'fetch'.
fetcher: (input, init) =>
// 'dispatcher' is specific to undici and not part of the standard Fetch API.
fetch(input, { ...init, dispatcher } as RequestInit),
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint