Files
lincodex/frontend/src/shared/api/endpoints/privacy/privacy.ts
T

968 lines
49 KiB
TypeScript

/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
import {
useMutation,
useQuery
} from '@tanstack/react-query';
import type {
DataTag,
DefinedInitialDataOptions,
DefinedUseQueryResult,
MutationFunction,
QueryClient,
QueryFunction,
QueryKey,
UndefinedInitialDataOptions,
UseMutationOptions,
UseMutationResult,
UseQueryOptions,
UseQueryResult
} from '@tanstack/react-query';
import type {
CardAccessList,
CardPreview,
HiddenOrganization,
HiddenOrganizationList,
ListMyCardAccessHistoryParams,
ListMyHiddenOrganizationsParams,
ListMyPrivacyHistoryParams,
PrivacyEventList,
PrivacySettings,
Problem,
Publication,
PublicationUpdate,
SearchStatus,
SearchStatusUpdate
} from '../../schemas';
import { apiRequest } from '../../client';
import type { ErrorType } from '../../client';
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
const withQueryKey = <T extends object, K>(query: T, queryKey: K): T & { queryKey: K } => {
const result = { queryKey } as T & { queryKey: K };
for (const key of Object.keys(query)) {
// The explicit queryKey always wins, matching the previous
// `{ ...query, queryKey }` spread where it was set last.
if (key === 'queryKey') continue;
Object.defineProperty(result, key, {
enumerable: true,
configurable: true,
get: () => (query as Record<string, unknown>)[key],
});
}
return result;
};
export const getGetMyPrivacySettingsUrl = () => {
return `/api/v1/me/privacy`
}
/**
* Requires the session cookie of a candidate account. The candidate comes from the session, never from a request parameter. Returns the publication of the candidate card, the search status, and the number of hidden organizations in one read. The response is `Cache-Control: no-store`.
*
* A profile is closed by default. A candidate who never published reads `publication.state` `closed` with `closed_reason` `never_published`, an empty field set, and version 0; creating or saving the profile (`SaveMyProfile`) never publishes it, and no operation of the profile, the questionnaire, or an assessment changes these settings. The C2 consent, the search status, and the hidden organizations are three independent settings: the C2 record in the consent ledger proves that the candidate accepted the publication text, the publication records which fields are published, and the search status is a statement of the candidate that is not a consent. A change of one never changes another, and none of them ever makes the candidate more visible by itself: the search status lapses to the non-public `not_looking`, a revoked C2 closes the card, and a new C2 grant publishes nothing.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
* @summary Read the visibility settings of the current candidate.
*/
export const getMyPrivacySettings = async ( options?: Parameters<typeof apiRequest>[1]): Promise<PrivacySettings> => {
return apiRequest<PrivacySettings>(getGetMyPrivacySettingsUrl(),
{
...options,
method: 'GET'
}
);}
export const getGetMyPrivacySettingsQueryKey = () => {
return [
`/api/v1/me/privacy`
] as const;
}
export const getGetMyPrivacySettingsQueryOptions = <TData = Awaited<ReturnType<typeof getMyPrivacySettings>>, TError = ErrorType<Problem>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getGetMyPrivacySettingsQueryKey();
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMyPrivacySettings>>> = ({ signal }) => getMyPrivacySettings({ signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type GetMyPrivacySettingsQueryResult = NonNullable<Awaited<ReturnType<typeof getMyPrivacySettings>>>
export type GetMyPrivacySettingsQueryError = ErrorType<Problem>
export function useGetMyPrivacySettings<TData = Awaited<ReturnType<typeof getMyPrivacySettings>>, TError = ErrorType<Problem>>(
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyPrivacySettings>>,
TError,
Awaited<ReturnType<typeof getMyPrivacySettings>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyPrivacySettings<TData = Awaited<ReturnType<typeof getMyPrivacySettings>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyPrivacySettings>>,
TError,
Awaited<ReturnType<typeof getMyPrivacySettings>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyPrivacySettings<TData = Awaited<ReturnType<typeof getMyPrivacySettings>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Read the visibility settings of the current candidate.
*/
export function useGetMyPrivacySettings<TData = Awaited<ReturnType<typeof getMyPrivacySettings>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyPrivacySettings>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getGetMyPrivacySettingsQueryOptions(options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getSetMyPublicationUrl = () => {
return `/api/v1/me/privacy/publication`
}
/**
* Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body is the complete new publication setting: `state` `published` with the non-empty set of card fields, or `closed` with an empty set. It changes only the publication; the search status and the hidden organizations stay as they were.
*
* Publication is not a consent and does not duplicate one. The consent C2 lives in the consent ledger (`ListMyConsents`); this setting refers to it. Publishing requires an active, unrevoked C2 record of the account and binds the publication to that record, so a client sends no consent identifier and cannot forge one. Without one the server answers 409 state_conflict with the entry `{in: body, pointer: /state, code: consent_required}` in `errors`, which tells it apart from every other conflict, and changes nothing: the client gives C2 first (planned in the consent settings) and then publishes. The server takes the C2 record under a share lock in the transaction that writes the publication, so a revocation that races with a publication either commits first (the publication is refused) or closes the card right after. A revocation of C2 closes the card at once, because `state` is computed from the unrevoked record; a later C2 grant never reopens it, and the candidate publishes again under the new record. The revocation path itself closes the stored publication and revokes the contact grants in its own transaction. A closing sent over a stored publication whose C2 was revoked is a real change: it stores the closing, records `publication_closed`, and revokes the grants as any closing does. Publishing, like every visibility change, needs a verified email (a usecase requirement; the unverified account cleanup deletes only accounts without such records). Publishing never adds a field that the body did not name, and a new `CardField` value is never published for a candidate who did not choose it.
*
* The field set contains only the groups of `CardField`. The full name, contacts, and the lowest salary have no value there, so no body can publish them. Only values that the candidate confirmed ever reach the card. Contacts reach an organization only through the contact grant (C4), and a profile that is published or closed changes none of the grants that exist; closing the publication, and hiding an organization that holds a grant, revoke the contact grants concerned with the reason `visibility_closed` in the same transaction as the change (planned together with the operations, see the invitation contract).
*
* Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read, 0 for the first publication. If it is not the current version the server answers 412 version_conflict and changes nothing. The version travels in the body rather than in If-Match because the generated client cannot read the ETag header yet. A body that equals the stored setting changes nothing, keeps the version, and answers 200 even when `expected_version` is older, so a retry after a lost response succeeds without an Idempotency-Key. A version above the current one never existed and always answers 412. Every change is recorded in the settings history with its time, the fields, and the C2 record.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), a version above the current one (412), rules that depend on the body alone (400), an unchanged body (200), a stale version (412), then the active C2 for a publication (409 state_conflict). The schema rejects an unknown field, a repeated or unknown card field, and more fields than there are groups; a published state with no field, and a closed state with a field, answer 400 validation_failed with the pointer `/fields`. Error bodies never repeat a submitted value.
* @summary Publish or close the anonymous candidate card.
*/
export const setMyPublication = async (publicationUpdate: PublicationUpdate, options?: Parameters<typeof apiRequest>[1]): Promise<Publication> => {
const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
if (!h) return {};
if (h instanceof Headers) return Object.fromEntries(h.entries());
if (Symbol.iterator in h) {
return Object.fromEntries(
Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
);
}
const headers: Record<string, string | readonly string[]> = {};
for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
if (value !== undefined) headers[name] = value;
}
return headers;
};
return apiRequest<Publication>(getSetMyPublicationUrl(),
{
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
body: JSON.stringify(publicationUpdate)
}
);}
export const getSetMyPublicationMutationKey = () => ['setMyPublication'] as const;
export const getSetMyPublicationMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setMyPublication>>, TError,SetMyPublicationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof setMyPublication>>, TError,SetMyPublicationMutationVariables, TContext> => {
const mutationKey = getSetMyPublicationMutationKey();
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof setMyPublication>>, SetMyPublicationMutationVariables> = (props) => {
const {data} = props ?? {};
return setMyPublication(data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type SetMyPublicationMutationResult = NonNullable<Awaited<ReturnType<typeof setMyPublication>>>
export type SetMyPublicationMutationBody = PublicationUpdate
export type SetMyPublicationMutationError = ErrorType<Problem>
export type SetMyPublicationMutationVariables = {data: PublicationUpdate}
/**
* @summary Publish or close the anonymous candidate card.
*/
export const useSetMyPublication = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setMyPublication>>, TError,SetMyPublicationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof setMyPublication>>,
TError,
SetMyPublicationMutationVariables,
TContext
> => {
return useMutation(getSetMyPublicationMutationOptions(options), queryClient);
}
export const getGetMyCardPreviewUrl = () => {
return `/api/v1/me/privacy/preview`
}
/**
* Requires the session cookie of a candidate account. Returns the card exactly as an organization that the candidate does not hide the profile from would read it now, built from the current profile, the current publication, and the consent ledger. The response is `Cache-Control: no-store`.
*
* The preview is a private read for the candidate: it creates no view, leaves no access record, and is never shown to an organization. While the profile is closed `card` is null. `card` is `AnonymousCardContent`, whose schema reaches no private profile schema, no contact, and no identifier of the candidate: it has no name, email, phone, Telegram name, employer, salary figure, or account or profile identifier, and each property is null when it is not published or has no value, so a reader cannot tell the two apart. Only the fields in `fields` are filled, and only with values that the candidate confirmed: an unconfirmed suggestion and an unknown value never appear. A free text value that looks like a contact (an email address, a phone number, a URL, a Telegram link, an @handle) is dropped from the card, so the preview shows exactly what an organization would read. The self-assessed grade is not a category and never appears; categories come only from assessment results.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
* @summary Preview the anonymous card that organizations would read.
*/
export const getMyCardPreview = async ( options?: Parameters<typeof apiRequest>[1]): Promise<CardPreview> => {
return apiRequest<CardPreview>(getGetMyCardPreviewUrl(),
{
...options,
method: 'GET'
}
);}
export const getGetMyCardPreviewQueryKey = () => {
return [
`/api/v1/me/privacy/preview`
] as const;
}
export const getGetMyCardPreviewQueryOptions = <TData = Awaited<ReturnType<typeof getMyCardPreview>>, TError = ErrorType<Problem>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getGetMyCardPreviewQueryKey();
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMyCardPreview>>> = ({ signal }) => getMyCardPreview({ signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type GetMyCardPreviewQueryResult = NonNullable<Awaited<ReturnType<typeof getMyCardPreview>>>
export type GetMyCardPreviewQueryError = ErrorType<Problem>
export function useGetMyCardPreview<TData = Awaited<ReturnType<typeof getMyCardPreview>>, TError = ErrorType<Problem>>(
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyCardPreview>>,
TError,
Awaited<ReturnType<typeof getMyCardPreview>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyCardPreview<TData = Awaited<ReturnType<typeof getMyCardPreview>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof getMyCardPreview>>,
TError,
Awaited<ReturnType<typeof getMyCardPreview>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetMyCardPreview<TData = Awaited<ReturnType<typeof getMyCardPreview>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Preview the anonymous card that organizations would read.
*/
export function useGetMyCardPreview<TData = Awaited<ReturnType<typeof getMyCardPreview>>, TError = ErrorType<Problem>>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getMyCardPreview>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getGetMyCardPreviewQueryOptions(options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getSetMySearchStatusUrl = () => {
return `/api/v1/me/privacy/search-status`
}
/**
* Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body is the complete new status: `looking` ("Ищу") or `not_looking`. The status is a statement of the candidate and never a consent. It changes neither the C2 consent, nor the publication, nor the hidden organizations, and it does not close or open any contact grant; a candidate whose profile is closed who sets `looking` becomes visible to no one.
*
* `looking` stores the moment of the confirmation and a lapse time. The server takes the interval from the `search_status` section of the effective product policy (30 days in the demo policy, `searching_confirmation_interval_days`), stores the policy version it used, and fixes the lapse time then, so a later policy change moves no stored time. Setting `looking` again is the confirmation: it replaces the confirmation time with now and advances the version, also after a lapse. The body carries no time, interval, or policy version.
*
* After the lapse time the status holds as `not_looking` with `lapsed` true on the next read. The lapse is computed and written nowhere, so it needs no job, it can never make the candidate more visible, and it never touches the publication or the hidden organizations. A reminder before the lapse is a planned notification, not a part of this operation.
*
* Optimistic concurrency uses `expected_version` in the body, 0 for a candidate who never set the status; a stale or non-existent version answers 412 version_conflict and changes nothing. `not_looking` over a stored `not_looking` changes nothing and answers 200 even with a stale version. `looking` always changes the stored confirmation, so a retry of a confirmation whose response was lost with the old version answers 412 and the client reads the status again.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), a version above the current one (412), an unchanged `not_looking` (200), then a stale version (412).
* @summary Set or confirm the search status of the current candidate.
*/
export const setMySearchStatus = async (searchStatusUpdate: SearchStatusUpdate, options?: Parameters<typeof apiRequest>[1]): Promise<SearchStatus> => {
const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
if (!h) return {};
if (h instanceof Headers) return Object.fromEntries(h.entries());
if (Symbol.iterator in h) {
return Object.fromEntries(
Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
);
}
const headers: Record<string, string | readonly string[]> = {};
for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
if (value !== undefined) headers[name] = value;
}
return headers;
};
return apiRequest<SearchStatus>(getSetMySearchStatusUrl(),
{
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
body: JSON.stringify(searchStatusUpdate)
}
);}
export const getSetMySearchStatusMutationKey = () => ['setMySearchStatus'] as const;
export const getSetMySearchStatusMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setMySearchStatus>>, TError,SetMySearchStatusMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof setMySearchStatus>>, TError,SetMySearchStatusMutationVariables, TContext> => {
const mutationKey = getSetMySearchStatusMutationKey();
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof setMySearchStatus>>, SetMySearchStatusMutationVariables> = (props) => {
const {data} = props ?? {};
return setMySearchStatus(data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type SetMySearchStatusMutationResult = NonNullable<Awaited<ReturnType<typeof setMySearchStatus>>>
export type SetMySearchStatusMutationBody = SearchStatusUpdate
export type SetMySearchStatusMutationError = ErrorType<Problem>
export type SetMySearchStatusMutationVariables = {data: SearchStatusUpdate}
/**
* @summary Set or confirm the search status of the current candidate.
*/
export const useSetMySearchStatus = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof setMySearchStatus>>, TError,SetMySearchStatusMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof setMySearchStatus>>,
TError,
SetMySearchStatusMutationVariables,
TContext
> => {
return useMutation(getSetMySearchStatusMutationOptions(options), queryClient);
}
export const getListMyHiddenOrganizationsUrl = (params?: ListMyHiddenOrganizationsParams,) => {
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 ? `/api/v1/me/privacy/hidden-organizations?${stringifiedParams}` : `/api/v1/me/privacy/hidden-organizations`
}
/**
* Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only the caller's own records and no request can name another account. Returns a page of the hidden organizations, newest first with the organization identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
*
* The records belong to the candidate. An organization never reads them, never learns that it is hidden, and sees a hidden candidate exactly as it sees one who is not published: no search result, no card, no contact read.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
* @summary List the organizations that the candidate hides the profile from.
*/
export const listMyHiddenOrganizations = async (params?: ListMyHiddenOrganizationsParams, options?: Parameters<typeof apiRequest>[1]): Promise<HiddenOrganizationList> => {
return apiRequest<HiddenOrganizationList>(getListMyHiddenOrganizationsUrl(params),
{
...options,
method: 'GET'
}
);}
export const getListMyHiddenOrganizationsQueryKey = (params?: ListMyHiddenOrganizationsParams,) => {
return [
`/api/v1/me/privacy/hidden-organizations`, ...(params ? [params] : [])
] as const;
}
export const getListMyHiddenOrganizationsQueryOptions = <TData = Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError = ErrorType<Problem>>(params?: ListMyHiddenOrganizationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getListMyHiddenOrganizationsQueryKey(params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMyHiddenOrganizations>>> = ({ signal }) => listMyHiddenOrganizations(params, { signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type ListMyHiddenOrganizationsQueryResult = NonNullable<Awaited<ReturnType<typeof listMyHiddenOrganizations>>>
export type ListMyHiddenOrganizationsQueryError = ErrorType<Problem>
export function useListMyHiddenOrganizations<TData = Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError = ErrorType<Problem>>(
params: undefined | ListMyHiddenOrganizationsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyHiddenOrganizations>>,
TError,
Awaited<ReturnType<typeof listMyHiddenOrganizations>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyHiddenOrganizations<TData = Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError = ErrorType<Problem>>(
params?: ListMyHiddenOrganizationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyHiddenOrganizations>>,
TError,
Awaited<ReturnType<typeof listMyHiddenOrganizations>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyHiddenOrganizations<TData = Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError = ErrorType<Problem>>(
params?: ListMyHiddenOrganizationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary List the organizations that the candidate hides the profile from.
*/
export function useListMyHiddenOrganizations<TData = Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError = ErrorType<Problem>>(
params?: ListMyHiddenOrganizationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyHiddenOrganizations>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getListMyHiddenOrganizationsQueryOptions(params,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getHideOrganizationUrl = (orgId: string,) => {
return `/api/v1/me/privacy/hidden-organizations/${orgId}`
}
/**
* Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The request has no body: the path names the organization and the candidate comes from the session. The hiding is a record that belongs to the candidate and references the organization; it changes neither the C2 consent, nor the publication, nor the search status.
*
* The operation sets a state, so it is idempotent and needs no Idempotency-Key: hiding an organization that is already hidden answers 200 with the existing record and its original `hidden_at`, changes nothing, and writes no history record. There is one record per candidate and organization.
*
* Anti-enumeration: an organization that does not exist and an organization that the candidate cannot see answer the same 404 not_found, with the same body and without a timing or an error code that tells them apart, so the operation is not a way to ask whether an identifier belongs to an organization. The candidate can see an organization that has sent them an invitation, and the organizations that a candidate lookup will list (planned; see the open questions of the contract). The response names the organization only after that check, with its current name. The identifiers are random, the general rate limit applies and can answer 429 with Retry-After before any check, and the record never reveals to an organization that a candidate hides it.
*
* A candidate hides at most 1000 organizations; hiding one more answers 409 state_conflict with the entry `{in: path, pointer: /org_id, code: limit_reached}` in `errors`, which tells it apart from other conflicts, and changes nothing, and a repeat of an existing hiding is never refused for the limit.
*
* Hiding an organization that holds an active contact grant of the candidate revokes that grant with the reason `visibility_closed` in the same transaction (planned together with the invitation operations). Lifting the hiding never reopens a grant.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the path (400), account scenario (403 forbidden for an employer), the organization and its visibility to the candidate (404 not_found), then the repeat (200), then the limit (409 state_conflict). Like every visibility change, hiding needs a verified email (a usecase requirement).
* @summary Hide the candidate profile from one organization.
*/
export const hideOrganization = async (orgId: string, options?: Parameters<typeof apiRequest>[1]): Promise<HiddenOrganization> => {
return apiRequest<HiddenOrganization>(getHideOrganizationUrl(orgId),
{
...options,
method: 'PUT'
}
);}
export const getHideOrganizationMutationKey = () => ['hideOrganization'] as const;
export const getHideOrganizationMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof hideOrganization>>, TError,HideOrganizationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof hideOrganization>>, TError,HideOrganizationMutationVariables, TContext> => {
const mutationKey = getHideOrganizationMutationKey();
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof hideOrganization>>, HideOrganizationMutationVariables> = (props) => {
const {orgId} = props ?? {};
return hideOrganization(orgId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type HideOrganizationMutationResult = NonNullable<Awaited<ReturnType<typeof hideOrganization>>>
export type HideOrganizationMutationError = ErrorType<Problem>
export type HideOrganizationMutationVariables = {orgId: string}
/**
* @summary Hide the candidate profile from one organization.
*/
export const useHideOrganization = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof hideOrganization>>, TError,HideOrganizationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof hideOrganization>>,
TError,
HideOrganizationMutationVariables,
TContext
> => {
return useMutation(getHideOrganizationMutationOptions(options), queryClient);
}
export const getUnhideOrganizationUrl = (orgId: string,) => {
return `/api/v1/me/privacy/hidden-organizations/${orgId}`
}
/**
* Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. Deletes the hiding record of the candidate for the organization in the path. The request is idempotent: it answers 204 whether the organization was hidden, was not hidden, or does not exist, so the operation reveals nothing about the organization, and a repeat after a lost response succeeds. The record is deleted, the settings history keeps the event `organization_unhidden` only when a record was deleted.
*
* Lifting the hiding makes the candidate readable by that organization again only if the profile is published and the organization otherwise may read it. It changes neither the C2 consent, nor the publication, nor the search status, and it never reopens a contact grant that the hiding closed.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the path (400), account scenario (403 forbidden for an employer), then the deletion (204).
* @summary Lift the hiding of the candidate profile from one organization.
*/
export const unhideOrganization = async (orgId: string, options?: Parameters<typeof apiRequest>[1]): Promise<void> => {
return apiRequest<void>(getUnhideOrganizationUrl(orgId),
{
...options,
method: 'DELETE'
}
);}
export const getUnhideOrganizationMutationKey = () => ['unhideOrganization'] as const;
export const getUnhideOrganizationMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof unhideOrganization>>, TError,UnhideOrganizationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof unhideOrganization>>, TError,UnhideOrganizationMutationVariables, TContext> => {
const mutationKey = getUnhideOrganizationMutationKey();
const {mutation: mutationOptions, request: requestOptions} = options ?
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
options
: {...options, mutation: {...options.mutation, mutationKey}}
: {mutation: { mutationKey, }, request: undefined};
const mutationFn: MutationFunction<Awaited<ReturnType<typeof unhideOrganization>>, UnhideOrganizationMutationVariables> = (props) => {
const {orgId} = props ?? {};
return unhideOrganization(orgId,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type UnhideOrganizationMutationResult = NonNullable<Awaited<ReturnType<typeof unhideOrganization>>>
export type UnhideOrganizationMutationError = ErrorType<Problem>
export type UnhideOrganizationMutationVariables = {orgId: string}
/**
* @summary Lift the hiding of the candidate profile from one organization.
*/
export const useUnhideOrganization = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof unhideOrganization>>, TError,UnhideOrganizationMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof unhideOrganization>>,
TError,
UnhideOrganizationMutationVariables,
TContext
> => {
return useMutation(getUnhideOrganizationMutationOptions(options), queryClient);
}
export const getListMyPrivacyHistoryUrl = (params?: ListMyPrivacyHistoryParams,) => {
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 ? `/api/v1/me/privacy/history?${stringifiedParams}` : `/api/v1/me/privacy/history`
}
/**
* Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only the caller's own records. Returns a page of the settings history, newest first with the event identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
*
* The history is append-only evidence of what the candidate published, hid, and announced, and when. A publication event keeps the published fields and the C2 record behind them, which is what the consent ledger deliberately does not carry (the C2 record proves the consent to the text, not the field set). A revocation of C2 and a lapse of the search status are computed and are not events here; the consent history shows the revocation. The history never contains a profile value.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
* @summary List the changes of the visibility settings of the current candidate.
*/
export const listMyPrivacyHistory = async (params?: ListMyPrivacyHistoryParams, options?: Parameters<typeof apiRequest>[1]): Promise<PrivacyEventList> => {
return apiRequest<PrivacyEventList>(getListMyPrivacyHistoryUrl(params),
{
...options,
method: 'GET'
}
);}
export const getListMyPrivacyHistoryQueryKey = (params?: ListMyPrivacyHistoryParams,) => {
return [
`/api/v1/me/privacy/history`, ...(params ? [params] : [])
] as const;
}
export const getListMyPrivacyHistoryQueryOptions = <TData = Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError = ErrorType<Problem>>(params?: ListMyPrivacyHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getListMyPrivacyHistoryQueryKey(params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMyPrivacyHistory>>> = ({ signal }) => listMyPrivacyHistory(params, { signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type ListMyPrivacyHistoryQueryResult = NonNullable<Awaited<ReturnType<typeof listMyPrivacyHistory>>>
export type ListMyPrivacyHistoryQueryError = ErrorType<Problem>
export function useListMyPrivacyHistory<TData = Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError = ErrorType<Problem>>(
params: undefined | ListMyPrivacyHistoryParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyPrivacyHistory>>,
TError,
Awaited<ReturnType<typeof listMyPrivacyHistory>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyPrivacyHistory<TData = Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError = ErrorType<Problem>>(
params?: ListMyPrivacyHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyPrivacyHistory>>,
TError,
Awaited<ReturnType<typeof listMyPrivacyHistory>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyPrivacyHistory<TData = Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError = ErrorType<Problem>>(
params?: ListMyPrivacyHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary List the changes of the visibility settings of the current candidate.
*/
export function useListMyPrivacyHistory<TData = Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError = ErrorType<Problem>>(
params?: ListMyPrivacyHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyPrivacyHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getListMyPrivacyHistoryQueryOptions(params,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getListMyCardAccessHistoryUrl = (params?: ListMyCardAccessHistoryParams,) => {
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 ? `/api/v1/me/privacy/access-history?${stringifiedParams}` : `/api/v1/me/privacy/access-history`
}
/**
* Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only accesses to the caller's own card. Returns a page, newest first with the record identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
*
* An access is a view of the anonymous card by an organization (`card_viewed`) or a read of the contacts through an active contact grant (`contact_read`). Reading the history is not an access and writes nothing. A view of the card by an organization that has no invitation relation with the candidate carries `organization` null, so the candidate sees that the card was viewed without learning a company that they cannot otherwise see; a contact read always names the organization, because the candidate accepted its invitation. The entries carry no search query, filter, or ranking of the organization, and no organization the candidate hides ever appears as a viewer, because a hidden organization cannot read the card.
*
* The storage of accesses is planned with the card and contact operations of the organization side (anonymous card reads and contact reads under the invitation contract); until then the operation answers 501 not_implemented after the session and request checks.
*
* A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
* @summary List the accesses of organizations to the card of the current candidate.
*/
export const listMyCardAccessHistory = async (params?: ListMyCardAccessHistoryParams, options?: Parameters<typeof apiRequest>[1]): Promise<CardAccessList> => {
return apiRequest<CardAccessList>(getListMyCardAccessHistoryUrl(params),
{
...options,
method: 'GET'
}
);}
export const getListMyCardAccessHistoryQueryKey = (params?: ListMyCardAccessHistoryParams,) => {
return [
`/api/v1/me/privacy/access-history`, ...(params ? [params] : [])
] as const;
}
export const getListMyCardAccessHistoryQueryOptions = <TData = Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError = ErrorType<Problem>>(params?: ListMyCardAccessHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getListMyCardAccessHistoryQueryKey(params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMyCardAccessHistory>>> = ({ signal }) => listMyCardAccessHistory(params, { signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type ListMyCardAccessHistoryQueryResult = NonNullable<Awaited<ReturnType<typeof listMyCardAccessHistory>>>
export type ListMyCardAccessHistoryQueryError = ErrorType<Problem>
export function useListMyCardAccessHistory<TData = Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError = ErrorType<Problem>>(
params: undefined | ListMyCardAccessHistoryParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyCardAccessHistory>>,
TError,
Awaited<ReturnType<typeof listMyCardAccessHistory>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyCardAccessHistory<TData = Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError = ErrorType<Problem>>(
params?: ListMyCardAccessHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyCardAccessHistory>>,
TError,
Awaited<ReturnType<typeof listMyCardAccessHistory>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyCardAccessHistory<TData = Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError = ErrorType<Problem>>(
params?: ListMyCardAccessHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary List the accesses of organizations to the card of the current candidate.
*/
export function useListMyCardAccessHistory<TData = Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError = ErrorType<Problem>>(
params?: ListMyCardAccessHistoryParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyCardAccessHistory>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getListMyCardAccessHistoryQueryOptions(params,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}