feat(api): add employer need contract with requirement versions and recommendations

This commit is contained in:
shira committed 2026-10-06 07:39:05 +03:00
1 parent 3adb0ef9e4
commit a7d5781f2d
95 files changed
+25352 -26

No files matched your search

@@ -3,3 +3,4 @@ export { getCandidateMock } from './candidate/candidate.msw'
export { getCatalogMock } from './catalog/catalog.msw'
export { getHealthMock } from './health/health.msw'
export { getIdentityMock } from './identity/identity.msw'
export { getNeedMock } from './need/need.msw'
@@ -3,3 +3,4 @@ export * from './candidate/candidate';
export * from './catalog/catalog';
export * from './health/health';
export * from './identity/identity';
export * from './need/need';
@@ -0,0 +1,119 @@
/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
import {
faker
} from '@faker-js/faker';
import {
HttpResponse,
http
} from 'msw';
import type {
RequestHandlerOptions
} from 'msw';
import {
CurrencyCode,
GradeCode,
NeedFieldName,
NeedItemStatus,
NeedMissingReason,
NeedMoneyStatus,
NeedReadinessStatus,
NeedRecommendationStatus,
NeedSupplyBand,
NeedValueOrigin,
NeedValueStatus,
SalaryPeriod,
SalaryTaxBasis,
SpecializationCode,
WorkFormat
} from '../../schemas';
import type {
Need,
NeedList,
NeedValueSource,
SalaryRange
} from '../../schemas';
export const getListOrganizationNeedsResponseNeedValueSourceMock = (overrideResponse: Partial<NeedValueSource> = {}): NeedValueSource => ({...{origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}, ...overrideResponse});
export const getListOrganizationNeedsResponseMock = (overrideResponse: Partial<Extract<NeedList, object>> = {}): NeedList => ({items: Array.from({ length: faker.number.int({min: 1, max: 100}) }, (_, i) => i + 1).map(() => ({id: faker.string.uuid(), vacancy_id: faker.helpers.arrayElement([faker.string.uuid(), null]), title: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), version: faker.number.int({min: 1}), specialization: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(SpecializationCode)),null,]), source: faker.helpers.arrayElement([{...getListOrganizationNeedsResponseNeedValueSourceMock()},null,])}, grade: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(GradeCode)),null,]), source: faker.helpers.arrayElement([{...getListOrganizationNeedsResponseNeedValueSourceMock()},null,])}, readiness: {status: faker.helpers.arrayElement(Object.values(NeedReadinessStatus)), missing_fields: Array.from({ length: faker.number.int({min: 1, max: 9}) }, (_, i) => i + 1).map(() => ({field: faker.helpers.arrayElement(Object.values(NeedFieldName)), reason: faker.helpers.arrayElement(Object.values(NeedMissingReason)), question: faker.string.alpha({length: {min: 1, max: 300}})}))}, created_at: faker.date.past().toISOString().slice(0, 19) + 'Z', updated_at: faker.date.past().toISOString().slice(0, 19) + 'Z'})), page: {has_more: faker.datatype.boolean(), next_cursor: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9_-]+$"), null])}, ...overrideResponse})
export const getCreateOrganizationNeedResponseNeedValueSourceMock = (overrideResponse: Partial<NeedValueSource> = {}): NeedValueSource => ({...{origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}, ...overrideResponse});
export const getCreateOrganizationNeedResponseSalaryRangeMock = (overrideResponse: Partial<SalaryRange> = {}): SalaryRange => ({...{salary_from: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), salary_to: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), currency: faker.helpers.arrayElement(Object.values(CurrencyCode)), period: faker.helpers.arrayElement(Object.values(SalaryPeriod)), tax_basis: faker.helpers.arrayElement(Object.values(SalaryTaxBasis))}, ...overrideResponse});
export const getCreateOrganizationNeedResponseMock = (overrideResponse: Partial<Extract<Need, object>> = {}): Need => ({id: faker.string.uuid(), organization_id: faker.string.uuid(), vacancy_id: faker.helpers.arrayElement([faker.string.uuid(), null]), title: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), source_text: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 10000}}),null,]), version: faker.number.int({min: 1}), requirements_version: faker.number.int({min: 1}), requirements: {specialization: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(SpecializationCode)),null,]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}, grade: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(GradeCode)),null,]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}, required_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), desired_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), tasks: Array.from({ length: faker.number.int({min: 1, max: 20}) }, (_, i) => i + 1).map(() => ({text: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), domain: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}, work_formats: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElements(Object.values(WorkFormat)), null]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}, location: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}, salary: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseSalaryRangeMock()},null,]), source: faker.helpers.arrayElement([{...getCreateOrganizationNeedResponseNeedValueSourceMock()},null,])}}, readiness: {status: faker.helpers.arrayElement(Object.values(NeedReadinessStatus)), missing_fields: Array.from({ length: faker.number.int({min: 1, max: 9}) }, (_, i) => i + 1).map(() => ({field: faker.helpers.arrayElement(Object.values(NeedFieldName)), reason: faker.helpers.arrayElement(Object.values(NeedMissingReason)), question: faker.string.alpha({length: {min: 1, max: 300}})}))}, recommendations: {status: faker.helpers.arrayElement(Object.values(NeedRecommendationStatus)), requirements_version: faker.number.int({min: 1}), policy_version: faker.helpers.arrayElement([faker.number.int({min: 1}), null]), algorithm_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,]), computed_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), categories: Array.from({ Line truncated
export const getGetOrganizationNeedResponseNeedValueSourceMock = (overrideResponse: Partial<NeedValueSource> = {}): NeedValueSource => ({...{origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}, ...overrideResponse});
export const getGetOrganizationNeedResponseSalaryRangeMock = (overrideResponse: Partial<SalaryRange> = {}): SalaryRange => ({...{salary_from: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), salary_to: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), currency: faker.helpers.arrayElement(Object.values(CurrencyCode)), period: faker.helpers.arrayElement(Object.values(SalaryPeriod)), tax_basis: faker.helpers.arrayElement(Object.values(SalaryTaxBasis))}, ...overrideResponse});
export const getGetOrganizationNeedResponseMock = (overrideResponse: Partial<Extract<Need, object>> = {}): Need => ({id: faker.string.uuid(), organization_id: faker.string.uuid(), vacancy_id: faker.helpers.arrayElement([faker.string.uuid(), null]), title: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), source_text: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 10000}}),null,]), version: faker.number.int({min: 1}), requirements_version: faker.number.int({min: 1}), requirements: {specialization: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(SpecializationCode)),null,]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}, grade: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(GradeCode)),null,]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}, required_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), desired_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), tasks: Array.from({ length: faker.number.int({min: 1, max: 20}) }, (_, i) => i + 1).map(() => ({text: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), domain: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}, work_formats: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElements(Object.values(WorkFormat)), null]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}, location: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}, salary: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseSalaryRangeMock()},null,]), source: faker.helpers.arrayElement([{...getGetOrganizationNeedResponseNeedValueSourceMock()},null,])}}, readiness: {status: faker.helpers.arrayElement(Object.values(NeedReadinessStatus)), missing_fields: Array.from({ length: faker.number.int({min: 1, max: 9}) }, (_, i) => i + 1).map(() => ({field: faker.helpers.arrayElement(Object.values(NeedFieldName)), reason: faker.helpers.arrayElement(Object.values(NeedMissingReason)), question: faker.string.alpha({length: {min: 1, max: 300}})}))}, recommendations: {status: faker.helpers.arrayElement(Object.values(NeedRecommendationStatus)), requirements_version: faker.number.int({min: 1}), policy_version: faker.helpers.arrayElement([faker.number.int({min: 1}), null]), algorithm_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,]), computed_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), categories: Array.from({ length: faker.number.intLine truncated
export const getUpdateOrganizationNeedResponseNeedValueSourceMock = (overrideResponse: Partial<NeedValueSource> = {}): NeedValueSource => ({...{origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}, ...overrideResponse});
export const getUpdateOrganizationNeedResponseSalaryRangeMock = (overrideResponse: Partial<SalaryRange> = {}): SalaryRange => ({...{salary_from: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), salary_to: faker.number.int({min: 1000, max: 100000000, multipleOf: 1000}), currency: faker.helpers.arrayElement(Object.values(CurrencyCode)), period: faker.helpers.arrayElement(Object.values(SalaryPeriod)), tax_basis: faker.helpers.arrayElement(Object.values(SalaryTaxBasis))}, ...overrideResponse});
export const getUpdateOrganizationNeedResponseMock = (overrideResponse: Partial<Extract<Need, object>> = {}): Need => ({id: faker.string.uuid(), organization_id: faker.string.uuid(), vacancy_id: faker.helpers.arrayElement([faker.string.uuid(), null]), title: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), source_text: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 10000}}),null,]), version: faker.number.int({min: 1}), requirements_version: faker.number.int({min: 1}), requirements: {specialization: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(SpecializationCode)),null,]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}, grade: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(GradeCode)),null,]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}, required_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), desired_skills: Array.from({ length: faker.number.int({min: 1, max: 30}) }, (_, i) => i + 1).map(() => ({name: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), taxonomy_code: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[a-z0-9][a-z0-9_.+#-]*$"),null,]), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), tasks: Array.from({ length: faker.number.int({min: 1, max: 20}) }, (_, i) => i + 1).map(() => ({text: faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"), status: faker.helpers.arrayElement(Object.values(NeedItemStatus)), source: {origin: faker.helpers.arrayElement(Object.values(NeedValueOrigin)), quote: faker.helpers.arrayElement([faker.string.alpha({length: {min: 1, max: 300}}),null,]), extracted_in_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,]), extraction_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,])}})), domain: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}, work_formats: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.arrayElements(Object.values(WorkFormat)), null]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}, location: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"),null,]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}, salary: {status: faker.helpers.arrayElement(Object.values(NeedValueStatus)), value: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseSalaryRangeMock()},null,]), source: faker.helpers.arrayElement([{...getUpdateOrganizationNeedResponseNeedValueSourceMock()},null,])}}, readiness: {status: faker.helpers.arrayElement(Object.values(NeedReadinessStatus)), missing_fields: Array.from({ length: faker.number.int({min: 1, max: 9}) }, (_, i) => i + 1).map(() => ({field: faker.helpers.arrayElement(Object.values(NeedFieldName)), reason: faker.helpers.arrayElement(Object.values(NeedMissingReason)), question: faker.string.alpha({length: {min: 1, max: 300}})}))}, recommendations: {status: faker.helpers.arrayElement(Object.values(NeedRecommendationStatus)), requirements_version: faker.number.int({min: 1}), policy_version: faker.helpers.arrayElement([faker.number.int({min: 1}), null]), algorithm_version: faker.helpers.arrayElement([faker.helpers.fromRegExp("^[A-Za-z0-9._-]+$"),null,]), computed_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), categories: Array.from({ Line truncated
export const getListOrganizationNeedsMockHandler = (overrideResponse?: NeedList | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<NeedList> | NeedList), options?: RequestHandlerOptions) => {
return http.get('*/api/v1/organizations/:orgId/needs', async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getListOrganizationNeedsResponseMock(),
{ status: 200
})
}, options)
}
export const getCreateOrganizationNeedMockHandler = (overrideResponse?: Need | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<Need> | Need), options?: RequestHandlerOptions) => {
return http.post('*/api/v1/organizations/:orgId/needs', async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getCreateOrganizationNeedResponseMock(),
{ status: 201
})
}, options)
}
export const getGetOrganizationNeedMockHandler = (overrideResponse?: Need | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<Need> | Need), options?: RequestHandlerOptions) => {
return http.get('*/api/v1/organizations/:orgId/needs/:needId', async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getGetOrganizationNeedResponseMock(),
{ status: 200
})
}, options)
}
export const getUpdateOrganizationNeedMockHandler = (overrideResponse?: Need | ((info: Parameters<Parameters<typeof http.patch>[1]>[0]) => Promise<Need> | Need), options?: RequestHandlerOptions) => {
return http.patch('*/api/v1/organizations/:orgId/needs/:needId', async (info: Parameters<Parameters<typeof http.patch>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getUpdateOrganizationNeedResponseMock(),
{ status: 200
})
}, options)
}
export const getNeedMock = () => [
getListOrganizationNeedsMockHandler(),
getCreateOrganizationNeedMockHandler(),
getGetOrganizationNeedMockHandler(),
getUpdateOrganizationNeedMockHandler()
]
@@ -0,0 +1,503 @@
/**
* 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 {
CreateOrganizationNeedHeaders,
ListOrganizationNeedsParams,
Need,
NeedCreate,
NeedList,
NeedUpdate,
Problem
} 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 getListOrganizationNeedsUrl = (orgId: string,
params?: ListOrganizationNeedsParams,) => {
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/organizations/${orgId}/needs?${stringifiedParams}` : `/api/v1/organizations/${orgId}/needs`
}
/**
* Requires the session cookie of an employer account with an active membership in `org_id`. The organization and the role come from the membership that the server holds for the session account, never from the request. In the MVP only the owner of the organization works with needs; the other roles of the PRD FR07 matrix (recruiter, hiring manager and technical expert for assigned needs) are planned and change no field of this contract. The list holds only the needs that the role may read.
*
* Returns a page of need summaries, newest first by creation time with the identifier as the tie-breaker, with cursor pagination. A summary has the current version, the target specialization and grade with their confirmation state, and the readiness; GetOrganizationNeed returns the requirements and the recommendations.
*
* Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an account without an active membership in the organization and an unknown organization both answer 404 not_found, so organizations cannot be enumerated; a member whose role does not allow reading needs answers 403 forbidden. A malformed `org_id`, `limit`, or `cursor` answers 400 validation_failed.
* @summary List the needs of an organization.
*/
export const listOrganizationNeeds = async (orgId: string,
params?: ListOrganizationNeedsParams, options?: Parameters<typeof apiRequest>[1]): Promise<NeedList> => {
return apiRequest<NeedList>(getListOrganizationNeedsUrl(orgId,params),
{
...options,
method: 'GET'
}
);}
export const getListOrganizationNeedsQueryKey = (orgId: string,
params?: ListOrganizationNeedsParams,) => {
return [
`/api/v1/organizations/${orgId}/needs`, ...(params ? [params] : [])
] as const;
}
export const getListOrganizationNeedsQueryOptions = <TData = Awaited<ReturnType<typeof listOrganizationNeeds>>, TError = ErrorType<Problem>>(orgId: string,
params?: ListOrganizationNeedsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getListOrganizationNeedsQueryKey(orgId,params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof listOrganizationNeeds>>> = ({ signal }) => listOrganizationNeeds(orgId,params, { signal, ...requestOptions });
return { queryKey, queryFn, enabled: orgId !== null && orgId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type ListOrganizationNeedsQueryResult = NonNullable<Awaited<ReturnType<typeof listOrganizationNeeds>>>
export type ListOrganizationNeedsQueryError = ErrorType<Problem>
export function useListOrganizationNeeds<TData = Awaited<ReturnType<typeof listOrganizationNeeds>>, TError = ErrorType<Problem>>(
orgId: string,
params: undefined | ListOrganizationNeedsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof listOrganizationNeeds>>,
TError,
Awaited<ReturnType<typeof listOrganizationNeeds>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListOrganizationNeeds<TData = Awaited<ReturnType<typeof listOrganizationNeeds>>, TError = ErrorType<Problem>>(
orgId: string,
params?: ListOrganizationNeedsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof listOrganizationNeeds>>,
TError,
Awaited<ReturnType<typeof listOrganizationNeeds>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListOrganizationNeeds<TData = Awaited<ReturnType<typeof listOrganizationNeeds>>, TError = ErrorType<Problem>>(
orgId: string,
params?: ListOrganizationNeedsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary List the needs of an organization.
*/
export function useListOrganizationNeeds<TData = Awaited<ReturnType<typeof listOrganizationNeeds>>, TError = ErrorType<Problem>>(
orgId: string,
params?: ListOrganizationNeedsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listOrganizationNeeds>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getListOrganizationNeedsQueryOptions(orgId,params,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getCreateOrganizationNeedUrl = (orgId: string,) => {
return `/api/v1/organizations/${orgId}/needs`
}
/**
* Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and an Idempotency-Key. The organization comes from the path and the server-side membership; the body has no organization, membership, or role field. In the MVP only the owner of the organization may create a need; the other roles of PRD FR07 are planned.
*
* A need does not require a vacancy: `vacancy_id` is optional and nullable. When it is given, it must name a vacancy of the same organization; until vacancies exist in the contract, any vacancy identifier answers 400 with the pointer `/vacancy_id`, the same for an unknown vacancy and one of another organization.
*
* Only `title` is required. A field is sent as a decision `{value, status}` and a list item as `{name or text, status}`; on creation the status must be `confirmed`, and the value becomes a confirmed manual value. When `source_text` is given, the server extracts suggestions for the absent fields with deterministic rules and a dictionary before it answers, so creation works while the ML service is disabled; every suggestion has the status `extracted`, the origin extracted_from_text, a quote where the extractor found one, and the extractor version, and it waits for a member to confirm it. A field that the text does not state stays `unknown` with null value and source; the server never guesses a grade, a format, or a salary. ML suggestions with quotes are planned as an asynchronous addition that creates a new version and never overwrites a confirmed value.
*
* The need is saved even when critical fields are missing: the response is 201 with version 1, and `readiness.missing_fields` names each critical field without a confirmed value with a specific question. `recommendations` is computed by the server from the confirmed requirements only; the request cannot set a recommendation, its score, or its components. Creating a need never contacts a candidate or sends an invitation.
*
* Salary limit: setting a salary range counts against a limit shared by the whole organization, every member and every need, on creation as on a change: at most three range settings a day (PRD FR13, planned in TASK-211). Over the limit the server answers 429 with Retry-After and creates nothing. After five settings within seven days the money component of the recommendations is `withheld` for seven days. The limit keeps an organization from probing hidden candidate minimums with new needs instead of edits; repeated range changes also feed the private risk signals of TASK-319.
*
* Idempotency: a retry with the same key and body within 24 hours replays the stored 201 and creates nothing, so a lost response never creates a second need. A different body with the same key answers 422 idempotency_key_reused. 400 is never stored, so a corrected retry is evaluated again.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for a candidate), membership (404 not_found) and role (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay), domain rules (400 with a pointer: `/salary/value/salary_to` for a range whose lower bound is not below the upper one or whose width is outside 10-40%, `/required_skills/1/name` for a repeated skill, `/grade/status` or `/required_skills/0/status` for `extracted`, which a new need cannot have, or `/vacancy_id`), then the salary limit (429). The schema already rejects unknown fields such as `rec_score`, `members`, or `candidate_minimum`, a field sent as a bare value instead of `{value, status}`, a salary bound that is not a positive multiple of 1000, and an unknown currency, period, or tax basis. The general rate limit can answer 429 with Retry-After before any check. 429 is never stored.
* @summary Create a need of an organization from a form, a text, or both.
*/
export const createOrganizationNeed = async (orgId: string,
needCreate: NeedCreate,
headers: CreateOrganizationNeedHeaders, options?: Parameters<typeof apiRequest>[1]): Promise<Need> => {
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<Need>(getCreateOrganizationNeedUrl(orgId),
{
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json',...headers, ...getHeaders(options?.headers) },
body: JSON.stringify(needCreate)
}
);}
export const getCreateOrganizationNeedMutationKey = () => ['createOrganizationNeed'] as const;
export const getCreateOrganizationNeedMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createOrganizationNeed>>, TError,CreateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof createOrganizationNeed>>, TError,CreateOrganizationNeedMutationVariables, TContext> => {
const mutationKey = getCreateOrganizationNeedMutationKey();
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 createOrganizationNeed>>, CreateOrganizationNeedMutationVariables> = (props) => {
const {orgId,data,headers} = props ?? {};
return createOrganizationNeed(orgId,data,headers,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type CreateOrganizationNeedMutationResult = NonNullable<Awaited<ReturnType<typeof createOrganizationNeed>>>
export type CreateOrganizationNeedMutationBody = NeedCreate
export type CreateOrganizationNeedMutationError = ErrorType<Problem>
export type CreateOrganizationNeedMutationVariables = {orgId: string;data: NeedCreate;headers: CreateOrganizationNeedHeaders}
/**
* @summary Create a need of an organization from a form, a text, or both.
*/
export const useCreateOrganizationNeed = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createOrganizationNeed>>, TError,CreateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof createOrganizationNeed>>,
TError,
CreateOrganizationNeedMutationVariables,
TContext
> => {
return useMutation(getCreateOrganizationNeedMutationOptions(options), queryClient);
}
export const getGetOrganizationNeedUrl = (orgId: string,
needId: string,) => {
return `/api/v1/organizations/${orgId}/needs/${needId}`
}
/**
* Requires the session cookie of an employer account with an active membership in `org_id`. The organization and the role come from the server-side membership, never from the request. In the MVP only the owner of the organization reads needs; the other roles of PRD FR07 are planned.
*
* Returns the current version of the need: `version`, the requirements with the confirmation state and provenance of each field (`status`, and `source` with the origin, the quote, the version whose text the quote belongs to, and the extractor version), the readiness with `missing_fields`, and the category recommendations of the server. A field with status `unknown` has null value and source; an `extracted` value is a suggestion that waits for confirmation and never feeds search or recommendations.
*
* Versions: every committed change creates a new immutable `version`, and this operation always returns the latest one. `requirements_version` is the version in which the confirmed requirements were last changed; a change of the title, the vacancy link, the text, or suggestions only keeps it. Search runs, selection snapshots, and invitations refer to a need by its identifier and `requirements_version`, so they keep the requirements they used, and only a new `requirements_version` calls for a new selection snapshot. Reading and comparing earlier versions (PRD FR10) are planned as separate operations that return the same NeedRequirementSet for a given version; they add no field here.
*
* Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an account without an active membership in the organization, an unknown organization, an unknown need, and a need of another organization all answer 404 not_found, so identifiers cannot be probed; a member whose role does not allow reading the need answers 403 forbidden. An `org_id` or `need_id` that is not a UUID answers 400 validation_failed with the path pointer.
* @summary Read the current version of a need of an organization.
*/
export const getOrganizationNeed = async (orgId: string,
needId: string, options?: Parameters<typeof apiRequest>[1]): Promise<Need> => {
return apiRequest<Need>(getGetOrganizationNeedUrl(orgId,needId),
{
...options,
method: 'GET'
}
);}
export const getGetOrganizationNeedQueryKey = (orgId: string,
needId: string,) => {
return [
`/api/v1/organizations/${orgId}/needs/${needId}`
] as const;
}
export const getGetOrganizationNeedQueryOptions = <TData = Awaited<ReturnType<typeof getOrganizationNeed>>, TError = ErrorType<Problem>>(orgId: string,
needId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getGetOrganizationNeedQueryKey(orgId,needId);
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganizationNeed>>> = ({ signal }) => getOrganizationNeed(orgId,needId, { signal, ...requestOptions });
return { queryKey, queryFn, enabled: orgId !== null && orgId !== undefined && needId !== null && needId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type GetOrganizationNeedQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganizationNeed>>>
export type GetOrganizationNeedQueryError = ErrorType<Problem>
export function useGetOrganizationNeed<TData = Awaited<ReturnType<typeof getOrganizationNeed>>, TError = ErrorType<Problem>>(
orgId: string,
needId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getOrganizationNeed>>,
TError,
Awaited<ReturnType<typeof getOrganizationNeed>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetOrganizationNeed<TData = Awaited<ReturnType<typeof getOrganizationNeed>>, TError = ErrorType<Problem>>(
orgId: string,
needId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof getOrganizationNeed>>,
TError,
Awaited<ReturnType<typeof getOrganizationNeed>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetOrganizationNeed<TData = Awaited<ReturnType<typeof getOrganizationNeed>>, TError = ErrorType<Problem>>(
orgId: string,
needId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Read the current version of a need of an organization.
*/
export function useGetOrganizationNeed<TData = Awaited<ReturnType<typeof getOrganizationNeed>>, TError = ErrorType<Problem>>(
orgId: string,
needId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganizationNeed>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getGetOrganizationNeedQueryOptions(orgId,needId,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
export const getUpdateOrganizationNeedUrl = (orgId: string,
needId: string,) => {
return `/api/v1/organizations/${orgId}/needs/${needId}`
}
/**
* Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The organization and the role come from the server-side membership; the body has no organization, membership, or role field. In the MVP only the owner of the organization changes needs; the technical expert, who may refine the requirements of assigned needs under PRD FR07, is planned.
*
* Merge rules: the body is `application/json` with explicit field replacement, not JSON Merge Patch. Each field present replaces that field as a whole and an absent field stays unchanged; a field decision and each list are replaced entirely and never merged. This keeps every field one optional value in the generated server and client, without nested partial updates.
*
* Each requirement field is sent as a decision `{value, status}` and each list item as `{name or text, status}`, so confirmation is always explicit:
* - Confirm a suggestion: send its stored value with `confirmed`. It keeps its origin and quote.
* - Keep a suggestion open: send its stored value with `extracted`, or leave the field out. `extracted` with any other value, or for a field or item without a stored suggestion, answers 400 with the pointer of that `status`, for example `/grade/status` or `/required_skills/2/status`. A client that sends back an unchanged form therefore never confirms a suggestion by accident.
* - Change: send another value with `confirmed`. It becomes a confirmed manual value, and its quote is dropped.
* - Delete: send null for a nullable field, which makes it `unknown` (or unlinks `vacancy_id`), or leave the item out of a skill or task list, which deletes it. An empty skill or task list deletes every item; a list sent as null answers 400. A deleted requirement really changes the requirements that search uses, not only an explanation, and a deleted suggestion is not proposed again by a later extraction.
* - Text: a different `source_text` extracts again. New suggestions replace only the `extracted` values and items of the fields not named in the body; confirmed values are never overwritten, and a suggested skill whose name is already in either skill list is skipped. Null removes the text and keeps every value.
*
* Versions: every committed change creates version `expected_version + 1` as an immutable snapshot and answers 200 with it. `requirements_version` becomes the new version only when a confirmed requirement was confirmed, changed, or removed. `expected_version` is the `version` the client read; when it is not current, the server answers 412 version_conflict and changes nothing, and the client reads the need again and reapplies its unsaved edits. The version travels in the body rather than in If-Match because the generated client cannot read the ETag response header yet, as for the questionnaire. Concurrent changes therefore never overwrite each other silently.
*
* The operation needs no Idempotency-Key: a body that changes nothing when applied to the current version, such as a retry of a change that already succeeded, keeps the version and answers 200 with the current need even when `expected_version` is older. An incomplete need is a valid result; `readiness.missing_fields` tells what remains.
*
* Salary limit: the recommendations aggregate candidates' minimums against the upper bound, so setting or changing a confirmed salary range counts against a limit shared by the whole organization, every member and every need, together with ranges set on creation: at most three a day (PRD FR13, planned in TASK-211). Over the limit the server answers 429 with Retry-After and changes nothing. After five settings within seven days the money component is `withheld` for seven days. Repeated range changes also feed the private risk signals of TASK-319.
*
* Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for a candidate), membership (404 not_found) and role (403 forbidden), the need (404 not_found), a body that changes nothing (200), the version (412), domain rules (400 with a pointer such as `/salary/value/salary_to` for a range whose lower bound is not below the upper one or whose width is outside 10-40%, `/desired_skills/0/name` for a skill that is also in the required list, `/grade/status` or `/required_skills/2/status` for `extracted` with a value that is not the stored suggestion, or `/vacancy_id`), then the salary change limit (429). The schema rejects a missing or non-positive `expected_version`, unknown fields such as `rec_score`, `members`, `candidate_minimum`, or `version`, a field sent as a bare value instead of `{value, status}`, a list sent as null, a salary bound that is not a positive multiple of 1000, and an unknown currency, period, or tax basis.
* @summary Confirm, change, or delete requirements of a need.
*/
export const updateOrganizationNeed = async (orgId: string,
needId: string,
needUpdate: NeedUpdate, options?: Parameters<typeof apiRequest>[1]): Promise<Need> => {
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<Need>(getUpdateOrganizationNeedUrl(orgId,needId),
{
...options,
method: 'PATCH',
headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
body: JSON.stringify(needUpdate)
}
);}
export const getUpdateOrganizationNeedMutationKey = () => ['updateOrganizationNeed'] as const;
export const getUpdateOrganizationNeedMutationOptions = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateOrganizationNeed>>, TError,UpdateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
): UseMutationOptions<Awaited<ReturnType<typeof updateOrganizationNeed>>, TError,UpdateOrganizationNeedMutationVariables, TContext> => {
const mutationKey = getUpdateOrganizationNeedMutationKey();
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 updateOrganizationNeed>>, UpdateOrganizationNeedMutationVariables> = (props) => {
const {orgId,needId,data} = props ?? {};
return updateOrganizationNeed(orgId,needId,data,requestOptions)
}
return { mutationFn, ...mutationOptions }}
export type UpdateOrganizationNeedMutationResult = NonNullable<Awaited<ReturnType<typeof updateOrganizationNeed>>>
export type UpdateOrganizationNeedMutationBody = NeedUpdate
export type UpdateOrganizationNeedMutationError = ErrorType<Problem>
export type UpdateOrganizationNeedMutationVariables = {orgId: string;needId: string;data: NeedUpdate}
/**
* @summary Confirm, change, or delete requirements of a need.
*/
export const useUpdateOrganizationNeed = <TError = ErrorType<Problem>,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateOrganizationNeed>>, TError,UpdateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof updateOrganizationNeed>>,
TError,
UpdateOrganizationNeedMutationVariables,
TContext
> => {
return useMutation(getUpdateOrganizationNeedMutationOptions(options), queryClient);
}