mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
`insights/mount.py` is explicit: `/v1/` is the mount and `/api/` is the older spelling, kept on the wire for released CLI builds and personal-API-key holders and rewritten once at the edge by `ApiRewriteMiddleware`. Our own frontend was still on the older spelling: the orval clients were generated two days before the mount moved and the move did not regenerate them, so 70 files and 2323 paths said `/api/`. That is not only a spelling. `prepareUrl` in `lib/api.ts` rewrites `/v1/*` to the selected region's host in OAuth mode and nothing else, because that is what the cloud CORS allowlist covers — so every generated call quietly stayed same-origin, and `getExportsContentRetrieveUrl` builds an `<img src>` that never reaches `lib/api.ts` at all. The clients are regenerated from a spec that needs postgres, the datastore and Django, so this is the path strings only, which is the whole of what the mount move changes in them: orval copies paths verbatim from the spec, and the spec takes them from the URLconf. Doc comments carried the same stale prefix and move with them; their Python docstrings already say `/v1/`. The two frozen OAuth client-metadata paths are identifiers rather than API surface and appear in none of these files. The Slack task prompt told the agent to POST to `$INSIGHTS_API_URL/api/projects/...`, which is a live request path, not prose.
172 lines
5.6 KiB
TypeScript
Generated
172 lines
5.6 KiB
TypeScript
Generated
import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
|
|
/**
|
|
* Auto-generated from the Django backend OpenAPI schema.
|
|
* To modify these types, update the Django serializers or views, then run:
|
|
* insightscli build:openapi
|
|
* Questions or issues? #team-devex on Slack
|
|
*
|
|
* Insights API - generated
|
|
* OpenAPI spec version: 1.0.0
|
|
*/
|
|
import type {
|
|
BulkNotificationIdsRequestApi,
|
|
NotificationsListParams,
|
|
PaginatedNotificationEventListApi,
|
|
} from './api.schemas'
|
|
|
|
export const getNotificationsListUrl = (projectId: string, params?: NotificationsListParams) => {
|
|
const normalizedParams = new URLSearchParams()
|
|
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
if (value !== undefined) {
|
|
normalizedParams.append(key, value === null ? 'null' : String(value))
|
|
}
|
|
})
|
|
|
|
const stringifiedParams = normalizedParams.toString()
|
|
|
|
return stringifiedParams.length > 0
|
|
? `/v1/projects/${projectId}/notifications/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/notifications/`
|
|
}
|
|
|
|
export const notificationsList = async (
|
|
projectId: string,
|
|
params?: NotificationsListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedNotificationEventListApi> => {
|
|
return apiMutator<PaginatedNotificationEventListApi>(getNotificationsListUrl(projectId, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsArchiveCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/notifications/${id}/archive/`
|
|
}
|
|
|
|
export const notificationsArchiveCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsArchiveCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsMarkReadCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/notifications/${id}/mark_read/`
|
|
}
|
|
|
|
export const notificationsMarkReadCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsMarkReadCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsMarkUnreadCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/notifications/${id}/mark_unread/`
|
|
}
|
|
|
|
export const notificationsMarkUnreadCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsMarkUnreadCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsArchiveAllCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/archive_all/`
|
|
}
|
|
|
|
export const notificationsArchiveAllCreate = async (projectId: string, options?: RequestInit): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsArchiveAllCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsArchiveBulkCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/archive_bulk/`
|
|
}
|
|
|
|
export const notificationsArchiveBulkCreate = async (
|
|
projectId: string,
|
|
bulkNotificationIdsRequestApi: BulkNotificationIdsRequestApi,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsArchiveBulkCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(bulkNotificationIdsRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getNotificationsMarkAllReadCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/mark_all_read/`
|
|
}
|
|
|
|
export const notificationsMarkAllReadCreate = async (projectId: string, options?: RequestInit): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsMarkAllReadCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getNotificationsMarkReadBulkCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/mark_read_bulk/`
|
|
}
|
|
|
|
export const notificationsMarkReadBulkCreate = async (
|
|
projectId: string,
|
|
bulkNotificationIdsRequestApi: BulkNotificationIdsRequestApi,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsMarkReadBulkCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(bulkNotificationIdsRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getNotificationsMarkUnreadBulkCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/mark_unread_bulk/`
|
|
}
|
|
|
|
export const notificationsMarkUnreadBulkCreate = async (
|
|
projectId: string,
|
|
bulkNotificationIdsRequestApi: BulkNotificationIdsRequestApi,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsMarkUnreadBulkCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(bulkNotificationIdsRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getNotificationsUnreadCountRetrieveUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/notifications/unread_count/`
|
|
}
|
|
|
|
export const notificationsUnreadCountRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {
|
|
return apiMutator<void>(getNotificationsUnreadCountRetrieveUrl(projectId), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|