Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/origin

src/types.ts

116 lines · 2.5 KB · TypeScript
export const ORIGIN_API_BASE_URL = 'https://api.cursor.com/v1/origin'

export default ORIGIN_API_BASE_URL

export type OriginAuthMode = 'app' | 'installation'

export type OriginQuery = Record<
	string,
	string | number | boolean | null | undefined
>

export type OriginAccountInput = {
	/** Account namespace. Alias of `integrationName`. Default `origin`. */
	account?: string
	/** Account namespace used to pick secret and storage keys. Default `origin`. */
	integrationName?: string
	/** Origin App private-key secret name. Default `originAppPrivateKey` or `originAppPrivateKey-<account>`. */
	secretName?: string
	/** Origin App id (`app_01…`). Overrides package storage for this call. */
	appId?: string
	/** Origin installation id (`i_01…`). Overrides package storage for this call. */
	installationId?: string
}

export type OriginMutationInput = {
	/** Preview a write without calling Origin. */
	dryRun?: boolean
	/** Perform the live write. Required when `dryRun` is not set. */
	confirm?: boolean
}

export type OriginRequestParams = OriginAccountInput &
	OriginMutationInput & {
		path: string
		method?: string
		query?: OriginQuery
		body?: unknown
		auth?: OriginAuthMode
		scopes?: Array<string>
	}

export type OriginRequestResult = {
	ok: boolean
	status: number
	body: unknown
	rateLimit: {
		limit: string | null
		remaining: string | null
		used: string | null
		reset: string | null
	}
	dryRun?: true
}

export type OriginOwner = {
	slug: string
	id: string
	type: string | null
}

export type OriginRepoSummary = {
	id: string
	name: string
	fullName: string | null
	owner: OriginOwner | null
	defaultBranch: string | null
	cloneUrl: string | null
	mirror: {
		source: string | null
		status: string | null
	} | null
}

export type OriginInstallation = {
	id: string
	appId: string | null
	target: OriginOwner | null
	repoSelectionMode: string | null
	scopes: Array<string>
}

export type OriginPullSummary = {
	number: string | number | null
	title: string | null
	state: string | null
	draft: boolean | null
	merged: boolean | null
	head: string | null
	base: string | null
	url: string | null
}

export type OriginRateLimit = {
	limit: number | null
	remaining: number | null
	used: number | null
	reset: number | null
}

export type OriginResolvedAccount = {
	account: string
	secretName: string
	appIdKey: string
	installationIdKey: string
}

export type OriginAuthLaneInfo = {
	lane: 'origin-app'
	default: boolean
	account: string
	secretName: string
	secretSetupUrl: string
	useWhen: string
	avoidWhen: string
	mutationGuidance: string
}