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.
579 lines
21 KiB
TypeScript
Generated
579 lines
21 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 {
|
|
AppMetricsResponseApi,
|
|
AppMetricsTotalsResponseApi,
|
|
InsightsFunctionApi,
|
|
InsightsFunctionInvocationApi,
|
|
InsightsFunctionPublishRequestApi,
|
|
InsightsFunctionPublishResponseApi,
|
|
InsightsFunctionRevisionApi,
|
|
InsightsFunctionRevisionRestoreRequestApi,
|
|
InsightsFunctionTemplateApi,
|
|
InsightsFunctionTemplatesListParams,
|
|
InsightsFunctionsListParams,
|
|
InsightsFunctionsLogsRetrieveParams,
|
|
InsightsFunctionsMetricsRetrieveParams,
|
|
InsightsFunctionsMetricsTotalsRetrieveParams,
|
|
InsightsFunctionsRevisionsListParams,
|
|
ScriptInvocationRerunRequestApi,
|
|
ScriptInvocationRerunResponseApi,
|
|
PaginatedInsightsFunctionMinimalListApi,
|
|
PaginatedInsightsFunctionRevisionBasicListApi,
|
|
PaginatedInsightsFunctionTemplateListApi,
|
|
PaginatedPluginLogEntryListApi,
|
|
PatchedInsightsFunctionApi,
|
|
PatchedInsightsFunctionRearrangeApi,
|
|
PluginConfigsLogsListParams,
|
|
PublicInsightsFunctionTemplatesListParams,
|
|
} from './api.schemas'
|
|
|
|
// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
|
|
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B
|
|
|
|
type WritableKeys<T> = {
|
|
[P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P>
|
|
}[keyof T]
|
|
|
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
|
|
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never
|
|
|
|
type Writable<T> = Pick<T, WritableKeys<T>>
|
|
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
|
|
? {
|
|
[P in keyof Writable<T>]: T[P] extends object ? NonReadonly<NonNullable<T[P]>> : T[P]
|
|
}
|
|
: DistributeReadOnlyOverUnions<T>
|
|
|
|
export const getInsightsFunctionTemplatesListUrl = (projectId: string, params?: InsightsFunctionTemplatesListParams) => {
|
|
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}/insights_function_templates/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_function_templates/`
|
|
}
|
|
|
|
export const insightsFunctionTemplatesList = async (
|
|
projectId: string,
|
|
params?: InsightsFunctionTemplatesListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedInsightsFunctionTemplateListApi> => {
|
|
return apiMutator<PaginatedInsightsFunctionTemplateListApi>(getInsightsFunctionTemplatesListUrl(projectId, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionTemplatesRetrieveUrl = (projectId: string, templateId: string) => {
|
|
return `/v1/projects/${projectId}/insights_function_templates/${templateId}/`
|
|
}
|
|
|
|
export const insightsFunctionTemplatesRetrieve = async (
|
|
projectId: string,
|
|
templateId: string,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionTemplateApi> => {
|
|
return apiMutator<InsightsFunctionTemplateApi>(getInsightsFunctionTemplatesRetrieveUrl(projectId, templateId), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsListUrl = (projectId: string, params?: InsightsFunctionsListParams) => {
|
|
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}/insights_functions/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_functions/`
|
|
}
|
|
|
|
export const insightsFunctionsList = async (
|
|
projectId: string,
|
|
params?: InsightsFunctionsListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedInsightsFunctionMinimalListApi> => {
|
|
return apiMutator<PaginatedInsightsFunctionMinimalListApi>(getInsightsFunctionsListUrl(projectId, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsCreateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/`
|
|
}
|
|
|
|
export const insightsFunctionsCreate = async (
|
|
projectId: string,
|
|
insightsFunctionApi?: NonReadonly<InsightsFunctionApi>,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsCreateUrl(projectId), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsRetrieveUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/`
|
|
}
|
|
|
|
export const insightsFunctionsRetrieve = async (
|
|
projectId: string,
|
|
id: string,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsRetrieveUrl(projectId, id), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsUpdateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/`
|
|
}
|
|
|
|
export const insightsFunctionsUpdate = async (
|
|
projectId: string,
|
|
id: string,
|
|
insightsFunctionApi?: NonReadonly<InsightsFunctionApi>,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsUpdateUrl(projectId, id), {
|
|
...options,
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsPartialUpdateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/`
|
|
}
|
|
|
|
export const insightsFunctionsPartialUpdate = async (
|
|
projectId: string,
|
|
id: string,
|
|
patchedInsightsFunctionApi?: NonReadonly<PatchedInsightsFunctionApi>,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsPartialUpdateUrl(projectId, id), {
|
|
...options,
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(patchedInsightsFunctionApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsDestroyUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/`
|
|
}
|
|
|
|
/**
|
|
* Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
|
|
*/
|
|
export const insightsFunctionsDestroy = async (projectId: string, id: string, options?: RequestInit): Promise<unknown> => {
|
|
return apiMutator<unknown>(getInsightsFunctionsDestroyUrl(projectId, id), {
|
|
...options,
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsDiscardDraftCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/discard_draft/`
|
|
}
|
|
|
|
export const insightsFunctionsDiscardDraftCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsDiscardDraftCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsEnableBackfillsCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/enable_backfills/`
|
|
}
|
|
|
|
export const insightsFunctionsEnableBackfillsCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
insightsFunctionApi?: NonReadonly<InsightsFunctionApi>,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getInsightsFunctionsEnableBackfillsCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsInvocationsCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/invocations/`
|
|
}
|
|
|
|
export const insightsFunctionsInvocationsCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
insightsFunctionInvocationApi?: NonReadonly<InsightsFunctionInvocationApi>,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionInvocationApi> => {
|
|
return apiMutator<InsightsFunctionInvocationApi>(getInsightsFunctionsInvocationsCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionInvocationApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsLogsRetrieveUrl = (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsLogsRetrieveParams
|
|
) => {
|
|
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}/insights_functions/${id}/logs/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_functions/${id}/logs/`
|
|
}
|
|
|
|
export const insightsFunctionsLogsRetrieve = async (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsLogsRetrieveParams,
|
|
options?: RequestInit
|
|
): Promise<void> => {
|
|
return apiMutator<void>(getInsightsFunctionsLogsRetrieveUrl(projectId, id, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsMetricsRetrieveUrl = (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsMetricsRetrieveParams
|
|
) => {
|
|
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}/insights_functions/${id}/metrics/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_functions/${id}/metrics/`
|
|
}
|
|
|
|
export const insightsFunctionsMetricsRetrieve = async (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsMetricsRetrieveParams,
|
|
options?: RequestInit
|
|
): Promise<AppMetricsResponseApi> => {
|
|
return apiMutator<AppMetricsResponseApi>(getInsightsFunctionsMetricsRetrieveUrl(projectId, id, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsMetricsTotalsRetrieveUrl = (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsMetricsTotalsRetrieveParams
|
|
) => {
|
|
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}/insights_functions/${id}/metrics/totals/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_functions/${id}/metrics/totals/`
|
|
}
|
|
|
|
export const insightsFunctionsMetricsTotalsRetrieve = async (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsMetricsTotalsRetrieveParams,
|
|
options?: RequestInit
|
|
): Promise<AppMetricsTotalsResponseApi> => {
|
|
return apiMutator<AppMetricsTotalsResponseApi>(getInsightsFunctionsMetricsTotalsRetrieveUrl(projectId, id, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsPublishCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/publish/`
|
|
}
|
|
|
|
export const insightsFunctionsPublishCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
insightsFunctionPublishRequestApi?: InsightsFunctionPublishRequestApi,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionPublishResponseApi> => {
|
|
return apiMutator<InsightsFunctionPublishResponseApi>(getInsightsFunctionsPublishCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionPublishRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsRerunCreateUrl = (projectId: string, id: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/rerun/`
|
|
}
|
|
|
|
/**
|
|
* Rerun past invocations of this script function from their stored payloads.
|
|
*
|
|
* The CDP worker reads matching rows from the `invocations`
|
|
* Datastore table, rehydrates the invocation from the stored
|
|
* `invocation_globals`, and re-enqueues onto cyclotron. Each rerun
|
|
* run reuses the original `invocation_id` with `is_retry=1` set on the
|
|
* new lifecycle row so the UI can surface that it was a rerun.
|
|
*
|
|
* Only types a cyclotron worker executes (`TYPES_THAT_CAN_RERUN`) can be
|
|
* rerun: rerun re-enqueues onto the cyclotron script queue, and other types
|
|
* run elsewhere (source webhooks inline in the cdp-api HTTP handler,
|
|
* transformations during ingestion, `site_*` transpiled to client-side
|
|
* JS). A re-enqueued invocation of one of those would never drain and
|
|
* wedges the partition, so a rerun of a non-rerunnable type is rejected
|
|
* with a 400 here.
|
|
*
|
|
* Because rerun replays historical event/person/group data, it requires
|
|
* `person:read` and `group:read` on top of `insights_function:write`.
|
|
*/
|
|
export const insightsFunctionsRerunCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
scriptInvocationRerunRequestApi: ScriptInvocationRerunRequestApi,
|
|
options?: RequestInit
|
|
): Promise<ScriptInvocationRerunResponseApi> => {
|
|
return apiMutator<ScriptInvocationRerunResponseApi>(getInsightsFunctionsRerunCreateUrl(projectId, id), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(scriptInvocationRerunRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsRevisionsListUrl = (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsRevisionsListParams
|
|
) => {
|
|
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}/insights_functions/${id}/revisions/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/insights_functions/${id}/revisions/`
|
|
}
|
|
|
|
export const insightsFunctionsRevisionsList = async (
|
|
projectId: string,
|
|
id: string,
|
|
params?: InsightsFunctionsRevisionsListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedInsightsFunctionRevisionBasicListApi> => {
|
|
return apiMutator<PaginatedInsightsFunctionRevisionBasicListApi>(
|
|
getInsightsFunctionsRevisionsListUrl(projectId, id, params),
|
|
{
|
|
...options,
|
|
method: 'GET',
|
|
}
|
|
)
|
|
}
|
|
|
|
export const getInsightsFunctionsRevisionsRetrieveUrl = (projectId: string, id: string, version: number) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/revisions/${version}/`
|
|
}
|
|
|
|
export const insightsFunctionsRevisionsRetrieve = async (
|
|
projectId: string,
|
|
id: string,
|
|
version: number,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionRevisionApi> => {
|
|
return apiMutator<InsightsFunctionRevisionApi>(getInsightsFunctionsRevisionsRetrieveUrl(projectId, id, version), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsRevisionsRestoreCreateUrl = (projectId: string, id: string, version: number) => {
|
|
return `/v1/projects/${projectId}/insights_functions/${id}/revisions/${version}/restore/`
|
|
}
|
|
|
|
export const insightsFunctionsRevisionsRestoreCreate = async (
|
|
projectId: string,
|
|
id: string,
|
|
version: number,
|
|
insightsFunctionRevisionRestoreRequestApi?: InsightsFunctionRevisionRestoreRequestApi,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi> => {
|
|
return apiMutator<InsightsFunctionApi>(getInsightsFunctionsRevisionsRestoreCreateUrl(projectId, id, version), {
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(insightsFunctionRevisionRestoreRequestApi),
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsIconRetrieveUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/icon/`
|
|
}
|
|
|
|
export const insightsFunctionsIconRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {
|
|
return apiMutator<void>(getInsightsFunctionsIconRetrieveUrl(projectId), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsIconsRetrieveUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/icons/`
|
|
}
|
|
|
|
export const insightsFunctionsIconsRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {
|
|
return apiMutator<void>(getInsightsFunctionsIconsRetrieveUrl(projectId), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getInsightsFunctionsRearrangePartialUpdateUrl = (projectId: string) => {
|
|
return `/v1/projects/${projectId}/insights_functions/rearrange/`
|
|
}
|
|
|
|
/**
|
|
* Update the execution order of multiple InsightsFunctions.
|
|
*/
|
|
export const insightsFunctionsRearrangePartialUpdate = async (
|
|
projectId: string,
|
|
patchedInsightsFunctionRearrangeApi?: PatchedInsightsFunctionRearrangeApi,
|
|
options?: RequestInit
|
|
): Promise<InsightsFunctionApi[]> => {
|
|
return apiMutator<InsightsFunctionApi[]>(getInsightsFunctionsRearrangePartialUpdateUrl(projectId), {
|
|
...options,
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(patchedInsightsFunctionRearrangeApi),
|
|
})
|
|
}
|
|
|
|
export const getPluginConfigsLogsListUrl = (
|
|
projectId: string,
|
|
pluginConfigId: number,
|
|
params?: PluginConfigsLogsListParams
|
|
) => {
|
|
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}/plugin_configs/${pluginConfigId}/logs/?${stringifiedParams}`
|
|
: `/v1/projects/${projectId}/plugin_configs/${pluginConfigId}/logs/`
|
|
}
|
|
|
|
export const pluginConfigsLogsList = async (
|
|
projectId: string,
|
|
pluginConfigId: number,
|
|
params?: PluginConfigsLogsListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedPluginLogEntryListApi> => {
|
|
return apiMutator<PaginatedPluginLogEntryListApi>(getPluginConfigsLogsListUrl(projectId, pluginConfigId, params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const getPublicInsightsFunctionTemplatesListUrl = (params?: PublicInsightsFunctionTemplatesListParams) => {
|
|
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/public_insights_function_templates/?${stringifiedParams}`
|
|
: `/v1/public_insights_function_templates/`
|
|
}
|
|
|
|
export const publicInsightsFunctionTemplatesList = async (
|
|
params?: PublicInsightsFunctionTemplatesListParams,
|
|
options?: RequestInit
|
|
): Promise<PaginatedInsightsFunctionTemplateListApi> => {
|
|
return apiMutator<PaginatedInsightsFunctionTemplateListApi>(getPublicInsightsFunctionTemplatesListUrl(params), {
|
|
...options,
|
|
method: 'GET',
|
|
})
|
|
}
|