From a7d5781f2d746d4b1f24289747861f88f2418ea2 Mon Sep 17 00:00:00 2001 From: shira Date: Tue, 6 Oct 2026 07:39:05 +0300 Subject: [PATCH] feat(api): add employer need contract with requirement versions and recommendations --- api/README.en.md | 74 +- api/README.md | 74 +- api/core/components/examples.yml | 674 ++ api/core/components/parameters.yml | 25 + api/core/components/responses.yml | 45 + api/core/components/schemas.yml | 912 +++ api/core/components/schemas/need_schemas.yml | 1175 +++ api/core/openapi.bundle.yml | 1844 +++++ api/core/openapi.yml | 124 + api/core/routes/organization_need.yml | 113 + api/core/routes/organization_needs.yml | 109 + .../adapter/primary/http/api/oas_cfg_gen.go | 1 + .../primary/http/api/oas_handlers_gen.go | 1034 +++ .../primary/http/api/oas_interfaces_gen.go | 16 + .../adapter/primary/http/api/oas_json_gen.go | 7251 +++++++++++++++++ .../primary/http/api/oas_operations_gen.go | 4 + .../primary/http/api/oas_parameters_gen.go | 632 ++ .../http/api/oas_request_decoders_gen.go | 158 + .../http/api/oas_response_encoders_gen.go | 432 + .../primary/http/api/oas_router_gen.go | 236 +- .../primary/http/api/oas_schemas_gen.go | 3605 ++++++++ .../primary/http/api/oas_security_gen.go | 6 + .../primary/http/api/oas_server_gen.go | 172 + .../primary/http/api/oas_unimplemented_gen.go | 184 + .../primary/http/api/oas_validators_gen.go | 2982 +++++++ .../adapter/primary/http/router_test.go | 324 + docs/en/ARCHITECTURE.md | 2 +- docs/ru/ARCHITECTURE.md | 2 +- .../src/shared/api/endpoints/index.msw.ts | 1 + frontend/src/shared/api/endpoints/index.ts | 1 + .../src/shared/api/endpoints/need/need.msw.ts | 119 + .../src/shared/api/endpoints/need/need.ts | 503 ++ .../src/shared/api/needs-contract.test.ts | 343 + .../src/shared/api/schemas/candidate/index.ts | 1 - frontend/src/shared/api/schemas/index.ts | 3 +- .../need/createOrganizationNeedBody.zod.ts | 101 + .../need/createOrganizationNeedHeaders.zod.ts | 19 + .../api/schemas/need/currencyCode.zod.ts | 12 + frontend/src/shared/api/schemas/need/index.ts | 65 + .../need/listOrganizationNeedsParams.zod.ts | 23 + .../src/shared/api/schemas/need/need.zod.ts | 301 + .../need/needCategoryRecommendation.zod.ts | 48 + .../need/needCategoryRecommendations.zod.ts | 63 + .../shared/api/schemas/need/needCreate.zod.ts | 101 + .../shared/api/schemas/need/needDomain.zod.ts | 33 + .../api/schemas/need/needDomainInput.zod.ts | 20 + .../api/schemas/need/needDomainName.zod.ts | 17 + .../api/schemas/need/needFieldName.zod.ts | 12 + .../shared/api/schemas/need/needGrade.zod.ts | 29 + .../api/schemas/need/needGradeInput.zod.ts | 15 + .../api/schemas/need/needItemStatus.zod.ts | 12 + .../shared/api/schemas/need/needList.zod.ts | 83 + .../api/schemas/need/needLocation.zod.ts | 33 + .../api/schemas/need/needLocationInput.zod.ts | 20 + .../api/schemas/need/needLocationName.zod.ts | 17 + .../api/schemas/need/needMissingField.zod.ts | 19 + .../api/schemas/need/needMissingReason.zod.ts | 12 + .../api/schemas/need/needMoneyFit.zod.ts | 19 + .../api/schemas/need/needMoneyStatus.zod.ts | 12 + .../schemas/need/needReadinessReport.zod.ts | 24 + .../schemas/need/needReadinessStatus.zod.ts | 12 + .../need/needRecommendationStatus.zod.ts | 12 + .../schemas/need/needRequirementSet.zod.ts | 219 + .../shared/api/schemas/need/needSalary.zod.ts | 43 + .../api/schemas/need/needSalaryInput.zod.ts | 30 + .../shared/api/schemas/need/needSkill.zod.ts | 38 + .../api/schemas/need/needSkillInput.zod.ts | 20 + .../api/schemas/need/needSkillOverlap.zod.ts | 32 + .../api/schemas/need/needSourceQuote.zod.ts | 15 + .../api/schemas/need/needSourceText.zod.ts | 15 + .../schemas/need/needSpecialization.zod.ts | 29 + .../need/needSpecializationInput.zod.ts | 15 + .../api/schemas/need/needSummary.zod.ts | 71 + .../api/schemas/need/needSupplyBand.zod.ts | 12 + .../shared/api/schemas/need/needTask.zod.ts | 33 + .../api/schemas/need/needTaskInput.zod.ts | 20 + .../api/schemas/need/needTaskText.zod.ts | 17 + .../shared/api/schemas/need/needTitle.zod.ts | 17 + .../shared/api/schemas/need/needUpdate.zod.ts | 103 + .../api/schemas/need/needValueOrigin.zod.ts | 12 + .../api/schemas/need/needValueSource.zod.ts | 25 + .../api/schemas/need/needValueStatus.zod.ts | 12 + .../api/schemas/need/needVersion.zod.ts | 14 + .../api/schemas/need/needVersionLabel.zod.ts | 17 + .../api/schemas/need/needWorkFormats.zod.ts | 31 + .../schemas/need/needWorkFormatsInput.zod.ts | 18 + .../api/schemas/{ => need}/pageInfo.zod.ts | 0 .../shared/api/schemas/need/rubAmount.zod.ts | 17 + .../api/schemas/need/salaryPeriod.zod.ts | 12 + .../api/schemas/need/salaryRange.zod.ts | 27 + .../api/schemas/need/salaryTaxBasis.zod.ts | 12 + .../shared/api/schemas/need/skillName.zod.ts | 17 + .../api/schemas/need/skillTaxonomyCode.zod.ts | 17 + .../need/updateOrganizationNeedBody.zod.ts | 103 + .../schemas/{candidate => }/workFormat.zod.ts | 0 95 files changed, 25352 insertions(+), 26 deletions(-) create mode 100644 api/core/components/schemas/need_schemas.yml create mode 100644 api/core/routes/organization_need.yml create mode 100644 api/core/routes/organization_needs.yml create mode 100644 frontend/src/shared/api/endpoints/need/need.msw.ts create mode 100644 frontend/src/shared/api/endpoints/need/need.ts create mode 100644 frontend/src/shared/api/needs-contract.test.ts create mode 100644 frontend/src/shared/api/schemas/need/createOrganizationNeedBody.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/createOrganizationNeedHeaders.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/currencyCode.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/index.ts create mode 100644 frontend/src/shared/api/schemas/need/listOrganizationNeedsParams.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/need.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needCategoryRecommendation.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needCategoryRecommendations.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needCreate.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needDomain.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needDomainInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needDomainName.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needFieldName.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needGrade.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needGradeInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needItemStatus.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needList.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needLocation.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needLocationInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needLocationName.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needMissingField.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needMissingReason.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needMoneyFit.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needMoneyStatus.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needReadinessReport.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needReadinessStatus.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needRecommendationStatus.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needRequirementSet.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSalary.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSalaryInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSkill.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSkillInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSkillOverlap.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSourceQuote.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSourceText.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSpecialization.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSpecializationInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSummary.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needSupplyBand.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needTask.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needTaskInput.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needTaskText.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needTitle.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needUpdate.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needValueOrigin.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needValueSource.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needValueStatus.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needVersion.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needVersionLabel.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needWorkFormats.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/needWorkFormatsInput.zod.ts rename frontend/src/shared/api/schemas/{ => need}/pageInfo.zod.ts (100%) create mode 100644 frontend/src/shared/api/schemas/need/rubAmount.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/salaryPeriod.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/salaryRange.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/salaryTaxBasis.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/skillName.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/skillTaxonomyCode.zod.ts create mode 100644 frontend/src/shared/api/schemas/need/updateOrganizationNeedBody.zod.ts rename frontend/src/shared/api/schemas/{candidate => }/workFormat.zod.ts (100%) diff --git a/api/README.en.md b/api/README.en.md index c6b5624..ccecbf4 100644 --- a/api/README.en.md +++ b/api/README.en.md @@ -14,7 +14,7 @@ From the repository root, `make -C api check` checks contracts and `make generat ## Contract conventions -`api/core/` fixes these conventions as reusable components in `openapi.yml` and the files under `components/`: schemas in `components/schemas/*_schemas.yml`, parameters in `parameters.yml`, response headers in `headers.yml`, responses in `responses.yml`, and examples in `examples.yml`. Operations reference them as they are added. Currently implemented: problem responses for errors of the Go public API and the ML service. Idempotency-Key storage, If-Match checks, and pagination are planned behavior for business operations; the declared `RegisterAccount` operation and the assessment commands require Idempotency-Key, but no operation stores keys yet. +`api/core/` fixes these conventions as reusable components in `openapi.yml` and the files under `components/`: schemas in `components/schemas/*_schemas.yml`, parameters in `parameters.yml`, response headers in `headers.yml`, responses in `responses.yml`, and examples in `examples.yml`. Operations reference them as they are added. Currently implemented: problem responses for errors of the Go public API and the ML service. Idempotency-Key storage, If-Match checks, and pagination are planned behavior for business operations; the declared `RegisterAccount` operation, the assessment commands, and `CreateOrganizationNeed` require Idempotency-Key, but no operation stores keys yet. ### Errors @@ -81,7 +81,7 @@ Lists use cursor pagination: `limit` from 1 to 100 (20 by default) and an opaque ### Time and money -Timestamps use the `Timestamp` schema: `string`, `format: date-time`, UTC with the `Z` suffix (RFC 3339). Servers always emit UTC. ogen generates `Timestamp` as a named Go type over `time.Time`; call `.UTC()` where a value is converted to it. Money is planned as an integer number of whole rubles with explicit fields for the base, such as the pay period and gross or net; the schema is added with the first business field that carries money. +Timestamps use the `Timestamp` schema: `string`, `format: date-time`, UTC with the `Z` suffix (RFC 3339). Servers always emit UTC. ogen generates `Timestamp` as a named Go type over `time.Time`; call `.UTC()` where a value is converted to it. Money is an integer number of whole rubles (`RubAmount`, int64) with an explicit base: `SalaryRange` requires `salary_from`, `salary_to`, `currency` (`RUB`), `period` (`month`), and `tax_basis` (`net` or `gross`); see Needs below. Invitations are expected to reuse `SalaryRange`. ### ML service errors @@ -237,6 +237,73 @@ Result: Planned, additive: a short approach description of up to 1500 characters next to the practice, which never decides the grade (PRD FR05); the debug run operation of the practice; the notice and storage of the anti-cheat signals (time, focus changes, pastes, parallel sessions), which lead to a review and an appeal, never to a public label and never to the employer (PRD FR05). +### Needs + +The `need` tag covers the hiring needs of an organization (PRD FR08, with the versions of FR10): requirements with their confirmation state and provenance, immutable versions, readiness, and category recommendations. The operations are in the contract; their business logic is not implemented yet, so every one answers 401 `unauthenticated` until sessions exist (`v1.DenyAllSecurity`). + +| Method and path | operationId | Security | Success | Specific errors | +| --- | --- | --- | --- | --- | +| `GET /api/v1/organizations/{org_id}/needs` | `ListOrganizationNeeds` | session | 200 `NeedList`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `forbidden`, 404 `not_found` | +| `POST /api/v1/organizations/{org_id}/needs` | `CreateOrganizationNeed` | session and CSRF, Idempotency-Key | 201 `Need`, `Cache-Control: no-store` | 400, 401, 403 `csrf_check_failed` or `forbidden`, 404, 409 `idempotency_in_progress`, 422 `idempotency_key_reused`, 429 | +| `GET /api/v1/organizations/{org_id}/needs/{need_id}` | `GetOrganizationNeed` | session | 200 `Need`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `forbidden`, 404 `not_found` | +| `PATCH /api/v1/organizations/{org_id}/needs/{need_id}` | `UpdateOrganizationNeed` | session and CSRF | 200 `Need`, `Cache-Control: no-store` | 400, 401, 403, 404, 412 `version_conflict`, 429 | + +Every operation also declares the `default` problem response. A malformed `org_id` or `need_id` answers 400 with the path pointer. + +Access: + +- `org_id` in the path is the only source of the organization, and the server checks it against the active membership of the session account; no request has an organization, membership, or role field. The organization contract (TASK-077) owns organizations and memberships and reuses the same path parameter, `parameters.yml#/OrganizationId`. +- An account without an active membership in `org_id`, an unknown organization, an unknown need, and a need of another organization all answer 404 `not_found`, so identifiers cannot be probed. A candidate account answers 403 `forbidden`, and so does a member whose role does not allow the operation. +- 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 the contract. + +Fields and provenance: + +- `requirements` (`NeedRequirementSet`) holds `specialization`, `grade`, `required_skills`, `desired_skills`, `tasks`, `domain`, `work_formats`, `location`, and `salary`. A field in a response is `{status, value, source}`; a list item has its own `status` and `source`. +- `status` is `confirmed` (a member entered or confirmed the value), `extracted` (a suggestion that waits for confirmation), or `unknown` (no value). An unknown field has null `value` and `source`; the server never fills it with a default or a guess such as Senior, remote, or a zero salary. Only confirmed values feed readiness, recommendations, search, and invitations. +- `source` has `origin` (`manual`, `extracted_from_text`, or the planned `imported`), `quote` (an exact excerpt of up to 300 characters, or null), `extracted_in_version`, and `extraction_version`. The quote is an excerpt of the `source_text` of `extracted_in_version`, not necessarily of the current text: a confirmed value keeps its quote after the text changes. Confirming a suggestion keeps its provenance; changing the value makes it `manual`. +- A skill has `taxonomy_code`. It is null for a skill that the platform taxonomy does not know: the name stays as given, no code is guessed, and recommendations count the skill as not covered. +- With `source_text`, the server extracts suggestions with deterministic rules and a dictionary before it answers, so needs work while ML is disabled. ML suggestions with quotes are planned as an asynchronous addition that creates a new version and never overwrites a confirmed value. +- The text is stored as written and may contain requirements that discriminate by a protected characteristic; the extractor never turns them into a need field. The field for what a candidate must not have, with the Labor Code article 64 check, is deferred to TASK-182 and will be added without a breaking change. + +Requests, confirmation, and changes: + +- Every requirement field in a request is a decision `{value, status}` (`NeedSpecializationInput`, `NeedGradeInput`, `NeedDomainInput`, `NeedWorkFormatsInput`, `NeedLocationInput`, `NeedSalaryInput`), and every list item is `{name or text, status}`. `status` is `confirmed` or `extracted`. A bare value fails validation, so confirmation is always explicit. +- `confirmed` with the stored suggested value confirms it and keeps its provenance; `confirmed` with another value sets a confirmed manual value. `extracted` keeps a stored suggestion open and is allowed only with exactly the stored suggested value; any other value, or a field or item without a suggestion, answers 400 with the pointer of that status, such as `/grade/status` or `/required_skills/2/status`. A client that sends back an unchanged form therefore confirms nothing by accident: it sends each suggestion with `extracted` or leaves the field out. +- A need never requires a vacancy: only `title` is required, and `vacancy_id` is optional and nullable. Until vacancies exist in the contract, any vacancy identifier answers 400 with the pointer `/vacancy_id`. +- On creation every decision must be `confirmed`, because a new need has no stored suggestion. An absent field is extracted from `source_text` or stays unknown. A nullable field sent as null stays unknown, and a skill or task list sent empty stays empty; neither is extracted. An empty `work_formats` value fails `minItems`. +- `UpdateOrganizationNeed` uses explicit field replacement in `application/json`, not JSON Merge Patch (RFC 7396): a present field replaces that field as a whole, an absent field stays unchanged, a decision and a list are never merged, and a stored item left out of a sent list is deleted. Null removes a nullable field (it becomes `unknown`, or `vacancy_id` is unlinked); an empty skill or task list deletes every item; a list sent as null answers 400. ogen generates one optional, or optional and nullable, value per decision (`OptNilNeedGradeInput`, `OptNilNeedSalaryInput`). +- A different `source_text` extracts again. New suggestions replace only the `extracted` values and items of fields not named in the body; confirmed values are never overwritten, a suggested skill whose name is already in either skill list is skipped, and a suggestion that a member deleted is not proposed again for this need. +- The server also rejects a repeated skill or task and a skill in both lists, with 400 and the pointer of the later item, such as `/required_skills/1/name`. + +Versions and concurrency: + +- `version` starts at 1 and advances by exactly one with each committed change, including server-side ones. Each version is an immutable snapshot. GET always returns the latest version. +- `requirements_version` is the version in which the confirmed requirements were last changed. Confirming, changing, or removing a requirement sets it to the new `version`; a change of the title, the vacancy link, the text, or suggestions only keeps it and invalidates neither the recommendations nor search results. Search runs, selection snapshots (FR10, TASK-193), and invitations refer to `(need_id, requirements_version)`, and only a new `requirements_version` calls for a new selection snapshot. Reading and comparing earlier versions are planned as separate operations that return `NeedRequirementSet` for a version; they add nothing to `Need`. +- A change carries `expected_version`, the version the client read, in the body for the same reason as the questionnaire: the generated client cannot read `ETag` yet. A stale value answers 412 `version_conflict` and changes nothing; TASK-179 says 409, but the repository rule keeps 412 for If-Match and a body version alike. A body that changes nothing answers 200 with the current need even with an older version, so PATCH needs no Idempotency-Key. POST needs one with the 24-hour replay; only the 201 is stored. + +Readiness: + +- `readiness.missing_fields` lists each critical field without a confirmed value: `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed formats include `office` or `hybrid`. Each item has `reason` (`unknown` or `unconfirmed`) and a specific Russian `question`. +- An incomplete need is saved (201 or 200), not rejected. `Problem` allows no extension fields, so the missing fields live in the resource, not in a problem. Each later operation, such as search or an invitation, states which readiness it requires. + +Salary: + +- `SalaryRange` `[A; B]` has `salary_from` and `salary_to` (`RubAmount`, whole rubles), `currency` (`RUB` only), `period` (`month` only), and `tax_basis` (`net` or `gross`); every field is required. Requests send it as `salary: {value, status}`, so its pointers are under `/salary/value`. +- The schema requires bounds that are positive multiples of 1000 up to 100000000 and rejects another currency, period, or basis, for example with `/salary/value/tax_basis`. A missing field of the nested range has the whole-body pointer. +- The server checks the cross-field rules of PRD FR13 in integer arithmetic: `A < B` and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation, including equal bounds, answers 400 with the pointer `/salary/value/salary_to`. `[95000; 105000]` (exactly 10%) and `[80000; 120000]` (exactly 40%) are accepted. FR13 applies the same rules to the range of a need and of an invitation, and `docs/*/ARCHITECTURE.md` now states them for invitations instead of `0 < salary_from <= salary_to`. +- Limit against probing hidden minimums (FR13, planned in TASK-211): setting a confirmed range, on creation or on a change, counts against a counter shared by the whole organization, every member and every need, so a new need does not reset it. At most three range settings a day; 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. + +Recommendations: + +- `recommendations` is computed by the server from the confirmed requirements of `requirements_version` with a versioned policy (`policy_version`, `algorithm_version`, `computed_at`). `status` is `computed`, `pending`, or `not_available` without a confirmed skill. The server may recompute them for the same `requirements_version`, for a new policy or a changed pool of candidates, without a new need version; `computed_at` and `policy_version` then change. +- Each category (`specialization` and `grade`) has `score`, `skill_overlap` (weighted share with weight 2 for required and 1 for desired skills, covered and uncovered skills), `money`, and `supply` as a band: `fewer_than_5`, `from_5_to_29`, `30_or_more`. The list order is the ranking. +- `money.status` is `computed`, `insufficient_data` (fewer than five candidates with a comparable known minimum), `no_salary`, or `withheld`; the last three use the neutral 0.5 and a null share. `money.share` is rounded down to a quarter (0, 0.25, 0.5, 0.75, 1): each probe of a new upper bound then tells at most which quarter of the group accepts it, and in the smallest allowed group of five a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept. +- `score` is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply`, rounded half up to two decimals, computed from the published components: the exact overlap, the quarter-rounded share or the neutral 0.5, and `Supply = min(1, active / 30)`. It is null when `supply` is `fewer_than_5`. The ranking uses Supply only at band precision below five: every group of fewer than five candidates enters it with Supply 0, so neither the score nor the order reveals the exact size of a group below five, which FR08 forbids. For five or more candidates the exact Supply is used, so the TASK-183 fixture (Overlap 1, Money 0.5, 15 active candidates) gives `score` 0.75. +- Deviation from the PRD formula and from TASK-183 and TASK-457: the money share in the score and ranking is the quarter-rounded share, not the exact one, and a category with fewer than five candidates has no score. Otherwise the score with the exact share would reveal the share that `money.share` rounds, and a score with the exact Supply of a small group would reveal its size. The breakdown that TASK-457 shows consists of the published components. +- Requests cannot set a recommendation, its score, membership, or a candidate minimum: bodies have `additionalProperties: false`, and unknown fields such as `rec_score`, `members`, `candidate_minimum`, `version`, `requirements_version`, or `recommendations` answer 400 with the whole-body pointer. `TestNeedSchemaValidationPrecedesImplementation` checks the schema rejections through the generated server, `TestNeedUpdateDecodingKeepsAbsentAndEmptyListsApart` checks the list decoding, and `frontend/src/shared/api/needs-contract.test.ts` pins the generated Zod limits, the explicit status of every decision, and the absence of these fields in the request types. + +Planned, additive: reading and comparing versions, exclusions (TASK-182), the market range hint (P25-P75) of FR08, the check plan "vacancy -> tasks", a need status for archiving, list filters, and need assignments. + ### Generator checks `testdata/openapi-3.2.0.yml` contains test operations that use the components above: pagination, Idempotency-Key, If-Match, ETag, and problem responses. ogen does not resolve external references, so the fixture keeps copies of the api/core components; `scripts/test_contract_copies.py` (part of `make -C api check`) checks that they, the fixture responses, and the ML `Problem` copy match api/core. @@ -262,12 +329,13 @@ Known generator limitations: - ogen requires a `SecurityHandler` as soon as the contract has security schemes and evaluates the schemes in the order of their generated type names, so renaming a scheme can change the order; `TestGeneratedServerSecurityOrder` fails if it does. Security failures reach `NewError` without a response header, so clearing the cookie on a 401 from `Logout` needs handwritten code. - Orval does not expose security scheme values as typed arguments, so `X-CSRF-Token` is not a generated parameter; the shared API client is planned to attach it to mutating requests. Orval also generates no type for `Set-Cookie`, which the browser handles. - Orval Zod schemas ignore `uniqueItems` and do not reject unknown fields of `additionalProperties: false` objects; the server stays authoritative for both. +- ogen generates an optional nullable field as `OptNil`, which tells absent (`IsSet` false), null (`IsNull`), and a value apart. An optional array that is not nullable is a plain slice instead, where nil and `[]` mean different things: an absent field decodes to nil (unchanged) and `[]` to an empty non-nil slice (delete every item), and null fails decoding. An `UpdateOrganizationNeed` handler must therefore test lists with `!= nil`, never with `len`; `TestNeedUpdateDecodingKeepsAbsentAndEmptyListsApart` pins this. - Orval clears `src/shared/api/endpoints/` and `src/shared/api/schemas/` before generation (`clean: true`), because a schema used by several tags moves from a tag directory to the schema root. #### Format unions - Format unions such as `ItemContent` and `AssessmentAnswer` are `oneOf` without a `discriminator` object. Redocly resolves `discriminator.mapping` values as references, and `scripts/merge-schemas.py` rewrites only `$ref`, so a mapping in a split schema file cannot resolve in the merged `components/schemas.yml`. Every variant fixes `format` with a one-value enum; ogen discriminates by that value and by the fields unique to a variant and rejects a body that matches several variants, and Orval generates a Zod union. -- Orval names the constants of an inline property ``, so a property name that repeats another schema name collides in `index.ts` (TS2308). The union of item formats is therefore `ItemContent`, not `AssessmentItemContent`, next to the `AssessmentItem.content` property. +- Orval names the constants of an inline property ``, so a property name that repeats another schema name collides in `index.ts` (TS2308). The union of item formats is therefore `ItemContent`, not `AssessmentItemContent`, next to the `AssessmentItem.content` property, and the parts of `Need` are `NeedRequirementSet`, `NeedReadinessReport`, and `NeedCategoryRecommendations`, not `NeedRequirements`, `NeedReadiness`, and `NeedRecommendations`. Generated Zod is not strict. A body that mixes the fields of two formats or carries an extra `score` or `seed` is accepted after unknown keys are silently stripped, and `uniqueItems` is not checked; only the server rejects such bodies. `frontend/src/shared/api/assessment-contract.test.ts` pins the accepted formats and that no answer or item DTO has a score, key, seed, or correctness field. diff --git a/api/README.md b/api/README.md index a243634..0c48e71 100644 --- a/api/README.md +++ b/api/README.md @@ -14,7 +14,7 @@ ## Соглашения контракта -`api/core/` закрепляет эти соглашения как переиспользуемые компоненты в `openapi.yml` и файлах `components/`: схемы в `components/schemas/*_schemas.yml`, параметры в `parameters.yml`, заголовки ответов в `headers.yml`, ответы в `responses.yml`, примеры в `examples.yml`. Операции ссылаются на них по мере появления. Сейчас реализованы problem-ответы для ошибок публичного Go API и ML-сервиса. Хранение Idempotency-Key, проверки If-Match и пагинация - запланированное поведение бизнес-операций; объявленная операция `RegisterAccount` и команды оценки требуют Idempotency-Key, но ни одна операция пока не хранит ключи. +`api/core/` закрепляет эти соглашения как переиспользуемые компоненты в `openapi.yml` и файлах `components/`: схемы в `components/schemas/*_schemas.yml`, параметры в `parameters.yml`, заголовки ответов в `headers.yml`, ответы в `responses.yml`, примеры в `examples.yml`. Операции ссылаются на них по мере появления. Сейчас реализованы problem-ответы для ошибок публичного Go API и ML-сервиса. Хранение Idempotency-Key, проверки If-Match и пагинация - запланированное поведение бизнес-операций; объявленная операция `RegisterAccount`, команды оценки и `CreateOrganizationNeed` требуют Idempotency-Key, но ни одна операция пока не хранит ключи. ### Ошибки @@ -81,7 +81,7 @@ ### Время и деньги -Метки времени используют схему `Timestamp`: `string`, `format: date-time`, UTC с суффиксом `Z` (RFC 3339). Серверы всегда отдают UTC. ogen генерирует `Timestamp` как именованный Go-тип поверх `time.Time`; при преобразовании к нему вызывайте `.UTC()`. Деньги запланированы как целое число полных рублей с явными полями базы, например периодом оплаты и gross или net; схема появится вместе с первым бизнес-полем с деньгами. +Метки времени используют схему `Timestamp`: `string`, `format: date-time`, UTC с суффиксом `Z` (RFC 3339). Серверы всегда отдают UTC. ogen генерирует `Timestamp` как именованный Go-тип поверх `time.Time`; при преобразовании к нему вызывайте `.UTC()`. Деньги - целое число полных рублей (`RubAmount`, int64) с явной базой: `SalaryRange` требует `salary_from`, `salary_to`, `currency` (`RUB`), `period` (`month`) и `tax_basis` (`net` или `gross`); см. раздел Потребности ниже. Приглашения, как ожидается, переиспользуют `SalaryRange`. ### Ошибки ML-сервиса @@ -237,6 +237,73 @@ ML-сервис отвечает на ошибки той же схемой `Pro Запланировано, добавляется без ломающих изменений: краткое описание подхода до 1500 знаков рядом с практикой, которое не определяет грейд (FR05 в PRD); операция отладочных запусков практики; уведомление о собираемых античит-сигналах (время, переключение фокуса, вставки, параллельные сессии) и их хранение; сигналы ведут к перепроверке и апелляции, а не к публичному ярлыку, и работодателю не показываются (FR05 в PRD). +### Потребности + +Тег `need` описывает потребности организации в найме (FR08 в PRD, с версиями из FR10): требования с состоянием подтверждения и происхождением, неизменяемые версии, готовность и рекомендации категорий. Операции есть в контракте, бизнес-логика еще не реализована, поэтому каждая отвечает 401 `unauthenticated`, пока сессий нет (`v1.DenyAllSecurity`). + +| Метод и путь | operationId | Защита | Успех | Конкретные ошибки | +| --- | --- | --- | --- | --- | +| `GET /api/v1/organizations/{org_id}/needs` | `ListOrganizationNeeds` | сессия | 200 `NeedList`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `forbidden`, 404 `not_found` | +| `POST /api/v1/organizations/{org_id}/needs` | `CreateOrganizationNeed` | сессия и CSRF, Idempotency-Key | 201 `Need`, `Cache-Control: no-store` | 400, 401, 403 `csrf_check_failed` или `forbidden`, 404, 409 `idempotency_in_progress`, 422 `idempotency_key_reused`, 429 | +| `GET /api/v1/organizations/{org_id}/needs/{need_id}` | `GetOrganizationNeed` | сессия | 200 `Need`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `forbidden`, 404 `not_found` | +| `PATCH /api/v1/organizations/{org_id}/needs/{need_id}` | `UpdateOrganizationNeed` | сессия и CSRF | 200 `Need`, `Cache-Control: no-store` | 400, 401, 403, 404, 412 `version_conflict`, 429 | + +Каждая операция также объявляет problem-ответ `default`. Некорректные `org_id` или `need_id` дают 400 с pointer на параметр пути. + +Доступ: + +- `org_id` в пути - единственный источник организации, и сервер сверяет его с действующим членством аккаунта сессии; ни один запрос не содержит поля организации, членства или роли. Организации и членства принадлежат контракту организации (TASK-077), который переиспользует тот же параметр пути `parameters.yml#/OrganizationId`. +- Аккаунт без действующего членства в `org_id`, неизвестная организация, неизвестная потребность и потребность другой организации одинаково дают 404 `not_found`, поэтому идентификаторы нельзя перебрать. Аккаунт кандидата получает 403 `forbidden`, как и участник, чья роль не разрешает операцию. +- В MVP с потребностями работает только владелец организации. Остальные роли матрицы FR07 в PRD (рекрутер, нанимающий менеджер и техэксперт для назначенных потребностей) запланированы и не меняют ни одного поля контракта. + +Поля и происхождение: + +- `requirements` (`NeedRequirementSet`) содержит `specialization`, `grade`, `required_skills`, `desired_skills`, `tasks`, `domain`, `work_formats`, `location` и `salary`. Поле в ответе - это `{status, value, source}`; у элемента списка свои `status` и `source`. +- `status` - `confirmed` (участник ввел или подтвердил значение), `extracted` (предложение, ожидающее подтверждения) или `unknown` (значения нет). У неизвестного поля `value` и `source` равны null; сервер никогда не заполняет его значением по умолчанию или догадкой, например Senior, remote или нулевой зарплатой. Только подтвержденные значения влияют на готовность, рекомендации, поиск и приглашения. +- `source` содержит `origin` (`manual`, `extracted_from_text` или запланированный `imported`), `quote` (точный фрагмент до 300 знаков или null), `extracted_in_version` и `extraction_version`. Цитата - фрагмент `source_text` версии `extracted_in_version`, а не обязательно текущего текста: подтвержденное значение сохраняет цитату после изменения текста. Подтверждение предложения сохраняет его происхождение; изменение значения делает его `manual`. +- У навыка есть `taxonomy_code`. Он равен null для навыка, которого нет в таксономии платформы: название остается как указано, код не угадывается, а рекомендации считают навык непокрытым. +- При наличии `source_text` сервер до ответа извлекает предложения детерминированными правилами и словарем, поэтому потребности работают при выключенном ML. ML-предложения с цитатами запланированы как асинхронное дополнение, которое создает новую версию и никогда не перезаписывает подтвержденное значение. +- Текст хранится как написан и может содержать дискриминирующие требования по защищенным признакам; извлечение никогда не превращает их в поле потребности. Поле того, чего не должно быть у кандидата, с проверкой по ст. 64 ТК РФ отложено до TASK-182 и добавится без ломающих изменений. + +Запросы, подтверждение и изменения: + +- Каждое поле требования в запросе - это решение `{value, status}` (`NeedSpecializationInput`, `NeedGradeInput`, `NeedDomainInput`, `NeedWorkFormatsInput`, `NeedLocationInput`, `NeedSalaryInput`), а каждый элемент списка - `{name или text, status}`. `status` - `confirmed` или `extracted`. Голое значение не проходит валидацию, поэтому подтверждение всегда явное. +- `confirmed` с сохраненным предложенным значением подтверждает его и сохраняет происхождение; `confirmed` с другим значением задает подтвержденное ручное значение. `extracted` оставляет сохраненное предложение открытым и допустим только с точно тем же предложенным значением; любое другое значение, а также поле или элемент без предложения дают 400 с pointer на этот статус, например `/grade/status` или `/required_skills/2/status`. Поэтому клиент, отправивший форму без изменений, ничего не подтверждает случайно: каждое предложение он отправляет с `extracted` или не отправляет поле. +- Потребности никогда не нужна вакансия: обязателен только `title`, а `vacancy_id` необязателен и допускает null. Пока вакансий нет в контракте, любой идентификатор вакансии дает 400 с pointer `/vacancy_id`. +- При создании каждое решение должно быть `confirmed`, потому что у новой потребности нет сохраненных предложений. Отсутствующее поле извлекается из `source_text` или остается неизвестным. Nullable-поле, переданное как null, остается неизвестным, а пустой список навыков или задач остается пустым; ни то ни другое не извлекается. Пустое значение `work_formats` не проходит `minItems`. +- `UpdateOrganizationNeed` использует явную замену полей в `application/json`, а не JSON Merge Patch (RFC 7396): переданное поле заменяется целиком, отсутствующее не меняется, решения и списки не сливаются, а сохраненный элемент, которого нет в переданном списке, удаляется. Null удаляет nullable-поле (оно становится `unknown`, а `vacancy_id` отвязывается); пустой список навыков или задач удаляет все элементы; список, переданный как null, дает 400. ogen генерирует одно необязательное или необязательное nullable значение на решение (`OptNilNeedGradeInput`, `OptNilNeedSalaryInput`). +- Другой `source_text` запускает повторное извлечение. Новые предложения заменяют только значения и элементы со статусом `extracted` в полях, не названных в теле; подтвержденные значения не перезаписываются, предложенный навык с названием, которое уже есть в одном из списков навыков, пропускается, а удаленное участником предложение для этой потребности больше не предлагается. +- Сервер также отклоняет повтор навыка или задачи и навык в обоих списках - 400 с pointer на более поздний элемент, например `/required_skills/1/name`. + +Версии и конкурентность: + +- `version` начинается с 1 и растет ровно на единицу с каждым зафиксированным изменением, включая серверные. Каждая версия - неизменяемый снимок. GET всегда возвращает последнюю версию. +- `requirements_version` - версия, в которой подтвержденные требования менялись последний раз. Подтверждение, изменение или удаление требования делает ее равной новой `version`; изменение названия, привязки вакансии, текста или только предложений ее сохраняет и не обесценивает ни рекомендации, ни результаты поиска. Запуски поиска, снимки подборки (FR10, TASK-193) и приглашения ссылаются на `(need_id, requirements_version)`, и новый снимок подборки нужен только при новой `requirements_version`. Чтение и сравнение прежних версий запланированы отдельными операциями, которые возвращают `NeedRequirementSet` для версии; в `Need` они ничего не добавляют. +- Изменение передает `expected_version` - прочитанную клиентом версию - в теле по той же причине, что и анкета: сгенерированный клиент пока не читает `ETag`. Устаревшее значение дает 412 `version_conflict` и ничего не меняет; в TASK-179 указан 409, но правило репозитория сохраняет 412 и для If-Match, и для версии в теле. Тело, которое ничего не меняет, дает 200 с текущей потребностью даже со старой версией, поэтому PATCH не нужен Idempotency-Key. POST требует его с повтором в течение 24 часов; сохраняется только 201. + +Готовность: + +- `readiness.missing_fields` перечисляет каждое критичное поле без подтвержденного значения: `specialization`, `grade`, `required_skills` (хотя бы один подтвержденный навык), `work_formats`, `salary` и `location`, если подтвержденные форматы включают `office` или `hybrid`. У каждого элемента есть `reason` (`unknown` или `unconfirmed`) и конкретный вопрос `question` на русском. +- Неполная потребность сохраняется (201 или 200), а не отклоняется. `Problem` не допускает полей расширения, поэтому недостающие поля находятся в ресурсе, а не в problem. Каждая следующая операция, например поиск или приглашение, сама указывает, какая готовность ей нужна. + +Зарплата: + +- `SalaryRange` `[A; B]` содержит `salary_from` и `salary_to` (`RubAmount`, целые рубли), `currency` (только `RUB`), `period` (только `month`) и `tax_basis` (`net` или `gross`); все поля обязательны. Запрос передает ее как `salary: {value, status}`, поэтому ее pointer начинаются с `/salary/value`. +- Схема требует положительных границ, кратных 1000, до 100000000 и отклоняет другую валюту, период или базу, например с `/salary/value/tax_basis`. Для отсутствующего поля вложенной вилки pointer указывает на все тело. +- Межполевые правила FR13 в PRD сервер проверяет в целочисленной арифметике: `A < B` и ширина `(B - A) / ((A + B) / 2)` от 10% до 40% включительно, то есть `20 * (B - A) >= A + B` и `5 * (B - A) <= A + B`. Нарушение, включая равные границы, дает 400 с pointer `/salary/value/salary_to`. `[95000; 105000]` (ровно 10%) и `[80000; 120000]` (ровно 40%) принимаются. FR13 применяет одни правила к вилке потребности и приглашения, и `docs/*/ARCHITECTURE.md` теперь указывает их для приглашений вместо `0 < salary_from <= salary_to`. +- Ограничение против подбора скрытых минимумов (FR13, запланировано в TASK-211): задание подтвержденной вилки при создании или изменении учитывается в счетчике, общем для всей организации, всех участников и всех потребностей, поэтому новая потребность его не обнуляет. Не больше трех заданий вилки в сутки; сверх лимита сервер отвечает 429 с Retry-After и ничего не меняет. После пяти заданий за семь дней денежная компонента получает статус `withheld` на семь дней. Повторные изменения вилки также питают приватные сигналы риска TASK-319. + +Рекомендации: + +- `recommendations` вычисляет сервер по подтвержденным требованиям версии `requirements_version` с версионируемой политикой (`policy_version`, `algorithm_version`, `computed_at`). `status` - `computed`, `pending` или `not_available` без подтвержденного навыка. Сервер может пересчитать их для той же `requirements_version` при новой политике или изменившемся пуле кандидатов без новой версии потребности; тогда меняются `computed_at` и `policy_version`. +- У каждой категории (`specialization` и `grade`) есть `score`, `skill_overlap` (взвешенная доля с весом 2 для обязательных и 1 для желательных навыков, покрытые и непокрытые навыки), `money` и `supply` диапазоном: `fewer_than_5`, `from_5_to_29`, `30_or_more`. Порядок списка задает ранжирование. +- `money.status` - `computed`, `insufficient_data` (меньше пяти кандидатов с известным сопоставимым минимумом), `no_salary` или `withheld`; последние три используют нейтральное 0,5 и null в доле. `money.share` округляется вниз до четверти (0, 0.25, 0.5, 0.75, 1): каждая проба новой верхней границы говорит не больше того, какая четверть группы ее принимает, а в наименьшей допустимой группе из пяти один минимум часто не сдвигает значение; при этом доля по-прежнему отличает вилку, которую принимает большинство, от той, которую принимают немногие. +- `score` равен `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` с округлением половины вверх до двух знаков и вычисляется по опубликованным компонентам: точному покрытию, доле с округлением до четверти или нейтральному 0,5 и `Supply = min(1, active / 30)`. Он равен null, когда `supply` - `fewer_than_5`. Ниже пяти ранжирование использует Supply только с точностью диапазона: каждая группа меньше пяти кандидатов входит в него с Supply 0, поэтому ни балл, ни порядок не раскрывают точный размер группы меньше пяти, что запрещает FR08. Для пяти и более кандидатов используется точный Supply, поэтому фикстура TASK-183 (Overlap 1, Money 0,5, 15 активных кандидатов) дает `score` 0.75. +- Отступление от формулы PRD, TASK-183 и TASK-457: в балле и ранжировании используется доля денег, округленная до четверти, а не точная, и у категории меньше чем с пятью кандидатами балла нет. Иначе балл с точной долей раскрыл бы долю, которую округляет `money.share`, а балл с точным Supply малой группы - ее размер. Разложение, которое показывает TASK-457, состоит из опубликованных компонент. +- Запрос не может задать рекомендацию, ее балл, членство или минимум кандидата: у тел `additionalProperties: false`, и неизвестные поля, например `rec_score`, `members`, `candidate_minimum`, `version`, `requirements_version` или `recommendations`, дают 400 с pointer на все тело. `TestNeedSchemaValidationPrecedesImplementation` проверяет отказы схемы через сгенерированный сервер, `TestNeedUpdateDecodingKeepsAbsentAndEmptyListsApart` - декодирование списков, а `frontend/src/shared/api/needs-contract.test.ts` закрепляет ограничения сгенерированного Zod, явный статус каждого решения и отсутствие этих полей в типах запросов. + +Запланировано, добавляется без ломающих изменений: чтение и сравнение версий, исключения (TASK-182), подсказка рыночной вилки (P25-P75) из FR08, план проверки "вакансия -> задания", статус потребности для архивации, фильтры списка и назначения на потребность. + ### Проверки генераторов `testdata/openapi-3.2.0.yml` содержит тестовые операции с перечисленными компонентами: пагинацией, Idempotency-Key, If-Match, ETag и problem-ответами. ogen не разрешает внешние ссылки, поэтому фикстура хранит копии компонентов api/core; `scripts/test_contract_copies.py` (входит в `make -C api check`) проверяет, что они, ответы фикстуры и ML-копия `Problem` совпадают с api/core. @@ -262,12 +329,13 @@ ML-сервис отвечает на ошибки той же схемой `Pro - ogen требует `SecurityHandler`, как только в контракте есть схемы защиты, и проверяет схемы в порядке имен их сгенерированных типов, поэтому переименование схемы может изменить порядок; тогда `TestGeneratedServerSecurityOrder` упадет. Сбои защиты попадают в `NewError` без заголовков ответа, поэтому удаление cookie при 401 от `Logout` требует ручного кода. - Orval не делает значения схем защиты типизированными аргументами, поэтому `X-CSRF-Token` не является сгенерированным параметром; его планируется добавлять к изменяющим запросам в общем API-клиенте. Тип для `Set-Cookie` Orval тоже не генерирует, этот заголовок обрабатывает браузер. - Zod-схемы Orval игнорируют `uniqueItems` и не отклоняют неизвестные поля объектов с `additionalProperties: false`; в обоих случаях решает сервер. +- ogen генерирует необязательное nullable-поле как `OptNil`, которое различает отсутствие (`IsSet` false), null (`IsNull`) и значение. Необязательный массив без null, напротив, - обычный slice, где nil и `[]` значат разное: отсутствующее поле декодируется в nil (без изменений), `[]` - в пустой slice, не равный nil (удалить все элементы), а null не декодируется. Поэтому обработчик `UpdateOrganizationNeed` должен проверять списки через `!= nil`, а не через `len`; это закрепляет `TestNeedUpdateDecodingKeepsAbsentAndEmptyListsApart`. - Orval очищает `src/shared/api/endpoints/` и `src/shared/api/schemas/` перед генерацией (`clean: true`), потому что схема, используемая несколькими тегами, переезжает из каталога тега в корень схем. #### Объединения форматов - Объединения форматов, например `ItemContent` и `AssessmentAnswer`, - это `oneOf` без объекта `discriminator`. Redocly разрешает значения `discriminator.mapping` как ссылки, а `scripts/merge-schemas.py` переписывает только `$ref`, поэтому mapping из отдельного файла схем не разрешается в объединенном `components/schemas.yml`. Каждый вариант фиксирует `format` перечислением из одного значения; ogen различает варианты по этому значению и по полям, уникальным для варианта, и отклоняет тело, подходящее под несколько вариантов, а Orval генерирует Zod-объединение. -- Orval называет константы встроенного свойства ``, поэтому имя свойства, повторяющее имя другой схемы, дает конфликт в `index.ts` (TS2308). Поэтому объединение форматов задания называется `ItemContent`, а не `AssessmentItemContent`, рядом со свойством `AssessmentItem.content`. +- Orval называет константы встроенного свойства ``, поэтому имя свойства, повторяющее имя другой схемы, дает конфликт в `index.ts` (TS2308). Поэтому объединение форматов задания называется `ItemContent`, а не `AssessmentItemContent`, рядом со свойством `AssessmentItem.content`, а части `Need` называются `NeedRequirementSet`, `NeedReadinessReport` и `NeedCategoryRecommendations`, а не `NeedRequirements`, `NeedReadiness` и `NeedRecommendations`. Сгенерированный Zod не строгий. Тело, смешивающее поля двух форматов или содержащее лишние `score` или `seed`, принимается после молчаливого удаления неизвестных ключей, а `uniqueItems` не проверяется; такие тела отклоняет только сервер. `frontend/src/shared/api/assessment-contract.test.ts` закрепляет принимаемые форматы и отсутствие в DTO ответа и задания полей балла, ключа, seed или правильности. diff --git a/api/core/components/examples.yml b/api/core/components/examples.yml index e614017..daa4ad8 100644 --- a/api/core/components/examples.yml +++ b/api/core/components/examples.yml @@ -1341,3 +1341,677 @@ AssessmentStaleVersion: code: version_conflict detail: The resource changed after it was read. Read it again before retrying. trace_id: 5f6a7b8c-9d0e-4f1a-8b2c-3d4e5f6a7b8c +NeedCreateManual: + summary: A manual need without a vacancy and without a text + description: Every field comes from the form as a decision with status confirmed, so every value is a confirmed manual value. There is no vacancy_id and no source_text; the domain is not given and stays unknown. + value: + title: Junior Go-разработчик для сервиса уведомлений + specialization: + value: backend + status: confirmed + grade: + value: junior + status: confirmed + required_skills: + - name: Go + status: confirmed + - name: PostgreSQL + status: confirmed + desired_skills: + - name: Docker + status: confirmed + tasks: + - text: Поддерживать и развивать сервис уведомлений + status: confirmed + work_formats: + value: + - hybrid + status: confirmed + location: + value: Москва + status: confirmed + salary: + value: + salary_from: 120000 + salary_to: 160000 + currency: RUB + period: month + tax_basis: net + status: confirmed +NeedCreateFromText: + summary: A need created from a pasted description + description: Only the title and the text are given. The server extracts suggestions from the text; nothing is confirmed until a member confirms it. + value: + title: Backend в команду платежей + source_text: "Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно." +NeedManualWithoutVacancy: + summary: A complete manual need without a vacancy, with computed recommendations + description: The need created by NeedCreateManual. Every value is confirmed and manual, so the quote, extracted_in_version, and extraction_version are null; the domain was not given and stays unknown with null value and source rather than a guessed one. The hybrid format makes the location critical, and it is confirmed. The range of 120000-160000 has a width of about 29%. The first category scores 0.75 with Overlap 1, a money share rounded down to 0.5, and Supply 0.5 for 15 available candidates. The other two have fewer than five candidates, so their score is null and Supply enters their ranking as 0. The recommendation values are illustrative and say nothing about a deployed policy or real candidates. + value: + id: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Junior Go-разработчик для сервиса уведомлений + source_text: null + version: 1 + requirements_version: 1 + requirements: + specialization: + status: confirmed + value: backend + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + grade: + status: confirmed + value: junior + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + required_skills: + - name: Go + taxonomy_code: go + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + - name: PostgreSQL + taxonomy_code: postgresql + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + desired_skills: + - name: Docker + taxonomy_code: docker + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + tasks: + - text: Поддерживать и развивать сервис уведомлений + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + domain: + status: unknown + value: null + source: null + work_formats: + status: confirmed + value: + - hybrid + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + location: + status: confirmed + value: Москва + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + salary: + status: confirmed + value: + salary_from: 120000 + salary_to: 160000 + currency: RUB + period: month + tax_basis: net + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + recommendations: + status: computed + requirements_version: 1 + policy_version: 1 + algorithm_version: need-rec.2026-10.1 + computed_at: "2026-10-06T08:15:02Z" + categories: + - specialization: backend + grade: junior + score: 0.75 + skill_overlap: + share: 1 + covered_skills: + - Go + - PostgreSQL + - Docker + uncovered_skills: [] + money: + status: computed + share: 0.5 + supply: from_5_to_29 + - specialization: backend + grade: intern + score: null + skill_overlap: + share: 0.8 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Docker + money: + status: insufficient_data + share: null + supply: fewer_than_5 + - specialization: devops_sre + grade: junior + score: null + skill_overlap: + share: 0.2 + covered_skills: + - Docker + uncovered_skills: + - Go + - PostgreSQL + money: + status: insufficient_data + share: null + supply: fewer_than_5 + created_at: "2026-10-06T08:15:00Z" + updated_at: "2026-10-06T08:15:00Z" +NeedExtractedWithUnknownSkill: + summary: A need from text with suggestions, an unknown skill, and missing fields + description: "The need created by NeedCreateFromText. Every value found in the text is extracted with its quote from the text of version 1 and the extractor version, and waits for confirmation. Temporal is not in the skill taxonomy, so its taxonomy_code is null instead of a guessed code. The text names no grade, place, or salary: they stay unknown with null value and source, and the critical ones are listed in missing_fields with a question. Without a confirmed skill there are no recommendations yet." + value: + id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Backend в команду платежей + source_text: "Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно." + version: 1 + requirements_version: 1 + requirements: + specialization: + status: extracted + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: unknown + value: null + source: null + required_skills: + - name: Go + taxonomy_code: go + status: extracted + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: PostgreSQL + taxonomy_code: postgresql + status: extracted + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: Temporal + taxonomy_code: null + status: extracted + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + desired_skills: + - name: Kafka + taxonomy_code: kafka + status: extracted + source: + origin: extracted_from_text + quote: Желательно опыт с Kafka + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + tasks: + - text: Развивать сервис выплат и переводить его на событийную модель + status: extracted + source: + origin: extracted_from_text + quote: "Задачи: развивать сервис выплат и переводить его на событийную модель" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + domain: + status: extracted + value: платежи + source: + origin: extracted_from_text + quote: в команду платежей + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + work_formats: + status: extracted + value: + - remote + source: + origin: extracted_from_text + quote: Работа удаленно + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + location: + status: unknown + value: null + source: null + salary: + status: unknown + value: null + source: null + readiness: + status: incomplete + missing_fields: + - field: specialization + reason: unconfirmed + question: Подтвердите специализацию, найденную в описании. + - field: grade + reason: unknown + question: "Какой грейд нужен: Intern, Junior, Middle или Senior?" + - field: required_skills + reason: unconfirmed + question: Подтвердите обязательные навыки, найденные в описании. + - field: work_formats + reason: unconfirmed + question: Подтвердите формат работы, найденный в описании. + - field: salary + reason: unknown + question: "Какую вилку в рублях вы предлагаете и в какой базе: на руки или до вычета НДФЛ?" + recommendations: + status: not_available + requirements_version: 1 + policy_version: null + algorithm_version: null + computed_at: null + categories: [] + created_at: "2026-10-06T09:00:00Z" + updated_at: "2026-10-06T09:00:00Z" +NeedUpdateConfirmSuggestions: + summary: Confirm suggestions, answer the missing fields, and keep two suggestions open + description: Sent over version 1 of NeedExtractedWithUnknownSkill. The specialization, the required skills, and the work format are sent with their stored values and status confirmed, so they are confirmed and keep their quotes. The grade and the salary are new manual values. Kafka and the domain are sent with status extracted and their stored values, so they stay open suggestions. The tasks are absent and stay unchanged. + value: + expected_version: 1 + specialization: + value: backend + status: confirmed + grade: + value: middle + status: confirmed + required_skills: + - name: Go + status: confirmed + - name: PostgreSQL + status: confirmed + - name: Temporal + status: confirmed + desired_skills: + - name: Kafka + status: extracted + domain: + value: платежи + status: extracted + work_formats: + value: + - remote + status: confirmed + salary: + value: + salary_from: 250000 + salary_to: 320000 + currency: RUB + period: month + tax_basis: gross + status: confirmed +NeedConfirmedAfterUpdate: + summary: The need after the confirmation, as version 2 + description: Confirmed suggestions keep the origin extracted_from_text, their quotes, and extracted_in_version 1; the grade and the salary are manual. A confirmed requirement changed, so requirements_version is 2 as well. Kafka and the domain are still open suggestions; Kafka does not count in the recommendations, and Temporal stays without a taxonomy code, so no category covers it. The place is unknown but not critical, because the only format is remote. The range of 250000-320000 has a width of about 25%. Scores use the overlap 4/6, the money share rounded down to a quarter or the neutral 0.5, and the exact Supply of groups of five or more. The recommendation values are illustrative. + value: + id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Backend в команду платежей + source_text: "Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно." + version: 2 + requirements_version: 2 + requirements: + specialization: + status: confirmed + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: confirmed + value: middle + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + required_skills: + - name: Go + taxonomy_code: go + status: confirmed + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: PostgreSQL + taxonomy_code: postgresql + status: confirmed + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: Temporal + taxonomy_code: null + status: confirmed + source: + origin: extracted_from_text + quote: "Обязательно: Go, PostgreSQL и Temporal" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + desired_skills: + - name: Kafka + taxonomy_code: kafka + status: extracted + source: + origin: extracted_from_text + quote: Желательно опыт с Kafka + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + tasks: + - text: Развивать сервис выплат и переводить его на событийную модель + status: extracted + source: + origin: extracted_from_text + quote: "Задачи: развивать сервис выплат и переводить его на событийную модель" + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + domain: + status: extracted + value: платежи + source: + origin: extracted_from_text + quote: в команду платежей + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + work_formats: + status: confirmed + value: + - remote + source: + origin: extracted_from_text + quote: Работа удаленно + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + location: + status: unknown + value: null + source: null + salary: + status: confirmed + value: + salary_from: 250000 + salary_to: 320000 + currency: RUB + period: month + tax_basis: gross + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + recommendations: + status: computed + requirements_version: 2 + policy_version: 1 + algorithm_version: need-rec.2026-10.1 + computed_at: "2026-10-06T09:20:01Z" + categories: + - specialization: backend + grade: middle + score: 0.61 + skill_overlap: + share: 0.67 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Temporal + money: + status: computed + share: 0.25 + supply: 30_or_more + - specialization: devops_sre + grade: middle + score: 0.45 + skill_overlap: + share: 0.33 + covered_skills: + - PostgreSQL + uncovered_skills: + - Go + - Temporal + money: + status: insufficient_data + share: null + supply: from_5_to_29 + - specialization: backend + grade: senior + score: 0.41 + skill_overlap: + share: 0.67 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Temporal + money: + status: computed + share: 0 + supply: from_5_to_29 + created_at: "2026-10-06T09:00:00Z" + updated_at: "2026-10-06T09:20:00Z" +NeedListPage: + summary: The last page of the needs of an organization + value: + items: + - id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + vacancy_id: null + title: Backend в команду платежей + version: 2 + specialization: + status: confirmed + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: confirmed + value: middle + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + created_at: "2026-10-06T09:00:00Z" + updated_at: "2026-10-06T09:20:00Z" + - id: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 + vacancy_id: null + title: Junior Go-разработчик для сервиса уведомлений + version: 1 + specialization: + status: confirmed + value: backend + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + grade: + status: confirmed + value: junior + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + created_at: "2026-10-06T08:15:00Z" + updated_at: "2026-10-06T08:15:00Z" + page: + has_more: false + next_cursor: null +NeedSalaryRangeReversed: + summary: The lower salary bound is above the upper one + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 6b7c8d9e-0f1a-4b2c-8d3e-4f5a6b7c8d9f + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. +NeedSalaryEqualBounds: + summary: Equal salary bounds; PRD FR13 requires salary_from < salary_to + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. +NeedSalaryRangeTooWide: + summary: A salary range wider than 40% of its midpoint, such as 100000-200000 + description: The width (200000 - 100000) / 150000 is about 67%. A range narrower than 10%, such as 100000-105000, gets the same answer. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. +NeedSalaryWithoutTaxBasis: + summary: A salary range without its tax basis + description: The decoder does not record the path of a missing field in a nested object, so the pointer is the whole body. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 7c8d9e0f-1a2b-4c3d-9e4f-5a6b7c8d9e0a + errors: + - in: body + pointer: "" + code: invalid + message: The value does not match the contract. +NeedExtractedValueMismatch: + summary: Status extracted with a value that is not the stored suggestion + description: A request may keep only the stored suggestion unconfirmed. To set another value, it sends status confirmed. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 3c4d5e6f-7a8b-4c9d-8e0f-2a3b4c5d6e7f + errors: + - in: body + pointer: /grade/status + code: invalid + message: The value does not match the contract. +NeedUnknownField: + summary: The client sent its own recommendation score + description: Recommendations, membership, and candidate minimums are never request fields; any unknown field fails validation. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 8d9e0f1a-2b3c-4d4e-8f5a-6b7c8d9e0f1b + errors: + - in: body + pointer: "" + code: invalid + message: The value does not match the contract. +NeedMissingExpectedVersion: + summary: A change without expected_version + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 9e0f1a2b-3c4d-4e5f-9a6b-7c8d9e0f1a2c + errors: + - in: body + pointer: /expected_version + code: required + message: The value is required. +NeedStaleVersion: + summary: The change carried a stale expected_version + description: Another member or a server-side extraction changed the need after the client read it. Nothing was changed; the client reads the need again and reapplies its unsaved edits. + value: + type: urn:lincodex:problem:version_conflict + title: Resource version conflict + status: 412 + code: version_conflict + detail: The resource changed after it was read. Read it again before retrying. + trace_id: 0f1a2b3c-4d5e-4f6a-8b7c-8d9e0f1a2b3d diff --git a/api/core/components/parameters.yml b/api/core/components/parameters.yml index f6d6f6b..1e8826d 100644 --- a/api/core/components/parameters.yml +++ b/api/core/components/parameters.yml @@ -68,3 +68,28 @@ AssessmentAttemptId: type: string format: uuid example: 01928f7a-3c4d-7e5f-8a9b-0c1d2e3f4a5b +OrganizationId: + name: org_id + in: path + required: true + description: >- + Identifier of an organization. Access comes only from an active + membership of the session account in this organization, checked by the + server on every request; the identifier itself grants nothing. An + organization without such a membership and an unknown identifier both + answer 404 not_found, so organizations cannot be enumerated. + schema: + type: string + format: uuid + example: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 +NeedId: + name: need_id + in: path + required: true + description: >- + Identifier of a need of the organization in the path. A need of another + organization and an unknown identifier both answer 404 not_found. + schema: + type: string + format: uuid + example: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 diff --git a/api/core/components/responses.yml b/api/core/components/responses.yml index 4892849..7d991d4 100644 --- a/api/core/components/responses.yml +++ b/api/core/components/responses.yml @@ -374,3 +374,48 @@ AssessmentVersionConflict: examples: version_conflict: $ref: ./examples.yml#/AssessmentStaleVersion +NeedValidationFailed: + description: >- + The body does not match the contract or violates a need rule: an unknown + field such as rec_score, members, or candidate_minimum, a field sent as a + bare value instead of `{value, status}`, a list sent as null, an unknown + specialization, grade, work format, currency, period, or tax basis, a + salary bound that is not a positive multiple of 1000, a lower bound that + is not below the upper one, a range width outside 10-40% of its midpoint, + a repeated skill or task, status `extracted` with a value that is not the + stored suggestion, a vacancy that is not a vacancy of the organization, + or a missing or invalid expected_version; code validation_failed with + body pointers. When the decoder does not record the path of a nested + field, the pointer is the whole body. Nothing was changed, and the + outcome is not stored under an Idempotency-Key. + content: + application/problem+json: + schema: + $ref: ./schemas.yml#/Problem + examples: + reversed_salary_range: + $ref: ./examples.yml#/NeedSalaryRangeReversed + equal_salary_bounds: + $ref: ./examples.yml#/NeedSalaryEqualBounds + salary_range_too_wide: + $ref: ./examples.yml#/NeedSalaryRangeTooWide + salary_without_tax_basis: + $ref: ./examples.yml#/NeedSalaryWithoutTaxBasis + extracted_value_mismatch: + $ref: ./examples.yml#/NeedExtractedValueMismatch + recommendation_score_sent_by_client: + $ref: ./examples.yml#/NeedUnknownField + missing_expected_version: + $ref: ./examples.yml#/NeedMissingExpectedVersion +NeedVersionConflict: + description: >- + `expected_version` is not the current need version; code + version_conflict. Nothing was changed; read the need again before + retrying. + content: + application/problem+json: + schema: + $ref: ./schemas.yml#/Problem + examples: + version_conflict: + $ref: ./examples.yml#/NeedStaleVersion diff --git a/api/core/components/schemas.yml b/api/core/components/schemas.yml index 680ed31..5f8d57d 100644 --- a/api/core/components/schemas.yml +++ b/api/core/components/schemas.yml @@ -1624,6 +1624,918 @@ Session: $ref: '#/Account' csrf_token: $ref: '#/CsrfToken' +NeedVersion: + type: integer + format: int64 + minimum: 1 + description: Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version. + examples: + - 2 +NeedTitle: + type: string + minLength: 1 + maxLength: 200 + pattern: ^\S(?:.*\S)?$ + description: Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML. +NeedSourceText: + type: string + minLength: 1 + maxLength: 10000 + description: 'Free description of the team''s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).' +NeedValueStatus: + type: string + description: 'Confirmation state of one need field. + + + - confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations. + + - extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness. + + - unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.' + enum: + - confirmed + - extracted + - unknown +NeedItemStatus: + type: string + description: 'Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.' + enum: + - confirmed + - extracted +NeedValueOrigin: + type: string + description: 'Where the value of a field or item came from. The server sets it; a request never sends it. + + + - manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null. + + - extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version. + + - imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it. + + + Confirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.' + enum: + - manual + - extracted_from_text + - imported +NeedSourceQuote: + type: string + minLength: 1 + maxLength: 300 + description: Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML. +NeedVersionLabel: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[A-Za-z0-9._-]+$ + description: Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it. +NeedValueSource: + type: object + description: 'Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.' + additionalProperties: false + required: + - origin + - quote + - extracted_in_version + - extraction_version + properties: + origin: + $ref: '#/NeedValueOrigin' + quote: + description: Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt. + oneOf: + - $ref: '#/NeedSourceQuote' + - type: 'null' + extracted_in_version: + description: Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`. + oneOf: + - $ref: '#/NeedVersion' + - type: 'null' + extraction_version: + description: Extractor version for an extracted or imported value, or null for a manual value. + oneOf: + - $ref: '#/NeedVersionLabel' + - type: 'null' +SkillName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML. +SkillTaxonomyCode: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[a-z0-9][a-z0-9_.+#-]*$ + description: Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name. +NeedTaskText: + type: string + minLength: 1 + maxLength: 300 + pattern: ^\S(?:.*\S)?$ + description: One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML. +NeedDomainName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML. +NeedLocationName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Place of work for the office or hybrid format, for example a city, as free text. It describes the employer's office, never a candidate's address. Plain text without line breaks; clients show it as text, never as HTML. +RubAmount: + type: integer + format: int64 + minimum: 1000 + maximum: 100000000 + multipleOf: 1000 + description: Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final. + examples: + - 120000 +CurrencyCode: + type: string + description: ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change. + enum: + - RUB +SalaryPeriod: + type: string + description: Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change. + enum: + - month +SalaryTaxBasis: + type: string + description: 'Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.' + enum: + - net + - gross +SalaryRange: + type: object + description: 'Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.' + additionalProperties: false + required: + - salary_from + - salary_to + - currency + - period + - tax_basis + properties: + salary_from: + $ref: '#/RubAmount' + salary_to: + $ref: '#/RubAmount' + currency: + $ref: '#/CurrencyCode' + period: + $ref: '#/SalaryPeriod' + tax_basis: + $ref: '#/SalaryTaxBasis' +NeedSpecialization: + type: object + description: Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + oneOf: + - $ref: '#/SpecializationCode' + - type: 'null' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedGrade: + type: object + description: Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + oneOf: + - $ref: '#/GradeCode' + - type: 'null' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedDomain: + type: object + description: Business domain of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + oneOf: + - $ref: '#/NeedDomainName' + - type: 'null' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedWorkFormats: + type: object + description: Work formats that the employer offers, with their confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a known value lists one to three formats. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + type: + - array + - 'null' + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: '#/WorkFormat' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedLocation: + type: object + description: Place of work with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats include `office` or `hybrid`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + oneOf: + - $ref: '#/NeedLocationName' + - type: 'null' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedSalary: + type: object + description: Salary range that the employer offers, with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the server never substitutes zero, a market estimate, or a range from another need. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/NeedValueStatus' + value: + oneOf: + - $ref: '#/SalaryRange' + - type: 'null' + source: + oneOf: + - $ref: '#/NeedValueSource' + - type: 'null' +NeedSkill: + type: object + description: 'One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.' + additionalProperties: false + required: + - name + - taxonomy_code + - status + - source + properties: + name: + $ref: '#/SkillName' + taxonomy_code: + oneOf: + - $ref: '#/SkillTaxonomyCode' + - type: 'null' + status: + $ref: '#/NeedItemStatus' + source: + $ref: '#/NeedValueSource' +NeedTask: + type: object + description: One work task of the team with its confirmation state and provenance. + additionalProperties: false + required: + - text + - status + - source + properties: + text: + $ref: '#/NeedTaskText' + status: + $ref: '#/NeedItemStatus' + source: + $ref: '#/NeedValueSource' +NeedSpecializationInput: + type: object + description: Decision about the specialization in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/SpecializationCode' + status: + $ref: '#/NeedItemStatus' +NeedGradeInput: + type: object + description: Decision about the grade in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/GradeCode' + status: + $ref: '#/NeedItemStatus' +NeedDomainInput: + type: object + description: Decision about the domain in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/NeedDomainName' + status: + $ref: '#/NeedItemStatus' +NeedWorkFormatsInput: + type: object + description: Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set. + additionalProperties: false + required: + - value + - status + properties: + value: + type: array + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: '#/WorkFormat' + status: + $ref: '#/NeedItemStatus' +NeedLocationInput: + type: object + description: Decision about the place of work in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/NeedLocationName' + status: + $ref: '#/NeedItemStatus' +NeedSalaryInput: + type: object + description: Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/SalaryRange' + status: + $ref: '#/NeedItemStatus' +NeedSkillInput: + type: object + description: 'One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.' + additionalProperties: false + required: + - name + - status + properties: + name: + $ref: '#/SkillName' + status: + $ref: '#/NeedItemStatus' +NeedTaskInput: + type: object + description: One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput. + additionalProperties: false + required: + - text + - status + properties: + text: + $ref: '#/NeedTaskText' + status: + $ref: '#/NeedItemStatus' +NeedRequirementSet: + type: object + description: Requirements of one need version, each with its confirmation state and provenance. Read-only; requests change them through the fields of NeedCreate and NeedUpdate. + additionalProperties: false + required: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary + properties: + specialization: + $ref: '#/NeedSpecialization' + grade: + $ref: '#/NeedGrade' + required_skills: + type: array + maxItems: 30 + description: Required skills; each has weight 2 in skill coverage. Only confirmed skills count. + items: + $ref: '#/NeedSkill' + desired_skills: + type: array + maxItems: 30 + description: Desired skills; each has weight 1 in skill coverage. Only confirmed skills count. + items: + $ref: '#/NeedSkill' + tasks: + type: array + maxItems: 20 + description: Work tasks of the team in the order given. + items: + $ref: '#/NeedTask' + domain: + $ref: '#/NeedDomain' + work_formats: + $ref: '#/NeedWorkFormats' + location: + $ref: '#/NeedLocation' + salary: + $ref: '#/NeedSalary' +NeedFieldName: + type: string + description: Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change. + enum: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary +NeedMissingReason: + type: string + description: 'Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.' + enum: + - unknown + - unconfirmed +NeedMissingField: + type: object + description: One critical field that has no confirmed value, with a specific question that the client shows next to the field. + additionalProperties: false + required: + - field + - reason + - question + properties: + field: + $ref: '#/NeedFieldName' + reason: + $ref: '#/NeedMissingReason' + question: + type: string + minLength: 1 + maxLength: 300 + description: Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML. +NeedReadinessStatus: + type: string + description: '`complete` when every critical field has a confirmed value, otherwise `incomplete`.' + enum: + - complete + - incomplete +NeedReadinessReport: + type: object + description: Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires. + additionalProperties: false + required: + - status + - missing_fields + properties: + status: + $ref: '#/NeedReadinessStatus' + missing_fields: + type: array + maxItems: 9 + description: Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`. + items: + $ref: '#/NeedMissingField' +NeedRecommendationStatus: + type: string + description: 'State of the category recommendations of the current requirements version. + + + - computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`. + + - pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later. + + - not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty.' + enum: + - computed + - pending + - not_available +NeedSkillOverlap: + type: object + description: 'Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.' + additionalProperties: false + required: + - share + - covered_skills + - uncovered_skills + properties: + share: + type: number + format: double + minimum: 0 + maximum: 1 + description: Weighted share from 0 to 1, rounded to two decimals. + covered_skills: + type: array + maxItems: 60 + description: Confirmed skills of the need that the category covers. + items: + $ref: '#/SkillName' + uncovered_skills: + type: array + maxItems: 60 + description: Confirmed skills of the need that the category does not cover, including skills without a taxonomy code. + items: + $ref: '#/SkillName' +NeedMoneyStatus: + type: string + description: 'How the salary component of a recommendation was obtained. + + + - computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given. + + - insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null. + + - no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null. + + - withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null. + + + An unknown candidate minimum never counts as zero.' + enum: + - computed + - insufficient_data + - no_salary + - withheld +NeedMoneyFit: + type: object + description: Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate. + additionalProperties: false + required: + - status + - share + properties: + status: + $ref: '#/NeedMoneyStatus' + share: + type: + - number + - 'null' + format: double + minimum: 0 + maximum: 1 + description: 'Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.' +NeedSupplyBand: + type: string + description: 'Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.' + enum: + - fewer_than_5 + - from_5_to_29 + - 30_or_more +NeedCategoryRecommendation: + type: object + description: 'One recommended category, a specialization with a grade, with its score and the reasons for it. The score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor the order reveals the exact size of a group below five.' + additionalProperties: false + required: + - specialization + - grade + - score + - skill_overlap + - money + - supply + properties: + specialization: + $ref: '#/SpecializationCode' + grade: + $ref: '#/GradeCode' + score: + type: + - number + - 'null' + format: double + minimum: 0 + maximum: 1 + description: Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is `fewer_than_5`. Read-only; no request can set it. + skill_overlap: + $ref: '#/NeedSkillOverlap' + money: + $ref: '#/NeedMoneyFit' + supply: + $ref: '#/NeedSupplyBand' +NeedCategoryRecommendations: + type: object + description: 'Category recommendations computed by the server from the confirmed requirements of `requirements_version` with a versioned policy (PRD FR08). Read-only: no request can set a recommendation, a score, or one of its components. The server may recompute them for the same requirements version, for example for a new policy or a changed pool of available candidates, without a new need version; `computed_at` and `policy_version` then change. The policy version and the candidate group used are stored with each computation, so a later policy never rewrites it.' + additionalProperties: false + required: + - status + - requirements_version + - policy_version + - algorithm_version + - computed_at + - categories + properties: + status: + $ref: '#/NeedRecommendationStatus' + requirements_version: + $ref: '#/NeedVersion' + policy_version: + type: + - integer + - 'null' + format: int32 + minimum: 1 + description: Number of the policy version whose weights were applied, or null unless `status` is `computed`. + algorithm_version: + description: Version of the recommendation algorithm, or null unless `status` is `computed`. + oneOf: + - $ref: '#/NeedVersionLabel' + - type: 'null' + computed_at: + description: Time of the computation, or null unless `status` is `computed`. + oneOf: + - $ref: '#/Timestamp' + - type: 'null' + categories: + type: array + maxItems: 10 + description: Recommended categories, best first by the score described in NeedCategoryRecommendation. Empty unless `status` is `computed`. + items: + $ref: '#/NeedCategoryRecommendation' +Need: + type: object + description: 'Hiring need of an organization: what the team needs, independent of any published vacancy. It holds the current version of the requirements with their provenance, the readiness of the critical fields, and the category recommendations. It never contains membership data, a candidate''s personal data, or a candidate''s salary minimum.' + additionalProperties: false + required: + - id + - organization_id + - vacancy_id + - title + - source_text + - version + - requirements_version + - requirements + - readiness + - recommendations + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + organization_id: + type: string + format: uuid + description: Organization that owns the need, equal to `org_id` of the path. It never changes. + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Linked vacancy of the same organization, or null. A need never requires a vacancy. + title: + $ref: '#/NeedTitle' + source_text: + description: Text the requirements were extracted from, or null. + oneOf: + - $ref: '#/NeedSourceText' + - type: 'null' + version: + $ref: '#/NeedVersion' + requirements_version: + description: Need version in which the current confirmed requirements were last changed, at most `version`. A change that confirms, changes, or removes a requirement makes it equal to the new `version`. A change of the title, the vacancy link, or the text, or of suggestions only, creates a new `version` but keeps `requirements_version`, so it invalidates neither the recommendations nor search results and selection snapshots. Search runs and selection snapshots (PRD FR10) refer to `(need id, requirements_version)`, and a new selection snapshot is due only when it changes. + allOf: + - $ref: '#/NeedVersion' + requirements: + $ref: '#/NeedRequirementSet' + readiness: + $ref: '#/NeedReadinessReport' + recommendations: + $ref: '#/NeedCategoryRecommendations' + created_at: + $ref: '#/Timestamp' + updated_at: + $ref: '#/Timestamp' +NeedSummary: + type: object + description: 'Need in a list: its identity, current version, target category fields, and readiness. Read the need for the requirements and the recommendations.' + additionalProperties: false + required: + - id + - vacancy_id + - title + - version + - specialization + - grade + - readiness + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Linked vacancy, or null. + title: + $ref: '#/NeedTitle' + version: + $ref: '#/NeedVersion' + specialization: + $ref: '#/NeedSpecialization' + grade: + $ref: '#/NeedGrade' + readiness: + $ref: '#/NeedReadinessReport' + created_at: + $ref: '#/Timestamp' + updated_at: + $ref: '#/Timestamp' +NeedList: + type: object + description: One page of the needs of an organization, newest first by creation time. + additionalProperties: false + required: + - items + - page + properties: + items: + type: array + maxItems: 100 + description: Needs of the page. + items: + $ref: '#/NeedSummary' + page: + $ref: '#/PageInfo' +NeedCreate: + type: object + description: New need. Only `title` is required, so a need can start from a title, from a text, or from form fields, and with or without a vacancy. A field or list item given here must have `status` `confirmed` and becomes a confirmed manual value; `extracted` answers 400 with the pointer of that `status`, such as `/grade/status`, because a new need has no stored suggestion. A field that is absent is extracted from `source_text` when the text is given and is left unknown or empty otherwise. A nullable field sent as null, and a skill or task list sent as an empty list, stays unknown or empty and is not extracted; an empty `work_formats` value fails `minItems`. Unknown fields are rejected, so a request cannot set membership, a role, a status of the need, a provenance, readiness, a recommendation or its score, or a candidate's salary minimum. + additionalProperties: false + required: + - title + properties: + title: + $ref: '#/NeedTitle' + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Vacancy of the same organization to link, or null or absent for a need without a vacancy. + source_text: + oneOf: + - $ref: '#/NeedSourceText' + - type: 'null' + specialization: + oneOf: + - $ref: '#/NeedSpecializationInput' + - type: 'null' + grade: + oneOf: + - $ref: '#/NeedGradeInput' + - type: 'null' + required_skills: + type: array + maxItems: 30 + items: + $ref: '#/NeedSkillInput' + desired_skills: + type: array + maxItems: 30 + items: + $ref: '#/NeedSkillInput' + tasks: + type: array + maxItems: 20 + items: + $ref: '#/NeedTaskInput' + domain: + oneOf: + - $ref: '#/NeedDomainInput' + - type: 'null' + work_formats: + oneOf: + - $ref: '#/NeedWorkFormatsInput' + - type: 'null' + location: + oneOf: + - $ref: '#/NeedLocationInput' + - type: 'null' + salary: + oneOf: + - $ref: '#/NeedSalaryInput' + - type: 'null' +NeedUpdate: + type: object + description: 'Change of a need over the version the client read. Each field present in the body replaces that field as a whole; an absent field stays unchanged. Nested objects and lists are not merged: a field decision and each list are replaced entirely, and a stored item missing from a sent list is deleted. A nullable field sent as null becomes unknown, or unlinked for `vacancy_id`; a skill or task list sent empty deletes every item; a list sent as null fails validation. A field decision `{value, status}` and a list item follow the same rules: `confirmed` with the stored value confirms it and keeps its origin and quote, and `confirmed` with another value sets a confirmed manual value; `extracted` keeps a stored suggestion unconfirmed and is allowed only with exactly the stored suggested value, otherwise it answers 400 with the pointer of that `status`, such as `/grade/status` or `/required_skills/0/status`. A client that sends back an unchanged form therefore confirms nothing by accident: + it sends each suggestion with `extracted`, or leaves the field out. Sending a different `source_text` extracts again: new suggestions replace only the `extracted` values and items of fields not named in this body; confirmed values are never overwritten, a suggested skill whose name is already in either skill list is skipped, and a suggestion that a member deleted is not proposed again for this need. Unknown fields are rejected, so a request cannot set membership, a role, a provenance, readiness, a recommendation or its score, or a candidate''s salary minimum.' + additionalProperties: false + required: + - expected_version + properties: + expected_version: + $ref: '#/NeedVersion' + title: + $ref: '#/NeedTitle' + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Vacancy of the same organization to link, or null to unlink. + source_text: + oneOf: + - $ref: '#/NeedSourceText' + - type: 'null' + specialization: + oneOf: + - $ref: '#/NeedSpecializationInput' + - type: 'null' + grade: + oneOf: + - $ref: '#/NeedGradeInput' + - type: 'null' + required_skills: + type: array + maxItems: 30 + items: + $ref: '#/NeedSkillInput' + desired_skills: + type: array + maxItems: 30 + items: + $ref: '#/NeedSkillInput' + tasks: + type: array + maxItems: 20 + items: + $ref: '#/NeedTaskInput' + domain: + oneOf: + - $ref: '#/NeedDomainInput' + - type: 'null' + work_formats: + oneOf: + - $ref: '#/NeedWorkFormatsInput' + - type: 'null' + location: + oneOf: + - $ref: '#/NeedLocationInput' + - type: 'null' + salary: + oneOf: + - $ref: '#/NeedSalaryInput' + - type: 'null' Problem: type: object description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values. diff --git a/api/core/components/schemas/need_schemas.yml b/api/core/components/schemas/need_schemas.yml new file mode 100644 index 0000000..e11ac57 --- /dev/null +++ b/api/core/components/schemas/need_schemas.yml @@ -0,0 +1,1175 @@ +schemas: + NeedVersion: + type: integer + format: int64 + minimum: 1 + description: >- + Version of an employer need. Creation makes version 1, and every + committed change of the need advances it by exactly one, including a + change made by the server, such as a planned asynchronous ML + suggestion. Each version is an immutable snapshot of the need. + `requirements_version` names the version whose confirmed requirements + are current, so a change that leaves them unchanged creates a need + version without a new requirements version. + examples: + - 2 + NeedTitle: + type: string + minLength: 1 + maxLength: 200 + pattern: '^\S(?:.*\S)?$' + description: >- + Short name of the need inside the organization, for example "Backend + for the payments team". It has no leading or trailing whitespace and no + line breaks. Plain text; clients show it as text, never as HTML. + NeedSourceText: + type: string + minLength: 1 + maxLength: 10000 + description: >- + Free description of the team's tasks as the employer wrote or pasted + it. The server extracts proposed requirements from it; the text itself + is never a requirement. It may contain line breaks. Plain text; clients + show it as text, never as HTML. It describes the job and must not + contain personal data of candidates. The server stores it as written: + it may contain requirements that discriminate by a protected + characteristic, and the extractor never turns such a requirement into + a need field. Exclusions, the requirements that a candidate must not + meet, are planned as a separate additive field with the Labor Code + article 64 check (TASK-182). + NeedValueStatus: + type: string + description: |- + Confirmation state of one need field. + + - confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations. + - extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness. + - unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary. + enum: + - confirmed + - extracted + - unknown + NeedItemStatus: + type: string + description: >- + Confirmation state of a list item, and the decision that a request + sends for a field or an item: `confirmed` or `extracted`, with the + meaning of NeedValueStatus. A request sends `confirmed` to confirm a + suggestion or to set a manual value, and `extracted` only to keep a + stored suggestion unconfirmed with exactly its stored value. An item is + never `unknown`; a list with no confirmed item is what readiness + reports as missing. + enum: + - confirmed + - extracted + NeedValueOrigin: + type: string + description: |- + Where the value of a field or item came from. The server sets it; a request never sends it. + + - manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null. + - extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version. + - imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it. + + Confirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change. + enum: + - manual + - extracted_from_text + - imported + NeedSourceQuote: + type: string + minLength: 1 + maxLength: 300 + description: >- + Exact excerpt of the `source_text` that the value was extracted from, + so a reviewer can check it. It may contain line breaks. Plain text; + clients show it as text, never as HTML. + NeedVersionLabel: + type: string + minLength: 1 + maxLength: 64 + pattern: "^[A-Za-z0-9._-]+$" + description: >- + Opaque identifier of a published extractor or algorithm version, for + example `need-rules.2026-10.1`. Clients show it as text and never + parse it. + NeedValueSource: + type: object + description: >- + Provenance of a value: its origin, the quote it was extracted from, the + need version whose text the quote belongs to, and the extractor + version. Read-only; the server derives it and a request cannot set it. + additionalProperties: false + required: + - origin + - quote + - extracted_in_version + - extraction_version + properties: + origin: + $ref: "#/schemas/NeedValueOrigin" + quote: + description: >- + Excerpt of the need text that supports the value, or null for a + manual value and for an extracted value that the extractor did not + tie to one excerpt. + oneOf: + - $ref: "#/schemas/NeedSourceQuote" + - type: "null" + extracted_in_version: + description: >- + Need version whose `source_text` the value was extracted from and + the quote is an excerpt of, or null for a manual value. A confirmed + value keeps it after the text changes, so its quote may be absent + from the current `source_text`. + oneOf: + - $ref: "#/schemas/NeedVersion" + - type: "null" + extraction_version: + description: >- + Extractor version for an extracted or imported value, or null for + a manual value. + oneOf: + - $ref: "#/schemas/NeedVersionLabel" + - type: "null" + SkillName: + type: string + minLength: 1 + maxLength: 100 + pattern: '^\S(?:.*\S)?$' + description: >- + Name of a skill or technology as the employer gave it, for example Go, + PostgreSQL, or Temporal. It has no leading or trailing whitespace and + no line breaks. The server compares names without regard to letter + case. Plain text; clients show it as text, never as HTML. + SkillTaxonomyCode: + type: string + minLength: 1 + maxLength: 64 + pattern: "^[a-z0-9][a-z0-9_.+#-]*$" + description: >- + Code of a skill in the platform skill taxonomy, for example + `postgresql`. The server assigns it from the taxonomy; clients never + send it and never derive it from the name. + NeedTaskText: + type: string + minLength: 1 + maxLength: 300 + pattern: '^\S(?:.*\S)?$' + description: >- + One work task of the team, for example "Move the payout service to an + event model". It has no leading or trailing whitespace and no line + breaks. Plain text; clients show it as text, never as HTML. + NeedDomainName: + type: string + minLength: 1 + maxLength: 100 + pattern: '^\S(?:.*\S)?$' + description: >- + Business domain of the work, for example payments or logistics, as + free text. Plain text without line breaks; clients show it as text, + never as HTML. + NeedLocationName: + type: string + minLength: 1 + maxLength: 100 + pattern: '^\S(?:.*\S)?$' + description: >- + Place of work for the office or hybrid format, for example a city, + as free text. It describes the employer's office, never a candidate's + address. Plain text without line breaks; clients show it as text, + never as HTML. + RubAmount: + type: integer + format: int64 + minimum: 1000 + maximum: 100000000 + multipleOf: 1000 + description: >- + Amount of money in whole rubles. A salary bound is positive and a + multiple of 1000, the step that PRD FR13 sets for the bounds of a + salary range and for the bids of the sealed final. + examples: + - 120000 + CurrencyCode: + type: string + description: >- + ISO 4217 currency code. The MVP accepts only RUB; adding a value is a + contract change. + enum: + - RUB + SalaryPeriod: + type: string + description: >- + Pay period of a salary amount. The MVP uses only `month`; adding a + value is a contract change. + enum: + - month + SalaryTaxBasis: + type: string + description: >- + Tax basis of a salary amount: `net`, the amount paid out after personal + income tax, or `gross`, the amount before it. The basis is always + explicit; amounts in different bases are never compared directly. + enum: + - net + - gross + SalaryRange: + type: object + description: >- + Salary range `[A; B]` in whole rubles with its base: the currency, the + pay period, and the tax basis (PRD FR13). The schema requires every + field, bounds that are positive multiples of 1000, and the known + currency, period, and basis. The server checks the cross-field rules + in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) + / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + + B` and `5 * (B - A) <= A + B`. A violation answers 400 + validation_failed with the pointer of `salary_to` in the request, for + example `/salary/value/salary_to`. For example, `[95000; 105000]` has + a width of exactly 10% and `[80000; 120000]` exactly 40%; both are + accepted. The rules are the same for a need and an invitation. + additionalProperties: false + required: + - salary_from + - salary_to + - currency + - period + - tax_basis + properties: + salary_from: + $ref: "#/schemas/RubAmount" + salary_to: + $ref: "#/schemas/RubAmount" + currency: + $ref: "#/schemas/CurrencyCode" + period: + $ref: "#/schemas/SalaryPeriod" + tax_basis: + $ref: "#/schemas/SalaryTaxBasis" + NeedSpecialization: + type: object + description: >- + Target specialization of the need with its confirmation state and + provenance. `value` and `source` are null exactly when `status` is + `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + oneOf: + - $ref: "./catalog_schemas.yml#/schemas/SpecializationCode" + - type: "null" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedGrade: + type: object + description: >- + Target grade of the need with its confirmation state and provenance. + `value` and `source` are null exactly when `status` is `unknown`; a + text that names no grade leaves the grade unknown instead of assuming + one. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + oneOf: + - $ref: "./catalog_schemas.yml#/schemas/GradeCode" + - type: "null" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedDomain: + type: object + description: >- + Business domain of the need with its confirmation state and + provenance. `value` and `source` are null exactly when `status` is + `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + oneOf: + - $ref: "#/schemas/NeedDomainName" + - type: "null" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedWorkFormats: + type: object + description: >- + Work formats that the employer offers, with their confirmation state + and provenance. `value` and `source` are null exactly when `status` is + `unknown`; a known value lists one to three formats. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + type: + - array + - "null" + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: "./questionnaire_schemas.yml#/schemas/WorkFormat" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedLocation: + type: object + description: >- + Place of work with its confirmation state and provenance. `value` and + `source` are null exactly when `status` is `unknown`. Readiness + requires a confirmed place only when the confirmed work formats + include `office` or `hybrid`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + oneOf: + - $ref: "#/schemas/NeedLocationName" + - type: "null" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedSalary: + type: object + description: >- + Salary range that the employer offers, with its confirmation state and + provenance. `value` and `source` are null exactly when `status` is + `unknown`. A text without a salary leaves it unknown; the server never + substitutes zero, a market estimate, or a range from another need. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: "#/schemas/NeedValueStatus" + value: + oneOf: + - $ref: "#/schemas/SalaryRange" + - type: "null" + source: + oneOf: + - $ref: "#/schemas/NeedValueSource" + - type: "null" + NeedSkill: + type: object + description: >- + One required or desired skill of the need. `taxonomy_code` is null for + a skill that the platform taxonomy does not know: the server keeps the + name as given, never maps it to a guessed code, and counts it as not + covered in category recommendations. + additionalProperties: false + required: + - name + - taxonomy_code + - status + - source + properties: + name: + $ref: "#/schemas/SkillName" + taxonomy_code: + oneOf: + - $ref: "#/schemas/SkillTaxonomyCode" + - type: "null" + status: + $ref: "#/schemas/NeedItemStatus" + source: + $ref: "#/schemas/NeedValueSource" + NeedTask: + type: object + description: One work task of the team with its confirmation state and provenance. + additionalProperties: false + required: + - text + - status + - source + properties: + text: + $ref: "#/schemas/NeedTaskText" + status: + $ref: "#/schemas/NeedItemStatus" + source: + $ref: "#/schemas/NeedValueSource" + NeedSpecializationInput: + type: object + description: >- + Decision about the specialization in a request; see NeedUpdate for the + rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: "./catalog_schemas.yml#/schemas/SpecializationCode" + status: + $ref: "#/schemas/NeedItemStatus" + NeedGradeInput: + type: object + description: >- + Decision about the grade in a request; see NeedUpdate for the rules of + `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: "./catalog_schemas.yml#/schemas/GradeCode" + status: + $ref: "#/schemas/NeedItemStatus" + NeedDomainInput: + type: object + description: >- + Decision about the domain in a request; see NeedUpdate for the rules of + `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: "#/schemas/NeedDomainName" + status: + $ref: "#/schemas/NeedItemStatus" + NeedWorkFormatsInput: + type: object + description: >- + Decision about the work formats in a request; see NeedUpdate for the + rules of `status`. Formats are compared as a set. + additionalProperties: false + required: + - value + - status + properties: + value: + type: array + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: "./questionnaire_schemas.yml#/schemas/WorkFormat" + status: + $ref: "#/schemas/NeedItemStatus" + NeedLocationInput: + type: object + description: >- + Decision about the place of work in a request; see NeedUpdate for the + rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: "#/schemas/NeedLocationName" + status: + $ref: "#/schemas/NeedItemStatus" + NeedSalaryInput: + type: object + description: >- + Decision about the salary range in a request; see NeedUpdate for the + rules of `status` and SalaryRange for the rules of the range, whose + pointers are under `/salary/value`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: "#/schemas/SalaryRange" + status: + $ref: "#/schemas/NeedItemStatus" + NeedSkillInput: + type: object + description: >- + One skill of a list in a request. A name that equals, without regard to + letter case, a skill of the current version in either skill list + refers to that skill and keeps its origin, quote, and taxonomy code; + this is how an extracted skill is confirmed or moved between the + required and desired lists. Any other name is a new manual skill. + `status` follows the rules of NeedUpdate: `extracted` for a name that + is not a stored suggestion answers 400 validation_failed with the + pointer of that `status`, for example `/required_skills/2/status`. A + name repeated within or across the two skill lists answers 400 with + the pointer of the later `name`. + additionalProperties: false + required: + - name + - status + properties: + name: + $ref: "#/schemas/SkillName" + status: + $ref: "#/schemas/NeedItemStatus" + NeedTaskInput: + type: object + description: >- + One task of the list in a request. A text equal to a task of the + current version refers to that task and keeps its origin and quote; + any other text is a new manual task. `status` and repeated texts follow + the rules of NeedSkillInput. + additionalProperties: false + required: + - text + - status + properties: + text: + $ref: "#/schemas/NeedTaskText" + status: + $ref: "#/schemas/NeedItemStatus" + NeedRequirementSet: + type: object + description: >- + Requirements of one need version, each with its confirmation state and + provenance. Read-only; requests change them through the fields of + NeedCreate and NeedUpdate. + additionalProperties: false + required: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary + properties: + specialization: + $ref: "#/schemas/NeedSpecialization" + grade: + $ref: "#/schemas/NeedGrade" + required_skills: + type: array + maxItems: 30 + description: >- + Required skills; each has weight 2 in skill coverage. Only + confirmed skills count. + items: + $ref: "#/schemas/NeedSkill" + desired_skills: + type: array + maxItems: 30 + description: >- + Desired skills; each has weight 1 in skill coverage. Only confirmed + skills count. + items: + $ref: "#/schemas/NeedSkill" + tasks: + type: array + maxItems: 20 + description: Work tasks of the team in the order given. + items: + $ref: "#/schemas/NeedTask" + domain: + $ref: "#/schemas/NeedDomain" + work_formats: + $ref: "#/schemas/NeedWorkFormats" + location: + $ref: "#/schemas/NeedLocation" + salary: + $ref: "#/schemas/NeedSalary" + NeedFieldName: + type: string + description: >- + Name of a need field, equal to its property name in NeedRequirementSet + and in the request bodies. Adding a value is a contract change. + enum: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary + NeedMissingReason: + type: string + description: >- + Why a critical field is missing: `unknown`, the field has no value, or + `unconfirmed`, it has only an extracted value or, for required + skills, only extracted items that wait for confirmation. + enum: + - unknown + - unconfirmed + NeedMissingField: + type: object + description: >- + One critical field that has no confirmed value, with a specific + question that the client shows next to the field. + additionalProperties: false + required: + - field + - reason + - question + properties: + field: + $ref: "#/schemas/NeedFieldName" + reason: + $ref: "#/schemas/NeedMissingReason" + question: + type: string + minLength: 1 + maxLength: 300 + description: >- + Specific Russian question about the missing value, for example + which grade is needed. Plain text; the client shows it as text, + never as HTML. + NeedReadinessStatus: + type: string + description: >- + `complete` when every critical field has a confirmed value, otherwise + `incomplete`. + enum: + - complete + - incomplete + NeedReadinessReport: + type: object + description: >- + Completeness of the critical fields, computed by the server for the + current version. The critical fields are `specialization`, `grade`, + `required_skills` (at least one confirmed skill), `work_formats`, + `salary`, and `location` when the confirmed work formats include + `office` or `hybrid`. An incomplete need is still a valid saved need; + each later operation, such as search or an invitation, states which + readiness it requires. + additionalProperties: false + required: + - status + - missing_fields + properties: + status: + $ref: "#/schemas/NeedReadinessStatus" + missing_fields: + type: array + maxItems: 9 + description: >- + Critical fields without a confirmed value, each at most once, in + the order of NeedFieldName. Empty exactly when `status` is + `complete`. + items: + $ref: "#/schemas/NeedMissingField" + NeedRecommendationStatus: + type: string + description: |- + State of the category recommendations of the current requirements version. + + - computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`. + - pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later. + - not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty. + enum: + - computed + - pending + - not_available + NeedSkillOverlap: + type: object + description: >- + Skill coverage of a category: the weighted share of the confirmed + skills of the need that the category taxonomy covers, with weight 2 + for a required and 1 for a desired skill. + additionalProperties: false + required: + - share + - covered_skills + - uncovered_skills + properties: + share: + type: number + format: double + minimum: 0 + maximum: 1 + description: Weighted share from 0 to 1, rounded to two decimals. + covered_skills: + type: array + maxItems: 60 + description: Confirmed skills of the need that the category covers. + items: + $ref: "#/schemas/SkillName" + uncovered_skills: + type: array + maxItems: 60 + description: >- + Confirmed skills of the need that the category does not cover, + including skills without a taxonomy code. + items: + $ref: "#/schemas/SkillName" + NeedMoneyStatus: + type: string + description: |- + How the salary component of a recommendation was obtained. + + - computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given. + - insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null. + - no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null. + - withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null. + + An unknown candidate minimum never counts as zero. + enum: + - computed + - insufficient_data + - no_salary + - withheld + NeedMoneyFit: + type: object + description: >- + Salary component of a recommendation. It is an aggregate over at least + five candidates and never reveals a minimum of any candidate. + additionalProperties: false + required: + - status + - share + properties: + status: + $ref: "#/schemas/NeedMoneyStatus" + share: + type: + - number + - "null" + format: double + minimum: 0 + maximum: 1 + description: >- + Share of those candidates whose minimum is not above the upper + bound of the range, rounded down to a multiple of 0.25 (one of 0, + 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The + score and the ranking use this rounded value, never the exact + share. A quarter step gives five levels: each probe of a new upper + bound tells at most which quarter of the group accepts it, and in + the smallest allowed group of five candidates a single minimum + often does not move the value, while the share still separates a + range that most candidates accept from one that few accept. + NeedSupplyBand: + type: string + description: >- + Number of available candidates of the category in the allowed + detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller + groups are never counted exactly. + enum: + - fewer_than_5 + - from_5_to_29 + - 30_or_more + NeedCategoryRecommendation: + type: object + description: >- + One recommended category, a specialization with a grade, with its + score and the reasons for it. The score is `0.5 * Overlap + 0.3 * + Money + 0.2 * Supply` (PRD FR08) computed from the published + components: the exact skill overlap, the money share rounded down to a + quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at + least five candidates are available. For a group of fewer than five, + Supply enters the ranking as 0, the same for every such group, so + neither the score nor the order reveals the exact size of a group + below five. + additionalProperties: false + required: + - specialization + - grade + - score + - skill_overlap + - money + - supply + properties: + specialization: + $ref: "./catalog_schemas.yml#/schemas/SpecializationCode" + grade: + $ref: "./catalog_schemas.yml#/schemas/GradeCode" + score: + type: + - number + - "null" + format: double + minimum: 0 + maximum: 1 + description: >- + Recommendation score from 0 to 1, rounded half up to two decimals, + or null when `supply` is `fewer_than_5`. Read-only; no request can + set it. + skill_overlap: + $ref: "#/schemas/NeedSkillOverlap" + money: + $ref: "#/schemas/NeedMoneyFit" + supply: + $ref: "#/schemas/NeedSupplyBand" + NeedCategoryRecommendations: + type: object + description: >- + Category recommendations computed by the server from the confirmed + requirements of `requirements_version` with a versioned policy (PRD + FR08). Read-only: no request can set a recommendation, a score, or one + of its components. The server may recompute them for the same + requirements version, for example for a new policy or a changed pool + of available candidates, without a new need version; `computed_at` + and `policy_version` then change. The policy version and the candidate + group used are stored with each computation, so a later policy never + rewrites it. + additionalProperties: false + required: + - status + - requirements_version + - policy_version + - algorithm_version + - computed_at + - categories + properties: + status: + $ref: "#/schemas/NeedRecommendationStatus" + requirements_version: + $ref: "#/schemas/NeedVersion" + policy_version: + type: + - integer + - "null" + format: int32 + minimum: 1 + description: >- + Number of the policy version whose weights were applied, or null + unless `status` is `computed`. + algorithm_version: + description: >- + Version of the recommendation algorithm, or null unless `status` + is `computed`. + oneOf: + - $ref: "#/schemas/NeedVersionLabel" + - type: "null" + computed_at: + description: >- + Time of the computation, or null unless `status` is `computed`. + oneOf: + - $ref: "./common_schemas.yml#/schemas/Timestamp" + - type: "null" + categories: + type: array + maxItems: 10 + description: >- + Recommended categories, best first by the score described in + NeedCategoryRecommendation. Empty unless `status` is `computed`. + items: + $ref: "#/schemas/NeedCategoryRecommendation" + Need: + type: object + description: >- + Hiring need of an organization: what the team needs, independent of + any published vacancy. It holds the current version of the + requirements with their provenance, the readiness of the critical + fields, and the category recommendations. It never contains + membership data, a candidate's personal data, or a candidate's salary + minimum. + additionalProperties: false + required: + - id + - organization_id + - vacancy_id + - title + - source_text + - version + - requirements_version + - requirements + - readiness + - recommendations + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + organization_id: + type: string + format: uuid + description: >- + Organization that owns the need, equal to `org_id` of the path. It + never changes. + vacancy_id: + type: + - string + - "null" + format: uuid + description: >- + Linked vacancy of the same organization, or null. A need never + requires a vacancy. + title: + $ref: "#/schemas/NeedTitle" + source_text: + description: Text the requirements were extracted from, or null. + oneOf: + - $ref: "#/schemas/NeedSourceText" + - type: "null" + version: + $ref: "#/schemas/NeedVersion" + requirements_version: + description: >- + Need version in which the current confirmed requirements were last + changed, at most `version`. A change that confirms, changes, or + removes a requirement makes it equal to the new `version`. A change + of the title, the vacancy link, or the text, or of suggestions + only, creates a new `version` but keeps `requirements_version`, so + it invalidates neither the recommendations nor search results and + selection snapshots. Search runs and selection snapshots (PRD FR10) + refer to `(need id, requirements_version)`, and a new selection + snapshot is due only when it changes. + allOf: + - $ref: "#/schemas/NeedVersion" + requirements: + $ref: "#/schemas/NeedRequirementSet" + readiness: + $ref: "#/schemas/NeedReadinessReport" + recommendations: + $ref: "#/schemas/NeedCategoryRecommendations" + created_at: + $ref: "./common_schemas.yml#/schemas/Timestamp" + updated_at: + $ref: "./common_schemas.yml#/schemas/Timestamp" + NeedSummary: + type: object + description: >- + Need in a list: its identity, current version, target category + fields, and readiness. Read the need for the requirements and the + recommendations. + additionalProperties: false + required: + - id + - vacancy_id + - title + - version + - specialization + - grade + - readiness + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + vacancy_id: + type: + - string + - "null" + format: uuid + description: Linked vacancy, or null. + title: + $ref: "#/schemas/NeedTitle" + version: + $ref: "#/schemas/NeedVersion" + specialization: + $ref: "#/schemas/NeedSpecialization" + grade: + $ref: "#/schemas/NeedGrade" + readiness: + $ref: "#/schemas/NeedReadinessReport" + created_at: + $ref: "./common_schemas.yml#/schemas/Timestamp" + updated_at: + $ref: "./common_schemas.yml#/schemas/Timestamp" + NeedList: + type: object + description: >- + One page of the needs of an organization, newest first by creation + time. + additionalProperties: false + required: + - items + - page + properties: + items: + type: array + maxItems: 100 + description: Needs of the page. + items: + $ref: "#/schemas/NeedSummary" + page: + $ref: "./common_schemas.yml#/schemas/PageInfo" + NeedCreate: + type: object + description: >- + New need. Only `title` is required, so a need can start from a title, + from a text, or from form fields, and with or without a vacancy. A + field or list item given here must have `status` `confirmed` and + becomes a confirmed manual value; `extracted` answers 400 with the + pointer of that `status`, such as `/grade/status`, because a new need + has no stored suggestion. A field that is absent is extracted from + `source_text` when the text is given and is left unknown or empty + otherwise. A nullable field sent as null, and a skill or task list sent + as an empty list, stays unknown or empty and is not extracted; an + empty `work_formats` value fails `minItems`. Unknown fields are + rejected, so a request cannot set membership, a role, a status of the + need, a provenance, readiness, a recommendation or its score, or a + candidate's salary minimum. + additionalProperties: false + required: + - title + properties: + title: + $ref: "#/schemas/NeedTitle" + vacancy_id: + type: + - string + - "null" + format: uuid + description: >- + Vacancy of the same organization to link, or null or absent for a + need without a vacancy. + source_text: + oneOf: + - $ref: "#/schemas/NeedSourceText" + - type: "null" + specialization: + oneOf: + - $ref: "#/schemas/NeedSpecializationInput" + - type: "null" + grade: + oneOf: + - $ref: "#/schemas/NeedGradeInput" + - type: "null" + required_skills: + type: array + maxItems: 30 + items: + $ref: "#/schemas/NeedSkillInput" + desired_skills: + type: array + maxItems: 30 + items: + $ref: "#/schemas/NeedSkillInput" + tasks: + type: array + maxItems: 20 + items: + $ref: "#/schemas/NeedTaskInput" + domain: + oneOf: + - $ref: "#/schemas/NeedDomainInput" + - type: "null" + work_formats: + oneOf: + - $ref: "#/schemas/NeedWorkFormatsInput" + - type: "null" + location: + oneOf: + - $ref: "#/schemas/NeedLocationInput" + - type: "null" + salary: + oneOf: + - $ref: "#/schemas/NeedSalaryInput" + - type: "null" + NeedUpdate: + type: object + description: >- + Change of a need over the version the client read. Each field present + in the body replaces that field as a whole; an absent field stays + unchanged. Nested objects and lists are not merged: a field decision + and each list are replaced entirely, and a stored item missing from a + sent list is deleted. A nullable field sent as null becomes unknown, or + unlinked for `vacancy_id`; a skill or task list sent empty deletes + every item; a list sent as null fails validation. A field decision + `{value, status}` and a list item follow the same rules: `confirmed` + with the stored value confirms it and keeps its origin and quote, and + `confirmed` with another value sets a confirmed manual value; + `extracted` keeps a stored suggestion unconfirmed and is allowed only + with exactly the stored suggested value, otherwise it answers 400 with + the pointer of that `status`, such as `/grade/status` or + `/required_skills/0/status`. A client that sends back an unchanged + form therefore confirms nothing by accident: it sends each suggestion + with `extracted`, or leaves the field out. Sending a different + `source_text` extracts again: new suggestions replace only the + `extracted` values and items of fields not named in this body; + confirmed values are never overwritten, a suggested skill whose name is + already in either skill list is skipped, and a suggestion that a + member deleted is not proposed again for this need. Unknown fields are + rejected, so a request cannot set membership, a role, a provenance, + readiness, a recommendation or its score, or a candidate's salary + minimum. + additionalProperties: false + required: + - expected_version + properties: + expected_version: + $ref: "#/schemas/NeedVersion" + title: + $ref: "#/schemas/NeedTitle" + vacancy_id: + type: + - string + - "null" + format: uuid + description: Vacancy of the same organization to link, or null to unlink. + source_text: + oneOf: + - $ref: "#/schemas/NeedSourceText" + - type: "null" + specialization: + oneOf: + - $ref: "#/schemas/NeedSpecializationInput" + - type: "null" + grade: + oneOf: + - $ref: "#/schemas/NeedGradeInput" + - type: "null" + required_skills: + type: array + maxItems: 30 + items: + $ref: "#/schemas/NeedSkillInput" + desired_skills: + type: array + maxItems: 30 + items: + $ref: "#/schemas/NeedSkillInput" + tasks: + type: array + maxItems: 20 + items: + $ref: "#/schemas/NeedTaskInput" + domain: + oneOf: + - $ref: "#/schemas/NeedDomainInput" + - type: "null" + work_formats: + oneOf: + - $ref: "#/schemas/NeedWorkFormatsInput" + - type: "null" + location: + oneOf: + - $ref: "#/schemas/NeedLocationInput" + - type: "null" + salary: + oneOf: + - $ref: "#/schemas/NeedSalaryInput" + - type: "null" diff --git a/api/core/openapi.bundle.yml b/api/core/openapi.bundle.yml index 80a92c6..a3d2081 100644 --- a/api/core/openapi.bundle.yml +++ b/api/core/openapi.bundle.yml @@ -17,6 +17,8 @@ tags: description: Data of the current candidate, such as the questionnaire with the chosen specializations and self-assessed grades. Confirmed grades and categories come only from assessment results. - name: assessment description: 'Assessment attempts of the current candidate: availability, start and resume, answers and the code practice, finalization, and the result. Answers, keys, and attempt history are visible only to the candidate.' + - name: need + description: 'Hiring needs of an organization: requirements with their confirmation state and provenance, immutable versions, readiness, and category recommendations. Access comes only from an active membership in the organization; a need never requires a vacancy.' paths: /api/v1/healthz: get: @@ -818,6 +820,226 @@ paths: $ref: '#/components/responses/AssessmentResultNotReady' default: $ref: '#/components/responses/Problem' + /api/v1/organizations/{org_id}/needs: + get: + operationId: ListOrganizationNeeds + summary: List the needs of an organization. + description: |- + 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. + security: + - sessionCookie: [] + tags: + - need + parameters: + - $ref: '#/components/parameters/OrganizationId' + - $ref: '#/components/parameters/PageLimit' + - $ref: '#/components/parameters/PageCursor' + responses: + '200': + description: A page of the needs of the organization. + headers: + Cache-Control: + $ref: '#/components/headers/CacheControlNoStore' + content: + application/json: + schema: + $ref: '#/components/schemas/NeedList' + examples: + last_page: + $ref: '#/components/examples/NeedListPage' + '400': + $ref: '#/components/responses/ValidationFailed' + '401': + $ref: '#/components/responses/Unauthenticated' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + default: + $ref: '#/components/responses/Problem' + post: + operationId: CreateOrganizationNeed + summary: Create a need of an organization from a form, a text, or both. + description: |- + 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. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - need + parameters: + - $ref: '#/components/parameters/OrganizationId' + - $ref: '#/components/parameters/IdempotencyKey' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NeedCreate' + examples: + manual_without_vacancy: + $ref: '#/components/examples/NeedCreateManual' + from_text: + $ref: '#/components/examples/NeedCreateFromText' + responses: + '201': + description: The need was created as version 1, or a retry with the same Idempotency-Key replayed its creation. + headers: + Cache-Control: + $ref: '#/components/headers/CacheControlNoStore' + content: + application/json: + schema: + $ref: '#/components/schemas/Need' + examples: + manual_without_vacancy: + $ref: '#/components/examples/NeedManualWithoutVacancy' + from_text_with_unknown_skill: + $ref: '#/components/examples/NeedExtractedWithUnknownSkill' + '400': + $ref: '#/components/responses/NeedValidationFailed' + '401': + $ref: '#/components/responses/Unauthenticated' + '403': + $ref: '#/components/responses/CsrfCheckFailedOrForbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/IdempotencyInProgress' + '422': + $ref: '#/components/responses/UnprocessableContent' + '429': + $ref: '#/components/responses/TooManyRequests' + default: + $ref: '#/components/responses/Problem' + /api/v1/organizations/{org_id}/needs/{need_id}: + get: + operationId: GetOrganizationNeed + summary: Read the current version of a need of an organization. + description: |- + 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. + security: + - sessionCookie: [] + tags: + - need + parameters: + - $ref: '#/components/parameters/OrganizationId' + - $ref: '#/components/parameters/NeedId' + responses: + '200': + description: The current version of the need. + headers: + Cache-Control: + $ref: '#/components/headers/CacheControlNoStore' + content: + application/json: + schema: + $ref: '#/components/schemas/Need' + examples: + manual_without_vacancy: + $ref: '#/components/examples/NeedManualWithoutVacancy' + from_text_with_unknown_skill: + $ref: '#/components/examples/NeedExtractedWithUnknownSkill' + confirmed: + $ref: '#/components/examples/NeedConfirmedAfterUpdate' + '400': + $ref: '#/components/responses/ValidationFailed' + '401': + $ref: '#/components/responses/Unauthenticated' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + default: + $ref: '#/components/responses/Problem' + patch: + operationId: UpdateOrganizationNeed + summary: Confirm, change, or delete requirements of a need. + description: |- + 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. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - need + parameters: + - $ref: '#/components/parameters/OrganizationId' + - $ref: '#/components/parameters/NeedId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NeedUpdate' + examples: + confirm_suggestions: + $ref: '#/components/examples/NeedUpdateConfirmSuggestions' + responses: + '200': + description: The need after the change, or the current need when the body changes nothing. + headers: + Cache-Control: + $ref: '#/components/headers/CacheControlNoStore' + content: + application/json: + schema: + $ref: '#/components/schemas/Need' + examples: + confirmed: + $ref: '#/components/examples/NeedConfirmedAfterUpdate' + '400': + $ref: '#/components/responses/NeedValidationFailed' + '401': + $ref: '#/components/responses/Unauthenticated' + '403': + $ref: '#/components/responses/CsrfCheckFailedOrForbidden' + '404': + $ref: '#/components/responses/NotFound' + '412': + $ref: '#/components/responses/NeedVersionConflict' + '429': + $ref: '#/components/responses/TooManyRequests' + default: + $ref: '#/components/responses/Problem' components: schemas: Problem: @@ -2655,6 +2877,906 @@ components: description: Questionnaire specializations in questionnaire order. items: $ref: '#/components/schemas/AssessmentSpecializationAvailability' + NeedVersion: + type: integer + format: int64 + minimum: 1 + description: Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version. + examples: + - 2 + NeedTitle: + type: string + minLength: 1 + maxLength: 200 + pattern: ^\S(?:.*\S)?$ + description: Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML. + NeedSourceText: + type: string + minLength: 1 + maxLength: 10000 + description: 'Free description of the team''s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).' + NeedValueStatus: + type: string + description: |- + Confirmation state of one need field. + + - confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations. + - extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness. + - unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary. + enum: + - confirmed + - extracted + - unknown + NeedItemStatus: + type: string + description: 'Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.' + enum: + - confirmed + - extracted + NeedValueOrigin: + type: string + description: |- + Where the value of a field or item came from. The server sets it; a request never sends it. + + - manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null. + - extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version. + - imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it. + + Confirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change. + enum: + - manual + - extracted_from_text + - imported + NeedSourceQuote: + type: string + minLength: 1 + maxLength: 300 + description: Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML. + NeedVersionLabel: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[A-Za-z0-9._-]+$ + description: Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it. + NeedValueSource: + type: object + description: 'Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.' + additionalProperties: false + required: + - origin + - quote + - extracted_in_version + - extraction_version + properties: + origin: + $ref: '#/components/schemas/NeedValueOrigin' + quote: + description: Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt. + oneOf: + - $ref: '#/components/schemas/NeedSourceQuote' + - type: 'null' + extracted_in_version: + description: Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`. + oneOf: + - $ref: '#/components/schemas/NeedVersion' + - type: 'null' + extraction_version: + description: Extractor version for an extracted or imported value, or null for a manual value. + oneOf: + - $ref: '#/components/schemas/NeedVersionLabel' + - type: 'null' + SkillName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML. + SkillTaxonomyCode: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[a-z0-9][a-z0-9_.+#-]*$ + description: Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name. + NeedTaskText: + type: string + minLength: 1 + maxLength: 300 + pattern: ^\S(?:.*\S)?$ + description: One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML. + NeedDomainName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML. + NeedLocationName: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Place of work for the office or hybrid format, for example a city, as free text. It describes the employer's office, never a candidate's address. Plain text without line breaks; clients show it as text, never as HTML. + RubAmount: + type: integer + format: int64 + minimum: 1000 + maximum: 100000000 + multipleOf: 1000 + description: Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final. + examples: + - 120000 + CurrencyCode: + type: string + description: ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change. + enum: + - RUB + SalaryPeriod: + type: string + description: Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change. + enum: + - month + SalaryTaxBasis: + type: string + description: 'Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.' + enum: + - net + - gross + SalaryRange: + type: object + description: 'Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.' + additionalProperties: false + required: + - salary_from + - salary_to + - currency + - period + - tax_basis + properties: + salary_from: + $ref: '#/components/schemas/RubAmount' + salary_to: + $ref: '#/components/schemas/RubAmount' + currency: + $ref: '#/components/schemas/CurrencyCode' + period: + $ref: '#/components/schemas/SalaryPeriod' + tax_basis: + $ref: '#/components/schemas/SalaryTaxBasis' + NeedSpecialization: + type: object + description: Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + oneOf: + - $ref: '#/components/schemas/SpecializationCode' + - type: 'null' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedGrade: + type: object + description: Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + oneOf: + - $ref: '#/components/schemas/GradeCode' + - type: 'null' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedDomain: + type: object + description: Business domain of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + oneOf: + - $ref: '#/components/schemas/NeedDomainName' + - type: 'null' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedWorkFormats: + type: object + description: Work formats that the employer offers, with their confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a known value lists one to three formats. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + type: + - array + - 'null' + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: '#/components/schemas/WorkFormat' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedLocation: + type: object + description: Place of work with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats include `office` or `hybrid`. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + oneOf: + - $ref: '#/components/schemas/NeedLocationName' + - type: 'null' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedSalary: + type: object + description: Salary range that the employer offers, with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the server never substitutes zero, a market estimate, or a range from another need. + additionalProperties: false + required: + - status + - value + - source + properties: + status: + $ref: '#/components/schemas/NeedValueStatus' + value: + oneOf: + - $ref: '#/components/schemas/SalaryRange' + - type: 'null' + source: + oneOf: + - $ref: '#/components/schemas/NeedValueSource' + - type: 'null' + NeedSkill: + type: object + description: 'One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.' + additionalProperties: false + required: + - name + - taxonomy_code + - status + - source + properties: + name: + $ref: '#/components/schemas/SkillName' + taxonomy_code: + oneOf: + - $ref: '#/components/schemas/SkillTaxonomyCode' + - type: 'null' + status: + $ref: '#/components/schemas/NeedItemStatus' + source: + $ref: '#/components/schemas/NeedValueSource' + NeedTask: + type: object + description: One work task of the team with its confirmation state and provenance. + additionalProperties: false + required: + - text + - status + - source + properties: + text: + $ref: '#/components/schemas/NeedTaskText' + status: + $ref: '#/components/schemas/NeedItemStatus' + source: + $ref: '#/components/schemas/NeedValueSource' + NeedSpecializationInput: + type: object + description: Decision about the specialization in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/components/schemas/SpecializationCode' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedGradeInput: + type: object + description: Decision about the grade in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/components/schemas/GradeCode' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedDomainInput: + type: object + description: Decision about the domain in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/components/schemas/NeedDomainName' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedWorkFormatsInput: + type: object + description: Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set. + additionalProperties: false + required: + - value + - status + properties: + value: + type: array + minItems: 1 + maxItems: 3 + uniqueItems: true + items: + $ref: '#/components/schemas/WorkFormat' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedLocationInput: + type: object + description: Decision about the place of work in a request; see NeedUpdate for the rules of `status`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/components/schemas/NeedLocationName' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedSalaryInput: + type: object + description: Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`. + additionalProperties: false + required: + - value + - status + properties: + value: + $ref: '#/components/schemas/SalaryRange' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedSkillInput: + type: object + description: 'One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.' + additionalProperties: false + required: + - name + - status + properties: + name: + $ref: '#/components/schemas/SkillName' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedTaskInput: + type: object + description: One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput. + additionalProperties: false + required: + - text + - status + properties: + text: + $ref: '#/components/schemas/NeedTaskText' + status: + $ref: '#/components/schemas/NeedItemStatus' + NeedRequirementSet: + type: object + description: Requirements of one need version, each with its confirmation state and provenance. Read-only; requests change them through the fields of NeedCreate and NeedUpdate. + additionalProperties: false + required: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary + properties: + specialization: + $ref: '#/components/schemas/NeedSpecialization' + grade: + $ref: '#/components/schemas/NeedGrade' + required_skills: + type: array + maxItems: 30 + description: Required skills; each has weight 2 in skill coverage. Only confirmed skills count. + items: + $ref: '#/components/schemas/NeedSkill' + desired_skills: + type: array + maxItems: 30 + description: Desired skills; each has weight 1 in skill coverage. Only confirmed skills count. + items: + $ref: '#/components/schemas/NeedSkill' + tasks: + type: array + maxItems: 20 + description: Work tasks of the team in the order given. + items: + $ref: '#/components/schemas/NeedTask' + domain: + $ref: '#/components/schemas/NeedDomain' + work_formats: + $ref: '#/components/schemas/NeedWorkFormats' + location: + $ref: '#/components/schemas/NeedLocation' + salary: + $ref: '#/components/schemas/NeedSalary' + NeedFieldName: + type: string + description: Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change. + enum: + - specialization + - grade + - required_skills + - desired_skills + - tasks + - domain + - work_formats + - location + - salary + NeedMissingReason: + type: string + description: 'Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.' + enum: + - unknown + - unconfirmed + NeedMissingField: + type: object + description: One critical field that has no confirmed value, with a specific question that the client shows next to the field. + additionalProperties: false + required: + - field + - reason + - question + properties: + field: + $ref: '#/components/schemas/NeedFieldName' + reason: + $ref: '#/components/schemas/NeedMissingReason' + question: + type: string + minLength: 1 + maxLength: 300 + description: Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML. + NeedReadinessStatus: + type: string + description: '`complete` when every critical field has a confirmed value, otherwise `incomplete`.' + enum: + - complete + - incomplete + NeedReadinessReport: + type: object + description: Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires. + additionalProperties: false + required: + - status + - missing_fields + properties: + status: + $ref: '#/components/schemas/NeedReadinessStatus' + missing_fields: + type: array + maxItems: 9 + description: Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`. + items: + $ref: '#/components/schemas/NeedMissingField' + NeedRecommendationStatus: + type: string + description: |- + State of the category recommendations of the current requirements version. + + - computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`. + - pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later. + - not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty. + enum: + - computed + - pending + - not_available + NeedSkillOverlap: + type: object + description: 'Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.' + additionalProperties: false + required: + - share + - covered_skills + - uncovered_skills + properties: + share: + type: number + format: double + minimum: 0 + maximum: 1 + description: Weighted share from 0 to 1, rounded to two decimals. + covered_skills: + type: array + maxItems: 60 + description: Confirmed skills of the need that the category covers. + items: + $ref: '#/components/schemas/SkillName' + uncovered_skills: + type: array + maxItems: 60 + description: Confirmed skills of the need that the category does not cover, including skills without a taxonomy code. + items: + $ref: '#/components/schemas/SkillName' + NeedMoneyStatus: + type: string + description: |- + How the salary component of a recommendation was obtained. + + - computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given. + - insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null. + - no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null. + - withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null. + + An unknown candidate minimum never counts as zero. + enum: + - computed + - insufficient_data + - no_salary + - withheld + NeedMoneyFit: + type: object + description: Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate. + additionalProperties: false + required: + - status + - share + properties: + status: + $ref: '#/components/schemas/NeedMoneyStatus' + share: + type: + - number + - 'null' + format: double + minimum: 0 + maximum: 1 + description: 'Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.' + NeedSupplyBand: + type: string + description: 'Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.' + enum: + - fewer_than_5 + - from_5_to_29 + - 30_or_more + NeedCategoryRecommendation: + type: object + description: 'One recommended category, a specialization with a grade, with its score and the reasons for it. The score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor the order reveals the exact size of a group below five.' + additionalProperties: false + required: + - specialization + - grade + - score + - skill_overlap + - money + - supply + properties: + specialization: + $ref: '#/components/schemas/SpecializationCode' + grade: + $ref: '#/components/schemas/GradeCode' + score: + type: + - number + - 'null' + format: double + minimum: 0 + maximum: 1 + description: Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is `fewer_than_5`. Read-only; no request can set it. + skill_overlap: + $ref: '#/components/schemas/NeedSkillOverlap' + money: + $ref: '#/components/schemas/NeedMoneyFit' + supply: + $ref: '#/components/schemas/NeedSupplyBand' + NeedCategoryRecommendations: + type: object + description: 'Category recommendations computed by the server from the confirmed requirements of `requirements_version` with a versioned policy (PRD FR08). Read-only: no request can set a recommendation, a score, or one of its components. The server may recompute them for the same requirements version, for example for a new policy or a changed pool of available candidates, without a new need version; `computed_at` and `policy_version` then change. The policy version and the candidate group used are stored with each computation, so a later policy never rewrites it.' + additionalProperties: false + required: + - status + - requirements_version + - policy_version + - algorithm_version + - computed_at + - categories + properties: + status: + $ref: '#/components/schemas/NeedRecommendationStatus' + requirements_version: + $ref: '#/components/schemas/NeedVersion' + policy_version: + type: + - integer + - 'null' + format: int32 + minimum: 1 + description: Number of the policy version whose weights were applied, or null unless `status` is `computed`. + algorithm_version: + description: Version of the recommendation algorithm, or null unless `status` is `computed`. + oneOf: + - $ref: '#/components/schemas/NeedVersionLabel' + - type: 'null' + computed_at: + description: Time of the computation, or null unless `status` is `computed`. + oneOf: + - $ref: '#/components/schemas/Timestamp' + - type: 'null' + categories: + type: array + maxItems: 10 + description: Recommended categories, best first by the score described in NeedCategoryRecommendation. Empty unless `status` is `computed`. + items: + $ref: '#/components/schemas/NeedCategoryRecommendation' + Need: + type: object + description: 'Hiring need of an organization: what the team needs, independent of any published vacancy. It holds the current version of the requirements with their provenance, the readiness of the critical fields, and the category recommendations. It never contains membership data, a candidate''s personal data, or a candidate''s salary minimum.' + additionalProperties: false + required: + - id + - organization_id + - vacancy_id + - title + - source_text + - version + - requirements_version + - requirements + - readiness + - recommendations + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + organization_id: + type: string + format: uuid + description: Organization that owns the need, equal to `org_id` of the path. It never changes. + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Linked vacancy of the same organization, or null. A need never requires a vacancy. + title: + $ref: '#/components/schemas/NeedTitle' + source_text: + description: Text the requirements were extracted from, or null. + oneOf: + - $ref: '#/components/schemas/NeedSourceText' + - type: 'null' + version: + $ref: '#/components/schemas/NeedVersion' + requirements_version: + description: Need version in which the current confirmed requirements were last changed, at most `version`. A change that confirms, changes, or removes a requirement makes it equal to the new `version`. A change of the title, the vacancy link, or the text, or of suggestions only, creates a new `version` but keeps `requirements_version`, so it invalidates neither the recommendations nor search results and selection snapshots. Search runs and selection snapshots (PRD FR10) refer to `(need id, requirements_version)`, and a new selection snapshot is due only when it changes. + allOf: + - $ref: '#/components/schemas/NeedVersion' + requirements: + $ref: '#/components/schemas/NeedRequirementSet' + readiness: + $ref: '#/components/schemas/NeedReadinessReport' + recommendations: + $ref: '#/components/schemas/NeedCategoryRecommendations' + created_at: + $ref: '#/components/schemas/Timestamp' + updated_at: + $ref: '#/components/schemas/Timestamp' + NeedSummary: + type: object + description: 'Need in a list: its identity, current version, target category fields, and readiness. Read the need for the requirements and the recommendations.' + additionalProperties: false + required: + - id + - vacancy_id + - title + - version + - specialization + - grade + - readiness + - created_at + - updated_at + properties: + id: + type: string + format: uuid + description: Identifier of the need. + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Linked vacancy, or null. + title: + $ref: '#/components/schemas/NeedTitle' + version: + $ref: '#/components/schemas/NeedVersion' + specialization: + $ref: '#/components/schemas/NeedSpecialization' + grade: + $ref: '#/components/schemas/NeedGrade' + readiness: + $ref: '#/components/schemas/NeedReadinessReport' + created_at: + $ref: '#/components/schemas/Timestamp' + updated_at: + $ref: '#/components/schemas/Timestamp' + NeedList: + type: object + description: One page of the needs of an organization, newest first by creation time. + additionalProperties: false + required: + - items + - page + properties: + items: + type: array + maxItems: 100 + description: Needs of the page. + items: + $ref: '#/components/schemas/NeedSummary' + page: + $ref: '#/components/schemas/PageInfo' + NeedCreate: + type: object + description: New need. Only `title` is required, so a need can start from a title, from a text, or from form fields, and with or without a vacancy. A field or list item given here must have `status` `confirmed` and becomes a confirmed manual value; `extracted` answers 400 with the pointer of that `status`, such as `/grade/status`, because a new need has no stored suggestion. A field that is absent is extracted from `source_text` when the text is given and is left unknown or empty otherwise. A nullable field sent as null, and a skill or task list sent as an empty list, stays unknown or empty and is not extracted; an empty `work_formats` value fails `minItems`. Unknown fields are rejected, so a request cannot set membership, a role, a status of the need, a provenance, readiness, a recommendation or its score, or a candidate's salary minimum. + additionalProperties: false + required: + - title + properties: + title: + $ref: '#/components/schemas/NeedTitle' + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Vacancy of the same organization to link, or null or absent for a need without a vacancy. + source_text: + oneOf: + - $ref: '#/components/schemas/NeedSourceText' + - type: 'null' + specialization: + oneOf: + - $ref: '#/components/schemas/NeedSpecializationInput' + - type: 'null' + grade: + oneOf: + - $ref: '#/components/schemas/NeedGradeInput' + - type: 'null' + required_skills: + type: array + maxItems: 30 + items: + $ref: '#/components/schemas/NeedSkillInput' + desired_skills: + type: array + maxItems: 30 + items: + $ref: '#/components/schemas/NeedSkillInput' + tasks: + type: array + maxItems: 20 + items: + $ref: '#/components/schemas/NeedTaskInput' + domain: + oneOf: + - $ref: '#/components/schemas/NeedDomainInput' + - type: 'null' + work_formats: + oneOf: + - $ref: '#/components/schemas/NeedWorkFormatsInput' + - type: 'null' + location: + oneOf: + - $ref: '#/components/schemas/NeedLocationInput' + - type: 'null' + salary: + oneOf: + - $ref: '#/components/schemas/NeedSalaryInput' + - type: 'null' + NeedUpdate: + type: object + description: 'Change of a need over the version the client read. Each field present in the body replaces that field as a whole; an absent field stays unchanged. Nested objects and lists are not merged: a field decision and each list are replaced entirely, and a stored item missing from a sent list is deleted. A nullable field sent as null becomes unknown, or unlinked for `vacancy_id`; a skill or task list sent empty deletes every item; a list sent as null fails validation. A field decision `{value, status}` and a list item follow the same rules: `confirmed` with the stored value confirms it and keeps its origin and quote, and `confirmed` with another value sets a confirmed manual value; `extracted` keeps a stored suggestion unconfirmed and is allowed only with exactly the stored suggested value, otherwise it answers 400 with the pointer of that `status`, such as `/grade/status` or `/required_skills/0/status`. A client that sends back an unchanged form therefore confirms nothing by accident: it sends each suggestion with `extracted`, or leaves the field out. Sending a different `source_text` extracts again: new suggestions replace only the `extracted` values and items of fields not named in this body; confirmed values are never overwritten, a suggested skill whose name is already in either skill list is skipped, and a suggestion that a member deleted is not proposed again for this need. Unknown fields are rejected, so a request cannot set membership, a role, a provenance, readiness, a recommendation or its score, or a candidate''s salary minimum.' + additionalProperties: false + required: + - expected_version + properties: + expected_version: + $ref: '#/components/schemas/NeedVersion' + title: + $ref: '#/components/schemas/NeedTitle' + vacancy_id: + type: + - string + - 'null' + format: uuid + description: Vacancy of the same organization to link, or null to unlink. + source_text: + oneOf: + - $ref: '#/components/schemas/NeedSourceText' + - type: 'null' + specialization: + oneOf: + - $ref: '#/components/schemas/NeedSpecializationInput' + - type: 'null' + grade: + oneOf: + - $ref: '#/components/schemas/NeedGradeInput' + - type: 'null' + required_skills: + type: array + maxItems: 30 + items: + $ref: '#/components/schemas/NeedSkillInput' + desired_skills: + type: array + maxItems: 30 + items: + $ref: '#/components/schemas/NeedSkillInput' + tasks: + type: array + maxItems: 20 + items: + $ref: '#/components/schemas/NeedTaskInput' + domain: + oneOf: + - $ref: '#/components/schemas/NeedDomainInput' + - type: 'null' + work_formats: + oneOf: + - $ref: '#/components/schemas/NeedWorkFormatsInput' + - type: 'null' + location: + oneOf: + - $ref: '#/components/schemas/NeedLocationInput' + - type: 'null' + salary: + oneOf: + - $ref: '#/components/schemas/NeedSalaryInput' + - type: 'null' HealthResponse: type: object additionalProperties: false @@ -2728,6 +3850,24 @@ components: type: string format: uuid example: 01928f7a-3c4d-7e5f-8a9b-0c1d2e3f4a5b + OrganizationId: + name: org_id + in: path + required: true + description: Identifier of an organization. Access comes only from an active membership of the session account in this organization, checked by the server on every request; the identifier itself grants nothing. An organization without such a membership and an unknown identifier both answer 404 not_found, so organizations cannot be enumerated. + schema: + type: string + format: uuid + example: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + NeedId: + name: need_id + in: path + required: true + description: Identifier of a need of the organization in the path. A need of another organization and an unknown identifier both answer 404 not_found. + schema: + type: string + format: uuid + example: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 headers: ETag: description: Strong entity tag of the returned resource version. Send it back in If-Match to change this version. @@ -3054,6 +4194,36 @@ components: examples: version_conflict: $ref: '#/components/examples/AssessmentStaleVersion' + NeedValidationFailed: + description: 'The body does not match the contract or violates a need rule: an unknown field such as rec_score, members, or candidate_minimum, a field sent as a bare value instead of `{value, status}`, a list sent as null, an unknown specialization, grade, work format, currency, period, or tax basis, a salary bound that is not a positive multiple of 1000, a lower bound that is not below the upper one, a range width outside 10-40% of its midpoint, a repeated skill or task, status `extracted` with a value that is not the stored suggestion, a vacancy that is not a vacancy of the organization, or a missing or invalid expected_version; code validation_failed with body pointers. When the decoder does not record the path of a nested field, the pointer is the whole body. Nothing was changed, and the outcome is not stored under an Idempotency-Key.' + content: + application/problem+json: + schema: + $ref: '#/components/schemas/Problem' + examples: + reversed_salary_range: + $ref: '#/components/examples/NeedSalaryRangeReversed' + equal_salary_bounds: + $ref: '#/components/examples/NeedSalaryEqualBounds' + salary_range_too_wide: + $ref: '#/components/examples/NeedSalaryRangeTooWide' + salary_without_tax_basis: + $ref: '#/components/examples/NeedSalaryWithoutTaxBasis' + extracted_value_mismatch: + $ref: '#/components/examples/NeedExtractedValueMismatch' + recommendation_score_sent_by_client: + $ref: '#/components/examples/NeedUnknownField' + missing_expected_version: + $ref: '#/components/examples/NeedMissingExpectedVersion' + NeedVersionConflict: + description: '`expected_version` is not the current need version; code version_conflict. Nothing was changed; read the need again before retrying.' + content: + application/problem+json: + schema: + $ref: '#/components/schemas/Problem' + examples: + version_conflict: + $ref: '#/components/examples/NeedStaleVersion' securitySchemes: sessionCookie: type: apiKey @@ -4354,6 +5524,680 @@ components: code: state_conflict detail: The resource is in a state that does not allow this operation. trace_id: 4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b + NeedListPage: + summary: The last page of the needs of an organization + value: + items: + - id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + vacancy_id: null + title: Backend в команду платежей + version: 2 + specialization: + status: confirmed + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: confirmed + value: middle + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + created_at: '2026-10-06T09:00:00Z' + updated_at: '2026-10-06T09:20:00Z' + - id: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 + vacancy_id: null + title: Junior Go-разработчик для сервиса уведомлений + version: 1 + specialization: + status: confirmed + value: backend + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + grade: + status: confirmed + value: junior + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + created_at: '2026-10-06T08:15:00Z' + updated_at: '2026-10-06T08:15:00Z' + page: + has_more: false + next_cursor: null + NeedCreateManual: + summary: A manual need without a vacancy and without a text + description: Every field comes from the form as a decision with status confirmed, so every value is a confirmed manual value. There is no vacancy_id and no source_text; the domain is not given and stays unknown. + value: + title: Junior Go-разработчик для сервиса уведомлений + specialization: + value: backend + status: confirmed + grade: + value: junior + status: confirmed + required_skills: + - name: Go + status: confirmed + - name: PostgreSQL + status: confirmed + desired_skills: + - name: Docker + status: confirmed + tasks: + - text: Поддерживать и развивать сервис уведомлений + status: confirmed + work_formats: + value: + - hybrid + status: confirmed + location: + value: Москва + status: confirmed + salary: + value: + salary_from: 120000 + salary_to: 160000 + currency: RUB + period: month + tax_basis: net + status: confirmed + NeedCreateFromText: + summary: A need created from a pasted description + description: Only the title and the text are given. The server extracts suggestions from the text; nothing is confirmed until a member confirms it. + value: + title: Backend в команду платежей + source_text: 'Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно.' + NeedManualWithoutVacancy: + summary: A complete manual need without a vacancy, with computed recommendations + description: The need created by NeedCreateManual. Every value is confirmed and manual, so the quote, extracted_in_version, and extraction_version are null; the domain was not given and stays unknown with null value and source rather than a guessed one. The hybrid format makes the location critical, and it is confirmed. The range of 120000-160000 has a width of about 29%. The first category scores 0.75 with Overlap 1, a money share rounded down to 0.5, and Supply 0.5 for 15 available candidates. The other two have fewer than five candidates, so their score is null and Supply enters their ranking as 0. The recommendation values are illustrative and say nothing about a deployed policy or real candidates. + value: + id: 01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Junior Go-разработчик для сервиса уведомлений + source_text: null + version: 1 + requirements_version: 1 + requirements: + specialization: + status: confirmed + value: backend + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + grade: + status: confirmed + value: junior + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + required_skills: + - name: Go + taxonomy_code: go + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + - name: PostgreSQL + taxonomy_code: postgresql + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + desired_skills: + - name: Docker + taxonomy_code: docker + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + tasks: + - text: Поддерживать и развивать сервис уведомлений + status: confirmed + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + domain: + status: unknown + value: null + source: null + work_formats: + status: confirmed + value: + - hybrid + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + location: + status: confirmed + value: Москва + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + salary: + status: confirmed + value: + salary_from: 120000 + salary_to: 160000 + currency: RUB + period: month + tax_basis: net + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + recommendations: + status: computed + requirements_version: 1 + policy_version: 1 + algorithm_version: need-rec.2026-10.1 + computed_at: '2026-10-06T08:15:02Z' + categories: + - specialization: backend + grade: junior + score: 0.75 + skill_overlap: + share: 1 + covered_skills: + - Go + - PostgreSQL + - Docker + uncovered_skills: [] + money: + status: computed + share: 0.5 + supply: from_5_to_29 + - specialization: backend + grade: intern + score: null + skill_overlap: + share: 0.8 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Docker + money: + status: insufficient_data + share: null + supply: fewer_than_5 + - specialization: devops_sre + grade: junior + score: null + skill_overlap: + share: 0.2 + covered_skills: + - Docker + uncovered_skills: + - Go + - PostgreSQL + money: + status: insufficient_data + share: null + supply: fewer_than_5 + created_at: '2026-10-06T08:15:00Z' + updated_at: '2026-10-06T08:15:00Z' + NeedExtractedWithUnknownSkill: + summary: A need from text with suggestions, an unknown skill, and missing fields + description: 'The need created by NeedCreateFromText. Every value found in the text is extracted with its quote from the text of version 1 and the extractor version, and waits for confirmation. Temporal is not in the skill taxonomy, so its taxonomy_code is null instead of a guessed code. The text names no grade, place, or salary: they stay unknown with null value and source, and the critical ones are listed in missing_fields with a question. Without a confirmed skill there are no recommendations yet.' + value: + id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Backend в команду платежей + source_text: 'Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно.' + version: 1 + requirements_version: 1 + requirements: + specialization: + status: extracted + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: unknown + value: null + source: null + required_skills: + - name: Go + taxonomy_code: go + status: extracted + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: PostgreSQL + taxonomy_code: postgresql + status: extracted + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: Temporal + taxonomy_code: null + status: extracted + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + desired_skills: + - name: Kafka + taxonomy_code: kafka + status: extracted + source: + origin: extracted_from_text + quote: Желательно опыт с Kafka + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + tasks: + - text: Развивать сервис выплат и переводить его на событийную модель + status: extracted + source: + origin: extracted_from_text + quote: 'Задачи: развивать сервис выплат и переводить его на событийную модель' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + domain: + status: extracted + value: платежи + source: + origin: extracted_from_text + quote: в команду платежей + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + work_formats: + status: extracted + value: + - remote + source: + origin: extracted_from_text + quote: Работа удаленно + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + location: + status: unknown + value: null + source: null + salary: + status: unknown + value: null + source: null + readiness: + status: incomplete + missing_fields: + - field: specialization + reason: unconfirmed + question: Подтвердите специализацию, найденную в описании. + - field: grade + reason: unknown + question: 'Какой грейд нужен: Intern, Junior, Middle или Senior?' + - field: required_skills + reason: unconfirmed + question: Подтвердите обязательные навыки, найденные в описании. + - field: work_formats + reason: unconfirmed + question: Подтвердите формат работы, найденный в описании. + - field: salary + reason: unknown + question: 'Какую вилку в рублях вы предлагаете и в какой базе: на руки или до вычета НДФЛ?' + recommendations: + status: not_available + requirements_version: 1 + policy_version: null + algorithm_version: null + computed_at: null + categories: [] + created_at: '2026-10-06T09:00:00Z' + updated_at: '2026-10-06T09:00:00Z' + NeedSalaryRangeReversed: + summary: The lower salary bound is above the upper one + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 6b7c8d9e-0f1a-4b2c-8d3e-4f5a6b7c8d9f + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. + NeedSalaryEqualBounds: + summary: Equal salary bounds; PRD FR13 requires salary_from < salary_to + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. + NeedSalaryRangeTooWide: + summary: A salary range wider than 40% of its midpoint, such as 100000-200000 + description: The width (200000 - 100000) / 150000 is about 67%. A range narrower than 10%, such as 100000-105000, gets the same answer. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e + errors: + - in: body + pointer: /salary/value/salary_to + code: invalid + message: The value does not match the contract. + NeedSalaryWithoutTaxBasis: + summary: A salary range without its tax basis + description: The decoder does not record the path of a missing field in a nested object, so the pointer is the whole body. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 7c8d9e0f-1a2b-4c3d-9e4f-5a6b7c8d9e0a + errors: + - in: body + pointer: '' + code: invalid + message: The value does not match the contract. + NeedExtractedValueMismatch: + summary: Status extracted with a value that is not the stored suggestion + description: A request may keep only the stored suggestion unconfirmed. To set another value, it sends status confirmed. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 3c4d5e6f-7a8b-4c9d-8e0f-2a3b4c5d6e7f + errors: + - in: body + pointer: /grade/status + code: invalid + message: The value does not match the contract. + NeedUnknownField: + summary: The client sent its own recommendation score + description: Recommendations, membership, and candidate minimums are never request fields; any unknown field fails validation. + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 8d9e0f1a-2b3c-4d4e-8f5a-6b7c8d9e0f1b + errors: + - in: body + pointer: '' + code: invalid + message: The value does not match the contract. + NeedMissingExpectedVersion: + summary: A change without expected_version + value: + type: urn:lincodex:problem:validation_failed + title: Request validation failed + status: 400 + code: validation_failed + detail: One or more request fields are invalid. + trace_id: 9e0f1a2b-3c4d-4e5f-9a6b-7c8d9e0f1a2c + errors: + - in: body + pointer: /expected_version + code: required + message: The value is required. + NeedConfirmedAfterUpdate: + summary: The need after the confirmation, as version 2 + description: Confirmed suggestions keep the origin extracted_from_text, their quotes, and extracted_in_version 1; the grade and the salary are manual. A confirmed requirement changed, so requirements_version is 2 as well. Kafka and the domain are still open suggestions; Kafka does not count in the recommendations, and Temporal stays without a taxonomy code, so no category covers it. The place is unknown but not critical, because the only format is remote. The range of 250000-320000 has a width of about 25%. Scores use the overlap 4/6, the money share rounded down to a quarter or the neutral 0.5, and the exact Supply of groups of five or more. The recommendation values are illustrative. + value: + id: 01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23 + organization_id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01 + vacancy_id: null + title: Backend в команду платежей + source_text: 'Ищем бэкенд-разработчика в команду платежей. Обязательно: Go, PostgreSQL и Temporal. Желательно опыт с Kafka. Задачи: развивать сервис выплат и переводить его на событийную модель. Работа удаленно.' + version: 2 + requirements_version: 2 + requirements: + specialization: + status: confirmed + value: backend + source: + origin: extracted_from_text + quote: Ищем бэкенд-разработчика + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + grade: + status: confirmed + value: middle + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + required_skills: + - name: Go + taxonomy_code: go + status: confirmed + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: PostgreSQL + taxonomy_code: postgresql + status: confirmed + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + - name: Temporal + taxonomy_code: null + status: confirmed + source: + origin: extracted_from_text + quote: 'Обязательно: Go, PostgreSQL и Temporal' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + desired_skills: + - name: Kafka + taxonomy_code: kafka + status: extracted + source: + origin: extracted_from_text + quote: Желательно опыт с Kafka + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + tasks: + - text: Развивать сервис выплат и переводить его на событийную модель + status: extracted + source: + origin: extracted_from_text + quote: 'Задачи: развивать сервис выплат и переводить его на событийную модель' + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + domain: + status: extracted + value: платежи + source: + origin: extracted_from_text + quote: в команду платежей + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + work_formats: + status: confirmed + value: + - remote + source: + origin: extracted_from_text + quote: Работа удаленно + extracted_in_version: 1 + extraction_version: need-rules.2026-10.1 + location: + status: unknown + value: null + source: null + salary: + status: confirmed + value: + salary_from: 250000 + salary_to: 320000 + currency: RUB + period: month + tax_basis: gross + source: + origin: manual + quote: null + extracted_in_version: null + extraction_version: null + readiness: + status: complete + missing_fields: [] + recommendations: + status: computed + requirements_version: 2 + policy_version: 1 + algorithm_version: need-rec.2026-10.1 + computed_at: '2026-10-06T09:20:01Z' + categories: + - specialization: backend + grade: middle + score: 0.61 + skill_overlap: + share: 0.67 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Temporal + money: + status: computed + share: 0.25 + supply: 30_or_more + - specialization: devops_sre + grade: middle + score: 0.45 + skill_overlap: + share: 0.33 + covered_skills: + - PostgreSQL + uncovered_skills: + - Go + - Temporal + money: + status: insufficient_data + share: null + supply: from_5_to_29 + - specialization: backend + grade: senior + score: 0.41 + skill_overlap: + share: 0.67 + covered_skills: + - Go + - PostgreSQL + uncovered_skills: + - Temporal + money: + status: computed + share: 0 + supply: from_5_to_29 + created_at: '2026-10-06T09:00:00Z' + updated_at: '2026-10-06T09:20:00Z' + NeedUpdateConfirmSuggestions: + summary: Confirm suggestions, answer the missing fields, and keep two suggestions open + description: Sent over version 1 of NeedExtractedWithUnknownSkill. The specialization, the required skills, and the work format are sent with their stored values and status confirmed, so they are confirmed and keep their quotes. The grade and the salary are new manual values. Kafka and the domain are sent with status extracted and their stored values, so they stay open suggestions. The tasks are absent and stay unchanged. + value: + expected_version: 1 + specialization: + value: backend + status: confirmed + grade: + value: middle + status: confirmed + required_skills: + - name: Go + status: confirmed + - name: PostgreSQL + status: confirmed + - name: Temporal + status: confirmed + desired_skills: + - name: Kafka + status: extracted + domain: + value: платежи + status: extracted + work_formats: + value: + - remote + status: confirmed + salary: + value: + salary_from: 250000 + salary_to: 320000 + currency: RUB + period: month + tax_basis: gross + status: confirmed + NeedStaleVersion: + summary: The change carried a stale expected_version + description: Another member or a server-side extraction changed the need after the client read it. Nothing was changed; the client reads the need again and reapplies its unsaved edits. + value: + type: urn:lincodex:problem:version_conflict + title: Resource version conflict + status: 412 + code: version_conflict + detail: The resource changed after it was read. Read it again before retrying. + trace_id: 0f1a2b3c-4d5e-4f6a-8b7c-8d9e0f1a2b3d StateConflict: summary: The resource state does not allow the operation value: diff --git a/api/core/openapi.yml b/api/core/openapi.yml index 88b9272..81291c8 100644 --- a/api/core/openapi.yml +++ b/api/core/openapi.yml @@ -26,6 +26,12 @@ tags: Assessment attempts of the current candidate: availability, start and resume, answers and the code practice, finalization, and the result. Answers, keys, and attempt history are visible only to the candidate. + - name: need + description: >- + Hiring needs of an organization: requirements with their confirmation + state and provenance, immutable versions, readiness, and category + recommendations. Access comes only from an active membership in the + organization; a need never requires a vacancy. # Operations require a session unless they declare `security: []`, so a new # operation that omits security is protected by default. security: @@ -63,6 +69,10 @@ paths: $ref: ./routes/candidate_assessment_attempt_finalize.yml /api/v1/me/assessment-attempts/{attempt_id}/result: $ref: ./routes/candidate_assessment_attempt_result.yml + /api/v1/organizations/{org_id}/needs: + $ref: ./routes/organization_needs.yml + /api/v1/organizations/{org_id}/needs/{need_id}: + $ref: ./routes/organization_need.yml components: schemas: Problem: @@ -265,6 +275,112 @@ components: $ref: ./components/schemas.yml#/AssessmentSpecializationAvailability AssessmentAvailability: $ref: ./components/schemas.yml#/AssessmentAvailability + NeedVersion: + $ref: ./components/schemas.yml#/NeedVersion + NeedTitle: + $ref: ./components/schemas.yml#/NeedTitle + NeedSourceText: + $ref: ./components/schemas.yml#/NeedSourceText + NeedValueStatus: + $ref: ./components/schemas.yml#/NeedValueStatus + NeedItemStatus: + $ref: ./components/schemas.yml#/NeedItemStatus + NeedValueOrigin: + $ref: ./components/schemas.yml#/NeedValueOrigin + NeedSourceQuote: + $ref: ./components/schemas.yml#/NeedSourceQuote + NeedVersionLabel: + $ref: ./components/schemas.yml#/NeedVersionLabel + NeedValueSource: + $ref: ./components/schemas.yml#/NeedValueSource + SkillName: + $ref: ./components/schemas.yml#/SkillName + SkillTaxonomyCode: + $ref: ./components/schemas.yml#/SkillTaxonomyCode + NeedTaskText: + $ref: ./components/schemas.yml#/NeedTaskText + NeedDomainName: + $ref: ./components/schemas.yml#/NeedDomainName + NeedLocationName: + $ref: ./components/schemas.yml#/NeedLocationName + RubAmount: + $ref: ./components/schemas.yml#/RubAmount + CurrencyCode: + $ref: ./components/schemas.yml#/CurrencyCode + SalaryPeriod: + $ref: ./components/schemas.yml#/SalaryPeriod + SalaryTaxBasis: + $ref: ./components/schemas.yml#/SalaryTaxBasis + SalaryRange: + $ref: ./components/schemas.yml#/SalaryRange + NeedSpecialization: + $ref: ./components/schemas.yml#/NeedSpecialization + NeedGrade: + $ref: ./components/schemas.yml#/NeedGrade + NeedDomain: + $ref: ./components/schemas.yml#/NeedDomain + NeedWorkFormats: + $ref: ./components/schemas.yml#/NeedWorkFormats + NeedLocation: + $ref: ./components/schemas.yml#/NeedLocation + NeedSalary: + $ref: ./components/schemas.yml#/NeedSalary + NeedSkill: + $ref: ./components/schemas.yml#/NeedSkill + NeedTask: + $ref: ./components/schemas.yml#/NeedTask + NeedSpecializationInput: + $ref: ./components/schemas.yml#/NeedSpecializationInput + NeedGradeInput: + $ref: ./components/schemas.yml#/NeedGradeInput + NeedDomainInput: + $ref: ./components/schemas.yml#/NeedDomainInput + NeedWorkFormatsInput: + $ref: ./components/schemas.yml#/NeedWorkFormatsInput + NeedLocationInput: + $ref: ./components/schemas.yml#/NeedLocationInput + NeedSalaryInput: + $ref: ./components/schemas.yml#/NeedSalaryInput + NeedSkillInput: + $ref: ./components/schemas.yml#/NeedSkillInput + NeedTaskInput: + $ref: ./components/schemas.yml#/NeedTaskInput + NeedRequirementSet: + $ref: ./components/schemas.yml#/NeedRequirementSet + NeedFieldName: + $ref: ./components/schemas.yml#/NeedFieldName + NeedMissingReason: + $ref: ./components/schemas.yml#/NeedMissingReason + NeedMissingField: + $ref: ./components/schemas.yml#/NeedMissingField + NeedReadinessStatus: + $ref: ./components/schemas.yml#/NeedReadinessStatus + NeedReadinessReport: + $ref: ./components/schemas.yml#/NeedReadinessReport + NeedRecommendationStatus: + $ref: ./components/schemas.yml#/NeedRecommendationStatus + NeedSkillOverlap: + $ref: ./components/schemas.yml#/NeedSkillOverlap + NeedMoneyStatus: + $ref: ./components/schemas.yml#/NeedMoneyStatus + NeedMoneyFit: + $ref: ./components/schemas.yml#/NeedMoneyFit + NeedSupplyBand: + $ref: ./components/schemas.yml#/NeedSupplyBand + NeedCategoryRecommendation: + $ref: ./components/schemas.yml#/NeedCategoryRecommendation + NeedCategoryRecommendations: + $ref: ./components/schemas.yml#/NeedCategoryRecommendations + Need: + $ref: ./components/schemas.yml#/Need + NeedSummary: + $ref: ./components/schemas.yml#/NeedSummary + NeedList: + $ref: ./components/schemas.yml#/NeedList + NeedCreate: + $ref: ./components/schemas.yml#/NeedCreate + NeedUpdate: + $ref: ./components/schemas.yml#/NeedUpdate parameters: IdempotencyKey: $ref: ./components/parameters.yml#/IdempotencyKey @@ -276,6 +392,10 @@ components: $ref: ./components/parameters.yml#/PageCursor AssessmentAttemptId: $ref: ./components/parameters.yml#/AssessmentAttemptId + OrganizationId: + $ref: ./components/parameters.yml#/OrganizationId + NeedId: + $ref: ./components/parameters.yml#/NeedId headers: ETag: $ref: ./components/headers.yml#/ETag @@ -344,6 +464,10 @@ components: $ref: ./components/responses.yml#/AssessmentResultNotReady AssessmentVersionConflict: $ref: ./components/responses.yml#/AssessmentVersionConflict + NeedValidationFailed: + $ref: ./components/responses.yml#/NeedValidationFailed + NeedVersionConflict: + $ref: ./components/responses.yml#/NeedVersionConflict securitySchemes: sessionCookie: type: apiKey diff --git a/api/core/routes/organization_need.yml b/api/core/routes/organization_need.yml new file mode 100644 index 0000000..aec1add --- /dev/null +++ b/api/core/routes/organization_need.yml @@ -0,0 +1,113 @@ +get: + operationId: GetOrganizationNeed + summary: Read the current version of a need of an organization. + description: |- + 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. + security: + - sessionCookie: [] + tags: + - need + parameters: + - $ref: ../components/parameters.yml#/OrganizationId + - $ref: ../components/parameters.yml#/NeedId + responses: + "200": + description: The current version of the need. + headers: + Cache-Control: + $ref: ../components/headers.yml#/CacheControlNoStore + content: + application/json: + schema: + $ref: ../components/schemas.yml#/Need + examples: + manual_without_vacancy: + $ref: ../components/examples.yml#/NeedManualWithoutVacancy + from_text_with_unknown_skill: + $ref: ../components/examples.yml#/NeedExtractedWithUnknownSkill + confirmed: + $ref: ../components/examples.yml#/NeedConfirmedAfterUpdate + "400": + $ref: ../components/responses.yml#/ValidationFailed + "401": + $ref: ../components/responses.yml#/Unauthenticated + "403": + $ref: ../components/responses.yml#/Forbidden + "404": + $ref: ../components/responses.yml#/NotFound + default: + $ref: ../components/responses.yml#/Problem +patch: + operationId: UpdateOrganizationNeed + summary: Confirm, change, or delete requirements of a need. + description: |- + 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. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - need + parameters: + - $ref: ../components/parameters.yml#/OrganizationId + - $ref: ../components/parameters.yml#/NeedId + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas.yml#/NeedUpdate + examples: + confirm_suggestions: + $ref: ../components/examples.yml#/NeedUpdateConfirmSuggestions + responses: + "200": + description: >- + The need after the change, or the current need when the body changes + nothing. + headers: + Cache-Control: + $ref: ../components/headers.yml#/CacheControlNoStore + content: + application/json: + schema: + $ref: ../components/schemas.yml#/Need + examples: + confirmed: + $ref: ../components/examples.yml#/NeedConfirmedAfterUpdate + "400": + $ref: ../components/responses.yml#/NeedValidationFailed + "401": + $ref: ../components/responses.yml#/Unauthenticated + "403": + $ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden + "404": + $ref: ../components/responses.yml#/NotFound + "412": + $ref: ../components/responses.yml#/NeedVersionConflict + "429": + $ref: ../components/responses.yml#/TooManyRequests + default: + $ref: ../components/responses.yml#/Problem diff --git a/api/core/routes/organization_needs.yml b/api/core/routes/organization_needs.yml new file mode 100644 index 0000000..afe693a --- /dev/null +++ b/api/core/routes/organization_needs.yml @@ -0,0 +1,109 @@ +get: + operationId: ListOrganizationNeeds + summary: List the needs of an organization. + description: |- + 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. + security: + - sessionCookie: [] + tags: + - need + parameters: + - $ref: ../components/parameters.yml#/OrganizationId + - $ref: ../components/parameters.yml#/PageLimit + - $ref: ../components/parameters.yml#/PageCursor + responses: + "200": + description: A page of the needs of the organization. + headers: + Cache-Control: + $ref: ../components/headers.yml#/CacheControlNoStore + content: + application/json: + schema: + $ref: ../components/schemas.yml#/NeedList + examples: + last_page: + $ref: ../components/examples.yml#/NeedListPage + "400": + $ref: ../components/responses.yml#/ValidationFailed + "401": + $ref: ../components/responses.yml#/Unauthenticated + "403": + $ref: ../components/responses.yml#/Forbidden + "404": + $ref: ../components/responses.yml#/NotFound + default: + $ref: ../components/responses.yml#/Problem +post: + operationId: CreateOrganizationNeed + summary: Create a need of an organization from a form, a text, or both. + description: |- + 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. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - need + parameters: + - $ref: ../components/parameters.yml#/OrganizationId + - $ref: ../components/parameters.yml#/IdempotencyKey + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas.yml#/NeedCreate + examples: + manual_without_vacancy: + $ref: ../components/examples.yml#/NeedCreateManual + from_text: + $ref: ../components/examples.yml#/NeedCreateFromText + responses: + "201": + description: >- + The need was created as version 1, or a retry with the same + Idempotency-Key replayed its creation. + headers: + Cache-Control: + $ref: ../components/headers.yml#/CacheControlNoStore + content: + application/json: + schema: + $ref: ../components/schemas.yml#/Need + examples: + manual_without_vacancy: + $ref: ../components/examples.yml#/NeedManualWithoutVacancy + from_text_with_unknown_skill: + $ref: ../components/examples.yml#/NeedExtractedWithUnknownSkill + "400": + $ref: ../components/responses.yml#/NeedValidationFailed + "401": + $ref: ../components/responses.yml#/Unauthenticated + "403": + $ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden + "404": + $ref: ../components/responses.yml#/NotFound + "409": + $ref: ../components/responses.yml#/IdempotencyInProgress + "422": + $ref: ../components/responses.yml#/UnprocessableContent + "429": + $ref: ../components/responses.yml#/TooManyRequests + default: + $ref: ../components/responses.yml#/Problem diff --git a/backend/internal/adapter/primary/http/api/oas_cfg_gen.go b/backend/internal/adapter/primary/http/api/oas_cfg_gen.go index 133a8be..eb27608 100644 --- a/backend/internal/adapter/primary/http/api/oas_cfg_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_cfg_gen.go @@ -21,6 +21,7 @@ var regexMap = map[string]ogenregex.Regexp{ "^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"), "^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"), "^[A-Za-z0-9_-]+$": ogenregex.MustCompile("^[A-Za-z0-9_-]+$"), + "^[a-z0-9][a-z0-9_.+#-]*$": ogenregex.MustCompile("^[a-z0-9][a-z0-9_.+#-]*$"), "^[a-z0-9_+-]+$": ogenregex.MustCompile("^[a-z0-9_+-]+$"), "^[a-z0-9_]+$": ogenregex.MustCompile("^[a-z0-9_]+$"), "^[a-z][a-z0-9_]*$": ogenregex.MustCompile("^[a-z][a-z0-9_]*$"), diff --git a/backend/internal/adapter/primary/http/api/oas_handlers_gen.go b/backend/internal/adapter/primary/http/api/oas_handlers_gen.go index 94326c1..346a0b2 100644 --- a/backend/internal/adapter/primary/http/api/oas_handlers_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_handlers_gen.go @@ -474,6 +474,290 @@ func (s *Server) handleCreateMyAssessmentAttemptRequest(args [0]string, argsEsca } } +// handleCreateOrganizationNeedRequest handles CreateOrganizationNeed operation. +// +// 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. +// +// POST /api/v1/organizations/{org_id}/needs +func (s *Server) handleCreateOrganizationNeedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("CreateOrganizationNeed"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/v1/organizations/{org_id}/needs"), + } + // Add attributes from config. + otelAttrs = append(otelAttrs, s.cfg.Attributes...) + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), CreateOrganizationNeedOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(attrs...) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + code := statusWriter.status + if code < 100 || code >= 500 { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: CreateOrganizationNeedOperation, + ID: "CreateOrganizationNeed", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securitySessionCookie(ctx, CreateOrganizationNeedOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCookie", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCookie", err) + } + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + { + sctx, ok, err := s.securitySessionCsrf(ctx, CreateOrganizationNeedOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCsrf", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCsrf", err) + } + return + } + if ok { + satisfied[0] |= 1 << 1 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000011}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security", err) + } + return + } + } + params, err := decodeCreateOrganizationNeedParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var rawBody []byte + request, rawBody, close, err := s.decodeCreateOrganizationNeedRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response CreateOrganizationNeedRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: CreateOrganizationNeedOperation, + OperationSummary: "Create a need of an organization from a form, a text, or both.", + OperationID: "CreateOrganizationNeed", + Body: request, + RawBody: rawBody, + Params: middleware.Parameters{ + { + Name: "org_id", + In: "path", + }: params.OrgID, + { + Name: "Idempotency-Key", + In: "header", + }: params.IdempotencyKey, + }, + Raw: r, + } + + type ( + Request = *NeedCreate + Params = CreateOrganizationNeedParams + Response = CreateOrganizationNeedRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackCreateOrganizationNeedParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.CreateOrganizationNeed(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.CreateOrganizationNeed(ctx, request, params) + } + if err != nil { + if errRes, ok := errors.Into[*ProblemStatusCode](err); ok { + if err := encodeErrorResponse(errRes, w, span); err != nil { + defer recordError("Internal", err) + } + return + } + if errors.Is(err, ht.ErrNotImplemented) { + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil { + defer recordError("Internal", err) + } + return + } + + if err := encodeCreateOrganizationNeedResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleFinalizeMyAssessmentAttemptRequest handles FinalizeMyAssessmentAttempt operation. // // Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, @@ -2246,6 +2530,235 @@ func (s *Server) handleGetMyQuestionnaireRequest(args [0]string, argsEscaped boo } } +// handleGetOrganizationNeedRequest handles GetOrganizationNeed operation. +// +// 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. +// +// GET /api/v1/organizations/{org_id}/needs/{need_id} +func (s *Server) handleGetOrganizationNeedRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("GetOrganizationNeed"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/organizations/{org_id}/needs/{need_id}"), + } + // Add attributes from config. + otelAttrs = append(otelAttrs, s.cfg.Attributes...) + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), GetOrganizationNeedOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(attrs...) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + code := statusWriter.status + if code < 100 || code >= 500 { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: GetOrganizationNeedOperation, + ID: "GetOrganizationNeed", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securitySessionCookie(ctx, GetOrganizationNeedOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCookie", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCookie", err) + } + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security", err) + } + return + } + } + params, err := decodeGetOrganizationNeedParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var rawBody []byte + + var response GetOrganizationNeedRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: GetOrganizationNeedOperation, + OperationSummary: "Read the current version of a need of an organization.", + OperationID: "GetOrganizationNeed", + Body: nil, + RawBody: rawBody, + Params: middleware.Parameters{ + { + Name: "org_id", + In: "path", + }: params.OrgID, + { + Name: "need_id", + In: "path", + }: params.NeedID, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = GetOrganizationNeedParams + Response = GetOrganizationNeedRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackGetOrganizationNeedParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.GetOrganizationNeed(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.GetOrganizationNeed(ctx, params) + } + if err != nil { + if errRes, ok := errors.Into[*ProblemStatusCode](err); ok { + if err := encodeErrorResponse(errRes, w, span); err != nil { + defer recordError("Internal", err) + } + return + } + if errors.Is(err, ht.ErrNotImplemented) { + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil { + defer recordError("Internal", err) + } + return + } + + if err := encodeGetOrganizationNeedResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleGetSpecializationCatalogRequest handles GetSpecializationCatalog operation. // // Public operation without a session. Returns the directions with their specializations, the @@ -2395,6 +2908,229 @@ func (s *Server) handleGetSpecializationCatalogRequest(args [0]string, argsEscap } } +// handleListOrganizationNeedsRequest handles ListOrganizationNeeds operation. +// +// 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. +// +// GET /api/v1/organizations/{org_id}/needs +func (s *Server) handleListOrganizationNeedsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("ListOrganizationNeeds"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/organizations/{org_id}/needs"), + } + // Add attributes from config. + otelAttrs = append(otelAttrs, s.cfg.Attributes...) + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListOrganizationNeedsOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(attrs...) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + code := statusWriter.status + if code < 100 || code >= 500 { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListOrganizationNeedsOperation, + ID: "ListOrganizationNeeds", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securitySessionCookie(ctx, ListOrganizationNeedsOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCookie", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCookie", err) + } + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security", err) + } + return + } + } + params, err := decodeListOrganizationNeedsParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var rawBody []byte + + var response ListOrganizationNeedsRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListOrganizationNeedsOperation, + OperationSummary: "List the needs of an organization.", + OperationID: "ListOrganizationNeeds", + Body: nil, + RawBody: rawBody, + Params: middleware.Parameters{ + { + Name: "org_id", + In: "path", + }: params.OrgID, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "cursor", + In: "query", + }: params.Cursor, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListOrganizationNeedsParams + Response = ListOrganizationNeedsRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListOrganizationNeedsParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListOrganizationNeeds(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListOrganizationNeeds(ctx, params) + } + if err != nil { + if errRes, ok := errors.Into[*ProblemStatusCode](err); ok { + if err := encodeErrorResponse(errRes, w, span); err != nil { + defer recordError("Internal", err) + } + return + } + if errors.Is(err, ht.ErrNotImplemented) { + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil { + defer recordError("Internal", err) + } + return + } + + if err := encodeListOrganizationNeedsResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleLoginRequest handles Login operation. // // Public operation that starts a server session. The server verifies the password with Argon2id; for @@ -3680,3 +4416,301 @@ func (s *Server) handleSubmitMyAssessmentAnswerRequest(args [1]string, argsEscap return } } + +// handleUpdateOrganizationNeedRequest handles UpdateOrganizationNeed operation. +// +// 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. +// +// PATCH /api/v1/organizations/{org_id}/needs/{need_id} +func (s *Server) handleUpdateOrganizationNeedRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("UpdateOrganizationNeed"), + semconv.HTTPRequestMethodKey.String("PATCH"), + semconv.HTTPRouteKey.String("/api/v1/organizations/{org_id}/needs/{need_id}"), + } + // Add attributes from config. + otelAttrs = append(otelAttrs, s.cfg.Attributes...) + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), UpdateOrganizationNeedOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(attrs...) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + code := statusWriter.status + if code < 100 || code >= 500 { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: UpdateOrganizationNeedOperation, + ID: "UpdateOrganizationNeed", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securitySessionCookie(ctx, UpdateOrganizationNeedOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCookie", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCookie", err) + } + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + { + sctx, ok, err := s.securitySessionCsrf(ctx, UpdateOrganizationNeedOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "SessionCsrf", + Err: err, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security:SessionCsrf", err) + } + return + } + if ok { + satisfied[0] |= 1 << 1 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000011}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil { + defer recordError("Security", err) + } + return + } + } + params, err := decodeUpdateOrganizationNeedParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var rawBody []byte + request, rawBody, close, err := s.decodeUpdateOrganizationNeedRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response UpdateOrganizationNeedRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: UpdateOrganizationNeedOperation, + OperationSummary: "Confirm, change, or delete requirements of a need.", + OperationID: "UpdateOrganizationNeed", + Body: request, + RawBody: rawBody, + Params: middleware.Parameters{ + { + Name: "org_id", + In: "path", + }: params.OrgID, + { + Name: "need_id", + In: "path", + }: params.NeedID, + }, + Raw: r, + } + + type ( + Request = *NeedUpdate + Params = UpdateOrganizationNeedParams + Response = UpdateOrganizationNeedRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackUpdateOrganizationNeedParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.UpdateOrganizationNeed(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.UpdateOrganizationNeed(ctx, request, params) + } + if err != nil { + if errRes, ok := errors.Into[*ProblemStatusCode](err); ok { + if err := encodeErrorResponse(errRes, w, span); err != nil { + defer recordError("Internal", err) + } + return + } + if errors.Is(err, ht.ErrNotImplemented) { + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil { + defer recordError("Internal", err) + } + return + } + + if err := encodeUpdateOrganizationNeedResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} diff --git a/backend/internal/adapter/primary/http/api/oas_interfaces_gen.go b/backend/internal/adapter/primary/http/api/oas_interfaces_gen.go index ebb886e..4062f4b 100644 --- a/backend/internal/adapter/primary/http/api/oas_interfaces_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_interfaces_gen.go @@ -9,6 +9,10 @@ type CreateMyAssessmentAttemptRes interface { createMyAssessmentAttemptRes() } +type CreateOrganizationNeedRes interface { + createOrganizationNeedRes() +} + type FinalizeMyAssessmentAttemptRes interface { finalizeMyAssessmentAttemptRes() } @@ -41,6 +45,14 @@ type GetMyQuestionnaireRes interface { getMyQuestionnaireRes() } +type GetOrganizationNeedRes interface { + getOrganizationNeedRes() +} + +type ListOrganizationNeedsRes interface { + listOrganizationNeedsRes() +} + type LoginRes interface { loginRes() } @@ -64,3 +76,7 @@ type SaveMyQuestionnaireRes interface { type SubmitMyAssessmentAnswerRes interface { submitMyAssessmentAnswerRes() } + +type UpdateOrganizationNeedRes interface { + updateOrganizationNeedRes() +} diff --git a/backend/internal/adapter/primary/http/api/oas_json_gen.go b/backend/internal/adapter/primary/http/api/oas_json_gen.go index f783799..3c20d14 100644 --- a/backend/internal/adapter/primary/http/api/oas_json_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_json_gen.go @@ -6285,6 +6285,234 @@ func (s *CreateMyAssessmentAttemptUnprocessableEntity) UnmarshalJSON(data []byte return s.Decode(d) } +// Encode encodes CreateOrganizationNeedBadRequest as json. +func (s *CreateOrganizationNeedBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedBadRequest from json. +func (s *CreateOrganizationNeedBadRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedBadRequest to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedBadRequest(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedBadRequest) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedBadRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationNeedConflict as json. +func (s *CreateOrganizationNeedConflict) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedConflict from json. +func (s *CreateOrganizationNeedConflict) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedConflict to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedConflict(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedConflict) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedConflict) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationNeedForbidden as json. +func (s *CreateOrganizationNeedForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedForbidden from json. +func (s *CreateOrganizationNeedForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedForbidden to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationNeedNotFound as json. +func (s *CreateOrganizationNeedNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedNotFound from json. +func (s *CreateOrganizationNeedNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedNotFound to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationNeedUnauthorized as json. +func (s *CreateOrganizationNeedUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedUnauthorized from json. +func (s *CreateOrganizationNeedUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedUnauthorized to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationNeedUnprocessableEntity as json. +func (s *CreateOrganizationNeedUnprocessableEntity) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateOrganizationNeedUnprocessableEntity from json. +func (s *CreateOrganizationNeedUnprocessableEntity) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateOrganizationNeedUnprocessableEntity to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateOrganizationNeedUnprocessableEntity(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateOrganizationNeedUnprocessableEntity) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateOrganizationNeedUnprocessableEntity) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes CsrfToken as json. func (s CsrfToken) Encode(e *jx.Encoder) { unwrapped := string(s) @@ -6325,6 +6553,44 @@ func (s *CsrfToken) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes CurrencyCode as json. +func (s CurrencyCode) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes CurrencyCode from json. +func (s *CurrencyCode) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CurrencyCode to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch CurrencyCode(v) { + case CurrencyCodeRUB: + *s = CurrencyCodeRUB + default: + *s = CurrencyCode(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s CurrencyCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CurrencyCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes DirectionCode as json. func (s DirectionCode) Encode(e *jx.Encoder) { e.Str(string(s)) @@ -7791,6 +8057,158 @@ func (s *GetMyQuestionnaireUnauthorized) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes GetOrganizationNeedBadRequest as json. +func (s *GetOrganizationNeedBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes GetOrganizationNeedBadRequest from json. +func (s *GetOrganizationNeedBadRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetOrganizationNeedBadRequest to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = GetOrganizationNeedBadRequest(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *GetOrganizationNeedBadRequest) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *GetOrganizationNeedBadRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GetOrganizationNeedForbidden as json. +func (s *GetOrganizationNeedForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes GetOrganizationNeedForbidden from json. +func (s *GetOrganizationNeedForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetOrganizationNeedForbidden to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = GetOrganizationNeedForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *GetOrganizationNeedForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *GetOrganizationNeedForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GetOrganizationNeedNotFound as json. +func (s *GetOrganizationNeedNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes GetOrganizationNeedNotFound from json. +func (s *GetOrganizationNeedNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetOrganizationNeedNotFound to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = GetOrganizationNeedNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *GetOrganizationNeedNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *GetOrganizationNeedNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GetOrganizationNeedUnauthorized as json. +func (s *GetOrganizationNeedUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes GetOrganizationNeedUnauthorized from json. +func (s *GetOrganizationNeedUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetOrganizationNeedUnauthorized to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = GetOrganizationNeedUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *GetOrganizationNeedUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *GetOrganizationNeedUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes GradeCode as json. func (s GradeCode) Encode(e *jx.Encoder) { e.Str(string(s)) @@ -8410,6 +8828,158 @@ func (s *ItemContent) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ListOrganizationNeedsBadRequest as json. +func (s *ListOrganizationNeedsBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ListOrganizationNeedsBadRequest from json. +func (s *ListOrganizationNeedsBadRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationNeedsBadRequest to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListOrganizationNeedsBadRequest(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ListOrganizationNeedsBadRequest) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListOrganizationNeedsBadRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ListOrganizationNeedsForbidden as json. +func (s *ListOrganizationNeedsForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ListOrganizationNeedsForbidden from json. +func (s *ListOrganizationNeedsForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationNeedsForbidden to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListOrganizationNeedsForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ListOrganizationNeedsForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListOrganizationNeedsForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ListOrganizationNeedsNotFound as json. +func (s *ListOrganizationNeedsNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ListOrganizationNeedsNotFound from json. +func (s *ListOrganizationNeedsNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationNeedsNotFound to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListOrganizationNeedsNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ListOrganizationNeedsNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListOrganizationNeedsNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ListOrganizationNeedsUnauthorized as json. +func (s *ListOrganizationNeedsUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ListOrganizationNeedsUnauthorized from json. +func (s *ListOrganizationNeedsUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationNeedsUnauthorized to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ListOrganizationNeedsUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ListOrganizationNeedsUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ListOrganizationNeedsUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes LoginBadRequest as json. func (s *LoginBadRequest) Encode(e *jx.Encoder) { unwrapped := (*Problem)(s) @@ -8673,6 +9243,5121 @@ func (s *LoginUnauthorized) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *Need) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Need) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + json.EncodeUUID(e, s.ID) + } + { + e.FieldStart("organization_id") + json.EncodeUUID(e, s.OrganizationID) + } + { + e.FieldStart("vacancy_id") + s.VacancyID.Encode(e) + } + { + e.FieldStart("title") + s.Title.Encode(e) + } + { + e.FieldStart("source_text") + s.SourceText.Encode(e) + } + { + e.FieldStart("version") + s.Version.Encode(e) + } + { + e.FieldStart("requirements_version") + s.RequirementsVersion.Encode(e) + } + { + e.FieldStart("requirements") + s.Requirements.Encode(e) + } + { + e.FieldStart("readiness") + s.Readiness.Encode(e) + } + { + e.FieldStart("recommendations") + s.Recommendations.Encode(e) + } + { + e.FieldStart("created_at") + s.CreatedAt.Encode(e) + } + { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e) + } +} + +var jsonFieldsNameOfNeed = [12]string{ + 0: "id", + 1: "organization_id", + 2: "vacancy_id", + 3: "title", + 4: "source_text", + 5: "version", + 6: "requirements_version", + 7: "requirements", + 8: "readiness", + 9: "recommendations", + 10: "created_at", + 11: "updated_at", +} + +// Decode decodes Need from json. +func (s *Need) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Need to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := json.DecodeUUID(d) + s.ID = v + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "organization_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := json.DecodeUUID(d) + s.OrganizationID = v + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"organization_id\"") + } + case "vacancy_id": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.VacancyID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"vacancy_id\"") + } + case "title": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "source_text": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.SourceText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source_text\"") + } + case "version": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + if err := s.Version.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"version\"") + } + case "requirements_version": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + if err := s.RequirementsVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"requirements_version\"") + } + case "requirements": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + if err := s.Requirements.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"requirements\"") + } + case "readiness": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + if err := s.Readiness.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"readiness\"") + } + case "recommendations": + requiredBitSet[1] |= 1 << 1 + if err := func() error { + if err := s.Recommendations.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"recommendations\"") + } + case "created_at": + requiredBitSet[1] |= 1 << 2 + if err := func() error { + if err := s.CreatedAt.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + case "updated_at": + requiredBitSet[1] |= 1 << 3 + if err := func() error { + if err := s.UpdatedAt.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"updated_at\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Need") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b11111111, + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeed) { + name = jsonFieldsNameOfNeed[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Need) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Need) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedCategoryRecommendation) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedCategoryRecommendation) encodeFields(e *jx.Encoder) { + { + e.FieldStart("specialization") + s.Specialization.Encode(e) + } + { + e.FieldStart("grade") + s.Grade.Encode(e) + } + { + e.FieldStart("score") + s.Score.Encode(e) + } + { + e.FieldStart("skill_overlap") + s.SkillOverlap.Encode(e) + } + { + e.FieldStart("money") + s.Money.Encode(e) + } + { + e.FieldStart("supply") + s.Supply.Encode(e) + } +} + +var jsonFieldsNameOfNeedCategoryRecommendation = [6]string{ + 0: "specialization", + 1: "grade", + 2: "score", + 3: "skill_overlap", + 4: "money", + 5: "supply", +} + +// Decode decodes NeedCategoryRecommendation from json. +func (s *NeedCategoryRecommendation) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedCategoryRecommendation to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "specialization": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Specialization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"specialization\"") + } + case "grade": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Grade.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grade\"") + } + case "score": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Score.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"score\"") + } + case "skill_overlap": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.SkillOverlap.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"skill_overlap\"") + } + case "money": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.Money.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"money\"") + } + case "supply": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + if err := s.Supply.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"supply\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedCategoryRecommendation") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00111111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedCategoryRecommendation) { + name = jsonFieldsNameOfNeedCategoryRecommendation[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedCategoryRecommendation) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedCategoryRecommendation) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedCategoryRecommendations) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedCategoryRecommendations) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("requirements_version") + s.RequirementsVersion.Encode(e) + } + { + e.FieldStart("policy_version") + s.PolicyVersion.Encode(e) + } + { + e.FieldStart("algorithm_version") + s.AlgorithmVersion.Encode(e) + } + { + e.FieldStart("computed_at") + s.ComputedAt.Encode(e) + } + { + e.FieldStart("categories") + e.ArrStart() + for _, elem := range s.Categories { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfNeedCategoryRecommendations = [6]string{ + 0: "status", + 1: "requirements_version", + 2: "policy_version", + 3: "algorithm_version", + 4: "computed_at", + 5: "categories", +} + +// Decode decodes NeedCategoryRecommendations from json. +func (s *NeedCategoryRecommendations) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedCategoryRecommendations to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "requirements_version": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.RequirementsVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"requirements_version\"") + } + case "policy_version": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.PolicyVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"policy_version\"") + } + case "algorithm_version": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.AlgorithmVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"algorithm_version\"") + } + case "computed_at": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.ComputedAt.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"computed_at\"") + } + case "categories": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + s.Categories = make([]NeedCategoryRecommendation, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedCategoryRecommendation + if err := elem.Decode(d); err != nil { + return err + } + s.Categories = append(s.Categories, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"categories\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedCategoryRecommendations") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00111111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedCategoryRecommendations) { + name = jsonFieldsNameOfNeedCategoryRecommendations[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedCategoryRecommendations) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedCategoryRecommendations) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedCreate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedCreate) encodeFields(e *jx.Encoder) { + { + e.FieldStart("title") + s.Title.Encode(e) + } + { + if s.VacancyID.Set { + e.FieldStart("vacancy_id") + s.VacancyID.Encode(e) + } + } + { + if s.SourceText.Set { + e.FieldStart("source_text") + s.SourceText.Encode(e) + } + } + { + if s.Specialization.Set { + e.FieldStart("specialization") + s.Specialization.Encode(e) + } + } + { + if s.Grade.Set { + e.FieldStart("grade") + s.Grade.Encode(e) + } + } + { + if s.RequiredSkills != nil { + e.FieldStart("required_skills") + e.ArrStart() + for _, elem := range s.RequiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DesiredSkills != nil { + e.FieldStart("desired_skills") + e.ArrStart() + for _, elem := range s.DesiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Tasks != nil { + e.FieldStart("tasks") + e.ArrStart() + for _, elem := range s.Tasks { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Domain.Set { + e.FieldStart("domain") + s.Domain.Encode(e) + } + } + { + if s.WorkFormats.Set { + e.FieldStart("work_formats") + s.WorkFormats.Encode(e) + } + } + { + if s.Location.Set { + e.FieldStart("location") + s.Location.Encode(e) + } + } + { + if s.Salary.Set { + e.FieldStart("salary") + s.Salary.Encode(e) + } + } +} + +var jsonFieldsNameOfNeedCreate = [12]string{ + 0: "title", + 1: "vacancy_id", + 2: "source_text", + 3: "specialization", + 4: "grade", + 5: "required_skills", + 6: "desired_skills", + 7: "tasks", + 8: "domain", + 9: "work_formats", + 10: "location", + 11: "salary", +} + +// Decode decodes NeedCreate from json. +func (s *NeedCreate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedCreate to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "title": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "vacancy_id": + if err := func() error { + s.VacancyID.Reset() + if err := s.VacancyID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"vacancy_id\"") + } + case "source_text": + if err := func() error { + s.SourceText.Reset() + if err := s.SourceText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source_text\"") + } + case "specialization": + if err := func() error { + s.Specialization.Reset() + if err := s.Specialization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"specialization\"") + } + case "grade": + if err := func() error { + s.Grade.Reset() + if err := s.Grade.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grade\"") + } + case "required_skills": + if err := func() error { + s.RequiredSkills = make([]NeedSkillInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkillInput + if err := elem.Decode(d); err != nil { + return err + } + s.RequiredSkills = append(s.RequiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"required_skills\"") + } + case "desired_skills": + if err := func() error { + s.DesiredSkills = make([]NeedSkillInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkillInput + if err := elem.Decode(d); err != nil { + return err + } + s.DesiredSkills = append(s.DesiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"desired_skills\"") + } + case "tasks": + if err := func() error { + s.Tasks = make([]NeedTaskInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedTaskInput + if err := elem.Decode(d); err != nil { + return err + } + s.Tasks = append(s.Tasks, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tasks\"") + } + case "domain": + if err := func() error { + s.Domain.Reset() + if err := s.Domain.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"domain\"") + } + case "work_formats": + if err := func() error { + s.WorkFormats.Reset() + if err := s.WorkFormats.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"work_formats\"") + } + case "location": + if err := func() error { + s.Location.Reset() + if err := s.Location.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location\"") + } + case "salary": + if err := func() error { + s.Salary.Reset() + if err := s.Salary.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"salary\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedCreate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b00000001, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedCreate) { + name = jsonFieldsNameOfNeedCreate[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedCreate) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedCreate) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedDomain) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedDomain) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedDomain = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedDomain from json. +func (s *NeedDomain) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedDomain to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedDomain") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedDomain) { + name = jsonFieldsNameOfNeedDomain[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedDomain) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedDomain) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedDomainInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedDomainInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedDomainInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedDomainInput from json. +func (s *NeedDomainInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedDomainInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedDomainInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedDomainInput) { + name = jsonFieldsNameOfNeedDomainInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedDomainInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedDomainInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedDomainName as json. +func (s NeedDomainName) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedDomainName from json. +func (s *NeedDomainName) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedDomainName to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedDomainName(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedDomainName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedDomainName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedFieldName as json. +func (s NeedFieldName) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedFieldName from json. +func (s *NeedFieldName) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedFieldName to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedFieldName(v) { + case NeedFieldNameSpecialization: + *s = NeedFieldNameSpecialization + case NeedFieldNameGrade: + *s = NeedFieldNameGrade + case NeedFieldNameRequiredSkills: + *s = NeedFieldNameRequiredSkills + case NeedFieldNameDesiredSkills: + *s = NeedFieldNameDesiredSkills + case NeedFieldNameTasks: + *s = NeedFieldNameTasks + case NeedFieldNameDomain: + *s = NeedFieldNameDomain + case NeedFieldNameWorkFormats: + *s = NeedFieldNameWorkFormats + case NeedFieldNameLocation: + *s = NeedFieldNameLocation + case NeedFieldNameSalary: + *s = NeedFieldNameSalary + default: + *s = NeedFieldName(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedFieldName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedFieldName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedGrade) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedGrade) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedGrade = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedGrade from json. +func (s *NeedGrade) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedGrade to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedGrade") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedGrade) { + name = jsonFieldsNameOfNeedGrade[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedGrade) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedGrade) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedGradeInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedGradeInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedGradeInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedGradeInput from json. +func (s *NeedGradeInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedGradeInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedGradeInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedGradeInput) { + name = jsonFieldsNameOfNeedGradeInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedGradeInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedGradeInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedItemStatus as json. +func (s NeedItemStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedItemStatus from json. +func (s *NeedItemStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedItemStatus to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedItemStatus(v) { + case NeedItemStatusConfirmed: + *s = NeedItemStatusConfirmed + case NeedItemStatusExtracted: + *s = NeedItemStatusExtracted + default: + *s = NeedItemStatus(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedItemStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedItemStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedList) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedList) encodeFields(e *jx.Encoder) { + { + e.FieldStart("items") + e.ArrStart() + for _, elem := range s.Items { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("page") + s.Page.Encode(e) + } +} + +var jsonFieldsNameOfNeedList = [2]string{ + 0: "items", + 1: "page", +} + +// Decode decodes NeedList from json. +func (s *NeedList) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedList to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "items": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Items = make([]NeedSummary, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSummary + if err := elem.Decode(d); err != nil { + return err + } + s.Items = append(s.Items, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"items\"") + } + case "page": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Page.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"page\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedList") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedList) { + name = jsonFieldsNameOfNeedList[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedList) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedList) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedLocation) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedLocation) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedLocation = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedLocation from json. +func (s *NeedLocation) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedLocation to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedLocation") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedLocation) { + name = jsonFieldsNameOfNeedLocation[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedLocation) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedLocation) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedLocationInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedLocationInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedLocationInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedLocationInput from json. +func (s *NeedLocationInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedLocationInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedLocationInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedLocationInput) { + name = jsonFieldsNameOfNeedLocationInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedLocationInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedLocationInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedLocationName as json. +func (s NeedLocationName) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedLocationName from json. +func (s *NeedLocationName) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedLocationName to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedLocationName(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedLocationName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedLocationName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedMissingField) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedMissingField) encodeFields(e *jx.Encoder) { + { + e.FieldStart("field") + s.Field.Encode(e) + } + { + e.FieldStart("reason") + s.Reason.Encode(e) + } + { + e.FieldStart("question") + e.Str(s.Question) + } +} + +var jsonFieldsNameOfNeedMissingField = [3]string{ + 0: "field", + 1: "reason", + 2: "question", +} + +// Decode decodes NeedMissingField from json. +func (s *NeedMissingField) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedMissingField to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "field": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Field.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"field\"") + } + case "reason": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Reason.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"reason\"") + } + case "question": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Question = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"question\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedMissingField") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedMissingField) { + name = jsonFieldsNameOfNeedMissingField[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedMissingField) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedMissingField) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedMissingReason as json. +func (s NeedMissingReason) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedMissingReason from json. +func (s *NeedMissingReason) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedMissingReason to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedMissingReason(v) { + case NeedMissingReasonUnknown: + *s = NeedMissingReasonUnknown + case NeedMissingReasonUnconfirmed: + *s = NeedMissingReasonUnconfirmed + default: + *s = NeedMissingReason(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedMissingReason) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedMissingReason) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedMoneyFit) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedMoneyFit) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("share") + s.Share.Encode(e) + } +} + +var jsonFieldsNameOfNeedMoneyFit = [2]string{ + 0: "status", + 1: "share", +} + +// Decode decodes NeedMoneyFit from json. +func (s *NeedMoneyFit) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedMoneyFit to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "share": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Share.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"share\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedMoneyFit") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedMoneyFit) { + name = jsonFieldsNameOfNeedMoneyFit[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedMoneyFit) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedMoneyFit) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedMoneyStatus as json. +func (s NeedMoneyStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedMoneyStatus from json. +func (s *NeedMoneyStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedMoneyStatus to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedMoneyStatus(v) { + case NeedMoneyStatusComputed: + *s = NeedMoneyStatusComputed + case NeedMoneyStatusInsufficientData: + *s = NeedMoneyStatusInsufficientData + case NeedMoneyStatusNoSalary: + *s = NeedMoneyStatusNoSalary + case NeedMoneyStatusWithheld: + *s = NeedMoneyStatusWithheld + default: + *s = NeedMoneyStatus(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedMoneyStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedMoneyStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedReadinessReport) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedReadinessReport) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("missing_fields") + e.ArrStart() + for _, elem := range s.MissingFields { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfNeedReadinessReport = [2]string{ + 0: "status", + 1: "missing_fields", +} + +// Decode decodes NeedReadinessReport from json. +func (s *NeedReadinessReport) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedReadinessReport to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "missing_fields": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.MissingFields = make([]NeedMissingField, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedMissingField + if err := elem.Decode(d); err != nil { + return err + } + s.MissingFields = append(s.MissingFields, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"missing_fields\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedReadinessReport") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedReadinessReport) { + name = jsonFieldsNameOfNeedReadinessReport[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedReadinessReport) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedReadinessReport) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedReadinessStatus as json. +func (s NeedReadinessStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedReadinessStatus from json. +func (s *NeedReadinessStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedReadinessStatus to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedReadinessStatus(v) { + case NeedReadinessStatusComplete: + *s = NeedReadinessStatusComplete + case NeedReadinessStatusIncomplete: + *s = NeedReadinessStatusIncomplete + default: + *s = NeedReadinessStatus(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedReadinessStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedReadinessStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedRecommendationStatus as json. +func (s NeedRecommendationStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedRecommendationStatus from json. +func (s *NeedRecommendationStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedRecommendationStatus to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedRecommendationStatus(v) { + case NeedRecommendationStatusComputed: + *s = NeedRecommendationStatusComputed + case NeedRecommendationStatusPending: + *s = NeedRecommendationStatusPending + case NeedRecommendationStatusNotAvailable: + *s = NeedRecommendationStatusNotAvailable + default: + *s = NeedRecommendationStatus(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedRecommendationStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedRecommendationStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedRequirementSet) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedRequirementSet) encodeFields(e *jx.Encoder) { + { + e.FieldStart("specialization") + s.Specialization.Encode(e) + } + { + e.FieldStart("grade") + s.Grade.Encode(e) + } + { + e.FieldStart("required_skills") + e.ArrStart() + for _, elem := range s.RequiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("desired_skills") + e.ArrStart() + for _, elem := range s.DesiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("tasks") + e.ArrStart() + for _, elem := range s.Tasks { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("domain") + s.Domain.Encode(e) + } + { + e.FieldStart("work_formats") + s.WorkFormats.Encode(e) + } + { + e.FieldStart("location") + s.Location.Encode(e) + } + { + e.FieldStart("salary") + s.Salary.Encode(e) + } +} + +var jsonFieldsNameOfNeedRequirementSet = [9]string{ + 0: "specialization", + 1: "grade", + 2: "required_skills", + 3: "desired_skills", + 4: "tasks", + 5: "domain", + 6: "work_formats", + 7: "location", + 8: "salary", +} + +// Decode decodes NeedRequirementSet from json. +func (s *NeedRequirementSet) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedRequirementSet to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "specialization": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Specialization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"specialization\"") + } + case "grade": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Grade.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grade\"") + } + case "required_skills": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + s.RequiredSkills = make([]NeedSkill, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkill + if err := elem.Decode(d); err != nil { + return err + } + s.RequiredSkills = append(s.RequiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"required_skills\"") + } + case "desired_skills": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + s.DesiredSkills = make([]NeedSkill, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkill + if err := elem.Decode(d); err != nil { + return err + } + s.DesiredSkills = append(s.DesiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"desired_skills\"") + } + case "tasks": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + s.Tasks = make([]NeedTask, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedTask + if err := elem.Decode(d); err != nil { + return err + } + s.Tasks = append(s.Tasks, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tasks\"") + } + case "domain": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + if err := s.Domain.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"domain\"") + } + case "work_formats": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + if err := s.WorkFormats.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"work_formats\"") + } + case "location": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + if err := s.Location.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location\"") + } + case "salary": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + if err := s.Salary.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"salary\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedRequirementSet") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b11111111, + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedRequirementSet) { + name = jsonFieldsNameOfNeedRequirementSet[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedRequirementSet) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedRequirementSet) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSalary) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSalary) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedSalary = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedSalary from json. +func (s *NeedSalary) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSalary to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSalary") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSalary) { + name = jsonFieldsNameOfNeedSalary[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSalary) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSalary) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSalaryInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSalaryInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedSalaryInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedSalaryInput from json. +func (s *NeedSalaryInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSalaryInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSalaryInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSalaryInput) { + name = jsonFieldsNameOfNeedSalaryInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSalaryInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSalaryInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSkill) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSkill) encodeFields(e *jx.Encoder) { + { + e.FieldStart("name") + s.Name.Encode(e) + } + { + e.FieldStart("taxonomy_code") + s.TaxonomyCode.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedSkill = [4]string{ + 0: "name", + 1: "taxonomy_code", + 2: "status", + 3: "source", +} + +// Decode decodes NeedSkill from json. +func (s *NeedSkill) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSkill to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "name": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Name.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "taxonomy_code": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.TaxonomyCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"taxonomy_code\"") + } + case "status": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "source": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSkill") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSkill) { + name = jsonFieldsNameOfNeedSkill[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSkill) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSkill) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSkillInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSkillInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("name") + s.Name.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedSkillInput = [2]string{ + 0: "name", + 1: "status", +} + +// Decode decodes NeedSkillInput from json. +func (s *NeedSkillInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSkillInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "name": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Name.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSkillInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSkillInput) { + name = jsonFieldsNameOfNeedSkillInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSkillInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSkillInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSkillOverlap) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSkillOverlap) encodeFields(e *jx.Encoder) { + { + e.FieldStart("share") + e.Float64(s.Share) + } + { + e.FieldStart("covered_skills") + e.ArrStart() + for _, elem := range s.CoveredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("uncovered_skills") + e.ArrStart() + for _, elem := range s.UncoveredSkills { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfNeedSkillOverlap = [3]string{ + 0: "share", + 1: "covered_skills", + 2: "uncovered_skills", +} + +// Decode decodes NeedSkillOverlap from json. +func (s *NeedSkillOverlap) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSkillOverlap to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "share": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Float64() + s.Share = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"share\"") + } + case "covered_skills": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.CoveredSkills = make([]SkillName, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem SkillName + if err := elem.Decode(d); err != nil { + return err + } + s.CoveredSkills = append(s.CoveredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"covered_skills\"") + } + case "uncovered_skills": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + s.UncoveredSkills = make([]SkillName, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem SkillName + if err := elem.Decode(d); err != nil { + return err + } + s.UncoveredSkills = append(s.UncoveredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"uncovered_skills\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSkillOverlap") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSkillOverlap) { + name = jsonFieldsNameOfNeedSkillOverlap[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSkillOverlap) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSkillOverlap) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSourceQuote as json. +func (s NeedSourceQuote) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedSourceQuote from json. +func (s *NeedSourceQuote) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSourceQuote to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedSourceQuote(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedSourceQuote) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSourceQuote) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSourceText as json. +func (s NeedSourceText) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedSourceText from json. +func (s *NeedSourceText) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSourceText to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedSourceText(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedSourceText) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSourceText) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSpecialization) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSpecialization) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedSpecialization = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedSpecialization from json. +func (s *NeedSpecialization) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSpecialization to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSpecialization") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSpecialization) { + name = jsonFieldsNameOfNeedSpecialization[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSpecialization) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSpecialization) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSpecializationInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSpecializationInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + s.Value.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedSpecializationInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedSpecializationInput from json. +func (s *NeedSpecializationInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSpecializationInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSpecializationInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSpecializationInput) { + name = jsonFieldsNameOfNeedSpecializationInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSpecializationInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSpecializationInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedSummary) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedSummary) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + json.EncodeUUID(e, s.ID) + } + { + e.FieldStart("vacancy_id") + s.VacancyID.Encode(e) + } + { + e.FieldStart("title") + s.Title.Encode(e) + } + { + e.FieldStart("version") + s.Version.Encode(e) + } + { + e.FieldStart("specialization") + s.Specialization.Encode(e) + } + { + e.FieldStart("grade") + s.Grade.Encode(e) + } + { + e.FieldStart("readiness") + s.Readiness.Encode(e) + } + { + e.FieldStart("created_at") + s.CreatedAt.Encode(e) + } + { + e.FieldStart("updated_at") + s.UpdatedAt.Encode(e) + } +} + +var jsonFieldsNameOfNeedSummary = [9]string{ + 0: "id", + 1: "vacancy_id", + 2: "title", + 3: "version", + 4: "specialization", + 5: "grade", + 6: "readiness", + 7: "created_at", + 8: "updated_at", +} + +// Decode decodes NeedSummary from json. +func (s *NeedSummary) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSummary to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := json.DecodeUUID(d) + s.ID = v + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "vacancy_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.VacancyID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"vacancy_id\"") + } + case "title": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "version": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Version.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"version\"") + } + case "specialization": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.Specialization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"specialization\"") + } + case "grade": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + if err := s.Grade.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grade\"") + } + case "readiness": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + if err := s.Readiness.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"readiness\"") + } + case "created_at": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + if err := s.CreatedAt.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created_at\"") + } + case "updated_at": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + if err := s.UpdatedAt.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"updated_at\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedSummary") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b11111111, + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedSummary) { + name = jsonFieldsNameOfNeedSummary[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedSummary) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSummary) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSupplyBand as json. +func (s NeedSupplyBand) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedSupplyBand from json. +func (s *NeedSupplyBand) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedSupplyBand to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedSupplyBand(v) { + case NeedSupplyBandFewerThan5: + *s = NeedSupplyBandFewerThan5 + case NeedSupplyBandFrom5To29: + *s = NeedSupplyBandFrom5To29 + case NeedSupplyBand30OrMore: + *s = NeedSupplyBand30OrMore + default: + *s = NeedSupplyBand(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedSupplyBand) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedSupplyBand) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedTask) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedTask) encodeFields(e *jx.Encoder) { + { + e.FieldStart("text") + s.Text.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedTask = [3]string{ + 0: "text", + 1: "status", + 2: "source", +} + +// Decode decodes NeedTask from json. +func (s *NeedTask) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedTask to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "text": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Text.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"text\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedTask") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedTask) { + name = jsonFieldsNameOfNeedTask[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedTask) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedTask) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedTaskInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedTaskInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("text") + s.Text.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedTaskInput = [2]string{ + 0: "text", + 1: "status", +} + +// Decode decodes NeedTaskInput from json. +func (s *NeedTaskInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedTaskInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "text": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Text.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"text\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedTaskInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedTaskInput) { + name = jsonFieldsNameOfNeedTaskInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedTaskInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedTaskInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedTaskText as json. +func (s NeedTaskText) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedTaskText from json. +func (s *NeedTaskText) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedTaskText to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedTaskText(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedTaskText) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedTaskText) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedTitle as json. +func (s NeedTitle) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedTitle from json. +func (s *NeedTitle) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedTitle to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedTitle(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedTitle) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedTitle) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedUpdate) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedUpdate) encodeFields(e *jx.Encoder) { + { + e.FieldStart("expected_version") + s.ExpectedVersion.Encode(e) + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.VacancyID.Set { + e.FieldStart("vacancy_id") + s.VacancyID.Encode(e) + } + } + { + if s.SourceText.Set { + e.FieldStart("source_text") + s.SourceText.Encode(e) + } + } + { + if s.Specialization.Set { + e.FieldStart("specialization") + s.Specialization.Encode(e) + } + } + { + if s.Grade.Set { + e.FieldStart("grade") + s.Grade.Encode(e) + } + } + { + if s.RequiredSkills != nil { + e.FieldStart("required_skills") + e.ArrStart() + for _, elem := range s.RequiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.DesiredSkills != nil { + e.FieldStart("desired_skills") + e.ArrStart() + for _, elem := range s.DesiredSkills { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Tasks != nil { + e.FieldStart("tasks") + e.ArrStart() + for _, elem := range s.Tasks { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Domain.Set { + e.FieldStart("domain") + s.Domain.Encode(e) + } + } + { + if s.WorkFormats.Set { + e.FieldStart("work_formats") + s.WorkFormats.Encode(e) + } + } + { + if s.Location.Set { + e.FieldStart("location") + s.Location.Encode(e) + } + } + { + if s.Salary.Set { + e.FieldStart("salary") + s.Salary.Encode(e) + } + } +} + +var jsonFieldsNameOfNeedUpdate = [13]string{ + 0: "expected_version", + 1: "title", + 2: "vacancy_id", + 3: "source_text", + 4: "specialization", + 5: "grade", + 6: "required_skills", + 7: "desired_skills", + 8: "tasks", + 9: "domain", + 10: "work_formats", + 11: "location", + 12: "salary", +} + +// Decode decodes NeedUpdate from json. +func (s *NeedUpdate) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedUpdate to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "expected_version": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.ExpectedVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"expected_version\"") + } + case "title": + if err := func() error { + s.Title.Reset() + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "vacancy_id": + if err := func() error { + s.VacancyID.Reset() + if err := s.VacancyID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"vacancy_id\"") + } + case "source_text": + if err := func() error { + s.SourceText.Reset() + if err := s.SourceText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source_text\"") + } + case "specialization": + if err := func() error { + s.Specialization.Reset() + if err := s.Specialization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"specialization\"") + } + case "grade": + if err := func() error { + s.Grade.Reset() + if err := s.Grade.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grade\"") + } + case "required_skills": + if err := func() error { + s.RequiredSkills = make([]NeedSkillInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkillInput + if err := elem.Decode(d); err != nil { + return err + } + s.RequiredSkills = append(s.RequiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"required_skills\"") + } + case "desired_skills": + if err := func() error { + s.DesiredSkills = make([]NeedSkillInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedSkillInput + if err := elem.Decode(d); err != nil { + return err + } + s.DesiredSkills = append(s.DesiredSkills, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"desired_skills\"") + } + case "tasks": + if err := func() error { + s.Tasks = make([]NeedTaskInput, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem NeedTaskInput + if err := elem.Decode(d); err != nil { + return err + } + s.Tasks = append(s.Tasks, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tasks\"") + } + case "domain": + if err := func() error { + s.Domain.Reset() + if err := s.Domain.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"domain\"") + } + case "work_formats": + if err := func() error { + s.WorkFormats.Reset() + if err := s.WorkFormats.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"work_formats\"") + } + case "location": + if err := func() error { + s.Location.Reset() + if err := s.Location.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"location\"") + } + case "salary": + if err := func() error { + s.Salary.Reset() + if err := s.Salary.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"salary\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedUpdate") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b00000001, + 0b00000000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedUpdate) { + name = jsonFieldsNameOfNeedUpdate[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedUpdate) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedUpdate) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedValueOrigin as json. +func (s NeedValueOrigin) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedValueOrigin from json. +func (s *NeedValueOrigin) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedValueOrigin to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedValueOrigin(v) { + case NeedValueOriginManual: + *s = NeedValueOriginManual + case NeedValueOriginExtractedFromText: + *s = NeedValueOriginExtractedFromText + case NeedValueOriginImported: + *s = NeedValueOriginImported + default: + *s = NeedValueOrigin(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedValueOrigin) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedValueOrigin) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedValueSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedValueSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("origin") + s.Origin.Encode(e) + } + { + e.FieldStart("quote") + s.Quote.Encode(e) + } + { + e.FieldStart("extracted_in_version") + s.ExtractedInVersion.Encode(e) + } + { + e.FieldStart("extraction_version") + s.ExtractionVersion.Encode(e) + } +} + +var jsonFieldsNameOfNeedValueSource = [4]string{ + 0: "origin", + 1: "quote", + 2: "extracted_in_version", + 3: "extraction_version", +} + +// Decode decodes NeedValueSource from json. +func (s *NeedValueSource) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedValueSource to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "origin": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Origin.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"origin\"") + } + case "quote": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Quote.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"quote\"") + } + case "extracted_in_version": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.ExtractedInVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"extracted_in_version\"") + } + case "extraction_version": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.ExtractionVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"extraction_version\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedValueSource") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedValueSource) { + name = jsonFieldsNameOfNeedValueSource[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedValueSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedValueSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedValueStatus as json. +func (s NeedValueStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NeedValueStatus from json. +func (s *NeedValueStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedValueStatus to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NeedValueStatus(v) { + case NeedValueStatusConfirmed: + *s = NeedValueStatusConfirmed + case NeedValueStatusExtracted: + *s = NeedValueStatusExtracted + case NeedValueStatusUnknown: + *s = NeedValueStatusUnknown + default: + *s = NeedValueStatus(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedValueStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedValueStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedVersion as json. +func (s NeedVersion) Encode(e *jx.Encoder) { + unwrapped := int64(s) + + e.Int64(unwrapped) +} + +// Decode decodes NeedVersion from json. +func (s *NeedVersion) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedVersion to nil") + } + var unwrapped int64 + if err := func() error { + v, err := d.Int64() + unwrapped = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedVersion(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedVersion) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedVersion) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedVersionLabel as json. +func (s NeedVersionLabel) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes NeedVersionLabel from json. +func (s *NeedVersionLabel) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedVersionLabel to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = NeedVersionLabel(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NeedVersionLabel) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedVersionLabel) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedWorkFormats) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedWorkFormats) encodeFields(e *jx.Encoder) { + { + e.FieldStart("status") + s.Status.Encode(e) + } + { + e.FieldStart("value") + if s.Value == nil { + e.Null() + } else { + e.ArrStart() + for _, elem := range s.Value { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + e.FieldStart("source") + s.Source.Encode(e) + } +} + +var jsonFieldsNameOfNeedWorkFormats = [3]string{ + 0: "status", + 1: "value", + 2: "source", +} + +// Decode decodes NeedWorkFormats from json. +func (s *NeedWorkFormats) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedWorkFormats to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "status": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + switch tt := d.Next(); tt { + case jx.Null: + if err := d.Skip(); err != nil { + return err + } + default: + s.Value = make([]WorkFormat, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem WorkFormat + if err := elem.Decode(d); err != nil { + return err + } + s.Value = append(s.Value, elem) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "source": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedWorkFormats") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedWorkFormats) { + name = jsonFieldsNameOfNeedWorkFormats[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedWorkFormats) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedWorkFormats) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NeedWorkFormatsInput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NeedWorkFormatsInput) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value") + e.ArrStart() + for _, elem := range s.Value { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} + +var jsonFieldsNameOfNeedWorkFormatsInput = [2]string{ + 0: "value", + 1: "status", +} + +// Decode decodes NeedWorkFormatsInput from json. +func (s *NeedWorkFormatsInput) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NeedWorkFormatsInput to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "value": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Value = make([]WorkFormat, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem WorkFormat + if err := elem.Decode(d); err != nil { + return err + } + s.Value = append(s.Value, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NeedWorkFormatsInput") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNeedWorkFormatsInput) { + name = jsonFieldsNameOfNeedWorkFormatsInput[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NeedWorkFormatsInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NeedWorkFormatsInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes NewPassword as json. func (s NewPassword) Encode(e *jx.Encoder) { unwrapped := string(s) @@ -9111,6 +14796,52 @@ func (s *NilCandidateExperience) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes float64 as json. +func (o NilFloat64) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + e.Float64(float64(o.Value)) +} + +// Decode decodes float64 from json. +func (o *NilFloat64) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilFloat64 to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v float64 + o.Value = v + o.Null = true + return nil + } + o.Null = false + v, err := d.Float64() + if err != nil { + return err + } + o.Value = float64(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilFloat64) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilFloat64) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes GradeCode as json. func (o NilGradeCode) Encode(e *jx.Encoder) { if o.Null { @@ -9201,6 +14932,314 @@ func (s *NilInt32) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes NeedDomainName as json. +func (o NilNeedDomainName) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedDomainName from json. +func (o *NilNeedDomainName) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedDomainName to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedDomainName + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedDomainName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedDomainName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedLocationName as json. +func (o NilNeedLocationName) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedLocationName from json. +func (o *NilNeedLocationName) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedLocationName to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedLocationName + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedLocationName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedLocationName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSourceQuote as json. +func (o NilNeedSourceQuote) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedSourceQuote from json. +func (o *NilNeedSourceQuote) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedSourceQuote to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedSourceQuote + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedSourceQuote) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedSourceQuote) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSourceText as json. +func (o NilNeedSourceText) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedSourceText from json. +func (o *NilNeedSourceText) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedSourceText to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedSourceText + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedSourceText) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedSourceText) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedValueSource as json. +func (o NilNeedValueSource) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedValueSource from json. +func (o *NilNeedValueSource) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedValueSource to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedValueSource + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedValueSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedValueSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedVersion as json. +func (o NilNeedVersion) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedVersion from json. +func (o *NilNeedVersion) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedVersion to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedVersion + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedVersion) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedVersion) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedVersionLabel as json. +func (o NilNeedVersionLabel) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedVersionLabel from json. +func (o *NilNeedVersionLabel) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilNeedVersionLabel to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedVersionLabel + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilNeedVersionLabel) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilNeedVersionLabel) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes PracticeFailureReason as json. func (o NilPracticeFailureReason) Encode(e *jx.Encoder) { if o.Null { @@ -9289,6 +15328,138 @@ func (s *NilPracticeVerdict) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes SalaryRange as json. +func (o NilSalaryRange) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes SalaryRange from json. +func (o *NilSalaryRange) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilSalaryRange to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v SalaryRange + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilSalaryRange) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilSalaryRange) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SkillTaxonomyCode as json. +func (o NilSkillTaxonomyCode) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes SkillTaxonomyCode from json. +func (o *NilSkillTaxonomyCode) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilSkillTaxonomyCode to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v SkillTaxonomyCode + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilSkillTaxonomyCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilSkillTaxonomyCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SpecializationCode as json. +func (o NilSpecializationCode) Encode(e *jx.Encoder) { + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes SpecializationCode from json. +func (o *NilSpecializationCode) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode NilSpecializationCode to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v SpecializationCode + o.Value = v + o.Null = true + return nil + } + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NilSpecializationCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NilSpecializationCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes string as json. func (o NilString) Encode(e *jx.Encoder) { if o.Null { @@ -9857,6 +16028,433 @@ func (s *OnboardingStep) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes NeedTitle as json. +func (o OptNeedTitle) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedTitle from json. +func (o *OptNeedTitle) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNeedTitle to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNeedTitle) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNeedTitle) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedDomainInput as json. +func (o OptNilNeedDomainInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedDomainInput from json. +func (o *OptNilNeedDomainInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedDomainInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedDomainInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedDomainInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedDomainInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedGradeInput as json. +func (o OptNilNeedGradeInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedGradeInput from json. +func (o *OptNilNeedGradeInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedGradeInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedGradeInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedGradeInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedGradeInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedLocationInput as json. +func (o OptNilNeedLocationInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedLocationInput from json. +func (o *OptNilNeedLocationInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedLocationInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedLocationInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedLocationInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedLocationInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSalaryInput as json. +func (o OptNilNeedSalaryInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedSalaryInput from json. +func (o *OptNilNeedSalaryInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedSalaryInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedSalaryInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedSalaryInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedSalaryInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSourceText as json. +func (o OptNilNeedSourceText) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedSourceText from json. +func (o *OptNilNeedSourceText) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedSourceText to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedSourceText + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedSourceText) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedSourceText) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedSpecializationInput as json. +func (o OptNilNeedSpecializationInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedSpecializationInput from json. +func (o *OptNilNeedSpecializationInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedSpecializationInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedSpecializationInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedSpecializationInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedSpecializationInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NeedWorkFormatsInput as json. +func (o OptNilNeedWorkFormatsInput) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + o.Value.Encode(e) +} + +// Decode decodes NeedWorkFormatsInput from json. +func (o *OptNilNeedWorkFormatsInput) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilNeedWorkFormatsInput to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v NeedWorkFormatsInput + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilNeedWorkFormatsInput) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilNeedWorkFormatsInput) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes uuid.UUID as json. +func (o OptNilUUID) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + json.EncodeUUID(e, o.Value) +} + +// Decode decodes uuid.UUID from json. +func (o *OptNilUUID) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilUUID to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v uuid.UUID + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + v, err := json.DecodeUUID(d) + if err != nil { + return err + } + o.Value = v + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilUUID) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilUUID) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes string as json. func (o OptString) Encode(e *jx.Encoder) { if !o.Set { @@ -10210,6 +16808,117 @@ func (s *OrderItemContentFormat) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *PageInfo) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *PageInfo) encodeFields(e *jx.Encoder) { + { + e.FieldStart("has_more") + e.Bool(s.HasMore) + } + { + e.FieldStart("next_cursor") + s.NextCursor.Encode(e) + } +} + +var jsonFieldsNameOfPageInfo = [2]string{ + 0: "has_more", + 1: "next_cursor", +} + +// Decode decodes PageInfo from json. +func (s *PageInfo) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PageInfo to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "has_more": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Bool() + s.HasMore = bool(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"has_more\"") + } + case "next_cursor": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.NextCursor.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"next_cursor\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode PageInfo") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfPageInfo) { + name = jsonFieldsNameOfPageInfo[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *PageInfo) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PageInfo) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *PersonalDataConsentAcceptance) Encode(e *jx.Encoder) { e.ObjStart() @@ -12284,6 +18993,278 @@ func (s *ResendEmailVerificationForbidden) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes RubAmount as json. +func (s RubAmount) Encode(e *jx.Encoder) { + unwrapped := int64(s) + + e.Int64(unwrapped) +} + +// Decode decodes RubAmount from json. +func (s *RubAmount) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RubAmount to nil") + } + var unwrapped int64 + if err := func() error { + v, err := d.Int64() + unwrapped = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = RubAmount(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s RubAmount) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RubAmount) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SalaryPeriod as json. +func (s SalaryPeriod) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes SalaryPeriod from json. +func (s *SalaryPeriod) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SalaryPeriod to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch SalaryPeriod(v) { + case SalaryPeriodMonth: + *s = SalaryPeriodMonth + default: + *s = SalaryPeriod(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SalaryPeriod) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SalaryPeriod) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *SalaryRange) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *SalaryRange) encodeFields(e *jx.Encoder) { + { + e.FieldStart("salary_from") + s.SalaryFrom.Encode(e) + } + { + e.FieldStart("salary_to") + s.SalaryTo.Encode(e) + } + { + e.FieldStart("currency") + s.Currency.Encode(e) + } + { + e.FieldStart("period") + s.Period.Encode(e) + } + { + e.FieldStart("tax_basis") + s.TaxBasis.Encode(e) + } +} + +var jsonFieldsNameOfSalaryRange = [5]string{ + 0: "salary_from", + 1: "salary_to", + 2: "currency", + 3: "period", + 4: "tax_basis", +} + +// Decode decodes SalaryRange from json. +func (s *SalaryRange) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SalaryRange to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "salary_from": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.SalaryFrom.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"salary_from\"") + } + case "salary_to": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.SalaryTo.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"salary_to\"") + } + case "currency": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Currency.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"currency\"") + } + case "period": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Period.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"period\"") + } + case "tax_basis": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.TaxBasis.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tax_basis\"") + } + default: + return errors.Errorf("unexpected field %q", k) + } + return nil + }); err != nil { + return errors.Wrap(err, "decode SalaryRange") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00011111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfSalaryRange) { + name = jsonFieldsNameOfSalaryRange[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *SalaryRange) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SalaryRange) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SalaryTaxBasis as json. +func (s SalaryTaxBasis) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes SalaryTaxBasis from json. +func (s *SalaryTaxBasis) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SalaryTaxBasis to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch SalaryTaxBasis(v) { + case SalaryTaxBasisNet: + *s = SalaryTaxBasisNet + case SalaryTaxBasisGross: + *s = SalaryTaxBasisGross + default: + *s = SalaryTaxBasis(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SalaryTaxBasis) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SalaryTaxBasis) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes SaveMyQuestionnaireBadRequest as json. func (s *SaveMyQuestionnaireBadRequest) Encode(e *jx.Encoder) { unwrapped := (*Problem)(s) @@ -12545,6 +19526,86 @@ func (s *Session) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes SkillName as json. +func (s SkillName) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes SkillName from json. +func (s *SkillName) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SkillName to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = SkillName(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SkillName) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SkillName) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SkillTaxonomyCode as json. +func (s SkillTaxonomyCode) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes SkillTaxonomyCode from json. +func (s *SkillTaxonomyCode) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SkillTaxonomyCode to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = SkillTaxonomyCode(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SkillTaxonomyCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SkillTaxonomyCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *SpecializationCatalog) Encode(e *jx.Encoder) { e.ObjStart() @@ -13619,6 +20680,196 @@ func (s *Timestamp) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes UpdateOrganizationNeedBadRequest as json. +func (s *UpdateOrganizationNeedBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UpdateOrganizationNeedBadRequest from json. +func (s *UpdateOrganizationNeedBadRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateOrganizationNeedBadRequest to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateOrganizationNeedBadRequest(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateOrganizationNeedBadRequest) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateOrganizationNeedBadRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationNeedForbidden as json. +func (s *UpdateOrganizationNeedForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UpdateOrganizationNeedForbidden from json. +func (s *UpdateOrganizationNeedForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateOrganizationNeedForbidden to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateOrganizationNeedForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateOrganizationNeedForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateOrganizationNeedForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationNeedNotFound as json. +func (s *UpdateOrganizationNeedNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UpdateOrganizationNeedNotFound from json. +func (s *UpdateOrganizationNeedNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateOrganizationNeedNotFound to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateOrganizationNeedNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateOrganizationNeedNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateOrganizationNeedNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationNeedPreconditionFailed as json. +func (s *UpdateOrganizationNeedPreconditionFailed) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UpdateOrganizationNeedPreconditionFailed from json. +func (s *UpdateOrganizationNeedPreconditionFailed) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateOrganizationNeedPreconditionFailed to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateOrganizationNeedPreconditionFailed(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateOrganizationNeedPreconditionFailed) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateOrganizationNeedPreconditionFailed) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationNeedUnauthorized as json. +func (s *UpdateOrganizationNeedUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Problem)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UpdateOrganizationNeedUnauthorized from json. +func (s *UpdateOrganizationNeedUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateOrganizationNeedUnauthorized to nil") + } + var unwrapped Problem + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateOrganizationNeedUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UpdateOrganizationNeedUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateOrganizationNeedUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes VerificationToken as json. func (s VerificationToken) Encode(e *jx.Encoder) { unwrapped := string(s) diff --git a/backend/internal/adapter/primary/http/api/oas_operations_gen.go b/backend/internal/adapter/primary/http/api/oas_operations_gen.go index 7201adb..df69798 100644 --- a/backend/internal/adapter/primary/http/api/oas_operations_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_operations_gen.go @@ -8,6 +8,7 @@ type OperationName = string const ( ConfirmEmailOperation OperationName = "ConfirmEmail" CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt" + CreateOrganizationNeedOperation OperationName = "CreateOrganizationNeed" FinalizeMyAssessmentAttemptOperation OperationName = "FinalizeMyAssessmentAttempt" GetConsentTextOperation OperationName = "GetConsentText" GetCurrentAccountOperation OperationName = "GetCurrentAccount" @@ -17,11 +18,14 @@ const ( GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability" GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult" GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire" + GetOrganizationNeedOperation OperationName = "GetOrganizationNeed" GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog" + ListOrganizationNeedsOperation OperationName = "ListOrganizationNeeds" LoginOperation OperationName = "Login" LogoutOperation OperationName = "Logout" RegisterAccountOperation OperationName = "RegisterAccount" ResendEmailVerificationOperation OperationName = "ResendEmailVerification" SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire" SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer" + UpdateOrganizationNeedOperation OperationName = "UpdateOrganizationNeed" ) diff --git a/backend/internal/adapter/primary/http/api/oas_parameters_gen.go b/backend/internal/adapter/primary/http/api/oas_parameters_gen.go index 9e70a75..e4f2b4a 100644 --- a/backend/internal/adapter/primary/http/api/oas_parameters_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_parameters_gen.go @@ -109,6 +109,157 @@ func decodeCreateMyAssessmentAttemptParams(args [0]string, argsEscaped bool, r * return params, nil } +// CreateOrganizationNeedParams is parameters of CreateOrganizationNeed operation. +type CreateOrganizationNeedParams struct { + // Identifier of an organization. Access comes only from an active membership of the session account in + // this organization, checked by the server on every request; the identifier itself grants nothing. An + // organization without such a membership and an unknown identifier both answer 404 not_found, so + // organizations cannot be enumerated. + OrgID uuid.UUID + // Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value + // is sent without quotes. The server scopes the key by caller and operation and fingerprints the + // request by method, path, and body. + // + // Stored for 24 hours after the first request and replayed with the same status, headers, and body: + // the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404 + // not_found or 409 state_conflict. A replay does not repeat the side effect. + // + // Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for + // the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428 + // precondition_required (nothing changed; read the resource again and retry), 422 + // idempotency_key_reused, 429, and every 5xx. + // + // Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then + // the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused + // before any other key check; a running request with the same fingerprint returns 409 + // idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that + // does the server check If-Match, so a retry of a completed change replays its outcome instead of + // failing on the version it has just changed. After 24 hours the key may be accepted as new. + IdempotencyKey string +} + +func unpackCreateOrganizationNeedParams(packed middleware.Parameters) (params CreateOrganizationNeedParams) { + { + key := middleware.ParameterKey{ + Name: "org_id", + In: "path", + } + params.OrgID = packed[key].(uuid.UUID) + } + { + key := middleware.ParameterKey{ + Name: "Idempotency-Key", + In: "header", + } + params.IdempotencyKey = packed[key].(string) + } + return params +} + +func decodeCreateOrganizationNeedParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateOrganizationNeedParams, _ error) { + h := uri.NewHeaderDecoder(r.Header) + // Decode path: org_id. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "org_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.OrgID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "org_id", + In: "path", + Err: err, + } + } + // Decode header: Idempotency-Key. + if err := func() error { + cfg := uri.HeaderParameterDecodingConfig{ + Name: "Idempotency-Key", + Explode: false, + } + if err := h.HasParam(cfg); err == nil { + if err := h.DecodeParam(cfg, func(d uri.Decoder) error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.IdempotencyKey = c + return nil + }); err != nil { + return err + } + if err := func() error { + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 255, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^[A-Za-z0-9._:-]+$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(params.IdempotencyKey)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } else { + return err + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "Idempotency-Key", + In: "header", + Err: err, + } + } + return params, nil +} + // FinalizeMyAssessmentAttemptParams is parameters of FinalizeMyAssessmentAttempt operation. type FinalizeMyAssessmentAttemptParams struct { // Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an @@ -466,6 +617,363 @@ func decodeGetMyAssessmentResultParams(args [1]string, argsEscaped bool, r *http return params, nil } +// GetOrganizationNeedParams is parameters of GetOrganizationNeed operation. +type GetOrganizationNeedParams struct { + // Identifier of an organization. Access comes only from an active membership of the session account in + // this organization, checked by the server on every request; the identifier itself grants nothing. An + // organization without such a membership and an unknown identifier both answer 404 not_found, so + // organizations cannot be enumerated. + OrgID uuid.UUID + // Identifier of a need of the organization in the path. A need of another organization and an unknown + // identifier both answer 404 not_found. + NeedID uuid.UUID +} + +func unpackGetOrganizationNeedParams(packed middleware.Parameters) (params GetOrganizationNeedParams) { + { + key := middleware.ParameterKey{ + Name: "org_id", + In: "path", + } + params.OrgID = packed[key].(uuid.UUID) + } + { + key := middleware.ParameterKey{ + Name: "need_id", + In: "path", + } + params.NeedID = packed[key].(uuid.UUID) + } + return params +} + +func decodeGetOrganizationNeedParams(args [2]string, argsEscaped bool, r *http.Request) (params GetOrganizationNeedParams, _ error) { + // Decode path: org_id. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "org_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.OrgID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "org_id", + In: "path", + Err: err, + } + } + // Decode path: need_id. + if err := func() error { + param := args[1] + if argsEscaped { + unescaped, err := url.PathUnescape(args[1]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "need_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.NeedID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "need_id", + In: "path", + Err: err, + } + } + return params, nil +} + +// ListOrganizationNeedsParams is parameters of ListOrganizationNeeds operation. +type ListOrganizationNeedsParams struct { + // Identifier of an organization. Access comes only from an active membership of the session account in + // this organization, checked by the server on every request; the identifier itself grants nothing. An + // organization without such a membership and an unknown identifier both answer 404 not_found, so + // organizations cannot be enumerated. + OrgID uuid.UUID + // Maximum number of items in the page. The server may return fewer items even when more remain; use + // `page.has_more` to detect the end. + Limit OptInt32 `json:",omitempty,omitzero"` + // Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the + // first page. A malformed or foreign cursor returns 400 with code validation_failed. + Cursor OptString `json:",omitempty,omitzero"` +} + +func unpackListOrganizationNeedsParams(packed middleware.Parameters) (params ListOrganizationNeedsParams) { + { + key := middleware.ParameterKey{ + Name: "org_id", + In: "path", + } + params.OrgID = packed[key].(uuid.UUID) + } + { + key := middleware.ParameterKey{ + Name: "limit", + In: "query", + } + if v, ok := packed[key]; ok { + params.Limit = v.(OptInt32) + } + } + { + key := middleware.ParameterKey{ + Name: "cursor", + In: "query", + } + if v, ok := packed[key]; ok { + params.Cursor = v.(OptString) + } + } + return params +} + +func decodeListOrganizationNeedsParams(args [1]string, argsEscaped bool, r *http.Request) (params ListOrganizationNeedsParams, _ error) { + q := uri.NewQueryDecoder(r.URL.Query()) + // Decode path: org_id. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "org_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.OrgID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "org_id", + In: "path", + Err: err, + } + } + // Set default value for query: limit. + { + val := int32(20) + params.Limit.SetTo(val) + } + // Decode query: limit. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "limit", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotLimitVal int32 + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt32(val) + if err != nil { + return err + } + + paramsDotLimitVal = c + return nil + }(); err != nil { + return err + } + params.Limit.SetTo(paramsDotLimitVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.Limit.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: true, + Max: 100, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + Pattern: nil, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "limit", + In: "query", + Err: err, + } + } + // Decode query: cursor. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "cursor", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotCursorVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotCursorVal = c + return nil + }(); err != nil { + return err + } + params.Cursor.SetTo(paramsDotCursorVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.Cursor.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 512, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^[A-Za-z0-9_-]+$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "cursor", + In: "query", + Err: err, + } + } + return params, nil +} + // RegisterAccountParams is parameters of RegisterAccount operation. type RegisterAccountParams struct { // Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value @@ -708,3 +1216,127 @@ func decodeSubmitMyAssessmentAnswerParams(args [1]string, argsEscaped bool, r *h } return params, nil } + +// UpdateOrganizationNeedParams is parameters of UpdateOrganizationNeed operation. +type UpdateOrganizationNeedParams struct { + // Identifier of an organization. Access comes only from an active membership of the session account in + // this organization, checked by the server on every request; the identifier itself grants nothing. An + // organization without such a membership and an unknown identifier both answer 404 not_found, so + // organizations cannot be enumerated. + OrgID uuid.UUID + // Identifier of a need of the organization in the path. A need of another organization and an unknown + // identifier both answer 404 not_found. + NeedID uuid.UUID +} + +func unpackUpdateOrganizationNeedParams(packed middleware.Parameters) (params UpdateOrganizationNeedParams) { + { + key := middleware.ParameterKey{ + Name: "org_id", + In: "path", + } + params.OrgID = packed[key].(uuid.UUID) + } + { + key := middleware.ParameterKey{ + Name: "need_id", + In: "path", + } + params.NeedID = packed[key].(uuid.UUID) + } + return params +} + +func decodeUpdateOrganizationNeedParams(args [2]string, argsEscaped bool, r *http.Request) (params UpdateOrganizationNeedParams, _ error) { + // Decode path: org_id. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "org_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.OrgID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "org_id", + In: "path", + Err: err, + } + } + // Decode path: need_id. + if err := func() error { + param := args[1] + if argsEscaped { + unescaped, err := url.PathUnescape(args[1]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "need_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToUUID(val) + if err != nil { + return err + } + + params.NeedID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "need_id", + In: "path", + Err: err, + } + } + return params, nil +} diff --git a/backend/internal/adapter/primary/http/api/oas_request_decoders_gen.go b/backend/internal/adapter/primary/http/api/oas_request_decoders_gen.go index a910081..339dc2a 100644 --- a/backend/internal/adapter/primary/http/api/oas_request_decoders_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_request_decoders_gen.go @@ -172,6 +172,85 @@ func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) ( } } +func (s *Server) decodeCreateOrganizationNeedRequest(r *http.Request) ( + req *NeedCreate, + rawBody []byte, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = errors.Join(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = errors.Join(rerr, close()) + } + }() + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, rawBody, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, rawBody, close, validate.ErrBodyRequired + } + buf, err := io.ReadAll(r.Body) + defer func() { + _ = r.Body.Close() + }() + if err != nil { + return req, rawBody, close, err + } + + // Reset the body to allow for downstream reading. + r.Body = io.NopCloser(bytes.NewBuffer(buf)) + + if len(buf) == 0 { + return req, rawBody, close, validate.ErrBodyRequired + } + + rawBody = append(rawBody, buf...) + d := jx.DecodeBytes(buf) + + var request NeedCreate + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, rawBody, close, err + } + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return req, rawBody, close, errors.Wrap(err, "validate") + } + return &request, rawBody, close, nil + default: + return req, rawBody, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeFinalizeMyAssessmentAttemptRequest(r *http.Request) ( req *AssessmentFinalization, rawBody []byte, @@ -645,3 +724,82 @@ func (s *Server) decodeSubmitMyAssessmentAnswerRequest(r *http.Request) ( return req, rawBody, close, validate.InvalidContentType(ct) } } + +func (s *Server) decodeUpdateOrganizationNeedRequest(r *http.Request) ( + req *NeedUpdate, + rawBody []byte, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = errors.Join(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = errors.Join(rerr, close()) + } + }() + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, rawBody, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, rawBody, close, validate.ErrBodyRequired + } + buf, err := io.ReadAll(r.Body) + defer func() { + _ = r.Body.Close() + }() + if err != nil { + return req, rawBody, close, err + } + + // Reset the body to allow for downstream reading. + r.Body = io.NopCloser(bytes.NewBuffer(buf)) + + if len(buf) == 0 { + return req, rawBody, close, validate.ErrBodyRequired + } + + rawBody = append(rawBody, buf...) + d := jx.DecodeBytes(buf) + + var request NeedUpdate + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, rawBody, close, err + } + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return req, rawBody, close, errors.Wrap(err, "validate") + } + return &request, rawBody, close, nil + default: + return req, rawBody, close, validate.InvalidContentType(ct) + } +} diff --git a/backend/internal/adapter/primary/http/api/oas_response_encoders_gen.go b/backend/internal/adapter/primary/http/api/oas_response_encoders_gen.go index 072e94a..cbbffc3 100644 --- a/backend/internal/adapter/primary/http/api/oas_response_encoders_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_response_encoders_gen.go @@ -216,6 +216,145 @@ func encodeCreateMyAssessmentAttemptResponse(response CreateMyAssessmentAttemptR } } +func encodeCreateOrganizationNeedResponse(response CreateOrganizationNeedRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *NeedHeaders: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Cache-Control" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Cache-Control", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + return e.EncodeValue(conv.StringToString(string(response.CacheControl))) + }); err != nil { + return errors.Wrap(err, "encode Cache-Control header") + } + } + } + w.WriteHeader(201) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedBadRequest: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(400) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedUnauthorized: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(401) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedForbidden: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(403) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedNotFound: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(404) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedConflict: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(409) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateOrganizationNeedUnprocessableEntity: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(422) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *TooManyRequestsHeaders: + w.Header().Set("Content-Type", "application/problem+json") + w.Header().Set("Access-Control-Expose-Headers", "Retry-After") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Retry-After" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Retry-After", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := response.RetryAfter.Get(); ok { + return e.EncodeValue(conv.Int32ToString(val)) + } + return nil + }); err != nil { + return errors.Wrap(err, "encode Retry-After header") + } + } + } + w.WriteHeader(429) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeFinalizeMyAssessmentAttemptResponse(response FinalizeMyAssessmentAttemptRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *AssessmentAttemptHeaders: @@ -745,6 +884,89 @@ func encodeGetMyQuestionnaireResponse(response GetMyQuestionnaireRes, w http.Res } } +func encodeGetOrganizationNeedResponse(response GetOrganizationNeedRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *NeedHeaders: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Cache-Control" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Cache-Control", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + return e.EncodeValue(conv.StringToString(string(response.CacheControl))) + }); err != nil { + return errors.Wrap(err, "encode Cache-Control header") + } + } + } + w.WriteHeader(200) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *GetOrganizationNeedBadRequest: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(400) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *GetOrganizationNeedUnauthorized: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(401) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *GetOrganizationNeedForbidden: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(403) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *GetOrganizationNeedNotFound: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(404) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeGetSpecializationCatalogResponse(response *SpecializationCatalog, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(200) @@ -758,6 +980,89 @@ func encodeGetSpecializationCatalogResponse(response *SpecializationCatalog, w h return nil } +func encodeListOrganizationNeedsResponse(response ListOrganizationNeedsRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *NeedListHeaders: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Cache-Control" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Cache-Control", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + return e.EncodeValue(conv.StringToString(string(response.CacheControl))) + }); err != nil { + return errors.Wrap(err, "encode Cache-Control header") + } + } + } + w.WriteHeader(200) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListOrganizationNeedsBadRequest: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(400) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListOrganizationNeedsUnauthorized: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(401) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListOrganizationNeedsForbidden: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(403) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListOrganizationNeedsNotFound: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(404) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeLoginResponse(response LoginRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *SessionHeaders: @@ -1352,6 +1657,133 @@ func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes } } +func encodeUpdateOrganizationNeedResponse(response UpdateOrganizationNeedRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *NeedHeaders: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Cache-Control" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Cache-Control", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + return e.EncodeValue(conv.StringToString(string(response.CacheControl))) + }); err != nil { + return errors.Wrap(err, "encode Cache-Control header") + } + } + } + w.WriteHeader(200) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateOrganizationNeedBadRequest: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(400) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateOrganizationNeedUnauthorized: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(401) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateOrganizationNeedForbidden: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(403) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateOrganizationNeedNotFound: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(404) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateOrganizationNeedPreconditionFailed: + w.Header().Set("Content-Type", "application/problem+json") + w.WriteHeader(412) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *TooManyRequestsHeaders: + w.Header().Set("Content-Type", "application/problem+json") + w.Header().Set("Access-Control-Expose-Headers", "Retry-After") + // Encoding response headers. + { + h := uri.NewHeaderEncoder(w.Header()) + // Encode "Retry-After" header. + { + cfg := uri.HeaderParameterEncodingConfig{ + Name: "Retry-After", + Explode: false, + } + if err := h.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := response.RetryAfter.Get(); ok { + return e.EncodeValue(conv.Int32ToString(val)) + } + return nil + }); err != nil { + return errors.Wrap(err, "encode Retry-After header") + } + } + } + w.WriteHeader(429) + + e := new(jx.Encoder) + response.Response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeErrorResponse(response *ProblemStatusCode, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Content-Type", "application/problem+json") code := response.StatusCode diff --git a/backend/internal/adapter/primary/http/api/oas_router_gen.go b/backend/internal/adapter/primary/http/api/oas_router_gen.go index 6bf06b0..741f7ab 100644 --- a/backend/internal/adapter/primary/http/api/oas_router_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_router_gen.go @@ -11,32 +11,38 @@ import ( ) var ( - rn23AllowedHeaders = map[string]string{ + rn28AllowedHeaders = map[string]string{ "POST": "Content-Type", } rn1AllowedHeaders = map[string]string{ "POST": "Content-Type", } - rn21AllowedHeaders = map[string]string{ + rn26AllowedHeaders = map[string]string{ "POST": "Content-Type,Idempotency-Key", } - rn20AllowedHeaders = map[string]string{ + rn25AllowedHeaders = map[string]string{ "POST": "Content-Type", } - rn11AllowedHeaders = map[string]string{ + rn14AllowedHeaders = map[string]string{ "DELETE": "X-Csrf-Token", } rn3AllowedHeaders = map[string]string{ "POST": "Content-Type,Idempotency-Key,X-Csrf-Token", } - rn24AllowedHeaders = map[string]string{ + rn29AllowedHeaders = map[string]string{ "POST": "Content-Type,Idempotency-Key,X-Csrf-Token", } + rn9AllowedHeaders = map[string]string{ + "POST": "Content-Type,Idempotency-Key,X-Csrf-Token", + } + rn21AllowedHeaders = map[string]string{ + "PUT": "Content-Type,X-Csrf-Token", + } rn6AllowedHeaders = map[string]string{ "POST": "Content-Type,Idempotency-Key,X-Csrf-Token", } - rn18AllowedHeaders = map[string]string{ - "PUT": "Content-Type,X-Csrf-Token", + rn23AllowedHeaders = map[string]string{ + "PATCH": "Content-Type,X-Csrf-Token", } ) @@ -70,7 +76,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.notFound(w, r) return } - args := [1]string{} + args := [2]string{} // Static code generated router with unwrapped path search. switch { @@ -192,7 +198,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "POST", - allowedHeaders: rn23AllowedHeaders, + allowedHeaders: rn28AllowedHeaders, acceptPost: "application/json", acceptPatch: "", }) @@ -269,7 +275,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "POST", - allowedHeaders: rn21AllowedHeaders, + allowedHeaders: rn26AllowedHeaders, acceptPost: "application/json", acceptPatch: "", }) @@ -293,7 +299,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "POST", - allowedHeaders: rn20AllowedHeaders, + allowedHeaders: rn25AllowedHeaders, acceptPost: "application/json", acceptPatch: "", }) @@ -320,7 +326,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "DELETE,GET", - allowedHeaders: rn11AllowedHeaders, + allowedHeaders: rn14AllowedHeaders, acceptPost: "", acceptPatch: "", }) @@ -446,7 +452,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "POST", - allowedHeaders: rn24AllowedHeaders, + allowedHeaders: rn29AllowedHeaders, acceptPost: "application/json", acceptPatch: "", }) @@ -473,7 +479,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "POST", - allowedHeaders: rn6AllowedHeaders, + allowedHeaders: rn9AllowedHeaders, acceptPost: "application/json", acceptPatch: "", }) @@ -560,7 +566,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { default: s.notAllowed(w, r, notAllowedParams{ allowedMethods: "GET,PUT", - allowedHeaders: rn18AllowedHeaders, + allowedHeaders: rn21AllowedHeaders, acceptPost: "", acceptPatch: "", }) @@ -571,6 +577,103 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } + case 'o': // Prefix: "organizations/" + + if l := len("organizations/"); len(elem) >= l && elem[0:l] == "organizations/" { + elem = elem[l:] + } else { + break + } + + // Param: "org_id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/needs" + + if l := len("/needs"); len(elem) >= l && elem[0:l] == "/needs" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch r.Method { + case "GET": + s.handleListOrganizationNeedsRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) + case "POST": + s.handleCreateOrganizationNeedRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, notAllowedParams{ + allowedMethods: "GET,POST", + allowedHeaders: rn6AllowedHeaders, + acceptPost: "application/json", + acceptPatch: "", + }) + } + + return + } + switch elem[0] { + case '/': // Prefix: "/" + + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "need_id" + // Leaf parameter, slashes are prohibited + idx := strings.IndexByte(elem, '/') + if idx >= 0 { + break + } + args[1] = elem + elem = "" + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "GET": + s.handleGetOrganizationNeedRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + case "PATCH": + s.handleUpdateOrganizationNeedRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, notAllowedParams{ + allowedMethods: "GET,PATCH", + allowedHeaders: rn23AllowedHeaders, + acceptPost: "", + acceptPatch: "application/json", + }) + } + + return + } + + } + + } + case 's': // Prefix: "specializations" if l := len("specializations"); len(elem) >= l && elem[0:l] == "specializations" { @@ -611,7 +714,7 @@ type Route struct { operationGroup string pathPattern string count int - args [1]string + args [2]string } // Name returns ogen operation name. @@ -1180,6 +1283,107 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } + case 'o': // Prefix: "organizations/" + + if l := len("organizations/"); len(elem) >= l && elem[0:l] == "organizations/" { + elem = elem[l:] + } else { + break + } + + // Param: "org_id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + break + } + switch elem[0] { + case '/': // Prefix: "/needs" + + if l := len("/needs"); len(elem) >= l && elem[0:l] == "/needs" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + switch method { + case "GET": + r.name = ListOrganizationNeedsOperation + r.summary = "List the needs of an organization." + r.operationID = "ListOrganizationNeeds" + r.operationGroup = "" + r.pathPattern = "/api/v1/organizations/{org_id}/needs" + r.args = args + r.count = 1 + return r, true + case "POST": + r.name = CreateOrganizationNeedOperation + r.summary = "Create a need of an organization from a form, a text, or both." + r.operationID = "CreateOrganizationNeed" + r.operationGroup = "" + r.pathPattern = "/api/v1/organizations/{org_id}/needs" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + switch elem[0] { + case '/': // Prefix: "/" + + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { + elem = elem[l:] + } else { + break + } + + // Param: "need_id" + // Leaf parameter, slashes are prohibited + idx := strings.IndexByte(elem, '/') + if idx >= 0 { + break + } + args[1] = elem + elem = "" + + if len(elem) == 0 { + // Leaf node. + switch method { + case "GET": + r.name = GetOrganizationNeedOperation + r.summary = "Read the current version of a need of an organization." + r.operationID = "GetOrganizationNeed" + r.operationGroup = "" + r.pathPattern = "/api/v1/organizations/{org_id}/needs/{need_id}" + r.args = args + r.count = 2 + return r, true + case "PATCH": + r.name = UpdateOrganizationNeedOperation + r.summary = "Confirm, change, or delete requirements of a need." + r.operationID = "UpdateOrganizationNeed" + r.operationGroup = "" + r.pathPattern = "/api/v1/organizations/{org_id}/needs/{need_id}" + r.args = args + r.count = 2 + return r, true + default: + return + } + } + + } + + } + case 's': // Prefix: "specializations" if l := len("specializations"); len(elem) >= l && elem[0:l] == "specializations" { diff --git a/backend/internal/adapter/primary/http/api/oas_schemas_gen.go b/backend/internal/adapter/primary/http/api/oas_schemas_gen.go index 507afca..3027254 100644 --- a/backend/internal/adapter/primary/http/api/oas_schemas_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_schemas_gen.go @@ -2985,8 +2985,68 @@ type CreateMyAssessmentAttemptUnprocessableEntity Problem func (*CreateMyAssessmentAttemptUnprocessableEntity) createMyAssessmentAttemptRes() {} +type CreateOrganizationNeedBadRequest Problem + +func (*CreateOrganizationNeedBadRequest) createOrganizationNeedRes() {} + +type CreateOrganizationNeedConflict Problem + +func (*CreateOrganizationNeedConflict) createOrganizationNeedRes() {} + +type CreateOrganizationNeedForbidden Problem + +func (*CreateOrganizationNeedForbidden) createOrganizationNeedRes() {} + +type CreateOrganizationNeedNotFound Problem + +func (*CreateOrganizationNeedNotFound) createOrganizationNeedRes() {} + +type CreateOrganizationNeedUnauthorized Problem + +func (*CreateOrganizationNeedUnauthorized) createOrganizationNeedRes() {} + +type CreateOrganizationNeedUnprocessableEntity Problem + +func (*CreateOrganizationNeedUnprocessableEntity) createOrganizationNeedRes() {} + type CsrfToken string +// ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change. +// Ref: #/components/schemas/CurrencyCode +type CurrencyCode string + +const ( + CurrencyCodeRUB CurrencyCode = "RUB" +) + +// AllValues returns all CurrencyCode values. +func (CurrencyCode) AllValues() []CurrencyCode { + return []CurrencyCode{ + CurrencyCodeRUB, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s CurrencyCode) MarshalText() ([]byte, error) { + switch s { + case CurrencyCodeRUB: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *CurrencyCode) UnmarshalText(data []byte) error { + switch CurrencyCode(data) { + case CurrencyCodeRUB: + *s = CurrencyCodeRUB + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // Stable code of a professional direction, the group that a specialization belongs to. // // - development: Development. @@ -3399,6 +3459,22 @@ type GetMyQuestionnaireUnauthorized Problem func (*GetMyQuestionnaireUnauthorized) getMyQuestionnaireRes() {} +type GetOrganizationNeedBadRequest Problem + +func (*GetOrganizationNeedBadRequest) getOrganizationNeedRes() {} + +type GetOrganizationNeedForbidden Problem + +func (*GetOrganizationNeedForbidden) getOrganizationNeedRes() {} + +type GetOrganizationNeedNotFound Problem + +func (*GetOrganizationNeedNotFound) getOrganizationNeedRes() {} + +type GetOrganizationNeedUnauthorized Problem + +func (*GetOrganizationNeedUnauthorized) getOrganizationNeedRes() {} + // Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes // describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an // assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a @@ -3765,6 +3841,22 @@ func NewPracticeItemContentItemContent(v PracticeItemContent) ItemContent { return s } +type ListOrganizationNeedsBadRequest Problem + +func (*ListOrganizationNeedsBadRequest) listOrganizationNeedsRes() {} + +type ListOrganizationNeedsForbidden Problem + +func (*ListOrganizationNeedsForbidden) listOrganizationNeedsRes() {} + +type ListOrganizationNeedsNotFound Problem + +func (*ListOrganizationNeedsNotFound) listOrganizationNeedsRes() {} + +type ListOrganizationNeedsUnauthorized Problem + +func (*ListOrganizationNeedsUnauthorized) listOrganizationNeedsRes() {} + type LoginBadRequest Problem func (*LoginBadRequest) loginRes() {} @@ -3823,6 +3915,2227 @@ func (s *LogoutNoContent) SetSetCookie(val string) { func (*LogoutNoContent) logoutRes() {} +// Hiring need of an organization: what the team needs, independent of any published vacancy. It holds +// the current version of the requirements with their provenance, the readiness of the critical fields, +// and the category recommendations. It never contains membership data, a candidate's personal data, or +// a candidate's salary minimum. +// Ref: #/components/schemas/Need +type Need struct { + // Identifier of the need. + ID uuid.UUID `json:"id"` + // Organization that owns the need, equal to `org_id` of the path. It never changes. + OrganizationID uuid.UUID `json:"organization_id"` + // Linked vacancy of the same organization, or null. A need never requires a vacancy. + VacancyID NilUUID `json:"vacancy_id"` + Title NeedTitle `json:"title"` + // Text the requirements were extracted from, or null. + SourceText NilNeedSourceText `json:"source_text"` + Version NeedVersion `json:"version"` + // Need version in which the current confirmed requirements were last changed, at most `version`. A + // change that confirms, changes, or removes a requirement makes it equal to the new `version`. A + // change of the title, the vacancy link, or the text, or of suggestions only, creates a new `version` + // but keeps `requirements_version`, so it invalidates neither the recommendations nor search results + // and selection snapshots. Search runs and selection snapshots (PRD FR10) refer to + // `(need id, requirements_version)`, and a new selection snapshot is due only when it changes. + RequirementsVersion NeedVersion `json:"requirements_version"` + Requirements NeedRequirementSet `json:"requirements"` + Readiness NeedReadinessReport `json:"readiness"` + Recommendations NeedCategoryRecommendations `json:"recommendations"` + CreatedAt Timestamp `json:"created_at"` + UpdatedAt Timestamp `json:"updated_at"` +} + +// GetID returns the value of ID. +func (s *Need) GetID() uuid.UUID { + return s.ID +} + +// GetOrganizationID returns the value of OrganizationID. +func (s *Need) GetOrganizationID() uuid.UUID { + return s.OrganizationID +} + +// GetVacancyID returns the value of VacancyID. +func (s *Need) GetVacancyID() NilUUID { + return s.VacancyID +} + +// GetTitle returns the value of Title. +func (s *Need) GetTitle() NeedTitle { + return s.Title +} + +// GetSourceText returns the value of SourceText. +func (s *Need) GetSourceText() NilNeedSourceText { + return s.SourceText +} + +// GetVersion returns the value of Version. +func (s *Need) GetVersion() NeedVersion { + return s.Version +} + +// GetRequirementsVersion returns the value of RequirementsVersion. +func (s *Need) GetRequirementsVersion() NeedVersion { + return s.RequirementsVersion +} + +// GetRequirements returns the value of Requirements. +func (s *Need) GetRequirements() NeedRequirementSet { + return s.Requirements +} + +// GetReadiness returns the value of Readiness. +func (s *Need) GetReadiness() NeedReadinessReport { + return s.Readiness +} + +// GetRecommendations returns the value of Recommendations. +func (s *Need) GetRecommendations() NeedCategoryRecommendations { + return s.Recommendations +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *Need) GetCreatedAt() Timestamp { + return s.CreatedAt +} + +// GetUpdatedAt returns the value of UpdatedAt. +func (s *Need) GetUpdatedAt() Timestamp { + return s.UpdatedAt +} + +// SetID sets the value of ID. +func (s *Need) SetID(val uuid.UUID) { + s.ID = val +} + +// SetOrganizationID sets the value of OrganizationID. +func (s *Need) SetOrganizationID(val uuid.UUID) { + s.OrganizationID = val +} + +// SetVacancyID sets the value of VacancyID. +func (s *Need) SetVacancyID(val NilUUID) { + s.VacancyID = val +} + +// SetTitle sets the value of Title. +func (s *Need) SetTitle(val NeedTitle) { + s.Title = val +} + +// SetSourceText sets the value of SourceText. +func (s *Need) SetSourceText(val NilNeedSourceText) { + s.SourceText = val +} + +// SetVersion sets the value of Version. +func (s *Need) SetVersion(val NeedVersion) { + s.Version = val +} + +// SetRequirementsVersion sets the value of RequirementsVersion. +func (s *Need) SetRequirementsVersion(val NeedVersion) { + s.RequirementsVersion = val +} + +// SetRequirements sets the value of Requirements. +func (s *Need) SetRequirements(val NeedRequirementSet) { + s.Requirements = val +} + +// SetReadiness sets the value of Readiness. +func (s *Need) SetReadiness(val NeedReadinessReport) { + s.Readiness = val +} + +// SetRecommendations sets the value of Recommendations. +func (s *Need) SetRecommendations(val NeedCategoryRecommendations) { + s.Recommendations = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *Need) SetCreatedAt(val Timestamp) { + s.CreatedAt = val +} + +// SetUpdatedAt sets the value of UpdatedAt. +func (s *Need) SetUpdatedAt(val Timestamp) { + s.UpdatedAt = val +} + +// One recommended category, a specialization with a grade, with its score and the reasons for it. The +// score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published +// components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, +// and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer +// than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor +// the order reveals the exact size of a group below five. +// Ref: #/components/schemas/NeedCategoryRecommendation +type NeedCategoryRecommendation struct { + Specialization SpecializationCode `json:"specialization"` + Grade GradeCode `json:"grade"` + // Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is + // `fewer_than_5`. Read-only; no request can set it. + Score NilFloat64 `json:"score"` + SkillOverlap NeedSkillOverlap `json:"skill_overlap"` + Money NeedMoneyFit `json:"money"` + Supply NeedSupplyBand `json:"supply"` +} + +// GetSpecialization returns the value of Specialization. +func (s *NeedCategoryRecommendation) GetSpecialization() SpecializationCode { + return s.Specialization +} + +// GetGrade returns the value of Grade. +func (s *NeedCategoryRecommendation) GetGrade() GradeCode { + return s.Grade +} + +// GetScore returns the value of Score. +func (s *NeedCategoryRecommendation) GetScore() NilFloat64 { + return s.Score +} + +// GetSkillOverlap returns the value of SkillOverlap. +func (s *NeedCategoryRecommendation) GetSkillOverlap() NeedSkillOverlap { + return s.SkillOverlap +} + +// GetMoney returns the value of Money. +func (s *NeedCategoryRecommendation) GetMoney() NeedMoneyFit { + return s.Money +} + +// GetSupply returns the value of Supply. +func (s *NeedCategoryRecommendation) GetSupply() NeedSupplyBand { + return s.Supply +} + +// SetSpecialization sets the value of Specialization. +func (s *NeedCategoryRecommendation) SetSpecialization(val SpecializationCode) { + s.Specialization = val +} + +// SetGrade sets the value of Grade. +func (s *NeedCategoryRecommendation) SetGrade(val GradeCode) { + s.Grade = val +} + +// SetScore sets the value of Score. +func (s *NeedCategoryRecommendation) SetScore(val NilFloat64) { + s.Score = val +} + +// SetSkillOverlap sets the value of SkillOverlap. +func (s *NeedCategoryRecommendation) SetSkillOverlap(val NeedSkillOverlap) { + s.SkillOverlap = val +} + +// SetMoney sets the value of Money. +func (s *NeedCategoryRecommendation) SetMoney(val NeedMoneyFit) { + s.Money = val +} + +// SetSupply sets the value of Supply. +func (s *NeedCategoryRecommendation) SetSupply(val NeedSupplyBand) { + s.Supply = val +} + +// Category recommendations computed by the server from the confirmed requirements of +// `requirements_version` with a versioned policy (PRD FR08). Read-only: no request can set a +// recommendation, a score, or one of its components. The server may recompute them for the same +// requirements version, for example for a new policy or a changed pool of available candidates, +// without a new need version; `computed_at` and `policy_version` then change. The policy version and +// the candidate group used are stored with each computation, so a later policy never rewrites it. +// Ref: #/components/schemas/NeedCategoryRecommendations +type NeedCategoryRecommendations struct { + Status NeedRecommendationStatus `json:"status"` + RequirementsVersion NeedVersion `json:"requirements_version"` + // Number of the policy version whose weights were applied, or null unless `status` is `computed`. + PolicyVersion NilInt32 `json:"policy_version"` + // Version of the recommendation algorithm, or null unless `status` is `computed`. + AlgorithmVersion NilNeedVersionLabel `json:"algorithm_version"` + // Time of the computation, or null unless `status` is `computed`. + ComputedAt NilTimestamp `json:"computed_at"` + // Recommended categories, best first by the score described in NeedCategoryRecommendation. Empty + // unless `status` is `computed`. + Categories []NeedCategoryRecommendation `json:"categories"` +} + +// GetStatus returns the value of Status. +func (s *NeedCategoryRecommendations) GetStatus() NeedRecommendationStatus { + return s.Status +} + +// GetRequirementsVersion returns the value of RequirementsVersion. +func (s *NeedCategoryRecommendations) GetRequirementsVersion() NeedVersion { + return s.RequirementsVersion +} + +// GetPolicyVersion returns the value of PolicyVersion. +func (s *NeedCategoryRecommendations) GetPolicyVersion() NilInt32 { + return s.PolicyVersion +} + +// GetAlgorithmVersion returns the value of AlgorithmVersion. +func (s *NeedCategoryRecommendations) GetAlgorithmVersion() NilNeedVersionLabel { + return s.AlgorithmVersion +} + +// GetComputedAt returns the value of ComputedAt. +func (s *NeedCategoryRecommendations) GetComputedAt() NilTimestamp { + return s.ComputedAt +} + +// GetCategories returns the value of Categories. +func (s *NeedCategoryRecommendations) GetCategories() []NeedCategoryRecommendation { + return s.Categories +} + +// SetStatus sets the value of Status. +func (s *NeedCategoryRecommendations) SetStatus(val NeedRecommendationStatus) { + s.Status = val +} + +// SetRequirementsVersion sets the value of RequirementsVersion. +func (s *NeedCategoryRecommendations) SetRequirementsVersion(val NeedVersion) { + s.RequirementsVersion = val +} + +// SetPolicyVersion sets the value of PolicyVersion. +func (s *NeedCategoryRecommendations) SetPolicyVersion(val NilInt32) { + s.PolicyVersion = val +} + +// SetAlgorithmVersion sets the value of AlgorithmVersion. +func (s *NeedCategoryRecommendations) SetAlgorithmVersion(val NilNeedVersionLabel) { + s.AlgorithmVersion = val +} + +// SetComputedAt sets the value of ComputedAt. +func (s *NeedCategoryRecommendations) SetComputedAt(val NilTimestamp) { + s.ComputedAt = val +} + +// SetCategories sets the value of Categories. +func (s *NeedCategoryRecommendations) SetCategories(val []NeedCategoryRecommendation) { + s.Categories = val +} + +// New need. Only `title` is required, so a need can start from a title, from a text, or from form +// fields, and with or without a vacancy. A field or list item given here must have `status` +// `confirmed` and becomes a confirmed manual value; `extracted` answers 400 with the pointer of that +// `status`, such as `/grade/status`, because a new need has no stored suggestion. A field that is +// absent is extracted from `source_text` when the text is given and is left unknown or empty +// otherwise. A nullable field sent as null, and a skill or task list sent as an empty list, stays +// unknown or empty and is not extracted; an empty `work_formats` value fails `minItems`. Unknown +// fields are rejected, so a request cannot set membership, a role, a status of the need, a provenance, +// readiness, a recommendation or its score, or a candidate's salary minimum. +// Ref: #/components/schemas/NeedCreate +type NeedCreate struct { + Title NeedTitle `json:"title"` + // Vacancy of the same organization to link, or null or absent for a need without a vacancy. + VacancyID OptNilUUID `json:"vacancy_id"` + SourceText OptNilNeedSourceText `json:"source_text"` + Specialization OptNilNeedSpecializationInput `json:"specialization"` + Grade OptNilNeedGradeInput `json:"grade"` + RequiredSkills []NeedSkillInput `json:"required_skills"` + DesiredSkills []NeedSkillInput `json:"desired_skills"` + Tasks []NeedTaskInput `json:"tasks"` + Domain OptNilNeedDomainInput `json:"domain"` + WorkFormats OptNilNeedWorkFormatsInput `json:"work_formats"` + Location OptNilNeedLocationInput `json:"location"` + Salary OptNilNeedSalaryInput `json:"salary"` +} + +// GetTitle returns the value of Title. +func (s *NeedCreate) GetTitle() NeedTitle { + return s.Title +} + +// GetVacancyID returns the value of VacancyID. +func (s *NeedCreate) GetVacancyID() OptNilUUID { + return s.VacancyID +} + +// GetSourceText returns the value of SourceText. +func (s *NeedCreate) GetSourceText() OptNilNeedSourceText { + return s.SourceText +} + +// GetSpecialization returns the value of Specialization. +func (s *NeedCreate) GetSpecialization() OptNilNeedSpecializationInput { + return s.Specialization +} + +// GetGrade returns the value of Grade. +func (s *NeedCreate) GetGrade() OptNilNeedGradeInput { + return s.Grade +} + +// GetRequiredSkills returns the value of RequiredSkills. +func (s *NeedCreate) GetRequiredSkills() []NeedSkillInput { + return s.RequiredSkills +} + +// GetDesiredSkills returns the value of DesiredSkills. +func (s *NeedCreate) GetDesiredSkills() []NeedSkillInput { + return s.DesiredSkills +} + +// GetTasks returns the value of Tasks. +func (s *NeedCreate) GetTasks() []NeedTaskInput { + return s.Tasks +} + +// GetDomain returns the value of Domain. +func (s *NeedCreate) GetDomain() OptNilNeedDomainInput { + return s.Domain +} + +// GetWorkFormats returns the value of WorkFormats. +func (s *NeedCreate) GetWorkFormats() OptNilNeedWorkFormatsInput { + return s.WorkFormats +} + +// GetLocation returns the value of Location. +func (s *NeedCreate) GetLocation() OptNilNeedLocationInput { + return s.Location +} + +// GetSalary returns the value of Salary. +func (s *NeedCreate) GetSalary() OptNilNeedSalaryInput { + return s.Salary +} + +// SetTitle sets the value of Title. +func (s *NeedCreate) SetTitle(val NeedTitle) { + s.Title = val +} + +// SetVacancyID sets the value of VacancyID. +func (s *NeedCreate) SetVacancyID(val OptNilUUID) { + s.VacancyID = val +} + +// SetSourceText sets the value of SourceText. +func (s *NeedCreate) SetSourceText(val OptNilNeedSourceText) { + s.SourceText = val +} + +// SetSpecialization sets the value of Specialization. +func (s *NeedCreate) SetSpecialization(val OptNilNeedSpecializationInput) { + s.Specialization = val +} + +// SetGrade sets the value of Grade. +func (s *NeedCreate) SetGrade(val OptNilNeedGradeInput) { + s.Grade = val +} + +// SetRequiredSkills sets the value of RequiredSkills. +func (s *NeedCreate) SetRequiredSkills(val []NeedSkillInput) { + s.RequiredSkills = val +} + +// SetDesiredSkills sets the value of DesiredSkills. +func (s *NeedCreate) SetDesiredSkills(val []NeedSkillInput) { + s.DesiredSkills = val +} + +// SetTasks sets the value of Tasks. +func (s *NeedCreate) SetTasks(val []NeedTaskInput) { + s.Tasks = val +} + +// SetDomain sets the value of Domain. +func (s *NeedCreate) SetDomain(val OptNilNeedDomainInput) { + s.Domain = val +} + +// SetWorkFormats sets the value of WorkFormats. +func (s *NeedCreate) SetWorkFormats(val OptNilNeedWorkFormatsInput) { + s.WorkFormats = val +} + +// SetLocation sets the value of Location. +func (s *NeedCreate) SetLocation(val OptNilNeedLocationInput) { + s.Location = val +} + +// SetSalary sets the value of Salary. +func (s *NeedCreate) SetSalary(val OptNilNeedSalaryInput) { + s.Salary = val +} + +// Business domain of the need with its confirmation state and provenance. `value` and `source` are +// null exactly when `status` is `unknown`. +// Ref: #/components/schemas/NeedDomain +type NeedDomain struct { + Status NeedValueStatus `json:"status"` + Value NilNeedDomainName `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedDomain) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedDomain) GetValue() NilNeedDomainName { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedDomain) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedDomain) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedDomain) SetValue(val NilNeedDomainName) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedDomain) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the domain in a request; see NeedUpdate for the rules of `status`. +// Ref: #/components/schemas/NeedDomainInput +type NeedDomainInput struct { + Value NeedDomainName `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedDomainInput) GetValue() NeedDomainName { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedDomainInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedDomainInput) SetValue(val NeedDomainName) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedDomainInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +type NeedDomainName string + +// Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. +// Adding a value is a contract change. +// Ref: #/components/schemas/NeedFieldName +type NeedFieldName string + +const ( + NeedFieldNameSpecialization NeedFieldName = "specialization" + NeedFieldNameGrade NeedFieldName = "grade" + NeedFieldNameRequiredSkills NeedFieldName = "required_skills" + NeedFieldNameDesiredSkills NeedFieldName = "desired_skills" + NeedFieldNameTasks NeedFieldName = "tasks" + NeedFieldNameDomain NeedFieldName = "domain" + NeedFieldNameWorkFormats NeedFieldName = "work_formats" + NeedFieldNameLocation NeedFieldName = "location" + NeedFieldNameSalary NeedFieldName = "salary" +) + +// AllValues returns all NeedFieldName values. +func (NeedFieldName) AllValues() []NeedFieldName { + return []NeedFieldName{ + NeedFieldNameSpecialization, + NeedFieldNameGrade, + NeedFieldNameRequiredSkills, + NeedFieldNameDesiredSkills, + NeedFieldNameTasks, + NeedFieldNameDomain, + NeedFieldNameWorkFormats, + NeedFieldNameLocation, + NeedFieldNameSalary, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedFieldName) MarshalText() ([]byte, error) { + switch s { + case NeedFieldNameSpecialization: + return []byte(s), nil + case NeedFieldNameGrade: + return []byte(s), nil + case NeedFieldNameRequiredSkills: + return []byte(s), nil + case NeedFieldNameDesiredSkills: + return []byte(s), nil + case NeedFieldNameTasks: + return []byte(s), nil + case NeedFieldNameDomain: + return []byte(s), nil + case NeedFieldNameWorkFormats: + return []byte(s), nil + case NeedFieldNameLocation: + return []byte(s), nil + case NeedFieldNameSalary: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedFieldName) UnmarshalText(data []byte) error { + switch NeedFieldName(data) { + case NeedFieldNameSpecialization: + *s = NeedFieldNameSpecialization + return nil + case NeedFieldNameGrade: + *s = NeedFieldNameGrade + return nil + case NeedFieldNameRequiredSkills: + *s = NeedFieldNameRequiredSkills + return nil + case NeedFieldNameDesiredSkills: + *s = NeedFieldNameDesiredSkills + return nil + case NeedFieldNameTasks: + *s = NeedFieldNameTasks + return nil + case NeedFieldNameDomain: + *s = NeedFieldNameDomain + return nil + case NeedFieldNameWorkFormats: + *s = NeedFieldNameWorkFormats + return nil + case NeedFieldNameLocation: + *s = NeedFieldNameLocation + return nil + case NeedFieldNameSalary: + *s = NeedFieldNameSalary + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Target grade of the need with its confirmation state and provenance. `value` and `source` are null +// exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of +// assuming one. +// Ref: #/components/schemas/NeedGrade +type NeedGrade struct { + Status NeedValueStatus `json:"status"` + Value NilGradeCode `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedGrade) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedGrade) GetValue() NilGradeCode { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedGrade) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedGrade) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedGrade) SetValue(val NilGradeCode) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedGrade) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the grade in a request; see NeedUpdate for the rules of `status`. +// Ref: #/components/schemas/NeedGradeInput +type NeedGradeInput struct { + Value GradeCode `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedGradeInput) GetValue() GradeCode { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedGradeInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedGradeInput) SetValue(val GradeCode) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedGradeInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// NeedHeaders wraps Need with response headers. +type NeedHeaders struct { + CacheControl CacheControlNoStore + Response Need +} + +// GetCacheControl returns the value of CacheControl. +func (s *NeedHeaders) GetCacheControl() CacheControlNoStore { + return s.CacheControl +} + +// GetResponse returns the value of Response. +func (s *NeedHeaders) GetResponse() Need { + return s.Response +} + +// SetCacheControl sets the value of CacheControl. +func (s *NeedHeaders) SetCacheControl(val CacheControlNoStore) { + s.CacheControl = val +} + +// SetResponse sets the value of Response. +func (s *NeedHeaders) SetResponse(val Need) { + s.Response = val +} + +func (*NeedHeaders) createOrganizationNeedRes() {} +func (*NeedHeaders) getOrganizationNeedRes() {} +func (*NeedHeaders) updateOrganizationNeedRes() {} + +// Confirmation state of a list item, and the decision that a request sends for a field or an item: +// `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to +// confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion +// unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item +// is what readiness reports as missing. +// Ref: #/components/schemas/NeedItemStatus +type NeedItemStatus string + +const ( + NeedItemStatusConfirmed NeedItemStatus = "confirmed" + NeedItemStatusExtracted NeedItemStatus = "extracted" +) + +// AllValues returns all NeedItemStatus values. +func (NeedItemStatus) AllValues() []NeedItemStatus { + return []NeedItemStatus{ + NeedItemStatusConfirmed, + NeedItemStatusExtracted, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedItemStatus) MarshalText() ([]byte, error) { + switch s { + case NeedItemStatusConfirmed: + return []byte(s), nil + case NeedItemStatusExtracted: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedItemStatus) UnmarshalText(data []byte) error { + switch NeedItemStatus(data) { + case NeedItemStatusConfirmed: + *s = NeedItemStatusConfirmed + return nil + case NeedItemStatusExtracted: + *s = NeedItemStatusExtracted + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// One page of the needs of an organization, newest first by creation time. +// Ref: #/components/schemas/NeedList +type NeedList struct { + // Needs of the page. + Items []NeedSummary `json:"items"` + Page PageInfo `json:"page"` +} + +// GetItems returns the value of Items. +func (s *NeedList) GetItems() []NeedSummary { + return s.Items +} + +// GetPage returns the value of Page. +func (s *NeedList) GetPage() PageInfo { + return s.Page +} + +// SetItems sets the value of Items. +func (s *NeedList) SetItems(val []NeedSummary) { + s.Items = val +} + +// SetPage sets the value of Page. +func (s *NeedList) SetPage(val PageInfo) { + s.Page = val +} + +// NeedListHeaders wraps NeedList with response headers. +type NeedListHeaders struct { + CacheControl CacheControlNoStore + Response NeedList +} + +// GetCacheControl returns the value of CacheControl. +func (s *NeedListHeaders) GetCacheControl() CacheControlNoStore { + return s.CacheControl +} + +// GetResponse returns the value of Response. +func (s *NeedListHeaders) GetResponse() NeedList { + return s.Response +} + +// SetCacheControl sets the value of CacheControl. +func (s *NeedListHeaders) SetCacheControl(val CacheControlNoStore) { + s.CacheControl = val +} + +// SetResponse sets the value of Response. +func (s *NeedListHeaders) SetResponse(val NeedList) { + s.Response = val +} + +func (*NeedListHeaders) listOrganizationNeedsRes() {} + +// Place of work with its confirmation state and provenance. `value` and `source` are null exactly when +// `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats +// include `office` or `hybrid`. +// Ref: #/components/schemas/NeedLocation +type NeedLocation struct { + Status NeedValueStatus `json:"status"` + Value NilNeedLocationName `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedLocation) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedLocation) GetValue() NilNeedLocationName { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedLocation) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedLocation) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedLocation) SetValue(val NilNeedLocationName) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedLocation) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the place of work in a request; see NeedUpdate for the rules of `status`. +// Ref: #/components/schemas/NeedLocationInput +type NeedLocationInput struct { + Value NeedLocationName `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedLocationInput) GetValue() NeedLocationName { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedLocationInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedLocationInput) SetValue(val NeedLocationName) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedLocationInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +type NeedLocationName string + +// One critical field that has no confirmed value, with a specific question that the client shows next +// to the field. +// Ref: #/components/schemas/NeedMissingField +type NeedMissingField struct { + Field NeedFieldName `json:"field"` + Reason NeedMissingReason `json:"reason"` + // Specific Russian question about the missing value, for example which grade is needed. Plain text; + // the client shows it as text, never as HTML. + Question string `json:"question"` +} + +// GetField returns the value of Field. +func (s *NeedMissingField) GetField() NeedFieldName { + return s.Field +} + +// GetReason returns the value of Reason. +func (s *NeedMissingField) GetReason() NeedMissingReason { + return s.Reason +} + +// GetQuestion returns the value of Question. +func (s *NeedMissingField) GetQuestion() string { + return s.Question +} + +// SetField sets the value of Field. +func (s *NeedMissingField) SetField(val NeedFieldName) { + s.Field = val +} + +// SetReason sets the value of Reason. +func (s *NeedMissingField) SetReason(val NeedMissingReason) { + s.Reason = val +} + +// SetQuestion sets the value of Question. +func (s *NeedMissingField) SetQuestion(val string) { + s.Question = val +} + +// Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an +// extracted value or, for required skills, only extracted items that wait for confirmation. +// Ref: #/components/schemas/NeedMissingReason +type NeedMissingReason string + +const ( + NeedMissingReasonUnknown NeedMissingReason = "unknown" + NeedMissingReasonUnconfirmed NeedMissingReason = "unconfirmed" +) + +// AllValues returns all NeedMissingReason values. +func (NeedMissingReason) AllValues() []NeedMissingReason { + return []NeedMissingReason{ + NeedMissingReasonUnknown, + NeedMissingReasonUnconfirmed, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedMissingReason) MarshalText() ([]byte, error) { + switch s { + case NeedMissingReasonUnknown: + return []byte(s), nil + case NeedMissingReasonUnconfirmed: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedMissingReason) UnmarshalText(data []byte) error { + switch NeedMissingReason(data) { + case NeedMissingReasonUnknown: + *s = NeedMissingReasonUnknown + return nil + case NeedMissingReasonUnconfirmed: + *s = NeedMissingReasonUnconfirmed + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Salary component of a recommendation. It is an aggregate over at least five candidates and never +// reveals a minimum of any candidate. +// Ref: #/components/schemas/NeedMoneyFit +type NeedMoneyFit struct { + Status NeedMoneyStatus `json:"status"` + // Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a + // multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score + // and the ranking use this rounded value, never the exact share. A quarter step gives five levels: + // each probe of a new upper bound tells at most which quarter of the group accepts it, and in the + // smallest allowed group of five candidates a single minimum often does not move the value, while the + // share still separates a range that most candidates accept from one that few accept. + Share NilFloat64 `json:"share"` +} + +// GetStatus returns the value of Status. +func (s *NeedMoneyFit) GetStatus() NeedMoneyStatus { + return s.Status +} + +// GetShare returns the value of Share. +func (s *NeedMoneyFit) GetShare() NilFloat64 { + return s.Share +} + +// SetStatus sets the value of Status. +func (s *NeedMoneyFit) SetStatus(val NeedMoneyStatus) { + s.Status = val +} + +// SetShare sets the value of Share. +func (s *NeedMoneyFit) SetShare(val NilFloat64) { + s.Share = val +} + +// How the salary component of a recommendation was obtained. +// +// - computed: at least five available candidates of the category have a known minimum comparable with +// the confirmed range; `share` is given. +// - insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and +// `share` is null. +// - no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and +// `share` is null. +// - withheld: the organization changed salary ranges five times within seven days, so salary +// aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the +// neutral value 0.5 and `share` is null. +// +// An unknown candidate minimum never counts as zero. +// Ref: #/components/schemas/NeedMoneyStatus +type NeedMoneyStatus string + +const ( + NeedMoneyStatusComputed NeedMoneyStatus = "computed" + NeedMoneyStatusInsufficientData NeedMoneyStatus = "insufficient_data" + NeedMoneyStatusNoSalary NeedMoneyStatus = "no_salary" + NeedMoneyStatusWithheld NeedMoneyStatus = "withheld" +) + +// AllValues returns all NeedMoneyStatus values. +func (NeedMoneyStatus) AllValues() []NeedMoneyStatus { + return []NeedMoneyStatus{ + NeedMoneyStatusComputed, + NeedMoneyStatusInsufficientData, + NeedMoneyStatusNoSalary, + NeedMoneyStatusWithheld, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedMoneyStatus) MarshalText() ([]byte, error) { + switch s { + case NeedMoneyStatusComputed: + return []byte(s), nil + case NeedMoneyStatusInsufficientData: + return []byte(s), nil + case NeedMoneyStatusNoSalary: + return []byte(s), nil + case NeedMoneyStatusWithheld: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedMoneyStatus) UnmarshalText(data []byte) error { + switch NeedMoneyStatus(data) { + case NeedMoneyStatusComputed: + *s = NeedMoneyStatusComputed + return nil + case NeedMoneyStatusInsufficientData: + *s = NeedMoneyStatusInsufficientData + return nil + case NeedMoneyStatusNoSalary: + *s = NeedMoneyStatusNoSalary + return nil + case NeedMoneyStatusWithheld: + *s = NeedMoneyStatusWithheld + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Completeness of the critical fields, computed by the server for the current version. The critical +// fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), +// `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or +// `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an +// invitation, states which readiness it requires. +// Ref: #/components/schemas/NeedReadinessReport +type NeedReadinessReport struct { + Status NeedReadinessStatus `json:"status"` + // Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty + // exactly when `status` is `complete`. + MissingFields []NeedMissingField `json:"missing_fields"` +} + +// GetStatus returns the value of Status. +func (s *NeedReadinessReport) GetStatus() NeedReadinessStatus { + return s.Status +} + +// GetMissingFields returns the value of MissingFields. +func (s *NeedReadinessReport) GetMissingFields() []NeedMissingField { + return s.MissingFields +} + +// SetStatus sets the value of Status. +func (s *NeedReadinessReport) SetStatus(val NeedReadinessStatus) { + s.Status = val +} + +// SetMissingFields sets the value of MissingFields. +func (s *NeedReadinessReport) SetMissingFields(val []NeedMissingField) { + s.MissingFields = val +} + +// `complete` when every critical field has a confirmed value, otherwise `incomplete`. +// Ref: #/components/schemas/NeedReadinessStatus +type NeedReadinessStatus string + +const ( + NeedReadinessStatusComplete NeedReadinessStatus = "complete" + NeedReadinessStatusIncomplete NeedReadinessStatus = "incomplete" +) + +// AllValues returns all NeedReadinessStatus values. +func (NeedReadinessStatus) AllValues() []NeedReadinessStatus { + return []NeedReadinessStatus{ + NeedReadinessStatusComplete, + NeedReadinessStatusIncomplete, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedReadinessStatus) MarshalText() ([]byte, error) { + switch s { + case NeedReadinessStatusComplete: + return []byte(s), nil + case NeedReadinessStatusIncomplete: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedReadinessStatus) UnmarshalText(data []byte) error { + switch NeedReadinessStatus(data) { + case NeedReadinessStatusComplete: + *s = NeedReadinessStatusComplete + return nil + case NeedReadinessStatusIncomplete: + *s = NeedReadinessStatusIncomplete + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// State of the category recommendations of the current requirements version. +// +// - computed: `categories` holds the recommendations computed from the confirmed requirements of +// `requirements_version`. +// - pending: the computation for the current requirements version has not finished yet; `categories` +// is empty. Read the need again later. +// - not_available: the current requirements have no confirmed required or desired skill to compute +// from; `categories` is empty. +// +// Ref: #/components/schemas/NeedRecommendationStatus +type NeedRecommendationStatus string + +const ( + NeedRecommendationStatusComputed NeedRecommendationStatus = "computed" + NeedRecommendationStatusPending NeedRecommendationStatus = "pending" + NeedRecommendationStatusNotAvailable NeedRecommendationStatus = "not_available" +) + +// AllValues returns all NeedRecommendationStatus values. +func (NeedRecommendationStatus) AllValues() []NeedRecommendationStatus { + return []NeedRecommendationStatus{ + NeedRecommendationStatusComputed, + NeedRecommendationStatusPending, + NeedRecommendationStatusNotAvailable, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedRecommendationStatus) MarshalText() ([]byte, error) { + switch s { + case NeedRecommendationStatusComputed: + return []byte(s), nil + case NeedRecommendationStatusPending: + return []byte(s), nil + case NeedRecommendationStatusNotAvailable: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedRecommendationStatus) UnmarshalText(data []byte) error { + switch NeedRecommendationStatus(data) { + case NeedRecommendationStatusComputed: + *s = NeedRecommendationStatusComputed + return nil + case NeedRecommendationStatusPending: + *s = NeedRecommendationStatusPending + return nil + case NeedRecommendationStatusNotAvailable: + *s = NeedRecommendationStatusNotAvailable + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Requirements of one need version, each with its confirmation state and provenance. Read-only; +// requests change them through the fields of NeedCreate and NeedUpdate. +// Ref: #/components/schemas/NeedRequirementSet +type NeedRequirementSet struct { + Specialization NeedSpecialization `json:"specialization"` + Grade NeedGrade `json:"grade"` + // Required skills; each has weight 2 in skill coverage. Only confirmed skills count. + RequiredSkills []NeedSkill `json:"required_skills"` + // Desired skills; each has weight 1 in skill coverage. Only confirmed skills count. + DesiredSkills []NeedSkill `json:"desired_skills"` + // Work tasks of the team in the order given. + Tasks []NeedTask `json:"tasks"` + Domain NeedDomain `json:"domain"` + WorkFormats NeedWorkFormats `json:"work_formats"` + Location NeedLocation `json:"location"` + Salary NeedSalary `json:"salary"` +} + +// GetSpecialization returns the value of Specialization. +func (s *NeedRequirementSet) GetSpecialization() NeedSpecialization { + return s.Specialization +} + +// GetGrade returns the value of Grade. +func (s *NeedRequirementSet) GetGrade() NeedGrade { + return s.Grade +} + +// GetRequiredSkills returns the value of RequiredSkills. +func (s *NeedRequirementSet) GetRequiredSkills() []NeedSkill { + return s.RequiredSkills +} + +// GetDesiredSkills returns the value of DesiredSkills. +func (s *NeedRequirementSet) GetDesiredSkills() []NeedSkill { + return s.DesiredSkills +} + +// GetTasks returns the value of Tasks. +func (s *NeedRequirementSet) GetTasks() []NeedTask { + return s.Tasks +} + +// GetDomain returns the value of Domain. +func (s *NeedRequirementSet) GetDomain() NeedDomain { + return s.Domain +} + +// GetWorkFormats returns the value of WorkFormats. +func (s *NeedRequirementSet) GetWorkFormats() NeedWorkFormats { + return s.WorkFormats +} + +// GetLocation returns the value of Location. +func (s *NeedRequirementSet) GetLocation() NeedLocation { + return s.Location +} + +// GetSalary returns the value of Salary. +func (s *NeedRequirementSet) GetSalary() NeedSalary { + return s.Salary +} + +// SetSpecialization sets the value of Specialization. +func (s *NeedRequirementSet) SetSpecialization(val NeedSpecialization) { + s.Specialization = val +} + +// SetGrade sets the value of Grade. +func (s *NeedRequirementSet) SetGrade(val NeedGrade) { + s.Grade = val +} + +// SetRequiredSkills sets the value of RequiredSkills. +func (s *NeedRequirementSet) SetRequiredSkills(val []NeedSkill) { + s.RequiredSkills = val +} + +// SetDesiredSkills sets the value of DesiredSkills. +func (s *NeedRequirementSet) SetDesiredSkills(val []NeedSkill) { + s.DesiredSkills = val +} + +// SetTasks sets the value of Tasks. +func (s *NeedRequirementSet) SetTasks(val []NeedTask) { + s.Tasks = val +} + +// SetDomain sets the value of Domain. +func (s *NeedRequirementSet) SetDomain(val NeedDomain) { + s.Domain = val +} + +// SetWorkFormats sets the value of WorkFormats. +func (s *NeedRequirementSet) SetWorkFormats(val NeedWorkFormats) { + s.WorkFormats = val +} + +// SetLocation sets the value of Location. +func (s *NeedRequirementSet) SetLocation(val NeedLocation) { + s.Location = val +} + +// SetSalary sets the value of Salary. +func (s *NeedRequirementSet) SetSalary(val NeedSalary) { + s.Salary = val +} + +// Salary range that the employer offers, with its confirmation state and provenance. `value` and +// `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the +// server never substitutes zero, a market estimate, or a range from another need. +// Ref: #/components/schemas/NeedSalary +type NeedSalary struct { + Status NeedValueStatus `json:"status"` + Value NilSalaryRange `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedSalary) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedSalary) GetValue() NilSalaryRange { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedSalary) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedSalary) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedSalary) SetValue(val NilSalaryRange) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedSalary) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the salary range in a request; see NeedUpdate for the rules of `status` and +// SalaryRange for the rules of the range, whose pointers are under `/salary/value`. +// Ref: #/components/schemas/NeedSalaryInput +type NeedSalaryInput struct { + Value SalaryRange `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedSalaryInput) GetValue() SalaryRange { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedSalaryInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedSalaryInput) SetValue(val SalaryRange) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedSalaryInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform +// taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and +// counts it as not covered in category recommendations. +// Ref: #/components/schemas/NeedSkill +type NeedSkill struct { + Name SkillName `json:"name"` + TaxonomyCode NilSkillTaxonomyCode `json:"taxonomy_code"` + Status NeedItemStatus `json:"status"` + Source NeedValueSource `json:"source"` +} + +// GetName returns the value of Name. +func (s *NeedSkill) GetName() SkillName { + return s.Name +} + +// GetTaxonomyCode returns the value of TaxonomyCode. +func (s *NeedSkill) GetTaxonomyCode() NilSkillTaxonomyCode { + return s.TaxonomyCode +} + +// GetStatus returns the value of Status. +func (s *NeedSkill) GetStatus() NeedItemStatus { + return s.Status +} + +// GetSource returns the value of Source. +func (s *NeedSkill) GetSource() NeedValueSource { + return s.Source +} + +// SetName sets the value of Name. +func (s *NeedSkill) SetName(val SkillName) { + s.Name = val +} + +// SetTaxonomyCode sets the value of TaxonomyCode. +func (s *NeedSkill) SetTaxonomyCode(val NilSkillTaxonomyCode) { + s.TaxonomyCode = val +} + +// SetStatus sets the value of Status. +func (s *NeedSkill) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// SetSource sets the value of Source. +func (s *NeedSkill) SetSource(val NeedValueSource) { + s.Source = val +} + +// One skill of a list in a request. A name that equals, without regard to letter case, a skill of the +// current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy +// code; this is how an extracted skill is confirmed or moved between the required and desired lists. +// Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a +// name that is not a stored suggestion answers 400 validation_failed with the pointer of that +// `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill +// lists answers 400 with the pointer of the later `name`. +// Ref: #/components/schemas/NeedSkillInput +type NeedSkillInput struct { + Name SkillName `json:"name"` + Status NeedItemStatus `json:"status"` +} + +// GetName returns the value of Name. +func (s *NeedSkillInput) GetName() SkillName { + return s.Name +} + +// GetStatus returns the value of Status. +func (s *NeedSkillInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetName sets the value of Name. +func (s *NeedSkillInput) SetName(val SkillName) { + s.Name = val +} + +// SetStatus sets the value of Status. +func (s *NeedSkillInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// Skill coverage of a category: the weighted share of the confirmed skills of the need that the +// category taxonomy covers, with weight 2 for a required and 1 for a desired skill. +// Ref: #/components/schemas/NeedSkillOverlap +type NeedSkillOverlap struct { + // Weighted share from 0 to 1, rounded to two decimals. + Share float64 `json:"share"` + // Confirmed skills of the need that the category covers. + CoveredSkills []SkillName `json:"covered_skills"` + // Confirmed skills of the need that the category does not cover, including skills without a taxonomy + // code. + UncoveredSkills []SkillName `json:"uncovered_skills"` +} + +// GetShare returns the value of Share. +func (s *NeedSkillOverlap) GetShare() float64 { + return s.Share +} + +// GetCoveredSkills returns the value of CoveredSkills. +func (s *NeedSkillOverlap) GetCoveredSkills() []SkillName { + return s.CoveredSkills +} + +// GetUncoveredSkills returns the value of UncoveredSkills. +func (s *NeedSkillOverlap) GetUncoveredSkills() []SkillName { + return s.UncoveredSkills +} + +// SetShare sets the value of Share. +func (s *NeedSkillOverlap) SetShare(val float64) { + s.Share = val +} + +// SetCoveredSkills sets the value of CoveredSkills. +func (s *NeedSkillOverlap) SetCoveredSkills(val []SkillName) { + s.CoveredSkills = val +} + +// SetUncoveredSkills sets the value of UncoveredSkills. +func (s *NeedSkillOverlap) SetUncoveredSkills(val []SkillName) { + s.UncoveredSkills = val +} + +type NeedSourceQuote string + +type NeedSourceText string + +// Target specialization of the need with its confirmation state and provenance. `value` and `source` +// are null exactly when `status` is `unknown`. +// Ref: #/components/schemas/NeedSpecialization +type NeedSpecialization struct { + Status NeedValueStatus `json:"status"` + Value NilSpecializationCode `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedSpecialization) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedSpecialization) GetValue() NilSpecializationCode { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedSpecialization) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedSpecialization) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedSpecialization) SetValue(val NilSpecializationCode) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedSpecialization) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the specialization in a request; see NeedUpdate for the rules of `status`. +// Ref: #/components/schemas/NeedSpecializationInput +type NeedSpecializationInput struct { + Value SpecializationCode `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedSpecializationInput) GetValue() SpecializationCode { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedSpecializationInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedSpecializationInput) SetValue(val SpecializationCode) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedSpecializationInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// Need in a list: its identity, current version, target category fields, and readiness. Read the need +// for the requirements and the recommendations. +// Ref: #/components/schemas/NeedSummary +type NeedSummary struct { + // Identifier of the need. + ID uuid.UUID `json:"id"` + // Linked vacancy, or null. + VacancyID NilUUID `json:"vacancy_id"` + Title NeedTitle `json:"title"` + Version NeedVersion `json:"version"` + Specialization NeedSpecialization `json:"specialization"` + Grade NeedGrade `json:"grade"` + Readiness NeedReadinessReport `json:"readiness"` + CreatedAt Timestamp `json:"created_at"` + UpdatedAt Timestamp `json:"updated_at"` +} + +// GetID returns the value of ID. +func (s *NeedSummary) GetID() uuid.UUID { + return s.ID +} + +// GetVacancyID returns the value of VacancyID. +func (s *NeedSummary) GetVacancyID() NilUUID { + return s.VacancyID +} + +// GetTitle returns the value of Title. +func (s *NeedSummary) GetTitle() NeedTitle { + return s.Title +} + +// GetVersion returns the value of Version. +func (s *NeedSummary) GetVersion() NeedVersion { + return s.Version +} + +// GetSpecialization returns the value of Specialization. +func (s *NeedSummary) GetSpecialization() NeedSpecialization { + return s.Specialization +} + +// GetGrade returns the value of Grade. +func (s *NeedSummary) GetGrade() NeedGrade { + return s.Grade +} + +// GetReadiness returns the value of Readiness. +func (s *NeedSummary) GetReadiness() NeedReadinessReport { + return s.Readiness +} + +// GetCreatedAt returns the value of CreatedAt. +func (s *NeedSummary) GetCreatedAt() Timestamp { + return s.CreatedAt +} + +// GetUpdatedAt returns the value of UpdatedAt. +func (s *NeedSummary) GetUpdatedAt() Timestamp { + return s.UpdatedAt +} + +// SetID sets the value of ID. +func (s *NeedSummary) SetID(val uuid.UUID) { + s.ID = val +} + +// SetVacancyID sets the value of VacancyID. +func (s *NeedSummary) SetVacancyID(val NilUUID) { + s.VacancyID = val +} + +// SetTitle sets the value of Title. +func (s *NeedSummary) SetTitle(val NeedTitle) { + s.Title = val +} + +// SetVersion sets the value of Version. +func (s *NeedSummary) SetVersion(val NeedVersion) { + s.Version = val +} + +// SetSpecialization sets the value of Specialization. +func (s *NeedSummary) SetSpecialization(val NeedSpecialization) { + s.Specialization = val +} + +// SetGrade sets the value of Grade. +func (s *NeedSummary) SetGrade(val NeedGrade) { + s.Grade = val +} + +// SetReadiness sets the value of Readiness. +func (s *NeedSummary) SetReadiness(val NeedReadinessReport) { + s.Readiness = val +} + +// SetCreatedAt sets the value of CreatedAt. +func (s *NeedSummary) SetCreatedAt(val Timestamp) { + s.CreatedAt = val +} + +// SetUpdatedAt sets the value of UpdatedAt. +func (s *NeedSummary) SetUpdatedAt(val Timestamp) { + s.UpdatedAt = val +} + +// Number of available candidates of the category in the allowed detail: `fewer_than_5`, +// `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly. +// Ref: #/components/schemas/NeedSupplyBand +type NeedSupplyBand string + +const ( + NeedSupplyBandFewerThan5 NeedSupplyBand = "fewer_than_5" + NeedSupplyBandFrom5To29 NeedSupplyBand = "from_5_to_29" + NeedSupplyBand30OrMore NeedSupplyBand = "30_or_more" +) + +// AllValues returns all NeedSupplyBand values. +func (NeedSupplyBand) AllValues() []NeedSupplyBand { + return []NeedSupplyBand{ + NeedSupplyBandFewerThan5, + NeedSupplyBandFrom5To29, + NeedSupplyBand30OrMore, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedSupplyBand) MarshalText() ([]byte, error) { + switch s { + case NeedSupplyBandFewerThan5: + return []byte(s), nil + case NeedSupplyBandFrom5To29: + return []byte(s), nil + case NeedSupplyBand30OrMore: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedSupplyBand) UnmarshalText(data []byte) error { + switch NeedSupplyBand(data) { + case NeedSupplyBandFewerThan5: + *s = NeedSupplyBandFewerThan5 + return nil + case NeedSupplyBandFrom5To29: + *s = NeedSupplyBandFrom5To29 + return nil + case NeedSupplyBand30OrMore: + *s = NeedSupplyBand30OrMore + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// One work task of the team with its confirmation state and provenance. +// Ref: #/components/schemas/NeedTask +type NeedTask struct { + Text NeedTaskText `json:"text"` + Status NeedItemStatus `json:"status"` + Source NeedValueSource `json:"source"` +} + +// GetText returns the value of Text. +func (s *NeedTask) GetText() NeedTaskText { + return s.Text +} + +// GetStatus returns the value of Status. +func (s *NeedTask) GetStatus() NeedItemStatus { + return s.Status +} + +// GetSource returns the value of Source. +func (s *NeedTask) GetSource() NeedValueSource { + return s.Source +} + +// SetText sets the value of Text. +func (s *NeedTask) SetText(val NeedTaskText) { + s.Text = val +} + +// SetStatus sets the value of Status. +func (s *NeedTask) SetStatus(val NeedItemStatus) { + s.Status = val +} + +// SetSource sets the value of Source. +func (s *NeedTask) SetSource(val NeedValueSource) { + s.Source = val +} + +// One task of the list in a request. A text equal to a task of the current version refers to that task +// and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts +// follow the rules of NeedSkillInput. +// Ref: #/components/schemas/NeedTaskInput +type NeedTaskInput struct { + Text NeedTaskText `json:"text"` + Status NeedItemStatus `json:"status"` +} + +// GetText returns the value of Text. +func (s *NeedTaskInput) GetText() NeedTaskText { + return s.Text +} + +// GetStatus returns the value of Status. +func (s *NeedTaskInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetText sets the value of Text. +func (s *NeedTaskInput) SetText(val NeedTaskText) { + s.Text = val +} + +// SetStatus sets the value of Status. +func (s *NeedTaskInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + +type NeedTaskText string + +type NeedTitle string + +// Change of a need over the version the client read. Each field present in the body replaces that +// field as a whole; an absent field stays unchanged. Nested objects and lists are not merged: a field +// decision and each list are replaced entirely, and a stored item missing from a sent list is deleted. +// A nullable field sent as null becomes unknown, or unlinked for `vacancy_id`; a skill or task list +// sent empty deletes every item; a list sent as null fails validation. A field decision +// `{value, status}` and a list item follow the same rules: `confirmed` with the stored value confirms +// it and keeps its origin and quote, and `confirmed` with another value sets a confirmed manual value; +// `extracted` keeps a stored suggestion unconfirmed and is allowed only with exactly the stored +// suggested value, otherwise it answers 400 with the pointer of that `status`, such as `/grade/status` +// or `/required_skills/0/status`. A client that sends back an unchanged form therefore confirms +// nothing by accident: it sends each suggestion with `extracted`, or leaves the field out. Sending a +// different `source_text` extracts again: new suggestions replace only the `extracted` values and +// items of fields not named in this body; confirmed values are never overwritten, a suggested skill +// whose name is already in either skill list is skipped, and a suggestion that a member deleted is not +// proposed again for this need. Unknown fields are rejected, so a request cannot set membership, a +// role, a provenance, readiness, a recommendation or its score, or a candidate's salary minimum. +// Ref: #/components/schemas/NeedUpdate +type NeedUpdate struct { + ExpectedVersion NeedVersion `json:"expected_version"` + Title OptNeedTitle `json:"title"` + // Vacancy of the same organization to link, or null to unlink. + VacancyID OptNilUUID `json:"vacancy_id"` + SourceText OptNilNeedSourceText `json:"source_text"` + Specialization OptNilNeedSpecializationInput `json:"specialization"` + Grade OptNilNeedGradeInput `json:"grade"` + RequiredSkills []NeedSkillInput `json:"required_skills"` + DesiredSkills []NeedSkillInput `json:"desired_skills"` + Tasks []NeedTaskInput `json:"tasks"` + Domain OptNilNeedDomainInput `json:"domain"` + WorkFormats OptNilNeedWorkFormatsInput `json:"work_formats"` + Location OptNilNeedLocationInput `json:"location"` + Salary OptNilNeedSalaryInput `json:"salary"` +} + +// GetExpectedVersion returns the value of ExpectedVersion. +func (s *NeedUpdate) GetExpectedVersion() NeedVersion { + return s.ExpectedVersion +} + +// GetTitle returns the value of Title. +func (s *NeedUpdate) GetTitle() OptNeedTitle { + return s.Title +} + +// GetVacancyID returns the value of VacancyID. +func (s *NeedUpdate) GetVacancyID() OptNilUUID { + return s.VacancyID +} + +// GetSourceText returns the value of SourceText. +func (s *NeedUpdate) GetSourceText() OptNilNeedSourceText { + return s.SourceText +} + +// GetSpecialization returns the value of Specialization. +func (s *NeedUpdate) GetSpecialization() OptNilNeedSpecializationInput { + return s.Specialization +} + +// GetGrade returns the value of Grade. +func (s *NeedUpdate) GetGrade() OptNilNeedGradeInput { + return s.Grade +} + +// GetRequiredSkills returns the value of RequiredSkills. +func (s *NeedUpdate) GetRequiredSkills() []NeedSkillInput { + return s.RequiredSkills +} + +// GetDesiredSkills returns the value of DesiredSkills. +func (s *NeedUpdate) GetDesiredSkills() []NeedSkillInput { + return s.DesiredSkills +} + +// GetTasks returns the value of Tasks. +func (s *NeedUpdate) GetTasks() []NeedTaskInput { + return s.Tasks +} + +// GetDomain returns the value of Domain. +func (s *NeedUpdate) GetDomain() OptNilNeedDomainInput { + return s.Domain +} + +// GetWorkFormats returns the value of WorkFormats. +func (s *NeedUpdate) GetWorkFormats() OptNilNeedWorkFormatsInput { + return s.WorkFormats +} + +// GetLocation returns the value of Location. +func (s *NeedUpdate) GetLocation() OptNilNeedLocationInput { + return s.Location +} + +// GetSalary returns the value of Salary. +func (s *NeedUpdate) GetSalary() OptNilNeedSalaryInput { + return s.Salary +} + +// SetExpectedVersion sets the value of ExpectedVersion. +func (s *NeedUpdate) SetExpectedVersion(val NeedVersion) { + s.ExpectedVersion = val +} + +// SetTitle sets the value of Title. +func (s *NeedUpdate) SetTitle(val OptNeedTitle) { + s.Title = val +} + +// SetVacancyID sets the value of VacancyID. +func (s *NeedUpdate) SetVacancyID(val OptNilUUID) { + s.VacancyID = val +} + +// SetSourceText sets the value of SourceText. +func (s *NeedUpdate) SetSourceText(val OptNilNeedSourceText) { + s.SourceText = val +} + +// SetSpecialization sets the value of Specialization. +func (s *NeedUpdate) SetSpecialization(val OptNilNeedSpecializationInput) { + s.Specialization = val +} + +// SetGrade sets the value of Grade. +func (s *NeedUpdate) SetGrade(val OptNilNeedGradeInput) { + s.Grade = val +} + +// SetRequiredSkills sets the value of RequiredSkills. +func (s *NeedUpdate) SetRequiredSkills(val []NeedSkillInput) { + s.RequiredSkills = val +} + +// SetDesiredSkills sets the value of DesiredSkills. +func (s *NeedUpdate) SetDesiredSkills(val []NeedSkillInput) { + s.DesiredSkills = val +} + +// SetTasks sets the value of Tasks. +func (s *NeedUpdate) SetTasks(val []NeedTaskInput) { + s.Tasks = val +} + +// SetDomain sets the value of Domain. +func (s *NeedUpdate) SetDomain(val OptNilNeedDomainInput) { + s.Domain = val +} + +// SetWorkFormats sets the value of WorkFormats. +func (s *NeedUpdate) SetWorkFormats(val OptNilNeedWorkFormatsInput) { + s.WorkFormats = val +} + +// SetLocation sets the value of Location. +func (s *NeedUpdate) SetLocation(val OptNilNeedLocationInput) { + s.Location = val +} + +// SetSalary sets the value of Salary. +func (s *NeedUpdate) SetSalary(val OptNilNeedSalaryInput) { + s.Salary = val +} + +// Where the value of a field or item came from. The server sets it; a request never sends it. +// +// - manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, +// and `extracted_in_version` are null. +// - extracted_from_text: the server extracted the value from `source_text`, with the deterministic +// rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor +// version. +// - imported: planned; the value was copied from a linked vacancy or an import. No MVP operation +// produces it. +// +// Confirming an extracted value keeps its origin and quote; changing the value makes it `manual`. +// Adding a value is a contract change. +// Ref: #/components/schemas/NeedValueOrigin +type NeedValueOrigin string + +const ( + NeedValueOriginManual NeedValueOrigin = "manual" + NeedValueOriginExtractedFromText NeedValueOrigin = "extracted_from_text" + NeedValueOriginImported NeedValueOrigin = "imported" +) + +// AllValues returns all NeedValueOrigin values. +func (NeedValueOrigin) AllValues() []NeedValueOrigin { + return []NeedValueOrigin{ + NeedValueOriginManual, + NeedValueOriginExtractedFromText, + NeedValueOriginImported, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedValueOrigin) MarshalText() ([]byte, error) { + switch s { + case NeedValueOriginManual: + return []byte(s), nil + case NeedValueOriginExtractedFromText: + return []byte(s), nil + case NeedValueOriginImported: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedValueOrigin) UnmarshalText(data []byte) error { + switch NeedValueOrigin(data) { + case NeedValueOriginManual: + *s = NeedValueOriginManual + return nil + case NeedValueOriginExtractedFromText: + *s = NeedValueOriginExtractedFromText + return nil + case NeedValueOriginImported: + *s = NeedValueOriginImported + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Provenance of a value: its origin, the quote it was extracted from, the need version whose text the +// quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot +// set it. +// Ref: #/components/schemas/NeedValueSource +type NeedValueSource struct { + Origin NeedValueOrigin `json:"origin"` + // Excerpt of the need text that supports the value, or null for a manual value and for an extracted + // value that the extractor did not tie to one excerpt. + Quote NilNeedSourceQuote `json:"quote"` + // Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or + // null for a manual value. A confirmed value keeps it after the text changes, so its quote may be + // absent from the current `source_text`. + ExtractedInVersion NilNeedVersion `json:"extracted_in_version"` + // Extractor version for an extracted or imported value, or null for a manual value. + ExtractionVersion NilNeedVersionLabel `json:"extraction_version"` +} + +// GetOrigin returns the value of Origin. +func (s *NeedValueSource) GetOrigin() NeedValueOrigin { + return s.Origin +} + +// GetQuote returns the value of Quote. +func (s *NeedValueSource) GetQuote() NilNeedSourceQuote { + return s.Quote +} + +// GetExtractedInVersion returns the value of ExtractedInVersion. +func (s *NeedValueSource) GetExtractedInVersion() NilNeedVersion { + return s.ExtractedInVersion +} + +// GetExtractionVersion returns the value of ExtractionVersion. +func (s *NeedValueSource) GetExtractionVersion() NilNeedVersionLabel { + return s.ExtractionVersion +} + +// SetOrigin sets the value of Origin. +func (s *NeedValueSource) SetOrigin(val NeedValueOrigin) { + s.Origin = val +} + +// SetQuote sets the value of Quote. +func (s *NeedValueSource) SetQuote(val NilNeedSourceQuote) { + s.Quote = val +} + +// SetExtractedInVersion sets the value of ExtractedInVersion. +func (s *NeedValueSource) SetExtractedInVersion(val NilNeedVersion) { + s.ExtractedInVersion = val +} + +// SetExtractionVersion sets the value of ExtractionVersion. +func (s *NeedValueSource) SetExtractionVersion(val NilNeedVersionLabel) { + s.ExtractionVersion = val +} + +// Confirmation state of one need field. +// +// - confirmed: a member of the organization entered the value or confirmed it. Only confirmed values +// feed readiness, category recommendations, search, and invitations. +// - extracted: the server proposed the value from the need text or an import, and nobody has +// confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts +// as an answer in readiness. +// - unknown: the field has no value. `value` and `source` are null. The server never fills an unknown +// field with a default or a guess, such as a Senior grade, the remote format, or a zero salary. +// +// Ref: #/components/schemas/NeedValueStatus +type NeedValueStatus string + +const ( + NeedValueStatusConfirmed NeedValueStatus = "confirmed" + NeedValueStatusExtracted NeedValueStatus = "extracted" + NeedValueStatusUnknown NeedValueStatus = "unknown" +) + +// AllValues returns all NeedValueStatus values. +func (NeedValueStatus) AllValues() []NeedValueStatus { + return []NeedValueStatus{ + NeedValueStatusConfirmed, + NeedValueStatusExtracted, + NeedValueStatusUnknown, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NeedValueStatus) MarshalText() ([]byte, error) { + switch s { + case NeedValueStatusConfirmed: + return []byte(s), nil + case NeedValueStatusExtracted: + return []byte(s), nil + case NeedValueStatusUnknown: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NeedValueStatus) UnmarshalText(data []byte) error { + switch NeedValueStatus(data) { + case NeedValueStatusConfirmed: + *s = NeedValueStatusConfirmed + return nil + case NeedValueStatusExtracted: + *s = NeedValueStatusExtracted + return nil + case NeedValueStatusUnknown: + *s = NeedValueStatusUnknown + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type NeedVersion int64 + +type NeedVersionLabel string + +// Work formats that the employer offers, with their confirmation state and provenance. `value` and +// `source` are null exactly when `status` is `unknown`; a known value lists one to three formats. +// Ref: #/components/schemas/NeedWorkFormats +type NeedWorkFormats struct { + Status NeedValueStatus `json:"status"` + Value []WorkFormat `json:"value"` + Source NilNeedValueSource `json:"source"` +} + +// GetStatus returns the value of Status. +func (s *NeedWorkFormats) GetStatus() NeedValueStatus { + return s.Status +} + +// GetValue returns the value of Value. +func (s *NeedWorkFormats) GetValue() []WorkFormat { + return s.Value +} + +// GetSource returns the value of Source. +func (s *NeedWorkFormats) GetSource() NilNeedValueSource { + return s.Source +} + +// SetStatus sets the value of Status. +func (s *NeedWorkFormats) SetStatus(val NeedValueStatus) { + s.Status = val +} + +// SetValue sets the value of Value. +func (s *NeedWorkFormats) SetValue(val []WorkFormat) { + s.Value = val +} + +// SetSource sets the value of Source. +func (s *NeedWorkFormats) SetSource(val NilNeedValueSource) { + s.Source = val +} + +// Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are +// compared as a set. +// Ref: #/components/schemas/NeedWorkFormatsInput +type NeedWorkFormatsInput struct { + Value []WorkFormat `json:"value"` + Status NeedItemStatus `json:"status"` +} + +// GetValue returns the value of Value. +func (s *NeedWorkFormatsInput) GetValue() []WorkFormat { + return s.Value +} + +// GetStatus returns the value of Status. +func (s *NeedWorkFormatsInput) GetStatus() NeedItemStatus { + return s.Status +} + +// SetValue sets the value of Value. +func (s *NeedWorkFormatsInput) SetValue(val []WorkFormat) { + s.Value = val +} + +// SetStatus sets the value of Status. +func (s *NeedWorkFormatsInput) SetStatus(val NeedItemStatus) { + s.Status = val +} + type NewPassword string // NewNilAssessmentItem returns new NilAssessmentItem with value set to v. @@ -4230,6 +6543,51 @@ func (o NilCandidateExperience) Or(d CandidateExperience) CandidateExperience { return d } +// NewNilFloat64 returns new NilFloat64 with value set to v. +func NewNilFloat64(v float64) NilFloat64 { + return NilFloat64{ + Value: v, + } +} + +// NilFloat64 is nullable float64. +type NilFloat64 struct { + Value float64 + Null bool +} + +// SetTo sets value to v. +func (o *NilFloat64) SetTo(v float64) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilFloat64) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilFloat64) SetToNull() { + o.Null = true + var v float64 + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilFloat64) Get() (v float64, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilFloat64) Or(d float64) float64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewNilGradeCode returns new NilGradeCode with value set to v. func NewNilGradeCode(v GradeCode) NilGradeCode { return NilGradeCode{ @@ -4320,6 +6678,321 @@ func (o NilInt32) Or(d int32) int32 { return d } +// NewNilNeedDomainName returns new NilNeedDomainName with value set to v. +func NewNilNeedDomainName(v NeedDomainName) NilNeedDomainName { + return NilNeedDomainName{ + Value: v, + } +} + +// NilNeedDomainName is nullable NeedDomainName. +type NilNeedDomainName struct { + Value NeedDomainName + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedDomainName) SetTo(v NeedDomainName) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedDomainName) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedDomainName) SetToNull() { + o.Null = true + var v NeedDomainName + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedDomainName) Get() (v NeedDomainName, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedDomainName) Or(d NeedDomainName) NeedDomainName { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedLocationName returns new NilNeedLocationName with value set to v. +func NewNilNeedLocationName(v NeedLocationName) NilNeedLocationName { + return NilNeedLocationName{ + Value: v, + } +} + +// NilNeedLocationName is nullable NeedLocationName. +type NilNeedLocationName struct { + Value NeedLocationName + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedLocationName) SetTo(v NeedLocationName) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedLocationName) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedLocationName) SetToNull() { + o.Null = true + var v NeedLocationName + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedLocationName) Get() (v NeedLocationName, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedLocationName) Or(d NeedLocationName) NeedLocationName { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedSourceQuote returns new NilNeedSourceQuote with value set to v. +func NewNilNeedSourceQuote(v NeedSourceQuote) NilNeedSourceQuote { + return NilNeedSourceQuote{ + Value: v, + } +} + +// NilNeedSourceQuote is nullable NeedSourceQuote. +type NilNeedSourceQuote struct { + Value NeedSourceQuote + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedSourceQuote) SetTo(v NeedSourceQuote) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedSourceQuote) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedSourceQuote) SetToNull() { + o.Null = true + var v NeedSourceQuote + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedSourceQuote) Get() (v NeedSourceQuote, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedSourceQuote) Or(d NeedSourceQuote) NeedSourceQuote { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedSourceText returns new NilNeedSourceText with value set to v. +func NewNilNeedSourceText(v NeedSourceText) NilNeedSourceText { + return NilNeedSourceText{ + Value: v, + } +} + +// NilNeedSourceText is nullable NeedSourceText. +type NilNeedSourceText struct { + Value NeedSourceText + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedSourceText) SetTo(v NeedSourceText) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedSourceText) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedSourceText) SetToNull() { + o.Null = true + var v NeedSourceText + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedSourceText) Get() (v NeedSourceText, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedSourceText) Or(d NeedSourceText) NeedSourceText { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedValueSource returns new NilNeedValueSource with value set to v. +func NewNilNeedValueSource(v NeedValueSource) NilNeedValueSource { + return NilNeedValueSource{ + Value: v, + } +} + +// NilNeedValueSource is nullable NeedValueSource. +type NilNeedValueSource struct { + Value NeedValueSource + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedValueSource) SetTo(v NeedValueSource) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedValueSource) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedValueSource) SetToNull() { + o.Null = true + var v NeedValueSource + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedValueSource) Get() (v NeedValueSource, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedValueSource) Or(d NeedValueSource) NeedValueSource { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedVersion returns new NilNeedVersion with value set to v. +func NewNilNeedVersion(v NeedVersion) NilNeedVersion { + return NilNeedVersion{ + Value: v, + } +} + +// NilNeedVersion is nullable NeedVersion. +type NilNeedVersion struct { + Value NeedVersion + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedVersion) SetTo(v NeedVersion) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedVersion) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedVersion) SetToNull() { + o.Null = true + var v NeedVersion + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedVersion) Get() (v NeedVersion, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedVersion) Or(d NeedVersion) NeedVersion { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilNeedVersionLabel returns new NilNeedVersionLabel with value set to v. +func NewNilNeedVersionLabel(v NeedVersionLabel) NilNeedVersionLabel { + return NilNeedVersionLabel{ + Value: v, + } +} + +// NilNeedVersionLabel is nullable NeedVersionLabel. +type NilNeedVersionLabel struct { + Value NeedVersionLabel + Null bool +} + +// SetTo sets value to v. +func (o *NilNeedVersionLabel) SetTo(v NeedVersionLabel) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilNeedVersionLabel) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilNeedVersionLabel) SetToNull() { + o.Null = true + var v NeedVersionLabel + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilNeedVersionLabel) Get() (v NeedVersionLabel, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilNeedVersionLabel) Or(d NeedVersionLabel) NeedVersionLabel { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewNilPracticeFailureReason returns new NilPracticeFailureReason with value set to v. func NewNilPracticeFailureReason(v PracticeFailureReason) NilPracticeFailureReason { return NilPracticeFailureReason{ @@ -4410,6 +7083,141 @@ func (o NilPracticeVerdict) Or(d PracticeVerdict) PracticeVerdict { return d } +// NewNilSalaryRange returns new NilSalaryRange with value set to v. +func NewNilSalaryRange(v SalaryRange) NilSalaryRange { + return NilSalaryRange{ + Value: v, + } +} + +// NilSalaryRange is nullable SalaryRange. +type NilSalaryRange struct { + Value SalaryRange + Null bool +} + +// SetTo sets value to v. +func (o *NilSalaryRange) SetTo(v SalaryRange) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilSalaryRange) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilSalaryRange) SetToNull() { + o.Null = true + var v SalaryRange + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilSalaryRange) Get() (v SalaryRange, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilSalaryRange) Or(d SalaryRange) SalaryRange { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilSkillTaxonomyCode returns new NilSkillTaxonomyCode with value set to v. +func NewNilSkillTaxonomyCode(v SkillTaxonomyCode) NilSkillTaxonomyCode { + return NilSkillTaxonomyCode{ + Value: v, + } +} + +// NilSkillTaxonomyCode is nullable SkillTaxonomyCode. +type NilSkillTaxonomyCode struct { + Value SkillTaxonomyCode + Null bool +} + +// SetTo sets value to v. +func (o *NilSkillTaxonomyCode) SetTo(v SkillTaxonomyCode) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilSkillTaxonomyCode) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilSkillTaxonomyCode) SetToNull() { + o.Null = true + var v SkillTaxonomyCode + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilSkillTaxonomyCode) Get() (v SkillTaxonomyCode, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilSkillTaxonomyCode) Or(d SkillTaxonomyCode) SkillTaxonomyCode { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewNilSpecializationCode returns new NilSpecializationCode with value set to v. +func NewNilSpecializationCode(v SpecializationCode) NilSpecializationCode { + return NilSpecializationCode{ + Value: v, + } +} + +// NilSpecializationCode is nullable SpecializationCode. +type NilSpecializationCode struct { + Value SpecializationCode + Null bool +} + +// SetTo sets value to v. +func (o *NilSpecializationCode) SetTo(v SpecializationCode) { + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o NilSpecializationCode) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *NilSpecializationCode) SetToNull() { + o.Null = true + var v SpecializationCode + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o NilSpecializationCode) Get() (v SpecializationCode, ok bool) { + if o.Null { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o NilSpecializationCode) Or(d SpecializationCode) SpecializationCode { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewNilString returns new NilString with value set to v. func NewNilString(v string) NilString { return NilString{ @@ -4890,6 +7698,596 @@ func (o OptInt32) Or(d int32) int32 { return d } +// NewOptNeedTitle returns new OptNeedTitle with value set to v. +func NewOptNeedTitle(v NeedTitle) OptNeedTitle { + return OptNeedTitle{ + Value: v, + Set: true, + } +} + +// OptNeedTitle is optional NeedTitle. +type OptNeedTitle struct { + Value NeedTitle + Set bool +} + +// IsSet returns true if OptNeedTitle was set. +func (o OptNeedTitle) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNeedTitle) Reset() { + var v NeedTitle + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptNeedTitle) SetTo(v NeedTitle) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNeedTitle) Get() (v NeedTitle, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNeedTitle) Or(d NeedTitle) NeedTitle { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedDomainInput returns new OptNilNeedDomainInput with value set to v. +func NewOptNilNeedDomainInput(v NeedDomainInput) OptNilNeedDomainInput { + return OptNilNeedDomainInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedDomainInput is optional nullable NeedDomainInput. +type OptNilNeedDomainInput struct { + Value NeedDomainInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedDomainInput was set. +func (o OptNilNeedDomainInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedDomainInput) Reset() { + var v NeedDomainInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedDomainInput) SetTo(v NeedDomainInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedDomainInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedDomainInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedDomainInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedDomainInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedDomainInput) Get() (v NeedDomainInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedDomainInput) Or(d NeedDomainInput) NeedDomainInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedGradeInput returns new OptNilNeedGradeInput with value set to v. +func NewOptNilNeedGradeInput(v NeedGradeInput) OptNilNeedGradeInput { + return OptNilNeedGradeInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedGradeInput is optional nullable NeedGradeInput. +type OptNilNeedGradeInput struct { + Value NeedGradeInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedGradeInput was set. +func (o OptNilNeedGradeInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedGradeInput) Reset() { + var v NeedGradeInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedGradeInput) SetTo(v NeedGradeInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedGradeInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedGradeInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedGradeInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedGradeInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedGradeInput) Get() (v NeedGradeInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedGradeInput) Or(d NeedGradeInput) NeedGradeInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedLocationInput returns new OptNilNeedLocationInput with value set to v. +func NewOptNilNeedLocationInput(v NeedLocationInput) OptNilNeedLocationInput { + return OptNilNeedLocationInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedLocationInput is optional nullable NeedLocationInput. +type OptNilNeedLocationInput struct { + Value NeedLocationInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedLocationInput was set. +func (o OptNilNeedLocationInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedLocationInput) Reset() { + var v NeedLocationInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedLocationInput) SetTo(v NeedLocationInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedLocationInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedLocationInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedLocationInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedLocationInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedLocationInput) Get() (v NeedLocationInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedLocationInput) Or(d NeedLocationInput) NeedLocationInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedSalaryInput returns new OptNilNeedSalaryInput with value set to v. +func NewOptNilNeedSalaryInput(v NeedSalaryInput) OptNilNeedSalaryInput { + return OptNilNeedSalaryInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedSalaryInput is optional nullable NeedSalaryInput. +type OptNilNeedSalaryInput struct { + Value NeedSalaryInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedSalaryInput was set. +func (o OptNilNeedSalaryInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedSalaryInput) Reset() { + var v NeedSalaryInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedSalaryInput) SetTo(v NeedSalaryInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedSalaryInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedSalaryInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedSalaryInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedSalaryInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedSalaryInput) Get() (v NeedSalaryInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedSalaryInput) Or(d NeedSalaryInput) NeedSalaryInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedSourceText returns new OptNilNeedSourceText with value set to v. +func NewOptNilNeedSourceText(v NeedSourceText) OptNilNeedSourceText { + return OptNilNeedSourceText{ + Value: v, + Set: true, + } +} + +// OptNilNeedSourceText is optional nullable NeedSourceText. +type OptNilNeedSourceText struct { + Value NeedSourceText + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedSourceText was set. +func (o OptNilNeedSourceText) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedSourceText) Reset() { + var v NeedSourceText + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedSourceText) SetTo(v NeedSourceText) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedSourceText) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedSourceText) SetToNull() { + o.Set = true + o.Null = true + var v NeedSourceText + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedSourceText) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedSourceText) Get() (v NeedSourceText, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedSourceText) Or(d NeedSourceText) NeedSourceText { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedSpecializationInput returns new OptNilNeedSpecializationInput with value set to v. +func NewOptNilNeedSpecializationInput(v NeedSpecializationInput) OptNilNeedSpecializationInput { + return OptNilNeedSpecializationInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedSpecializationInput is optional nullable NeedSpecializationInput. +type OptNilNeedSpecializationInput struct { + Value NeedSpecializationInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedSpecializationInput was set. +func (o OptNilNeedSpecializationInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedSpecializationInput) Reset() { + var v NeedSpecializationInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedSpecializationInput) SetTo(v NeedSpecializationInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedSpecializationInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedSpecializationInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedSpecializationInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedSpecializationInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedSpecializationInput) Get() (v NeedSpecializationInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedSpecializationInput) Or(d NeedSpecializationInput) NeedSpecializationInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilNeedWorkFormatsInput returns new OptNilNeedWorkFormatsInput with value set to v. +func NewOptNilNeedWorkFormatsInput(v NeedWorkFormatsInput) OptNilNeedWorkFormatsInput { + return OptNilNeedWorkFormatsInput{ + Value: v, + Set: true, + } +} + +// OptNilNeedWorkFormatsInput is optional nullable NeedWorkFormatsInput. +type OptNilNeedWorkFormatsInput struct { + Value NeedWorkFormatsInput + Set bool + Null bool +} + +// IsSet returns true if OptNilNeedWorkFormatsInput was set. +func (o OptNilNeedWorkFormatsInput) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilNeedWorkFormatsInput) Reset() { + var v NeedWorkFormatsInput + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilNeedWorkFormatsInput) SetTo(v NeedWorkFormatsInput) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilNeedWorkFormatsInput) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilNeedWorkFormatsInput) SetToNull() { + o.Set = true + o.Null = true + var v NeedWorkFormatsInput + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilNeedWorkFormatsInput) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilNeedWorkFormatsInput) Get() (v NeedWorkFormatsInput, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilNeedWorkFormatsInput) Or(d NeedWorkFormatsInput) NeedWorkFormatsInput { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilUUID returns new OptNilUUID with value set to v. +func NewOptNilUUID(v uuid.UUID) OptNilUUID { + return OptNilUUID{ + Value: v, + Set: true, + } +} + +// OptNilUUID is optional nullable uuid.UUID. +type OptNilUUID struct { + Value uuid.UUID + Set bool + Null bool +} + +// IsSet returns true if OptNilUUID was set. +func (o OptNilUUID) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilUUID) Reset() { + var v uuid.UUID + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilUUID) SetTo(v uuid.UUID) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilUUID) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilUUID) SetToNull() { + o.Set = true + o.Null = true + var v uuid.UUID + o.Value = v +} + +// IsEmpty returns true if the field was omitted from the payload (not Set and not Null). +func (o OptNilUUID) IsEmpty() bool { + return !o.Set && !o.Null +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilUUID) Get() (v uuid.UUID, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilUUID) Or(d uuid.UUID) uuid.UUID { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptString returns new OptString with value set to v. func NewOptString(v string) OptString { return OptString{ @@ -5060,6 +8458,37 @@ func (s *OrderItemContentFormat) UnmarshalText(data []byte) error { } } +// Cursor pagination state of a list response. Lists are ordered by a stable server-defined key. To +// read the next page, repeat the request with the same filters and `cursor` set to `next_cursor`. +// Ref: #/components/schemas/PageInfo +type PageInfo struct { + // Whether another page follows this one. + HasMore bool `json:"has_more"` + // Opaque cursor of the next page, or null on the last page. Clients must not parse, build, or store it + // beyond the current listing. + NextCursor NilString `json:"next_cursor"` +} + +// GetHasMore returns the value of HasMore. +func (s *PageInfo) GetHasMore() bool { + return s.HasMore +} + +// GetNextCursor returns the value of NextCursor. +func (s *PageInfo) GetNextCursor() NilString { + return s.NextCursor +} + +// SetHasMore sets the value of HasMore. +func (s *PageInfo) SetHasMore(val bool) { + s.HasMore = val +} + +// SetNextCursor sets the value of NextCursor. +func (s *PageInfo) SetNextCursor(val NilString) { + s.NextCursor = val +} + // Consent C1 to the processing of personal data, given at registration. The client reads the current // text and its version with GetConsentText(c1) and sends that version here. A version that is not the // currently published one answers 400 validation_failed with the pointer `/consent_c1/text_version`; @@ -6155,6 +9584,156 @@ type ResendEmailVerificationForbidden Problem func (*ResendEmailVerificationForbidden) resendEmailVerificationRes() {} +type RubAmount int64 + +// Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change. +// Ref: #/components/schemas/SalaryPeriod +type SalaryPeriod string + +const ( + SalaryPeriodMonth SalaryPeriod = "month" +) + +// AllValues returns all SalaryPeriod values. +func (SalaryPeriod) AllValues() []SalaryPeriod { + return []SalaryPeriod{ + SalaryPeriodMonth, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s SalaryPeriod) MarshalText() ([]byte, error) { + switch s { + case SalaryPeriodMonth: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *SalaryPeriod) UnmarshalText(data []byte) error { + switch SalaryPeriod(data) { + case SalaryPeriodMonth: + *s = SalaryPeriodMonth + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis +// (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the +// known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: +// `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is +// `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with +// the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, +// `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. +// The rules are the same for a need and an invitation. +// Ref: #/components/schemas/SalaryRange +type SalaryRange struct { + SalaryFrom RubAmount `json:"salary_from"` + SalaryTo RubAmount `json:"salary_to"` + Currency CurrencyCode `json:"currency"` + Period SalaryPeriod `json:"period"` + TaxBasis SalaryTaxBasis `json:"tax_basis"` +} + +// GetSalaryFrom returns the value of SalaryFrom. +func (s *SalaryRange) GetSalaryFrom() RubAmount { + return s.SalaryFrom +} + +// GetSalaryTo returns the value of SalaryTo. +func (s *SalaryRange) GetSalaryTo() RubAmount { + return s.SalaryTo +} + +// GetCurrency returns the value of Currency. +func (s *SalaryRange) GetCurrency() CurrencyCode { + return s.Currency +} + +// GetPeriod returns the value of Period. +func (s *SalaryRange) GetPeriod() SalaryPeriod { + return s.Period +} + +// GetTaxBasis returns the value of TaxBasis. +func (s *SalaryRange) GetTaxBasis() SalaryTaxBasis { + return s.TaxBasis +} + +// SetSalaryFrom sets the value of SalaryFrom. +func (s *SalaryRange) SetSalaryFrom(val RubAmount) { + s.SalaryFrom = val +} + +// SetSalaryTo sets the value of SalaryTo. +func (s *SalaryRange) SetSalaryTo(val RubAmount) { + s.SalaryTo = val +} + +// SetCurrency sets the value of Currency. +func (s *SalaryRange) SetCurrency(val CurrencyCode) { + s.Currency = val +} + +// SetPeriod sets the value of Period. +func (s *SalaryRange) SetPeriod(val SalaryPeriod) { + s.Period = val +} + +// SetTaxBasis sets the value of TaxBasis. +func (s *SalaryRange) SetTaxBasis(val SalaryTaxBasis) { + s.TaxBasis = val +} + +// Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the +// amount before it. The basis is always explicit; amounts in different bases are never compared +// directly. +// Ref: #/components/schemas/SalaryTaxBasis +type SalaryTaxBasis string + +const ( + SalaryTaxBasisNet SalaryTaxBasis = "net" + SalaryTaxBasisGross SalaryTaxBasis = "gross" +) + +// AllValues returns all SalaryTaxBasis values. +func (SalaryTaxBasis) AllValues() []SalaryTaxBasis { + return []SalaryTaxBasis{ + SalaryTaxBasisNet, + SalaryTaxBasisGross, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s SalaryTaxBasis) MarshalText() ([]byte, error) { + switch s { + case SalaryTaxBasisNet: + return []byte(s), nil + case SalaryTaxBasisGross: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *SalaryTaxBasis) UnmarshalText(data []byte) error { + switch SalaryTaxBasis(data) { + case SalaryTaxBasisNet: + *s = SalaryTaxBasisNet + return nil + case SalaryTaxBasisGross: + *s = SalaryTaxBasisGross + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + type SaveMyQuestionnaireBadRequest Problem func (*SaveMyQuestionnaireBadRequest) saveMyQuestionnaireRes() {} @@ -6288,6 +9867,10 @@ func (s *SessionHeaders) SetResponse(val Session) { func (*SessionHeaders) loginRes() {} +type SkillName string + +type SkillTaxonomyCode string + // Catalog of directions, specializations, and the grade scale that the questionnaire and the // assessment use. The catalog is reference data and identical for every caller; it contains no // personal data. @@ -6763,10 +10346,32 @@ func (s *TooManyRequestsHeaders) SetResponse(val Problem) { func (*TooManyRequestsHeaders) confirmEmailRes() {} func (*TooManyRequestsHeaders) createMyAssessmentAttemptRes() {} +func (*TooManyRequestsHeaders) createOrganizationNeedRes() {} func (*TooManyRequestsHeaders) loginRes() {} func (*TooManyRequestsHeaders) registerAccountRes() {} func (*TooManyRequestsHeaders) resendEmailVerificationRes() {} func (*TooManyRequestsHeaders) submitMyAssessmentAnswerRes() {} +func (*TooManyRequestsHeaders) updateOrganizationNeedRes() {} + +type UpdateOrganizationNeedBadRequest Problem + +func (*UpdateOrganizationNeedBadRequest) updateOrganizationNeedRes() {} + +type UpdateOrganizationNeedForbidden Problem + +func (*UpdateOrganizationNeedForbidden) updateOrganizationNeedRes() {} + +type UpdateOrganizationNeedNotFound Problem + +func (*UpdateOrganizationNeedNotFound) updateOrganizationNeedRes() {} + +type UpdateOrganizationNeedPreconditionFailed Problem + +func (*UpdateOrganizationNeedPreconditionFailed) updateOrganizationNeedRes() {} + +type UpdateOrganizationNeedUnauthorized Problem + +func (*UpdateOrganizationNeedUnauthorized) updateOrganizationNeedRes() {} type VerificationToken string diff --git a/backend/internal/adapter/primary/http/api/oas_security_gen.go b/backend/internal/adapter/primary/http/api/oas_security_gen.go index b47ad6f..ed1a146 100644 --- a/backend/internal/adapter/primary/http/api/oas_security_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_security_gen.go @@ -57,6 +57,7 @@ func findAuthorization(h http.Header, prefix string) (string, bool) { // operationRolesSessionCookie is a private map storing roles per operation. var operationRolesSessionCookie = map[string][]string{ CreateMyAssessmentAttemptOperation: []string{}, + CreateOrganizationNeedOperation: []string{}, FinalizeMyAssessmentAttemptOperation: []string{}, GetCurrentAccountOperation: []string{}, GetCurrentSessionOperation: []string{}, @@ -64,9 +65,12 @@ var operationRolesSessionCookie = map[string][]string{ GetMyAssessmentAvailabilityOperation: []string{}, GetMyAssessmentResultOperation: []string{}, GetMyQuestionnaireOperation: []string{}, + GetOrganizationNeedOperation: []string{}, + ListOrganizationNeedsOperation: []string{}, LogoutOperation: []string{}, SaveMyQuestionnaireOperation: []string{}, SubmitMyAssessmentAnswerOperation: []string{}, + UpdateOrganizationNeedOperation: []string{}, } // GetRolesForSessionCookie returns the required roles for the given operation. @@ -93,10 +97,12 @@ func GetRolesForSessionCookie(operation string) []string { // operationRolesSessionCsrf is a private map storing roles per operation. var operationRolesSessionCsrf = map[string][]string{ CreateMyAssessmentAttemptOperation: []string{}, + CreateOrganizationNeedOperation: []string{}, FinalizeMyAssessmentAttemptOperation: []string{}, LogoutOperation: []string{}, SaveMyQuestionnaireOperation: []string{}, SubmitMyAssessmentAnswerOperation: []string{}, + UpdateOrganizationNeedOperation: []string{}, } // GetRolesForSessionCsrf returns the required roles for the given operation. diff --git a/backend/internal/adapter/primary/http/api/oas_server_gen.go b/backend/internal/adapter/primary/http/api/oas_server_gen.go index 36d7735..51f48fe 100644 --- a/backend/internal/adapter/primary/http/api/oas_server_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_server_gen.go @@ -74,6 +74,59 @@ type Handler interface { // // POST /api/v1/me/assessment-attempts CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error) + // CreateOrganizationNeed implements CreateOrganizationNeed operation. + // + // 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. + // + // POST /api/v1/organizations/{org_id}/needs + CreateOrganizationNeed(ctx context.Context, req *NeedCreate, params CreateOrganizationNeedParams) (CreateOrganizationNeedRes, error) // FinalizeMyAssessmentAttempt implements FinalizeMyAssessmentAttempt operation. // // Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, @@ -234,6 +287,37 @@ type Handler interface { // // GET /api/v1/me/questionnaire GetMyQuestionnaire(ctx context.Context) (GetMyQuestionnaireRes, error) + // GetOrganizationNeed implements GetOrganizationNeed operation. + // + // 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. + // + // GET /api/v1/organizations/{org_id}/needs/{need_id} + GetOrganizationNeed(ctx context.Context, params GetOrganizationNeedParams) (GetOrganizationNeedRes, error) // GetSpecializationCatalog implements GetSpecializationCatalog operation. // // Public operation without a session. Returns the directions with their specializations, the @@ -254,6 +338,27 @@ type Handler interface { // // GET /api/v1/specializations GetSpecializationCatalog(ctx context.Context) (*SpecializationCatalog, error) + // ListOrganizationNeeds implements ListOrganizationNeeds operation. + // + // 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. + // + // GET /api/v1/organizations/{org_id}/needs + ListOrganizationNeeds(ctx context.Context, params ListOrganizationNeedsParams) (ListOrganizationNeedsRes, error) // Login implements Login operation. // // Public operation that starts a server session. The server verifies the password with Argon2id; for @@ -441,6 +546,73 @@ type Handler interface { // // POST /api/v1/me/assessment-attempts/{attempt_id}/answers SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error) + // UpdateOrganizationNeed implements UpdateOrganizationNeed operation. + // + // 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. + // + // PATCH /api/v1/organizations/{org_id}/needs/{need_id} + UpdateOrganizationNeed(ctx context.Context, req *NeedUpdate, params UpdateOrganizationNeedParams) (UpdateOrganizationNeedRes, error) // NewError creates *ProblemStatusCode from error returned by handler. // // Used for common default response. diff --git a/backend/internal/adapter/primary/http/api/oas_unimplemented_gen.go b/backend/internal/adapter/primary/http/api/oas_unimplemented_gen.go index 49605af..2f7ba91 100644 --- a/backend/internal/adapter/primary/http/api/oas_unimplemented_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_unimplemented_gen.go @@ -85,6 +85,62 @@ func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req * return r, ht.ErrNotImplemented } +// CreateOrganizationNeed implements CreateOrganizationNeed operation. +// +// 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. +// +// POST /api/v1/organizations/{org_id}/needs +func (UnimplementedHandler) CreateOrganizationNeed(ctx context.Context, req *NeedCreate, params CreateOrganizationNeedParams) (r CreateOrganizationNeedRes, _ error) { + return r, ht.ErrNotImplemented +} + // FinalizeMyAssessmentAttempt implements FinalizeMyAssessmentAttempt operation. // // Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, @@ -272,6 +328,40 @@ func (UnimplementedHandler) GetMyQuestionnaire(ctx context.Context) (r GetMyQues return r, ht.ErrNotImplemented } +// GetOrganizationNeed implements GetOrganizationNeed operation. +// +// 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. +// +// GET /api/v1/organizations/{org_id}/needs/{need_id} +func (UnimplementedHandler) GetOrganizationNeed(ctx context.Context, params GetOrganizationNeedParams) (r GetOrganizationNeedRes, _ error) { + return r, ht.ErrNotImplemented +} + // GetSpecializationCatalog implements GetSpecializationCatalog operation. // // Public operation without a session. Returns the directions with their specializations, the @@ -295,6 +385,30 @@ func (UnimplementedHandler) GetSpecializationCatalog(ctx context.Context) (r *Sp return r, ht.ErrNotImplemented } +// ListOrganizationNeeds implements ListOrganizationNeeds operation. +// +// 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. +// +// GET /api/v1/organizations/{org_id}/needs +func (UnimplementedHandler) ListOrganizationNeeds(ctx context.Context, params ListOrganizationNeedsParams) (r ListOrganizationNeedsRes, _ error) { + return r, ht.ErrNotImplemented +} + // Login implements Login operation. // // Public operation that starts a server session. The server verifies the password with Argon2id; for @@ -500,6 +614,76 @@ func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *A return r, ht.ErrNotImplemented } +// UpdateOrganizationNeed implements UpdateOrganizationNeed operation. +// +// 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. +// +// PATCH /api/v1/organizations/{org_id}/needs/{need_id} +func (UnimplementedHandler) UpdateOrganizationNeed(ctx context.Context, req *NeedUpdate, params UpdateOrganizationNeedParams) (r UpdateOrganizationNeedRes, _ error) { + return r, ht.ErrNotImplemented +} + // NewError creates *ProblemStatusCode from error returned by handler. // // Used for common default response. diff --git a/backend/internal/adapter/primary/http/api/oas_validators_gen.go b/backend/internal/adapter/primary/http/api/oas_validators_gen.go index 43cda93..9a52be5 100644 --- a/backend/internal/adapter/primary/http/api/oas_validators_gen.go +++ b/backend/internal/adapter/primary/http/api/oas_validators_gen.go @@ -2998,6 +2998,54 @@ func (s *CreateMyAssessmentAttemptUnprocessableEntity) Validate() error { return nil } +func (s *CreateOrganizationNeedBadRequest) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *CreateOrganizationNeedConflict) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *CreateOrganizationNeedForbidden) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *CreateOrganizationNeedNotFound) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *CreateOrganizationNeedUnauthorized) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *CreateOrganizationNeedUnprocessableEntity) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + func (s CsrfToken) Validate() error { alias := (string)(s) if err := (validate.String{ @@ -3018,6 +3066,15 @@ func (s CsrfToken) Validate() error { return nil } +func (s CurrencyCode) Validate() error { + switch s { + case "RUB": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s DirectionCode) Validate() error { switch s { case "development": @@ -3533,6 +3590,38 @@ func (s *GetMyQuestionnaireUnauthorized) Validate() error { return nil } +func (s *GetOrganizationNeedBadRequest) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *GetOrganizationNeedForbidden) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *GetOrganizationNeedNotFound) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *GetOrganizationNeedUnauthorized) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + func (s GradeCode) Validate() error { switch s { case "intern": @@ -3654,6 +3743,38 @@ func (s ItemContent) Validate() error { } } +func (s *ListOrganizationNeedsBadRequest) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *ListOrganizationNeedsForbidden) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *ListOrganizationNeedsNotFound) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *ListOrganizationNeedsUnauthorized) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + func (s *LoginBadRequest) Validate() error { alias := (*Problem)(s) if err := alias.Validate(); err != nil { @@ -3767,6 +3888,2640 @@ func (s *LogoutNoContent) Validate() error { return nil } +func (s *Need) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Title.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "title", + Error: err, + }) + } + if err := func() error { + if value, ok := s.SourceText.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source_text", + Error: err, + }) + } + if err := func() error { + if err := s.Version.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "version", + Error: err, + }) + } + if err := func() error { + if err := s.RequirementsVersion.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "requirements_version", + Error: err, + }) + } + if err := func() error { + if err := s.Requirements.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "requirements", + Error: err, + }) + } + if err := func() error { + if err := s.Readiness.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "readiness", + Error: err, + }) + } + if err := func() error { + if err := s.Recommendations.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "recommendations", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedCategoryRecommendation) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Specialization.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "specialization", + Error: err, + }) + } + if err := func() error { + if err := s.Grade.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "grade", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Score.Get(); ok { + if err := func() error { + if err := (validate.Float{ + MinSet: true, + Min: 0, + MaxSet: true, + Max: 1, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: nil, + Pattern: nil, + }).Validate(float64(value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "score", + Error: err, + }) + } + if err := func() error { + if err := s.SkillOverlap.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "skill_overlap", + Error: err, + }) + } + if err := func() error { + if err := s.Money.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "money", + Error: err, + }) + } + if err := func() error { + if err := s.Supply.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "supply", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedCategoryRecommendations) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if err := s.RequirementsVersion.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "requirements_version", + Error: err, + }) + } + if err := func() error { + if value, ok := s.PolicyVersion.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + Pattern: nil, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "policy_version", + Error: err, + }) + } + if err := func() error { + if value, ok := s.AlgorithmVersion.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "algorithm_version", + Error: err, + }) + } + if err := func() error { + if s.Categories == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 10, + MaxLengthSet: true, + }).ValidateLength(len(s.Categories)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Categories { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "categories", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedCreate) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Title.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "title", + Error: err, + }) + } + if err := func() error { + if value, ok := s.SourceText.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source_text", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Specialization.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "specialization", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Grade.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "grade", + Error: err, + }) + } + if err := func() error { + if s.RequiredSkills == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.RequiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.RequiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "required_skills", + Error: err, + }) + } + if err := func() error { + if s.DesiredSkills == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.DesiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.DesiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "desired_skills", + Error: err, + }) + } + if err := func() error { + if s.Tasks == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 20, + MaxLengthSet: true, + }).ValidateLength(len(s.Tasks)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Tasks { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tasks", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Domain.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "domain", + Error: err, + }) + } + if err := func() error { + if value, ok := s.WorkFormats.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "work_formats", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Location.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "location", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Salary.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "salary", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedDomain) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Value.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedDomainInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedDomainName) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 100, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^\\S(?:.*\\S)?$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s NeedFieldName) Validate() error { + switch s { + case "specialization": + return nil + case "grade": + return nil + case "required_skills": + return nil + case "desired_skills": + return nil + case "tasks": + return nil + case "domain": + return nil + case "work_formats": + return nil + case "location": + return nil + case "salary": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedGrade) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Value.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedGradeInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedHeaders) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.CacheControl.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "CacheControl", + Error: err, + }) + } + if err := func() error { + if err := s.Response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "Response", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedItemStatus) Validate() error { + switch s { + case "confirmed": + return nil + case "extracted": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedList) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Items == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 100, + MaxLengthSet: true, + }).ValidateLength(len(s.Items)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Items { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "items", + Error: err, + }) + } + if err := func() error { + if err := s.Page.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "page", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedListHeaders) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.CacheControl.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "CacheControl", + Error: err, + }) + } + if err := func() error { + if err := s.Response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "Response", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedLocation) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Value.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedLocationInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedLocationName) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 100, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^\\S(?:.*\\S)?$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s *NeedMissingField) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Field.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "field", + Error: err, + }) + } + if err := func() error { + if err := s.Reason.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "reason", + Error: err, + }) + } + if err := func() error { + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 300, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: nil, + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(s.Question)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "question", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedMissingReason) Validate() error { + switch s { + case "unknown": + return nil + case "unconfirmed": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedMoneyFit) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Share.Get(); ok { + if err := func() error { + if err := (validate.Float{ + MinSet: true, + Min: 0, + MaxSet: true, + Max: 1, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: nil, + Pattern: nil, + }).Validate(float64(value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "share", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedMoneyStatus) Validate() error { + switch s { + case "computed": + return nil + case "insufficient_data": + return nil + case "no_salary": + return nil + case "withheld": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedReadinessReport) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if s.MissingFields == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 9, + MaxLengthSet: true, + }).ValidateLength(len(s.MissingFields)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.MissingFields { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "missing_fields", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedReadinessStatus) Validate() error { + switch s { + case "complete": + return nil + case "incomplete": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s NeedRecommendationStatus) Validate() error { + switch s { + case "computed": + return nil + case "pending": + return nil + case "not_available": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedRequirementSet) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Specialization.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "specialization", + Error: err, + }) + } + if err := func() error { + if err := s.Grade.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "grade", + Error: err, + }) + } + if err := func() error { + if s.RequiredSkills == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.RequiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.RequiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "required_skills", + Error: err, + }) + } + if err := func() error { + if s.DesiredSkills == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.DesiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.DesiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "desired_skills", + Error: err, + }) + } + if err := func() error { + if s.Tasks == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 20, + MaxLengthSet: true, + }).ValidateLength(len(s.Tasks)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Tasks { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tasks", + Error: err, + }) + } + if err := func() error { + if err := s.Domain.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "domain", + Error: err, + }) + } + if err := func() error { + if err := s.WorkFormats.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "work_formats", + Error: err, + }) + } + if err := func() error { + if err := s.Location.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "location", + Error: err, + }) + } + if err := func() error { + if err := s.Salary.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "salary", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSalary) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Value.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSalaryInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSkill) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Name.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "name", + Error: err, + }) + } + if err := func() error { + if value, ok := s.TaxonomyCode.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "taxonomy_code", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if err := s.Source.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSkillInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Name.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "name", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSkillOverlap) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := (validate.Float{ + MinSet: true, + Min: 0, + MaxSet: true, + Max: 1, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: nil, + Pattern: nil, + }).Validate(float64(s.Share)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "share", + Error: err, + }) + } + if err := func() error { + if s.CoveredSkills == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 60, + MaxLengthSet: true, + }).ValidateLength(len(s.CoveredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.CoveredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "covered_skills", + Error: err, + }) + } + if err := func() error { + if s.UncoveredSkills == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 60, + MaxLengthSet: true, + }).ValidateLength(len(s.UncoveredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.UncoveredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "uncovered_skills", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedSourceQuote) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 300, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: nil, + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s NeedSourceText) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 10000, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: nil, + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s *NeedSpecialization) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Value.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSpecializationInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedSummary) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Title.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "title", + Error: err, + }) + } + if err := func() error { + if err := s.Version.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "version", + Error: err, + }) + } + if err := func() error { + if err := s.Specialization.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "specialization", + Error: err, + }) + } + if err := func() error { + if err := s.Grade.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "grade", + Error: err, + }) + } + if err := func() error { + if err := s.Readiness.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "readiness", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedSupplyBand) Validate() error { + switch s { + case "fewer_than_5": + return nil + case "from_5_to_29": + return nil + case "30_or_more": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedTask) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Text.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "text", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if err := s.Source.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedTaskInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Text.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "text", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedTaskText) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 300, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^\\S(?:.*\\S)?$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s NeedTitle) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 200, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^\\S(?:.*\\S)?$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s *NeedUpdate) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.ExpectedVersion.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "expected_version", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Title.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "title", + Error: err, + }) + } + if err := func() error { + if value, ok := s.SourceText.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source_text", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Specialization.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "specialization", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Grade.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "grade", + Error: err, + }) + } + if err := func() error { + if s.RequiredSkills == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.RequiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.RequiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "required_skills", + Error: err, + }) + } + if err := func() error { + if s.DesiredSkills == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 30, + MaxLengthSet: true, + }).ValidateLength(len(s.DesiredSkills)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.DesiredSkills { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "desired_skills", + Error: err, + }) + } + if err := func() error { + if s.Tasks == nil { + return nil // optional + } + if err := (validate.Array{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 20, + MaxLengthSet: true, + }).ValidateLength(len(s.Tasks)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Tasks { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tasks", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Domain.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "domain", + Error: err, + }) + } + if err := func() error { + if value, ok := s.WorkFormats.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "work_formats", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Location.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "location", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Salary.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "salary", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedValueOrigin) Validate() error { + switch s { + case "manual": + return nil + case "extracted_from_text": + return nil + case "imported": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NeedValueSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Origin.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "origin", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Quote.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "quote", + Error: err, + }) + } + if err := func() error { + if value, ok := s.ExtractedInVersion.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "extracted_in_version", + Error: err, + }) + } + if err := func() error { + if value, ok := s.ExtractionVersion.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "extraction_version", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NeedValueStatus) Validate() error { + switch s { + case "confirmed": + return nil + case "extracted": + return nil + case "unknown": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s NeedVersion) Validate() error { + alias := (int64)(s) + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + Pattern: nil, + }).Validate(int64(alias)); err != nil { + return errors.Wrap(err, "int") + } + return nil +} + +func (s NeedVersionLabel) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 64, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^[A-Za-z0-9._-]+$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s *NeedWorkFormats) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if s.Value == nil { + return nil // null + } + if err := (validate.Array{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 3, + MaxLengthSet: true, + }).ValidateLength(len(s.Value)); err != nil { + return errors.Wrap(err, "array") + } + if err := validate.UniqueItems(s.Value); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Value { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Source.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NeedWorkFormatsInput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Value == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 3, + MaxLengthSet: true, + }).ValidateLength(len(s.Value)); err != nil { + return errors.Wrap(err, "array") + } + if err := validate.UniqueItems(s.Value); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range s.Value { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value", + Error: err, + }) + } + if err := func() error { + if err := s.Status.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s NewPassword) Validate() error { alias := (string)(s) if err := (validate.String{ @@ -4050,6 +6805,48 @@ func (s OrderItemContentFormat) Validate() error { } } +func (s *PageInfo) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if value, ok := s.NextCursor.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 512, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^[A-Za-z0-9_-]+$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "next_cursor", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *PersonalDataConsentAcceptance) Validate() error { if s == nil { return validate.ErrNilPointer @@ -5205,6 +8002,111 @@ func (s *ResendEmailVerificationForbidden) Validate() error { return nil } +func (s RubAmount) Validate() error { + alias := (int64)(s) + if err := (validate.Int{ + MinSet: true, + Min: 1000, + MaxSet: true, + Max: 100000000, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: true, + MultipleOf: 1000, + Pattern: nil, + }).Validate(int64(alias)); err != nil { + return errors.Wrap(err, "int") + } + return nil +} + +func (s SalaryPeriod) Validate() error { + switch s { + case "month": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *SalaryRange) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.SalaryFrom.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "salary_from", + Error: err, + }) + } + if err := func() error { + if err := s.SalaryTo.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "salary_to", + Error: err, + }) + } + if err := func() error { + if err := s.Currency.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "currency", + Error: err, + }) + } + if err := func() error { + if err := s.Period.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "period", + Error: err, + }) + } + if err := func() error { + if err := s.TaxBasis.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tax_basis", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s SalaryTaxBasis) Validate() error { + switch s { + case "net": + return nil + case "gross": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *SaveMyQuestionnaireBadRequest) Validate() error { alias := (*Problem)(s) if err := alias.Validate(); err != nil { @@ -5328,6 +8230,46 @@ func (s *SessionHeaders) Validate() error { return nil } +func (s SkillName) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 100, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^\\S(?:.*\\S)?$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s SkillTaxonomyCode) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 64, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: regexMap["^[a-z0-9][a-z0-9_.+#-]*$"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + func (s *SpecializationCatalog) Validate() error { if s == nil { return validate.ErrNilPointer @@ -5825,6 +8767,46 @@ func (s *TooManyRequestsHeaders) Validate() error { return nil } +func (s *UpdateOrganizationNeedBadRequest) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *UpdateOrganizationNeedForbidden) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *UpdateOrganizationNeedNotFound) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *UpdateOrganizationNeedPreconditionFailed) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + +func (s *UpdateOrganizationNeedUnauthorized) Validate() error { + alias := (*Problem)(s) + if err := alias.Validate(); err != nil { + return err + } + return nil +} + func (s VerificationToken) Validate() error { alias := (string)(s) if err := (validate.String{ diff --git a/backend/internal/adapter/primary/http/router_test.go b/backend/internal/adapter/primary/http/router_test.go index 9bb7c55..28fe7a7 100644 --- a/backend/internal/adapter/primary/http/router_test.go +++ b/backend/internal/adapter/primary/http/router_test.go @@ -756,6 +756,330 @@ func TestAssessmentAccessBeforeImplementation(t *testing.T) { } } +// Need request fixtures shared by the need tests. +const ( + organizationNeedsPath = "/api/v1/organizations/01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01/needs" + organizationNeedPath = organizationNeedsPath + "/01928f7a-2b3c-7d4e-9f5a-6b7c8d9e0f12" + netSalaryRange = `{"salary_from":120000,"salary_to":160000,"currency":"RUB","period":"month","tax_basis":"net"}` + validNeedCreate = `{"title":"Backend","specialization":{"value":"backend","status":"confirmed"},` + + `"grade":{"value":"junior","status":"confirmed"},"required_skills":[{"name":"Go","status":"confirmed"}],` + + `"work_formats":{"value":["remote"],"status":"confirmed"},"salary":{"value":` + netSalaryRange + `,"status":"confirmed"}}` +) + +// needUpdateBody returns an UpdateOrganizationNeed body over version 1 with +// the given extra fields, for example `"grade":null`. +func needUpdateBody(fields string) string { + return `{"expected_version":1,` + fields + `}` +} + +// needSalary returns a confirmed salary decision for the given range bounds +// and tax basis in RUB per month. +func needSalary(from, to, basis string) string { + return `{"value":{"salary_from":` + from + `,"salary_to":` + to + `,"currency":"RUB","period":"month","tax_basis":"` + basis + `"},"status":"confirmed"}` +} + +// The schema alone must accept a need without a vacancy and reject what an +// employer may never send: membership, a recommendation score, or a +// candidate's minimum, a bare value without an explicit confirmation status, +// a salary range without a valid RUB base, and a missing or invalid +// expected_version. Security accepts the session here, so the request +// reaches validation; a valid request then answers 501 until needs are +// implemented. Cross-field salary rules (A < B, a width of 10-40%) and +// `extracted` with another value pass the schema; the server rejects them. +func TestNeedSchemaValidationPrecedesImplementation(t *testing.T) { + session := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken} + command := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken, "Idempotency-Key": testIdempotencyKey} + create := func(body string) identityRequest { + return identityRequest{method: http.MethodPost, path: organizationNeedsPath, body: body, headers: command} + } + update := func(fields string) identityRequest { + return identityRequest{method: http.MethodPatch, path: organizationNeedPath, body: needUpdateBody(fields), headers: session} + } + withSalary := func(salary string) string { + return strings.Replace(validNeedCreate, `{"value":`+netSalaryRange+`,"status":"confirmed"}`, salary, 1) + } + for _, test := range []struct { + name string + request identityRequest + location api.ProblemFieldLocation + pointer string + code string + }{ + { + name: "list", + request: identityRequest{method: http.MethodGet, path: organizationNeedsPath + "?limit=20", headers: session}, + }, + { + name: "list with a limit above the maximum", + request: identityRequest{method: http.MethodGet, path: organizationNeedsPath + "?limit=101", headers: session}, + location: api.ProblemFieldLocationQuery, pointer: "/limit", code: "invalid", + }, + { + name: "list for an organization identifier that is not a UUID", + request: identityRequest{method: http.MethodGet, path: "/api/v1/organizations/acme/needs", headers: session}, + location: api.ProblemFieldLocationPath, pointer: "/org_id", code: "invalid", + }, + { + name: "create a manual need without a vacancy", + request: create(validNeedCreate), + }, + { + name: "create from a text only", + request: create(`{"title":"Backend","source_text":"Ищем бэкенд-разработчика. Обязательно: Go."}`), + }, + { + name: "create with an explicit null vacancy and unknown fields", + request: create(`{"title":"Backend","vacancy_id":null,"grade":null,"salary":null,"work_formats":null,"tasks":[]}`), + }, + { + // The cross-field salary rules are domain rules that the server + // checks after the schema. + name: "create with a reversed salary range", + request: create(withSalary(needSalary("160000", "120000", "net"))), + }, + { + name: "create with equal salary bounds", + request: create(withSalary(needSalary("150000", "150000", "net"))), + }, + { + name: "create with a salary range wider than 40%", + request: create(withSalary(needSalary("100000", "200000", "net"))), + }, + { + name: "create without a title", + request: create(`{"specialization":{"value":"backend","status":"confirmed"}}`), + location: api.ProblemFieldLocationBody, pointer: "/title", code: "required", + }, + { + name: "create without an Idempotency-Key", + request: identityRequest{method: http.MethodPost, path: organizationNeedsPath, body: validNeedCreate, headers: session}, + location: api.ProblemFieldLocationHeader, pointer: "/Idempotency-Key", code: "required", + }, + { + name: "salary bound of zero", + request: create(withSalary(needSalary("0", "160000", "net"))), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/salary_from", code: "invalid", + }, + { + name: "salary bound that is not a multiple of 1000", + request: create(withSalary(needSalary("120000", "160500", "net"))), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/salary_to", code: "invalid", + }, + { + name: "salary in another currency", + request: create(withSalary(strings.Replace(needSalary("120000", "160000", "net"), "RUB", "USD", 1))), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/currency", code: "invalid", + }, + { + name: "salary with an unknown tax basis", + request: create(withSalary(needSalary("120000", "160000", "after_tax"))), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/tax_basis", code: "invalid", + }, + { + name: "salary per hour", + request: create(withSalary(strings.Replace(needSalary("1000", "2000", "net"), "month", "hour", 1))), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/period", code: "invalid", + }, + { + // The decoder does not record the path of a missing field in a + // nested object, so the pointer is the whole body. + name: "salary without a tax basis", + request: create(withSalary(`{"value":{"salary_from":120000,"salary_to":160000,"currency":"RUB","period":"month"},"status":"confirmed"}`)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + // A bare range would confirm it implicitly; the status is explicit. + name: "salary range without a decision", + request: create(withSalary(netSalaryRange)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "grade as a bare value", + request: create(strings.Replace(validNeedCreate, `{"value":"junior","status":"confirmed"}`, `"junior"`, 1)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "grade with an unknown status", + request: create(strings.Replace(validNeedCreate, `{"value":"junior","status":"confirmed"}`, `{"value":"junior","status":"unknown"}`, 1)), + location: api.ProblemFieldLocationBody, pointer: "/grade/status", code: "invalid", + }, + { + name: "recommendation score set by the employer", + request: create(strings.Replace(validNeedCreate, `{"title"`, `{"rec_score":0.99,"title"`, 1)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "organization membership in the body", + request: create(strings.Replace(validNeedCreate, `{"title"`, `{"members":[{"user_id":"01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01","role":"owner"}],"title"`, 1)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "candidate minimum inside the salary range", + request: create(withSalary(`{"value":{"salary_from":120000,"salary_to":160000,"currency":"RUB","period":"month","tax_basis":"net","candidate_minimum":130000},"status":"confirmed"}`)), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "skill with an unknown status", + request: create(strings.Replace(validNeedCreate, `{"name":"Go","status":"confirmed"}`, `{"name":"Go","status":"unknown"}`, 1)), + location: api.ProblemFieldLocationBody, pointer: "/required_skills/0/status", code: "invalid", + }, + { + name: "empty list of work formats", + request: create(strings.Replace(validNeedCreate, `["remote"]`, `[]`, 1)), + location: api.ProblemFieldLocationBody, pointer: "/work_formats/value", code: "invalid", + }, + { + name: "read", + request: identityRequest{method: http.MethodGet, path: organizationNeedPath, headers: session}, + }, + { + name: "read with a need identifier that is not a UUID", + request: identityRequest{method: http.MethodGet, path: organizationNeedsPath + "/1", headers: session}, + location: api.ProblemFieldLocationPath, pointer: "/need_id", code: "invalid", + }, + { + name: "confirm suggestions, keep two open, and answer missing fields", + request: update(`"specialization":{"value":"backend","status":"confirmed"},"grade":{"value":"middle","status":"confirmed"},` + + `"required_skills":[{"name":"Go","status":"confirmed"},{"name":"Temporal","status":"confirmed"}],` + + `"desired_skills":[{"name":"Kafka","status":"extracted"}],"domain":{"value":"платежи","status":"extracted"},` + + `"salary":` + needSalary("250000", "320000", "gross")), + }, + { + name: "delete requirements", + request: update(`"grade":null,"salary":null,"vacancy_id":null,"tasks":[]`), + }, + { + name: "update with a list sent as null", + request: update(`"tasks":null`), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update with a bare grade", + request: update(`"grade":"middle"`), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update without an expected version", + request: identityRequest{method: http.MethodPatch, path: organizationNeedPath, body: `{"grade":null}`, headers: session}, + location: api.ProblemFieldLocationBody, pointer: "/expected_version", code: "required", + }, + { + name: "update with version zero", + request: identityRequest{method: http.MethodPatch, path: organizationNeedPath, body: `{"expected_version":0,"grade":null}`, headers: session}, + location: api.ProblemFieldLocationBody, pointer: "/expected_version", code: "invalid", + }, + { + name: "update with a version as text", + request: identityRequest{method: http.MethodPatch, path: organizationNeedPath, body: `{"expected_version":"1","grade":null}`, headers: session}, + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update that sets the version itself", + request: update(`"version":7`), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update that sets the requirements version", + request: update(`"requirements_version":7`), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update with recommendations", + request: update(`"recommendations":{"status":"computed"}`), + location: api.ProblemFieldLocationBody, pointer: "", code: "invalid", + }, + { + name: "update with a salary in gross and net at once", + request: update(`"salary":` + needSalary("120000", "160000", "net_or_gross")), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/tax_basis", code: "invalid", + }, + { + name: "update with a negative salary bound", + request: update(`"salary":` + needSalary("-1000", "160000", "gross")), + location: api.ProblemFieldLocationBody, pointer: "/salary/value/salary_from", code: "invalid", + }, + } { + t.Run(test.name, func(t *testing.T) { + logger := slog.New(slog.DiscardHandler) + healthHandler := newTestHealthHandler(func(context.Context) error { return nil }) + router, err := NewRouter(healthHandler, v1.NewHandler(healthHandler, problem.NewResponder(logger)), &recordingSecurity{}, problem.NewResponder(logger), metrics.New(), logger) + if err != nil { + t.Fatalf("NewRouter() error = %v", err) + } + response := serveIdentityRequest(t, router, test.request) + + if test.code == "" { + requireProblem(t, response, http.StatusNotImplemented, api.ProblemCodeNotImplemented) + return + } + body := requireProblem(t, response, http.StatusBadRequest, api.ProblemCodeValidationFailed) + want := api.ProblemFieldError{In: test.location, Pointer: test.pointer, Code: test.code} + for _, field := range body.Errors { + if field.In == want.In && field.Pointer == want.Pointer && field.Code == want.Code { + return + } + } + t.Fatalf("errors = %+v, want an entry %+v", body.Errors, want) + }) + } +} + +// A non-nullable optional list decodes to a plain slice, so an +// UpdateOrganizationNeed handler tells an absent list (unchanged) from an +// empty one (delete every item) only by nil; null is not a list and fails. +func TestNeedUpdateDecodingKeepsAbsentAndEmptyListsApart(t *testing.T) { + var empty api.NeedUpdate + if err := empty.UnmarshalJSON([]byte(`{"expected_version":1,"tasks":[]}`)); err != nil { + t.Fatalf("decode an empty list: %v", err) + } + if empty.Tasks == nil || len(empty.Tasks) != 0 { + t.Fatalf("tasks = %#v, want a non-nil empty slice", empty.Tasks) + } + + var absent api.NeedUpdate + if err := absent.UnmarshalJSON([]byte(`{"expected_version":1}`)); err != nil { + t.Fatalf("decode an absent list: %v", err) + } + if absent.Tasks != nil || absent.RequiredSkills != nil || absent.DesiredSkills != nil { + t.Fatalf("lists = %#v %#v %#v, want nil for absent fields", absent.Tasks, absent.RequiredSkills, absent.DesiredSkills) + } + if absent.Grade.IsSet() || absent.Salary.IsSet() { + t.Fatal("absent field decisions are set, want unset") + } + + var cleared api.NeedUpdate + if err := cleared.UnmarshalJSON([]byte(`{"expected_version":1,"grade":null}`)); err != nil { + t.Fatalf("decode a null field decision: %v", err) + } + if !cleared.Grade.IsSet() || !cleared.Grade.IsNull() { + t.Fatal("grade sent as null is not a set null, want a removal") + } + + var null api.NeedUpdate + if err := null.UnmarshalJSON([]byte(`{"expected_version":1,"tasks":null}`)); err == nil { + t.Fatal("decode a list sent as null succeeded, want an error") + } +} + +// Every need operation requires an employer session; DenyAllSecurity grants +// none, with or without a cookie and a CSRF token. +func TestNeedAccessBeforeImplementation(t *testing.T) { + session := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken} + command := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken, "Idempotency-Key": testIdempotencyKey} + for _, test := range []identityRequest{ + {method: http.MethodGet, path: organizationNeedsPath}, + {method: http.MethodGet, path: organizationNeedsPath, headers: map[string]string{"Cookie": testSessionCookie}}, + {method: http.MethodPost, path: organizationNeedsPath, body: validNeedCreate, headers: command}, + {method: http.MethodGet, path: organizationNeedPath}, + {method: http.MethodPatch, path: organizationNeedPath, body: needUpdateBody(`"grade":{"value":"middle","status":"confirmed"}`), headers: session}, + } { + t.Run(test.method+" "+test.path, func(t *testing.T) { + router := newTestRouter(t, func(context.Context) error { return nil }) + requireProblem(t, serveIdentityRequest(t, router, test), http.StatusUnauthorized, api.ProblemCodeUnauthenticated) + }) + } +} + func TestPublicOperationInternalErrorIsLoggedButNotExposed(t *testing.T) { var logs bytes.Buffer logger := slog.New(slog.NewJSONHandler(&logs, nil)) diff --git a/docs/en/ARCHITECTURE.md b/docs/en/ARCHITECTURE.md index f2cfe6b..54533c1 100644 --- a/docs/en/ARCHITECTURE.md +++ b/docs/en/ARCHITECTURE.md @@ -338,7 +338,7 @@ Candidate flow: verify email -> complete profile and consent -> answer questionn Employer flow: verify email -> create company profile -> describe need -> confirm extracted skills -> choose filters -> review an explainable result set -> send a salary offer -> candidate accepts -> only that company can access contacts. -An invitation includes the employer, description, contact channel, both salary bounds, and RUB currency. Both salary values are required and must satisfy 0 < salary_from <= salary_to. Show the pay period and tax basis. vacancy_id is optional. Main transitions are sent -> viewed -> accepted or declined; direct acceptance from sent is allowed. withdrawn and expired are additional states. Retries are idempotent, and transactions protect concurrent state changes. +An invitation includes the employer, description, contact channel, both salary bounds, and RUB currency. Both salary values are required whole rubles in multiples of 1000 and must satisfy 0 < salary_from < salary_to, with a width (salary_to - salary_from) / ((salary_from + salary_to) / 2) from 10% to 40% inclusive (PRD FR13); the same rule applies to the salary range of a need. Show the pay period and tax basis (net or gross). vacancy_id is optional. Main transitions are sent -> viewed -> accepted or declined; direct acceptance from sent is allowed. withdrawn and expired are additional states. Retries are idempotent, and transactions protect concurrent state changes. A contact grant belongs to one candidate-company pair and is created after an accepted invitation or a candidate's own application. The server checks the user, company membership, grant, and current visibility on each read. Before a grant, employers receive no contacts, original PDF, messaging links, or contact fragments from resumes or ML. diff --git a/docs/ru/ARCHITECTURE.md b/docs/ru/ARCHITECTURE.md index 2764dfd..5cb3be4 100644 --- a/docs/ru/ARCHITECTURE.md +++ b/docs/ru/ARCHITECTURE.md @@ -338,7 +338,7 @@ backend/ Целевой сценарий работодателя: подтверждение email -> профиль компании -> описание потребности -> выбор или подтверждение извлеченных навыков -> фильтры и объяснимая подборка -> предложение с диапазоном зарплаты -> принятие кандидатом -> контактный доступ только этой компании. -Приглашение содержит работодателя, описание, способ связи, обе границы зарплаты и валюту RUB. 0 < salary_from <= salary_to; период и налоги показываются явно. vacancy_id необязателен. Базовые переходы: sent -> viewed -> accepted или declined; принять можно также из sent. withdraw и expire - дополнительные состояния. Повторные операции идемпотентны, конкурирующие переходы защищены транзакцией и текущей версией. +Приглашение содержит работодателя, описание, способ связи, обе границы зарплаты и валюту RUB. Обе границы - целые рубли, кратные 1000, 0 < salary_from < salary_to, ширина (salary_to - salary_from) / ((salary_from + salary_to) / 2) от 10% до 40% включительно (FR13 в PRD); то же правило действует для вилки потребности. Период и база налога (net или gross) показываются явно. vacancy_id необязателен. Базовые переходы: sent -> viewed -> accepted или declined; принять можно также из sent. withdraw и expire - дополнительные состояния. Повторные операции идемпотентны, конкурирующие переходы защищены транзакцией и текущей версией. contact_grant относится к паре кандидат-компания и создается после принятого приглашения или собственного отклика кандидата. Сервер проверяет пользователя, компанию, grant и актуальную видимость при каждом чтении. До grant работодатель не получает контакты, оригинальный PDF, мессенджеры или контактные фрагменты из резюме и ML. diff --git a/frontend/src/shared/api/endpoints/index.msw.ts b/frontend/src/shared/api/endpoints/index.msw.ts index a596a37..26efec2 100644 --- a/frontend/src/shared/api/endpoints/index.msw.ts +++ b/frontend/src/shared/api/endpoints/index.msw.ts @@ -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' diff --git a/frontend/src/shared/api/endpoints/index.ts b/frontend/src/shared/api/endpoints/index.ts index c890676..bc8d7e2 100644 --- a/frontend/src/shared/api/endpoints/index.ts +++ b/frontend/src/shared/api/endpoints/index.ts @@ -3,3 +3,4 @@ export * from './candidate/candidate'; export * from './catalog/catalog'; export * from './health/health'; export * from './identity/identity'; +export * from './need/need'; diff --git a/frontend/src/shared/api/endpoints/need/need.msw.ts b/frontend/src/shared/api/endpoints/need/need.msw.ts new file mode 100644 index 0000000..5e2e8b4 --- /dev/null +++ b/frontend/src/shared/api/endpoints/need/need.msw.ts @@ -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 => ({...{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> = {}): 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 => ({...{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 => ({...{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> = {}): 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({ length: faker.number.int({min: 1, max: 10}) }, (_, i) => i + 1).map(() => ({specialization: faker.helpers.arrayElement(Object.values(SpecializationCode)), grade: faker.helpers.arrayElement(Object.values(GradeCode)), score: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null]), skill_overlap: {share: faker.number.float({min: 0, max: 1, fractionDigits: 2}), covered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"))), uncovered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$")))}, money: {status: faker.helpers.arrayElement(Object.values(NeedMoneyStatus)), share: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null])}, supply: faker.helpers.arrayElement(Object.values(NeedSupplyBand))}))}, created_at: faker.date.past().toISOString().slice(0, 19) + 'Z', updated_at: faker.date.past().toISOString().slice(0, 19) + 'Z', ...overrideResponse}) + +export const getGetOrganizationNeedResponseNeedValueSourceMock = (overrideResponse: Partial = {}): 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 => ({...{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> = {}): 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.int({min: 1, max: 10}) }, (_, i) => i + 1).map(() => ({specialization: faker.helpers.arrayElement(Object.values(SpecializationCode)), grade: faker.helpers.arrayElement(Object.values(GradeCode)), score: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null]), skill_overlap: {share: faker.number.float({min: 0, max: 1, fractionDigits: 2}), covered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"))), uncovered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$")))}, money: {status: faker.helpers.arrayElement(Object.values(NeedMoneyStatus)), share: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null])}, supply: faker.helpers.arrayElement(Object.values(NeedSupplyBand))}))}, created_at: faker.date.past().toISOString().slice(0, 19) + 'Z', updated_at: faker.date.past().toISOString().slice(0, 19) + 'Z', ...overrideResponse}) + +export const getUpdateOrganizationNeedResponseNeedValueSourceMock = (overrideResponse: Partial = {}): 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 => ({...{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> = {}): 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({ length: faker.number.int({min: 1, max: 10}) }, (_, i) => i + 1).map(() => ({specialization: faker.helpers.arrayElement(Object.values(SpecializationCode)), grade: faker.helpers.arrayElement(Object.values(GradeCode)), score: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null]), skill_overlap: {share: faker.number.float({min: 0, max: 1, fractionDigits: 2}), covered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$"))), uncovered_skills: Array.from({ length: faker.number.int({min: 1, max: 60}) }, (_, i) => i + 1).map(() => (faker.helpers.fromRegExp("^\\S(?:.*\\S)?$")))}, money: {status: faker.helpers.arrayElement(Object.values(NeedMoneyStatus)), share: faker.helpers.arrayElement([faker.number.float({min: 0, max: 1, fractionDigits: 2}), null])}, supply: faker.helpers.arrayElement(Object.values(NeedSupplyBand))}))}, created_at: faker.date.past().toISOString().slice(0, 19) + 'Z', updated_at: faker.date.past().toISOString().slice(0, 19) + 'Z', ...overrideResponse}) + + +export const getListOrganizationNeedsMockHandler = (overrideResponse?: NeedList | ((info: Parameters[1]>[0]) => Promise | NeedList), options?: RequestHandlerOptions) => { + return http.get('*/api/v1/organizations/:orgId/needs', async (info: Parameters[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[1]>[0]) => Promise | Need), options?: RequestHandlerOptions) => { + return http.post('*/api/v1/organizations/:orgId/needs', async (info: Parameters[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[1]>[0]) => Promise | Need), options?: RequestHandlerOptions) => { + return http.get('*/api/v1/organizations/:orgId/needs/:needId', async (info: Parameters[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[1]>[0]) => Promise | Need), options?: RequestHandlerOptions) => { + return http.patch('*/api/v1/organizations/:orgId/needs/:needId', async (info: Parameters[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() +] diff --git a/frontend/src/shared/api/endpoints/need/need.ts b/frontend/src/shared/api/endpoints/need/need.ts new file mode 100644 index 0000000..abbe76c --- /dev/null +++ b/frontend/src/shared/api/endpoints/need/need.ts @@ -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 unknown> = Parameters[1]; + + + +const withQueryKey = (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)[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[1]): Promise => { + + return apiRequest(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 = >, TError = ErrorType>(orgId: string, + params?: ListOrganizationNeedsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getListOrganizationNeedsQueryKey(orgId,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => listOrganizationNeeds(orgId,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: orgId !== null && orgId !== undefined, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type ListOrganizationNeedsQueryResult = NonNullable>> +export type ListOrganizationNeedsQueryError = ErrorType + + +export function useListOrganizationNeeds>, TError = ErrorType>( + orgId: string, + params: undefined | ListOrganizationNeedsParams, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useListOrganizationNeeds>, TError = ErrorType>( + orgId: string, + params?: ListOrganizationNeedsParams, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useListOrganizationNeeds>, TError = ErrorType>( + orgId: string, + params?: ListOrganizationNeedsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary List the needs of an organization. + */ + +export function useListOrganizationNeeds>, TError = ErrorType>( + orgId: string, + params?: ListOrganizationNeedsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getListOrganizationNeedsQueryOptions(orgId,params,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + 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[1]): Promise => { + + const getHeaders = (h?: NonNullable): Record => { + 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>, (entry) => Array.from(entry) as [string, string]), + ); + } + const headers: Record = {}; + for (const [name, value] of Object.entries(h)) { + if (value !== undefined) headers[name] = value; + } + return headers; + }; +return apiRequest(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 = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,CreateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter} +): UseMutationOptions>, 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>, CreateOrganizationNeedMutationVariables> = (props) => { + const {orgId,data,headers} = props ?? {}; + + return createOrganizationNeed(orgId,data,headers,requestOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type CreateOrganizationNeedMutationResult = NonNullable>> + export type CreateOrganizationNeedMutationBody = NeedCreate + export type CreateOrganizationNeedMutationError = ErrorType + 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 = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,CreateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + 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[1]): Promise => { + + return apiRequest(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 = >, TError = ErrorType>(orgId: string, + needId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOrganizationNeedQueryKey(orgId,needId); + + + + const queryFn: QueryFunction>> = ({ signal }) => getOrganizationNeed(orgId,needId, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: orgId !== null && orgId !== undefined && needId !== null && needId !== undefined, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type GetOrganizationNeedQueryResult = NonNullable>> +export type GetOrganizationNeedQueryError = ErrorType + + +export function useGetOrganizationNeed>, TError = ErrorType>( + orgId: string, + needId: string, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetOrganizationNeed>, TError = ErrorType>( + orgId: string, + needId: string, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useGetOrganizationNeed>, TError = ErrorType>( + orgId: string, + needId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Read the current version of a need of an organization. + */ + +export function useGetOrganizationNeed>, TError = ErrorType>( + orgId: string, + needId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getGetOrganizationNeedQueryOptions(orgId,needId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + 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[1]): Promise => { + + const getHeaders = (h?: NonNullable): Record => { + 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>, (entry) => Array.from(entry) as [string, string]), + ); + } + const headers: Record = {}; + for (const [name, value] of Object.entries(h)) { + if (value !== undefined) headers[name] = value; + } + return headers; + }; +return apiRequest(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 = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,UpdateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter} +): UseMutationOptions>, 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>, UpdateOrganizationNeedMutationVariables> = (props) => { + const {orgId,needId,data} = props ?? {}; + + return updateOrganizationNeed(orgId,needId,data,requestOptions) + } + + + + + + + return { mutationFn, ...mutationOptions }} + + export type UpdateOrganizationNeedMutationResult = NonNullable>> + export type UpdateOrganizationNeedMutationBody = NeedUpdate + export type UpdateOrganizationNeedMutationError = ErrorType + export type UpdateOrganizationNeedMutationVariables = {orgId: string;needId: string;data: NeedUpdate} + + /** + * @summary Confirm, change, or delete requirements of a need. + */ +export const useUpdateOrganizationNeed = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,UpdateOrganizationNeedMutationVariables, TContext>, request?: SecondParameter} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + TError, + UpdateOrganizationNeedMutationVariables, + TContext + > => { + return useMutation(getUpdateOrganizationNeedMutationOptions(options), queryClient); + } diff --git a/frontend/src/shared/api/needs-contract.test.ts b/frontend/src/shared/api/needs-contract.test.ts new file mode 100644 index 0000000..750907d --- /dev/null +++ b/frontend/src/shared/api/needs-contract.test.ts @@ -0,0 +1,343 @@ +import { describe, expect, expectTypeOf, it } from "vitest"; +import { createOrganizationNeed, updateOrganizationNeed } from "./endpoints/need/need"; +import { + CreateOrganizationNeedBody, + Need, + NeedCategoryRecommendation, + NeedCreate, + NeedUpdate, + SalaryRange, + UpdateOrganizationNeedBody, +} from "./schemas"; + +// These tests pin the generated need contract that the FSD adapters consume. +// They fail when regeneration drops a salary limit, an unknown state, or the +// explicit confirmation status of a field, or adds a request field that would +// let an employer set membership, a candidate's minimum, or a ready +// recommendation score. + +const salary = { + salary_from: 120000, + salary_to: 160000, + currency: "RUB", + period: "month", + tax_basis: "net", +} as const; + +const manualNeed = { + title: "Junior Go-разработчик для сервиса уведомлений", + specialization: { value: "backend", status: "confirmed" }, + grade: { value: "junior", status: "confirmed" }, + required_skills: [ + { name: "Go", status: "confirmed" }, + { name: "PostgreSQL", status: "confirmed" }, + ], + desired_skills: [{ name: "Docker", status: "confirmed" }], + tasks: [{ text: "Поддерживать и развивать сервис уведомлений", status: "confirmed" }], + work_formats: { value: ["hybrid"], status: "confirmed" }, + location: { value: "Москва", status: "confirmed" }, + salary: { value: salary, status: "confirmed" }, +} as const; + +const createSchemas = [ + ["NeedCreate", NeedCreate], + ["CreateOrganizationNeedBody", CreateOrganizationNeedBody], +] as const; + +describe.each(createSchemas)("generated %s", (_name, schema) => { + it("accepts a manual need without a vacancy", () => { + const parsed = schema.parse(manualNeed); + + expect(parsed).not.toHaveProperty("vacancy_id"); + expect(parsed.salary).toEqual({ value: salary, status: "confirmed" }); + }); + + it("accepts a need from a title and a text only", () => { + const parsed = schema.parse({ title: "Backend", source_text: "Ищем бэкенд-разработчика." }); + + expect(parsed).toEqual({ title: "Backend", source_text: "Ищем бэкенд-разработчика." }); + }); + + it("keeps an explicit null as a field without a value", () => { + const parsed = schema.parse({ title: "Backend", vacancy_id: null, grade: null, salary: null }); + + expect(parsed).toEqual({ title: "Backend", vacancy_id: null, grade: null, salary: null }); + }); + + it("requires a title", () => { + const result = schema.safeParse({ specialization: { value: "backend", status: "confirmed" } }); + + expect(result.success).toBe(false); + expect(result.error?.issues).toEqual([expect.objectContaining({ path: ["title"] })]); + }); + + it.each([ + ["a bare value", "junior"], + ["a value without a status", { value: "junior" }], + ["an unknown status", { value: "junior", status: "unknown" }], + ["a grade outside the scale", { value: "lead", status: "confirmed" }], + ])("rejects a grade decision with %s", (_case, grade) => { + const result = schema.safeParse({ ...manualNeed, grade }); + + expect(result.success).toBe(false); + expect(result.error?.issues).toEqual([ + expect.objectContaining({ path: expect.arrayContaining(["grade"]) }), + ]); + }); + + it.each([ + ["a zero lower bound", { salary_from: 0 }, "salary_from"], + ["a negative lower bound", { salary_from: -1000 }, "salary_from"], + ["a bound that is not a multiple of 1000", { salary_to: 160500 }, "salary_to"], + ["a fractional bound", { salary_to: 160000.5 }, "salary_to"], + ["another currency", { currency: "USD" }, "currency"], + ["an hourly period", { period: "hour" }, "period"], + ["an unknown tax basis", { tax_basis: "after_tax" }, "tax_basis"], + ])("rejects a salary with %s", (_case, change, field) => { + const range = { ...salary, ...change }; + const result = schema.safeParse({ + ...manualNeed, + salary: { value: range, status: "confirmed" }, + }); + + // The nullable salary is a union, so Zod reports some failures on the + // union and others on the field; the range schema itself names the field. + expect(result.success).toBe(false); + expect(result.error?.issues).toEqual([ + expect.objectContaining({ path: expect.arrayContaining(["salary"]) }), + ]); + expect(SalaryRange.safeParse(range).error?.issues).toEqual([ + expect.objectContaining({ path: [field] }), + ]); + }); + + it("rejects a salary without a tax basis or without a decision", () => { + const withoutBasis = { + salary_from: salary.salary_from, + salary_to: salary.salary_to, + currency: salary.currency, + period: salary.period, + }; + + expect( + schema.safeParse({ ...manualNeed, salary: { value: withoutBasis, status: "confirmed" } }) + .success, + ).toBe(false); + expect(schema.safeParse({ ...manualNeed, salary }).success).toBe(false); + }); + + it("leaves the cross-field salary rules to the server", () => { + // A < B and the 10-40% width compare two fields; the server answers 400 + // with the pointer /salary/value/salary_to. + for (const [from, to] of [ + [150000, 150000], + [100000, 200000], + ]) { + const range = { ...salary, salary_from: from, salary_to: to }; + + expect(SalaryRange.safeParse(range).success).toBe(true); + } + }); + + it("rejects an unknown item status and empty work formats", () => { + expect( + schema.safeParse({ ...manualNeed, required_skills: [{ name: "Go", status: "unknown" }] }) + .success, + ).toBe(false); + expect( + schema.safeParse({ ...manualNeed, work_formats: { value: [], status: "confirmed" } }).success, + ).toBe(false); + }); + + it("never carries membership, a candidate minimum, or a score in the parsed body", () => { + const parsed = schema.parse({ + ...manualNeed, + rec_score: 0.99, + members: [{ user_id: "01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01", role: "owner" }], + candidate_minimum: 130000, + salary: { value: { ...salary, candidate_minimum: 130000 }, status: "confirmed" }, + }); + + // Generated Zod strips unknown keys; the server rejects them with 400. + expect(parsed).not.toHaveProperty("rec_score"); + expect(parsed).not.toHaveProperty("members"); + expect(parsed).not.toHaveProperty("candidate_minimum"); + expect(parsed.salary?.value).not.toHaveProperty("candidate_minimum"); + }); +}); + +const updateSchemas = [ + ["NeedUpdate", NeedUpdate], + ["UpdateOrganizationNeedBody", UpdateOrganizationNeedBody], +] as const; + +describe.each(updateSchemas)("generated %s", (_name, schema) => { + it("confirms suggestions and keeps others open explicitly", () => { + const parsed = schema.parse({ + expected_version: 1, + specialization: { value: "backend", status: "confirmed" }, + grade: { value: "middle", status: "confirmed" }, + domain: { value: "платежи", status: "extracted" }, + required_skills: [{ name: "Temporal", status: "confirmed" }], + desired_skills: [{ name: "Kafka", status: "extracted" }], + salary: { value: { ...salary, tax_basis: "gross" }, status: "confirmed" }, + }); + + expect(parsed.domain).toEqual({ value: "платежи", status: "extracted" }); + expect(parsed.desired_skills).toEqual([{ name: "Kafka", status: "extracted" }]); + }); + + it("keeps null, which removes a requirement, apart from an absent field", () => { + const parsed = schema.parse({ expected_version: 3, grade: null, salary: null, tasks: [] }); + + expect(parsed).toEqual({ expected_version: 3, grade: null, salary: null, tasks: [] }); + expect(parsed).not.toHaveProperty("specialization"); + }); + + it("rejects a list sent as null", () => { + expect(schema.safeParse({ expected_version: 3, tasks: null }).success).toBe(false); + }); + + it.each([ + ["missing", {}], + ["zero", { expected_version: 0 }], + ["fractional", { expected_version: 1.5 }], + ["text", { expected_version: "1" }], + ])("rejects an expected_version that is %s", (_case, version) => { + const result = schema.safeParse({ ...version, grade: null }); + + expect(result.success).toBe(false); + expect(result.error?.issues).toEqual([expect.objectContaining({ path: ["expected_version"] })]); + }); +}); + +it("parses a need whose unknown fields stay null instead of guessed values", () => { + const unknown = { status: "unknown", value: null, source: null } as const; + const parsed = Need.parse({ + id: "01928f7a-3c4d-7e5f-8a6b-7c8d9e0f1a23", + organization_id: "01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01", + vacancy_id: null, + title: "Backend в команду платежей", + source_text: "Ищем бэкенд-разработчика. Обязательно: Go и Temporal.", + version: 1, + requirements_version: 1, + requirements: { + specialization: { + status: "extracted", + value: "backend", + source: { + origin: "extracted_from_text", + quote: "Ищем бэкенд-разработчика", + extracted_in_version: 1, + extraction_version: "need-rules.2026-10.1", + }, + }, + grade: unknown, + required_skills: [ + { + name: "Temporal", + taxonomy_code: null, + status: "extracted", + source: { + origin: "extracted_from_text", + quote: "Обязательно: Go и Temporal", + extracted_in_version: 1, + extraction_version: "need-rules.2026-10.1", + }, + }, + ], + desired_skills: [], + tasks: [], + domain: unknown, + work_formats: unknown, + location: unknown, + salary: unknown, + }, + readiness: { + status: "incomplete", + missing_fields: [ + { + field: "grade", + reason: "unknown", + question: "Какой грейд нужен: Intern, Junior, Middle или Senior?", + }, + ], + }, + recommendations: { + status: "not_available", + requirements_version: 1, + policy_version: null, + algorithm_version: null, + computed_at: null, + categories: [], + }, + created_at: "2026-10-06T09:00:00Z", + updated_at: "2026-10-06T09:00:00Z", + }); + + expect(parsed.requirements.grade).toEqual(unknown); + expect(parsed.requirements.salary.value).toBeNull(); + expect(parsed.requirements.required_skills[0]?.taxonomy_code).toBeNull(); + expect(parsed.requirements.required_skills[0]?.source.extracted_in_version).toBe(1); +}); + +it("parses a recommendation whose small group hides the score", () => { + const parsed = NeedCategoryRecommendation.parse({ + specialization: "backend", + grade: "intern", + score: null, + skill_overlap: { share: 0.8, covered_skills: ["Go"], uncovered_skills: ["Docker"] }, + money: { status: "withheld", share: null }, + supply: "fewer_than_5", + }); + + expect(parsed.score).toBeNull(); + expect( + NeedCategoryRecommendation.safeParse({ ...parsed, money: { status: "hidden", share: null } }) + .success, + ).toBe(false); +}); + +type ForbiddenRequestKey = + | "rec_score" + | "score" + | "recommendations" + | "candidate_minimum" + | "salary_minimum" + | "minimum" + | "members" + | "membership" + | "role" + | "organization_id" + | "version" + | "requirements_version" + | "readiness" + | "source" + | "origin" + | "quote"; + +type ItemOf = T extends readonly (infer Item)[] ? Item : never; + +it("exposes request DTOs without membership, candidate minimum, or recommendation fields", () => { + expectTypeOf>().toEqualTypeOf(); + expectTypeOf>().toEqualTypeOf(); + expectTypeOf< + Extract, ForbiddenRequestKey> + >().toEqualTypeOf(); + expectTypeOf< + Extract["value"], ForbiddenRequestKey> + >().toEqualTypeOf(); + expectTypeOf< + Extract, ForbiddenRequestKey> + >().toEqualTypeOf(); + expectTypeOf< + Extract>, ForbiddenRequestKey> + >().toEqualTypeOf(); + // A field decision always carries an explicit status, so a round-tripped + // form cannot confirm a suggestion without saying so. + expectTypeOf["status"]>().toEqualTypeOf< + "confirmed" | "extracted" + >(); + expectTypeOf(createOrganizationNeed).parameter(1).toEqualTypeOf(); + expectTypeOf(updateOrganizationNeed).parameter(2).toEqualTypeOf(); +}); diff --git a/frontend/src/shared/api/schemas/candidate/index.ts b/frontend/src/shared/api/schemas/candidate/index.ts index 8b8b710..b974317 100644 --- a/frontend/src/shared/api/schemas/candidate/index.ts +++ b/frontend/src/shared/api/schemas/candidate/index.ts @@ -13,4 +13,3 @@ export * from './questionnaireVersion.zod'; export * from './saveMyQuestionnaireBody.zod'; export * from './stackTag.zod'; export * from './workContext.zod'; -export * from './workFormat.zod'; diff --git a/frontend/src/shared/api/schemas/index.ts b/frontend/src/shared/api/schemas/index.ts index 4211c22..aca2779 100644 --- a/frontend/src/shared/api/schemas/index.ts +++ b/frontend/src/shared/api/schemas/index.ts @@ -6,7 +6,6 @@ */ export * from './gradeCode.zod'; -export * from './pageInfo.zod'; export * from './problem.zod'; export * from './problemCode.zod'; export * from './problemFieldError.zod'; @@ -14,8 +13,10 @@ export * from './problemFieldLocation.zod'; export * from './specializationCode.zod'; export * from './taskLanguage.zod'; export * from './timestamp.zod'; +export * from './workFormat.zod'; export * from './assessment'; export * from './candidate'; export * from './catalog'; export * from './health'; export * from './identity'; +export * from './need'; diff --git a/frontend/src/shared/api/schemas/need/createOrganizationNeedBody.zod.ts b/frontend/src/shared/api/schemas/need/createOrganizationNeedBody.zod.ts new file mode 100644 index 0000000..b60683f --- /dev/null +++ b/frontend/src/shared/api/schemas/need/createOrganizationNeedBody.zod.ts @@ -0,0 +1,101 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const createOrganizationNeedBodyTitleMax = 200; + + +export const createOrganizationNeedBodyTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodySourceTextOneMax = 10000; + +export const createOrganizationNeedBodyRequiredSkillsItemNameMax = 100; + + +export const createOrganizationNeedBodyRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodyRequiredSkillsMax = 30; + +export const createOrganizationNeedBodyDesiredSkillsItemNameMax = 100; + + +export const createOrganizationNeedBodyDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodyDesiredSkillsMax = 30; + +export const createOrganizationNeedBodyTasksItemTextMax = 300; + + +export const createOrganizationNeedBodyTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodyTasksMax = 20; + +export const createOrganizationNeedBodyDomainOneValueMax = 100; + + +export const createOrganizationNeedBodyDomainOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodyWorkFormatsOneValueMax = 3; + +export const createOrganizationNeedBodyLocationOneValueMax = 100; + + +export const createOrganizationNeedBodyLocationOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const createOrganizationNeedBodySalaryOneValueSalaryFromMin = 1000; +export const createOrganizationNeedBodySalaryOneValueSalaryFromMax = 100000000; +export const createOrganizationNeedBodySalaryOneValueSalaryFromMultipleOf = 1000; + +export const createOrganizationNeedBodySalaryOneValueSalaryToMin = 1000; +export const createOrganizationNeedBodySalaryOneValueSalaryToMax = 100000000; +export const createOrganizationNeedBodySalaryOneValueSalaryToMultipleOf = 1000; + + +export const CreateOrganizationNeedBody = zod.object({ + "title": zod.string().min(1).max(createOrganizationNeedBodyTitleMax).regex(createOrganizationNeedBodyTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "vacancy_id": zod.uuid().nullish().describe('Vacancy of the same organization to link, or null or absent for a need without a vacancy.'), + "source_text": zod.union([zod.string().min(1).max(createOrganizationNeedBodySourceTextOneMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).'),zod.null()]).exactOptional(), + "specialization": zod.union([zod.object({ + "value": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the specialization in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "grade": zod.union([zod.object({ + "value": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the grade in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(createOrganizationNeedBodyRequiredSkillsItemNameMax).regex(createOrganizationNeedBodyRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(createOrganizationNeedBodyRequiredSkillsMax).exactOptional(), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(createOrganizationNeedBodyDesiredSkillsItemNameMax).regex(createOrganizationNeedBodyDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(createOrganizationNeedBodyDesiredSkillsMax).exactOptional(), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(createOrganizationNeedBodyTasksItemTextMax).regex(createOrganizationNeedBodyTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput.')).max(createOrganizationNeedBodyTasksMax).exactOptional(), + "domain": zod.union([zod.object({ + "value": zod.string().min(1).max(createOrganizationNeedBodyDomainOneValueMax).regex(createOrganizationNeedBodyDomainOneValueRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the domain in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "work_formats": zod.union([zod.object({ + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(createOrganizationNeedBodyWorkFormatsOneValueMax), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set.'),zod.null()]).exactOptional(), + "location": zod.union([zod.object({ + "value": zod.string().min(1).max(createOrganizationNeedBodyLocationOneValueMax).regex(createOrganizationNeedBodyLocationOneValueRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the place of work in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "salary": zod.union([zod.object({ + "value": zod.object({ + "salary_from": zod.int().min(createOrganizationNeedBodySalaryOneValueSalaryFromMin).max(createOrganizationNeedBodySalaryOneValueSalaryFromMax).multipleOf(createOrganizationNeedBodySalaryOneValueSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(createOrganizationNeedBodySalaryOneValueSalaryToMin).max(createOrganizationNeedBodySalaryOneValueSalaryToMax).multipleOf(createOrganizationNeedBodySalaryOneValueSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`.'),zod.null()]).exactOptional() +}).describe('New need. Only `title` is required, so a need can start from a title, from a text, or from form fields, and with or without a vacancy. A field or list item given here must have `status` `confirmed` and becomes a confirmed manual value; `extracted` answers 400 with the pointer of that `status`, such as `/grade/status`, because a new need has no stored suggestion. A field that is absent is extracted from `source_text` when the text is given and is left unknown or empty otherwise. A nullable field sent as null, and a skill or task list sent as an empty list, stays unknown or empty and is not extracted; an empty `work_formats` value fails `minItems`. Unknown fields are rejected, so a request cannot set membership, a role, a status of the need, a provenance, readiness, a recommendation or its score, or a candidate\'s salary minimum.') + +export type CreateOrganizationNeedBody = zod.input; +export type CreateOrganizationNeedBodyOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/createOrganizationNeedHeaders.zod.ts b/frontend/src/shared/api/schemas/need/createOrganizationNeedHeaders.zod.ts new file mode 100644 index 0000000..71fbdda --- /dev/null +++ b/frontend/src/shared/api/schemas/need/createOrganizationNeedHeaders.zod.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const createOrganizationNeedHeadersIdempotencyKeyMax = 255; + + +export const createOrganizationNeedHeadersIdempotencyKeyRegExp = new RegExp('^[A-Za-z0-9._:-]+$'); + +export const CreateOrganizationNeedHeaders = zod.object({ + "Idempotency-Key": zod.string().min(1).max(createOrganizationNeedHeadersIdempotencyKeyMax).regex(createOrganizationNeedHeadersIdempotencyKeyRegExp) +}) + +export type CreateOrganizationNeedHeaders = zod.input; +export type CreateOrganizationNeedHeadersOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/currencyCode.zod.ts b/frontend/src/shared/api/schemas/need/currencyCode.zod.ts new file mode 100644 index 0000000..67bd773 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/currencyCode.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const CurrencyCode = zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.') + +export type CurrencyCode = zod.input; +export type CurrencyCodeOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/index.ts b/frontend/src/shared/api/schemas/need/index.ts new file mode 100644 index 0000000..622cde7 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/index.ts @@ -0,0 +1,65 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ + +export * from './createOrganizationNeedBody.zod'; +export * from './createOrganizationNeedHeaders.zod'; +export * from './currencyCode.zod'; +export * from './listOrganizationNeedsParams.zod'; +export * from './need.zod'; +export * from './needCategoryRecommendation.zod'; +export * from './needCategoryRecommendations.zod'; +export * from './needCreate.zod'; +export * from './needDomain.zod'; +export * from './needDomainInput.zod'; +export * from './needDomainName.zod'; +export * from './needFieldName.zod'; +export * from './needGrade.zod'; +export * from './needGradeInput.zod'; +export * from './needItemStatus.zod'; +export * from './needList.zod'; +export * from './needLocation.zod'; +export * from './needLocationInput.zod'; +export * from './needLocationName.zod'; +export * from './needMissingField.zod'; +export * from './needMissingReason.zod'; +export * from './needMoneyFit.zod'; +export * from './needMoneyStatus.zod'; +export * from './needReadinessReport.zod'; +export * from './needReadinessStatus.zod'; +export * from './needRecommendationStatus.zod'; +export * from './needRequirementSet.zod'; +export * from './needSalary.zod'; +export * from './needSalaryInput.zod'; +export * from './needSkill.zod'; +export * from './needSkillInput.zod'; +export * from './needSkillOverlap.zod'; +export * from './needSourceQuote.zod'; +export * from './needSourceText.zod'; +export * from './needSpecialization.zod'; +export * from './needSpecializationInput.zod'; +export * from './needSummary.zod'; +export * from './needSupplyBand.zod'; +export * from './needTask.zod'; +export * from './needTaskInput.zod'; +export * from './needTaskText.zod'; +export * from './needTitle.zod'; +export * from './needUpdate.zod'; +export * from './needValueOrigin.zod'; +export * from './needValueSource.zod'; +export * from './needValueStatus.zod'; +export * from './needVersion.zod'; +export * from './needVersionLabel.zod'; +export * from './needWorkFormats.zod'; +export * from './needWorkFormatsInput.zod'; +export * from './pageInfo.zod'; +export * from './rubAmount.zod'; +export * from './salaryPeriod.zod'; +export * from './salaryRange.zod'; +export * from './salaryTaxBasis.zod'; +export * from './skillName.zod'; +export * from './skillTaxonomyCode.zod'; +export * from './updateOrganizationNeedBody.zod'; diff --git a/frontend/src/shared/api/schemas/need/listOrganizationNeedsParams.zod.ts b/frontend/src/shared/api/schemas/need/listOrganizationNeedsParams.zod.ts new file mode 100644 index 0000000..7dd03c3 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/listOrganizationNeedsParams.zod.ts @@ -0,0 +1,23 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const listOrganizationNeedsParamsLimitDefault = 20; +export const listOrganizationNeedsParamsLimitMax = 100; + +export const listOrganizationNeedsParamsCursorMax = 512; + + +export const listOrganizationNeedsParamsCursorRegExp = new RegExp('^[A-Za-z0-9_-]+$'); + +export const ListOrganizationNeedsParams = zod.object({ + "limit": zod.int().min(1).max(listOrganizationNeedsParamsLimitMax).default(listOrganizationNeedsParamsLimitDefault), + "cursor": zod.string().min(1).max(listOrganizationNeedsParamsCursorMax).regex(listOrganizationNeedsParamsCursorRegExp).exactOptional() +}) + +export type ListOrganizationNeedsParams = zod.input; +export type ListOrganizationNeedsParamsOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/need.zod.ts b/frontend/src/shared/api/schemas/need/need.zod.ts new file mode 100644 index 0000000..db110cd --- /dev/null +++ b/frontend/src/shared/api/schemas/need/need.zod.ts @@ -0,0 +1,301 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needTitleMax = 200; + + +export const needTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needSourceTextOneMax = 10000; + + + +export const needRequirementsSpecializationSourceOneQuoteOneMax = 300; + + +export const needRequirementsSpecializationSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsSpecializationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsGradeSourceOneQuoteOneMax = 300; + + +export const needRequirementsGradeSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsGradeSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsRequiredSkillsItemNameMax = 100; + + +export const needRequirementsRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementsRequiredSkillsItemTaxonomyCodeOneMax = 64; + + +export const needRequirementsRequiredSkillsItemTaxonomyCodeOneRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); +export const needRequirementsRequiredSkillsItemSourceQuoteOneMax = 300; + + +export const needRequirementsRequiredSkillsItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementsRequiredSkillsItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsRequiredSkillsMax = 30; + +export const needRequirementsDesiredSkillsItemNameMax = 100; + + +export const needRequirementsDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementsDesiredSkillsItemTaxonomyCodeOneMax = 64; + + +export const needRequirementsDesiredSkillsItemTaxonomyCodeOneRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); +export const needRequirementsDesiredSkillsItemSourceQuoteOneMax = 300; + + +export const needRequirementsDesiredSkillsItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementsDesiredSkillsItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsDesiredSkillsMax = 30; + +export const needRequirementsTasksItemTextMax = 300; + + +export const needRequirementsTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementsTasksItemSourceQuoteOneMax = 300; + + +export const needRequirementsTasksItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementsTasksItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsTasksMax = 20; + +export const needRequirementsDomainValueOneMax = 100; + + +export const needRequirementsDomainValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementsDomainSourceOneQuoteOneMax = 300; + + +export const needRequirementsDomainSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsDomainSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsWorkFormatsValueMax = 3; + +export const needRequirementsWorkFormatsSourceOneQuoteOneMax = 300; + + +export const needRequirementsWorkFormatsSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsWorkFormatsSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsLocationValueOneMax = 100; + + +export const needRequirementsLocationValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementsLocationSourceOneQuoteOneMax = 300; + + +export const needRequirementsLocationSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsLocationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementsSalaryValueOneSalaryFromMin = 1000; +export const needRequirementsSalaryValueOneSalaryFromMax = 100000000; +export const needRequirementsSalaryValueOneSalaryFromMultipleOf = 1000; + +export const needRequirementsSalaryValueOneSalaryToMin = 1000; +export const needRequirementsSalaryValueOneSalaryToMax = 100000000; +export const needRequirementsSalaryValueOneSalaryToMultipleOf = 1000; + +export const needRequirementsSalarySourceOneQuoteOneMax = 300; + + +export const needRequirementsSalarySourceOneExtractionVersionOneMax = 64; + + +export const needRequirementsSalarySourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needReadinessMissingFieldsItemQuestionMax = 300; + +export const needReadinessMissingFieldsMax = 9; + + + +export const needRecommendationsAlgorithmVersionOneMax = 64; + + +export const needRecommendationsAlgorithmVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRecommendationsCategoriesItemScoreMin = 0; +export const needRecommendationsCategoriesItemScoreMax = 1; + +export const needRecommendationsCategoriesItemSkillOverlapShareMin = 0; +export const needRecommendationsCategoriesItemSkillOverlapShareMax = 1; + +export const needRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemMax = 100; + + +export const needRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRecommendationsCategoriesItemSkillOverlapCoveredSkillsMax = 60; + +export const needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemMax = 100; + + +export const needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsMax = 60; + +export const needRecommendationsCategoriesItemMoneyShareMin = 0; +export const needRecommendationsCategoriesItemMoneyShareMax = 1; + +export const needRecommendationsCategoriesMax = 10; + + +export const Need = zod.object({ + "id": zod.uuid().describe('Identifier of the need.'), + "organization_id": zod.uuid().describe('Organization that owns the need, equal to `org_id` of the path. It never changes.'), + "vacancy_id": zod.uuid().nullable().describe('Linked vacancy of the same organization, or null. A need never requires a vacancy.'), + "title": zod.string().min(1).max(needTitleMax).regex(needTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "source_text": zod.union([zod.string().min(1).max(needSourceTextOneMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).'),zod.null()]).describe('Text the requirements were extracted from, or null.'), + "version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "requirements_version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.').describe('Need version in which the current confirmed requirements were last changed, at most `version`. A change that confirms, changes, or removes a requirement makes it equal to the new `version`. A change of the title, the vacancy link, or the text, or of suggestions only, creates a new `version` but keeps `requirements_version`, so it invalidates neither the recommendations nor search results and selection snapshots. Search runs and selection snapshots (PRD FR10) refer to `(need id, requirements_version)`, and a new selection snapshot is due only when it changes.'), + "requirements": zod.object({ + "specialization": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsSpecializationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsSpecializationSourceOneExtractionVersionOneMax).regex(needRequirementsSpecializationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "grade": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsGradeSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsGradeSourceOneExtractionVersionOneMax).regex(needRequirementsGradeSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one.'), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needRequirementsRequiredSkillsItemNameMax).regex(needRequirementsRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "taxonomy_code": zod.union([zod.string().min(1).max(needRequirementsRequiredSkillsItemTaxonomyCodeOneMax).regex(needRequirementsRequiredSkillsItemTaxonomyCodeOneRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.'),zod.null()]), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsRequiredSkillsItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsRequiredSkillsItemSourceExtractionVersionOneMax).regex(needRequirementsRequiredSkillsItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.')).max(needRequirementsRequiredSkillsMax).describe('Required skills; each has weight 2 in skill coverage. Only confirmed skills count.'), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needRequirementsDesiredSkillsItemNameMax).regex(needRequirementsDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "taxonomy_code": zod.union([zod.string().min(1).max(needRequirementsDesiredSkillsItemTaxonomyCodeOneMax).regex(needRequirementsDesiredSkillsItemTaxonomyCodeOneRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.'),zod.null()]), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsDesiredSkillsItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsDesiredSkillsItemSourceExtractionVersionOneMax).regex(needRequirementsDesiredSkillsItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.')).max(needRequirementsDesiredSkillsMax).describe('Desired skills; each has weight 1 in skill coverage. Only confirmed skills count.'), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(needRequirementsTasksItemTextMax).regex(needRequirementsTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsTasksItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsTasksItemSourceExtractionVersionOneMax).regex(needRequirementsTasksItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One work task of the team with its confirmation state and provenance.')).max(needRequirementsTasksMax).describe('Work tasks of the team in the order given.'), + "domain": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needRequirementsDomainValueOneMax).regex(needRequirementsDomainValueOneRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsDomainSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsDomainSourceOneExtractionVersionOneMax).regex(needRequirementsDomainSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Business domain of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "work_formats": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needRequirementsWorkFormatsValueMax).nullable(), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsWorkFormatsSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsWorkFormatsSourceOneExtractionVersionOneMax).regex(needRequirementsWorkFormatsSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Work formats that the employer offers, with their confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a known value lists one to three formats.'), + "location": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needRequirementsLocationValueOneMax).regex(needRequirementsLocationValueOneRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsLocationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsLocationSourceOneExtractionVersionOneMax).regex(needRequirementsLocationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Place of work with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats include `office` or `hybrid`.'), + "salary": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.object({ + "salary_from": zod.int().min(needRequirementsSalaryValueOneSalaryFromMin).max(needRequirementsSalaryValueOneSalaryFromMax).multipleOf(needRequirementsSalaryValueOneSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needRequirementsSalaryValueOneSalaryToMin).max(needRequirementsSalaryValueOneSalaryToMax).multipleOf(needRequirementsSalaryValueOneSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementsSalarySourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementsSalarySourceOneExtractionVersionOneMax).regex(needRequirementsSalarySourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Salary range that the employer offers, with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the server never substitutes zero, a market estimate, or a range from another need.') +}).describe('Requirements of one need version, each with its confirmation state and provenance. Read-only; requests change them through the fields of NeedCreate and NeedUpdate.'), + "readiness": zod.object({ + "status": zod.enum(['complete', 'incomplete']).describe('`complete` when every critical field has a confirmed value, otherwise `incomplete`.'), + "missing_fields": zod.array(zod.object({ + "field": zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.'), + "reason": zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.'), + "question": zod.string().min(1).max(needReadinessMissingFieldsItemQuestionMax).describe('Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML.') +}).describe('One critical field that has no confirmed value, with a specific question that the client shows next to the field.')).max(needReadinessMissingFieldsMax).describe('Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`.') +}).describe('Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires.'), + "recommendations": zod.object({ + "status": zod.enum(['computed', 'pending', 'not_available']).describe('State of the category recommendations of the current requirements version.\n\n- computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`.\n- pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later.\n- not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty.'), + "requirements_version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "policy_version": zod.int().min(1).nullable().describe('Number of the policy version whose weights were applied, or null unless `status` is `computed`.'), + "algorithm_version": zod.union([zod.string().min(1).max(needRecommendationsAlgorithmVersionOneMax).regex(needRecommendationsAlgorithmVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Version of the recommendation algorithm, or null unless `status` is `computed`.'), + "computed_at": zod.union([zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),zod.null()]).describe('Time of the computation, or null unless `status` is `computed`.'), + "categories": zod.array(zod.object({ + "specialization": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "grade": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "score": zod.number().min(needRecommendationsCategoriesItemScoreMin).max(needRecommendationsCategoriesItemScoreMax).nullable().describe('Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is `fewer_than_5`. Read-only; no request can set it.'), + "skill_overlap": zod.object({ + "share": zod.number().min(needRecommendationsCategoriesItemSkillOverlapShareMin).max(needRecommendationsCategoriesItemSkillOverlapShareMax).describe('Weighted share from 0 to 1, rounded to two decimals.'), + "covered_skills": zod.array(zod.string().min(1).max(needRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemMax).regex(needRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needRecommendationsCategoriesItemSkillOverlapCoveredSkillsMax).describe('Confirmed skills of the need that the category covers.'), + "uncovered_skills": zod.array(zod.string().min(1).max(needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemMax).regex(needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needRecommendationsCategoriesItemSkillOverlapUncoveredSkillsMax).describe('Confirmed skills of the need that the category does not cover, including skills without a taxonomy code.') +}).describe('Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.'), + "money": zod.object({ + "status": zod.enum(['computed', 'insufficient_data', 'no_salary', 'withheld']).describe('How the salary component of a recommendation was obtained.\n\n- computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given.\n- insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null.\n- no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null.\n- withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null.\n\nAn unknown candidate minimum never counts as zero.'), + "share": zod.number().min(needRecommendationsCategoriesItemMoneyShareMin).max(needRecommendationsCategoriesItemMoneyShareMax).nullable().describe('Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.') +}).describe('Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate.'), + "supply": zod.enum(['fewer_than_5', 'from_5_to_29', '30_or_more']).describe('Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.') +}).describe('One recommended category, a specialization with a grade, with its score and the reasons for it. The score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor the order reveals the exact size of a group below five.')).max(needRecommendationsCategoriesMax).describe('Recommended categories, best first by the score described in NeedCategoryRecommendation. Empty unless `status` is `computed`.') +}).describe('Category recommendations computed by the server from the confirmed requirements of `requirements_version` with a versioned policy (PRD FR08). Read-only: no request can set a recommendation, a score, or one of its components. The server may recompute them for the same requirements version, for example for a new policy or a changed pool of available candidates, without a new need version; `computed_at` and `policy_version` then change. The policy version and the candidate group used are stored with each computation, so a later policy never rewrites it.'), + "created_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'), + "updated_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.') +}).describe('Hiring need of an organization: what the team needs, independent of any published vacancy. It holds the current version of the requirements with their provenance, the readiness of the critical fields, and the category recommendations. It never contains membership data, a candidate\'s personal data, or a candidate\'s salary minimum.') + +export type Need = zod.input; +export type NeedOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needCategoryRecommendation.zod.ts b/frontend/src/shared/api/schemas/need/needCategoryRecommendation.zod.ts new file mode 100644 index 0000000..6294f4f --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needCategoryRecommendation.zod.ts @@ -0,0 +1,48 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needCategoryRecommendationScoreMin = 0; +export const needCategoryRecommendationScoreMax = 1; + +export const needCategoryRecommendationSkillOverlapShareMin = 0; +export const needCategoryRecommendationSkillOverlapShareMax = 1; + +export const needCategoryRecommendationSkillOverlapCoveredSkillsItemMax = 100; + + +export const needCategoryRecommendationSkillOverlapCoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCategoryRecommendationSkillOverlapCoveredSkillsMax = 60; + +export const needCategoryRecommendationSkillOverlapUncoveredSkillsItemMax = 100; + + +export const needCategoryRecommendationSkillOverlapUncoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCategoryRecommendationSkillOverlapUncoveredSkillsMax = 60; + +export const needCategoryRecommendationMoneyShareMin = 0; +export const needCategoryRecommendationMoneyShareMax = 1; + + +export const NeedCategoryRecommendation = zod.object({ + "specialization": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "grade": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "score": zod.number().min(needCategoryRecommendationScoreMin).max(needCategoryRecommendationScoreMax).nullable().describe('Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is `fewer_than_5`. Read-only; no request can set it.'), + "skill_overlap": zod.object({ + "share": zod.number().min(needCategoryRecommendationSkillOverlapShareMin).max(needCategoryRecommendationSkillOverlapShareMax).describe('Weighted share from 0 to 1, rounded to two decimals.'), + "covered_skills": zod.array(zod.string().min(1).max(needCategoryRecommendationSkillOverlapCoveredSkillsItemMax).regex(needCategoryRecommendationSkillOverlapCoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needCategoryRecommendationSkillOverlapCoveredSkillsMax).describe('Confirmed skills of the need that the category covers.'), + "uncovered_skills": zod.array(zod.string().min(1).max(needCategoryRecommendationSkillOverlapUncoveredSkillsItemMax).regex(needCategoryRecommendationSkillOverlapUncoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needCategoryRecommendationSkillOverlapUncoveredSkillsMax).describe('Confirmed skills of the need that the category does not cover, including skills without a taxonomy code.') +}).describe('Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.'), + "money": zod.object({ + "status": zod.enum(['computed', 'insufficient_data', 'no_salary', 'withheld']).describe('How the salary component of a recommendation was obtained.\n\n- computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given.\n- insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null.\n- no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null.\n- withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null.\n\nAn unknown candidate minimum never counts as zero.'), + "share": zod.number().min(needCategoryRecommendationMoneyShareMin).max(needCategoryRecommendationMoneyShareMax).nullable().describe('Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.') +}).describe('Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate.'), + "supply": zod.enum(['fewer_than_5', 'from_5_to_29', '30_or_more']).describe('Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.') +}).describe('One recommended category, a specialization with a grade, with its score and the reasons for it. The score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor the order reveals the exact size of a group below five.') + +export type NeedCategoryRecommendation = zod.input; +export type NeedCategoryRecommendationOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needCategoryRecommendations.zod.ts b/frontend/src/shared/api/schemas/need/needCategoryRecommendations.zod.ts new file mode 100644 index 0000000..8ac8285 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needCategoryRecommendations.zod.ts @@ -0,0 +1,63 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + + + +export const needCategoryRecommendationsAlgorithmVersionOneMax = 64; + + +export const needCategoryRecommendationsAlgorithmVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needCategoryRecommendationsCategoriesItemScoreMin = 0; +export const needCategoryRecommendationsCategoriesItemScoreMax = 1; + +export const needCategoryRecommendationsCategoriesItemSkillOverlapShareMin = 0; +export const needCategoryRecommendationsCategoriesItemSkillOverlapShareMax = 1; + +export const needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemMax = 100; + + +export const needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsMax = 60; + +export const needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemMax = 100; + + +export const needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsMax = 60; + +export const needCategoryRecommendationsCategoriesItemMoneyShareMin = 0; +export const needCategoryRecommendationsCategoriesItemMoneyShareMax = 1; + +export const needCategoryRecommendationsCategoriesMax = 10; + + +export const NeedCategoryRecommendations = zod.object({ + "status": zod.enum(['computed', 'pending', 'not_available']).describe('State of the category recommendations of the current requirements version.\n\n- computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`.\n- pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later.\n- not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty.'), + "requirements_version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "policy_version": zod.int().min(1).nullable().describe('Number of the policy version whose weights were applied, or null unless `status` is `computed`.'), + "algorithm_version": zod.union([zod.string().min(1).max(needCategoryRecommendationsAlgorithmVersionOneMax).regex(needCategoryRecommendationsAlgorithmVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Version of the recommendation algorithm, or null unless `status` is `computed`.'), + "computed_at": zod.union([zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),zod.null()]).describe('Time of the computation, or null unless `status` is `computed`.'), + "categories": zod.array(zod.object({ + "specialization": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "grade": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "score": zod.number().min(needCategoryRecommendationsCategoriesItemScoreMin).max(needCategoryRecommendationsCategoriesItemScoreMax).nullable().describe('Recommendation score from 0 to 1, rounded half up to two decimals, or null when `supply` is `fewer_than_5`. Read-only; no request can set it.'), + "skill_overlap": zod.object({ + "share": zod.number().min(needCategoryRecommendationsCategoriesItemSkillOverlapShareMin).max(needCategoryRecommendationsCategoriesItemSkillOverlapShareMax).describe('Weighted share from 0 to 1, rounded to two decimals.'), + "covered_skills": zod.array(zod.string().min(1).max(needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemMax).regex(needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needCategoryRecommendationsCategoriesItemSkillOverlapCoveredSkillsMax).describe('Confirmed skills of the need that the category covers.'), + "uncovered_skills": zod.array(zod.string().min(1).max(needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemMax).regex(needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needCategoryRecommendationsCategoriesItemSkillOverlapUncoveredSkillsMax).describe('Confirmed skills of the need that the category does not cover, including skills without a taxonomy code.') +}).describe('Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.'), + "money": zod.object({ + "status": zod.enum(['computed', 'insufficient_data', 'no_salary', 'withheld']).describe('How the salary component of a recommendation was obtained.\n\n- computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given.\n- insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null.\n- no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null.\n- withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null.\n\nAn unknown candidate minimum never counts as zero.'), + "share": zod.number().min(needCategoryRecommendationsCategoriesItemMoneyShareMin).max(needCategoryRecommendationsCategoriesItemMoneyShareMax).nullable().describe('Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.') +}).describe('Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate.'), + "supply": zod.enum(['fewer_than_5', 'from_5_to_29', '30_or_more']).describe('Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.') +}).describe('One recommended category, a specialization with a grade, with its score and the reasons for it. The score is `0.5 * Overlap + 0.3 * Money + 0.2 * Supply` (PRD FR08) computed from the published components: the exact skill overlap, the money share rounded down to a quarter or the neutral 0.5, and `Supply = min(1, active / 30)` when at least five candidates are available. For a group of fewer than five, Supply enters the ranking as 0, the same for every such group, so neither the score nor the order reveals the exact size of a group below five.')).max(needCategoryRecommendationsCategoriesMax).describe('Recommended categories, best first by the score described in NeedCategoryRecommendation. Empty unless `status` is `computed`.') +}).describe('Category recommendations computed by the server from the confirmed requirements of `requirements_version` with a versioned policy (PRD FR08). Read-only: no request can set a recommendation, a score, or one of its components. The server may recompute them for the same requirements version, for example for a new policy or a changed pool of available candidates, without a new need version; `computed_at` and `policy_version` then change. The policy version and the candidate group used are stored with each computation, so a later policy never rewrites it.') + +export type NeedCategoryRecommendations = zod.input; +export type NeedCategoryRecommendationsOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needCreate.zod.ts b/frontend/src/shared/api/schemas/need/needCreate.zod.ts new file mode 100644 index 0000000..127683c --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needCreate.zod.ts @@ -0,0 +1,101 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needCreateTitleMax = 200; + + +export const needCreateTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateSourceTextOneMax = 10000; + +export const needCreateRequiredSkillsItemNameMax = 100; + + +export const needCreateRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateRequiredSkillsMax = 30; + +export const needCreateDesiredSkillsItemNameMax = 100; + + +export const needCreateDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateDesiredSkillsMax = 30; + +export const needCreateTasksItemTextMax = 300; + + +export const needCreateTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateTasksMax = 20; + +export const needCreateDomainOneValueMax = 100; + + +export const needCreateDomainOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateWorkFormatsOneValueMax = 3; + +export const needCreateLocationOneValueMax = 100; + + +export const needCreateLocationOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needCreateSalaryOneValueSalaryFromMin = 1000; +export const needCreateSalaryOneValueSalaryFromMax = 100000000; +export const needCreateSalaryOneValueSalaryFromMultipleOf = 1000; + +export const needCreateSalaryOneValueSalaryToMin = 1000; +export const needCreateSalaryOneValueSalaryToMax = 100000000; +export const needCreateSalaryOneValueSalaryToMultipleOf = 1000; + + +export const NeedCreate = zod.object({ + "title": zod.string().min(1).max(needCreateTitleMax).regex(needCreateTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "vacancy_id": zod.uuid().nullish().describe('Vacancy of the same organization to link, or null or absent for a need without a vacancy.'), + "source_text": zod.union([zod.string().min(1).max(needCreateSourceTextOneMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).'),zod.null()]).exactOptional(), + "specialization": zod.union([zod.object({ + "value": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the specialization in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "grade": zod.union([zod.object({ + "value": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the grade in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needCreateRequiredSkillsItemNameMax).regex(needCreateRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(needCreateRequiredSkillsMax).exactOptional(), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needCreateDesiredSkillsItemNameMax).regex(needCreateDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(needCreateDesiredSkillsMax).exactOptional(), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(needCreateTasksItemTextMax).regex(needCreateTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput.')).max(needCreateTasksMax).exactOptional(), + "domain": zod.union([zod.object({ + "value": zod.string().min(1).max(needCreateDomainOneValueMax).regex(needCreateDomainOneValueRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the domain in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "work_formats": zod.union([zod.object({ + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needCreateWorkFormatsOneValueMax), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set.'),zod.null()]).exactOptional(), + "location": zod.union([zod.object({ + "value": zod.string().min(1).max(needCreateLocationOneValueMax).regex(needCreateLocationOneValueRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the place of work in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "salary": zod.union([zod.object({ + "value": zod.object({ + "salary_from": zod.int().min(needCreateSalaryOneValueSalaryFromMin).max(needCreateSalaryOneValueSalaryFromMax).multipleOf(needCreateSalaryOneValueSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needCreateSalaryOneValueSalaryToMin).max(needCreateSalaryOneValueSalaryToMax).multipleOf(needCreateSalaryOneValueSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`.'),zod.null()]).exactOptional() +}).describe('New need. Only `title` is required, so a need can start from a title, from a text, or from form fields, and with or without a vacancy. A field or list item given here must have `status` `confirmed` and becomes a confirmed manual value; `extracted` answers 400 with the pointer of that `status`, such as `/grade/status`, because a new need has no stored suggestion. A field that is absent is extracted from `source_text` when the text is given and is left unknown or empty otherwise. A nullable field sent as null, and a skill or task list sent as an empty list, stays unknown or empty and is not extracted; an empty `work_formats` value fails `minItems`. Unknown fields are rejected, so a request cannot set membership, a role, a status of the need, a provenance, readiness, a recommendation or its score, or a candidate\'s salary minimum.') + +export type NeedCreate = zod.input; +export type NeedCreateOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needDomain.zod.ts b/frontend/src/shared/api/schemas/need/needDomain.zod.ts new file mode 100644 index 0000000..5f80542 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needDomain.zod.ts @@ -0,0 +1,33 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needDomainValueOneMax = 100; + + +export const needDomainValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needDomainSourceOneQuoteOneMax = 300; + + +export const needDomainSourceOneExtractionVersionOneMax = 64; + + +export const needDomainSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedDomain = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needDomainValueOneMax).regex(needDomainValueOneRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needDomainSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needDomainSourceOneExtractionVersionOneMax).regex(needDomainSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Business domain of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.') + +export type NeedDomain = zod.input; +export type NeedDomainOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needDomainInput.zod.ts b/frontend/src/shared/api/schemas/need/needDomainInput.zod.ts new file mode 100644 index 0000000..b82dd37 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needDomainInput.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needDomainInputValueMax = 100; + + +export const needDomainInputValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedDomainInput = zod.object({ + "value": zod.string().min(1).max(needDomainInputValueMax).regex(needDomainInputValueRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the domain in a request; see NeedUpdate for the rules of `status`.') + +export type NeedDomainInput = zod.input; +export type NeedDomainInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needDomainName.zod.ts b/frontend/src/shared/api/schemas/need/needDomainName.zod.ts new file mode 100644 index 0000000..b184d21 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needDomainName.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedDomainNameMax = 100; + + +export const NeedDomainNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedDomainName = zod.string().min(1).max(NeedDomainNameMax).regex(NeedDomainNameRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.') + +export type NeedDomainName = zod.input; +export type NeedDomainNameOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needFieldName.zod.ts b/frontend/src/shared/api/schemas/need/needFieldName.zod.ts new file mode 100644 index 0000000..41fa6af --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needFieldName.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedFieldName = zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.') + +export type NeedFieldName = zod.input; +export type NeedFieldNameOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needGrade.zod.ts b/frontend/src/shared/api/schemas/need/needGrade.zod.ts new file mode 100644 index 0000000..4366159 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needGrade.zod.ts @@ -0,0 +1,29 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needGradeSourceOneQuoteOneMax = 300; + + +export const needGradeSourceOneExtractionVersionOneMax = 64; + + +export const needGradeSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedGrade = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needGradeSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needGradeSourceOneExtractionVersionOneMax).regex(needGradeSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one.') + +export type NeedGrade = zod.input; +export type NeedGradeOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needGradeInput.zod.ts b/frontend/src/shared/api/schemas/need/needGradeInput.zod.ts new file mode 100644 index 0000000..f10662b --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needGradeInput.zod.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedGradeInput = zod.object({ + "value": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the grade in a request; see NeedUpdate for the rules of `status`.') + +export type NeedGradeInput = zod.input; +export type NeedGradeInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needItemStatus.zod.ts b/frontend/src/shared/api/schemas/need/needItemStatus.zod.ts new file mode 100644 index 0000000..ba42de6 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needItemStatus.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedItemStatus = zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') + +export type NeedItemStatus = zod.input; +export type NeedItemStatusOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needList.zod.ts b/frontend/src/shared/api/schemas/need/needList.zod.ts new file mode 100644 index 0000000..eae128a --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needList.zod.ts @@ -0,0 +1,83 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needListItemsItemTitleMax = 200; + + +export const needListItemsItemTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const needListItemsItemSpecializationSourceOneQuoteOneMax = 300; + + +export const needListItemsItemSpecializationSourceOneExtractionVersionOneMax = 64; + + +export const needListItemsItemSpecializationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needListItemsItemGradeSourceOneQuoteOneMax = 300; + + +export const needListItemsItemGradeSourceOneExtractionVersionOneMax = 64; + + +export const needListItemsItemGradeSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needListItemsItemReadinessMissingFieldsItemQuestionMax = 300; + +export const needListItemsItemReadinessMissingFieldsMax = 9; + +export const needListItemsMax = 100; + +export const needListPageNextCursorMax = 512; + + +export const needListPageNextCursorRegExp = new RegExp('^[A-Za-z0-9_-]+$'); + +export const NeedList = zod.object({ + "items": zod.array(zod.object({ + "id": zod.uuid().describe('Identifier of the need.'), + "vacancy_id": zod.uuid().nullable().describe('Linked vacancy, or null.'), + "title": zod.string().min(1).max(needListItemsItemTitleMax).regex(needListItemsItemTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "specialization": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needListItemsItemSpecializationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needListItemsItemSpecializationSourceOneExtractionVersionOneMax).regex(needListItemsItemSpecializationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "grade": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needListItemsItemGradeSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needListItemsItemGradeSourceOneExtractionVersionOneMax).regex(needListItemsItemGradeSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one.'), + "readiness": zod.object({ + "status": zod.enum(['complete', 'incomplete']).describe('`complete` when every critical field has a confirmed value, otherwise `incomplete`.'), + "missing_fields": zod.array(zod.object({ + "field": zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.'), + "reason": zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.'), + "question": zod.string().min(1).max(needListItemsItemReadinessMissingFieldsItemQuestionMax).describe('Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML.') +}).describe('One critical field that has no confirmed value, with a specific question that the client shows next to the field.')).max(needListItemsItemReadinessMissingFieldsMax).describe('Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`.') +}).describe('Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires.'), + "created_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'), + "updated_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.') +}).describe('Need in a list: its identity, current version, target category fields, and readiness. Read the need for the requirements and the recommendations.')).max(needListItemsMax).describe('Needs of the page.'), + "page": zod.object({ + "has_more": zod.boolean().describe('Whether another page follows this one.'), + "next_cursor": zod.string().min(1).max(needListPageNextCursorMax).regex(needListPageNextCursorRegExp).nullable().describe('Opaque cursor of the next page, or null on the last page. Clients must not parse, build, or store it beyond the current listing.') +}).describe('Cursor pagination state of a list response. Lists are ordered by a stable server-defined key. To read the next page, repeat the request with the same filters and `cursor` set to `next_cursor`.') +}).describe('One page of the needs of an organization, newest first by creation time.') + +export type NeedList = zod.input; +export type NeedListOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needLocation.zod.ts b/frontend/src/shared/api/schemas/need/needLocation.zod.ts new file mode 100644 index 0000000..9f80621 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needLocation.zod.ts @@ -0,0 +1,33 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needLocationValueOneMax = 100; + + +export const needLocationValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needLocationSourceOneQuoteOneMax = 300; + + +export const needLocationSourceOneExtractionVersionOneMax = 64; + + +export const needLocationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedLocation = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needLocationValueOneMax).regex(needLocationValueOneRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needLocationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needLocationSourceOneExtractionVersionOneMax).regex(needLocationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Place of work with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats include `office` or `hybrid`.') + +export type NeedLocation = zod.input; +export type NeedLocationOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needLocationInput.zod.ts b/frontend/src/shared/api/schemas/need/needLocationInput.zod.ts new file mode 100644 index 0000000..d1912f9 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needLocationInput.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needLocationInputValueMax = 100; + + +export const needLocationInputValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedLocationInput = zod.object({ + "value": zod.string().min(1).max(needLocationInputValueMax).regex(needLocationInputValueRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the place of work in a request; see NeedUpdate for the rules of `status`.') + +export type NeedLocationInput = zod.input; +export type NeedLocationInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needLocationName.zod.ts b/frontend/src/shared/api/schemas/need/needLocationName.zod.ts new file mode 100644 index 0000000..ea6b1c6 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needLocationName.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedLocationNameMax = 100; + + +export const NeedLocationNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedLocationName = zod.string().min(1).max(NeedLocationNameMax).regex(NeedLocationNameRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.') + +export type NeedLocationName = zod.input; +export type NeedLocationNameOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needMissingField.zod.ts b/frontend/src/shared/api/schemas/need/needMissingField.zod.ts new file mode 100644 index 0000000..518d276 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needMissingField.zod.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needMissingFieldQuestionMax = 300; + + +export const NeedMissingField = zod.object({ + "field": zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.'), + "reason": zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.'), + "question": zod.string().min(1).max(needMissingFieldQuestionMax).describe('Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML.') +}).describe('One critical field that has no confirmed value, with a specific question that the client shows next to the field.') + +export type NeedMissingField = zod.input; +export type NeedMissingFieldOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needMissingReason.zod.ts b/frontend/src/shared/api/schemas/need/needMissingReason.zod.ts new file mode 100644 index 0000000..3e68d8e --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needMissingReason.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedMissingReason = zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.') + +export type NeedMissingReason = zod.input; +export type NeedMissingReasonOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needMoneyFit.zod.ts b/frontend/src/shared/api/schemas/need/needMoneyFit.zod.ts new file mode 100644 index 0000000..af71fbb --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needMoneyFit.zod.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needMoneyFitShareMin = 0; +export const needMoneyFitShareMax = 1; + + +export const NeedMoneyFit = zod.object({ + "status": zod.enum(['computed', 'insufficient_data', 'no_salary', 'withheld']).describe('How the salary component of a recommendation was obtained.\n\n- computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given.\n- insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null.\n- no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null.\n- withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null.\n\nAn unknown candidate minimum never counts as zero.'), + "share": zod.number().min(needMoneyFitShareMin).max(needMoneyFitShareMax).nullable().describe('Share of those candidates whose minimum is not above the upper bound of the range, rounded down to a multiple of 0.25 (one of 0, 0.25, 0.5, 0.75, 1), or null unless `status` is `computed`. The score and the ranking use this rounded value, never the exact share. A quarter step gives five levels: each probe of a new upper bound tells at most which quarter of the group accepts it, and in the smallest allowed group of five candidates a single minimum often does not move the value, while the share still separates a range that most candidates accept from one that few accept.') +}).describe('Salary component of a recommendation. It is an aggregate over at least five candidates and never reveals a minimum of any candidate.') + +export type NeedMoneyFit = zod.input; +export type NeedMoneyFitOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needMoneyStatus.zod.ts b/frontend/src/shared/api/schemas/need/needMoneyStatus.zod.ts new file mode 100644 index 0000000..53ee522 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needMoneyStatus.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedMoneyStatus = zod.enum(['computed', 'insufficient_data', 'no_salary', 'withheld']).describe('How the salary component of a recommendation was obtained.\n\n- computed: at least five available candidates of the category have a known minimum comparable with the confirmed range; `share` is given.\n- insufficient_data: fewer than five such candidates; the policy uses the neutral value 0.5 and `share` is null.\n- no_salary: the need has no confirmed salary range; the policy uses the neutral value 0.5 and `share` is null.\n- withheld: the organization changed salary ranges five times within seven days, so salary aggregates are withheld for seven days (PRD FR13, planned in TASK-211); the policy uses the neutral value 0.5 and `share` is null.\n\nAn unknown candidate minimum never counts as zero.') + +export type NeedMoneyStatus = zod.input; +export type NeedMoneyStatusOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needReadinessReport.zod.ts b/frontend/src/shared/api/schemas/need/needReadinessReport.zod.ts new file mode 100644 index 0000000..44300ae --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needReadinessReport.zod.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needReadinessReportMissingFieldsItemQuestionMax = 300; + +export const needReadinessReportMissingFieldsMax = 9; + + +export const NeedReadinessReport = zod.object({ + "status": zod.enum(['complete', 'incomplete']).describe('`complete` when every critical field has a confirmed value, otherwise `incomplete`.'), + "missing_fields": zod.array(zod.object({ + "field": zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.'), + "reason": zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.'), + "question": zod.string().min(1).max(needReadinessReportMissingFieldsItemQuestionMax).describe('Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML.') +}).describe('One critical field that has no confirmed value, with a specific question that the client shows next to the field.')).max(needReadinessReportMissingFieldsMax).describe('Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`.') +}).describe('Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires.') + +export type NeedReadinessReport = zod.input; +export type NeedReadinessReportOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needReadinessStatus.zod.ts b/frontend/src/shared/api/schemas/need/needReadinessStatus.zod.ts new file mode 100644 index 0000000..fa80d86 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needReadinessStatus.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedReadinessStatus = zod.enum(['complete', 'incomplete']).describe('`complete` when every critical field has a confirmed value, otherwise `incomplete`.') + +export type NeedReadinessStatus = zod.input; +export type NeedReadinessStatusOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needRecommendationStatus.zod.ts b/frontend/src/shared/api/schemas/need/needRecommendationStatus.zod.ts new file mode 100644 index 0000000..18495af --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needRecommendationStatus.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedRecommendationStatus = zod.enum(['computed', 'pending', 'not_available']).describe('State of the category recommendations of the current requirements version.\n\n- computed: `categories` holds the recommendations computed from the confirmed requirements of `requirements_version`.\n- pending: the computation for the current requirements version has not finished yet; `categories` is empty. Read the need again later.\n- not_available: the current requirements have no confirmed required or desired skill to compute from; `categories` is empty.') + +export type NeedRecommendationStatus = zod.input; +export type NeedRecommendationStatusOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needRequirementSet.zod.ts b/frontend/src/shared/api/schemas/need/needRequirementSet.zod.ts new file mode 100644 index 0000000..b1187a6 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needRequirementSet.zod.ts @@ -0,0 +1,219 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needRequirementSetSpecializationSourceOneQuoteOneMax = 300; + + +export const needRequirementSetSpecializationSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetSpecializationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetGradeSourceOneQuoteOneMax = 300; + + +export const needRequirementSetGradeSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetGradeSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetRequiredSkillsItemNameMax = 100; + + +export const needRequirementSetRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementSetRequiredSkillsItemTaxonomyCodeOneMax = 64; + + +export const needRequirementSetRequiredSkillsItemTaxonomyCodeOneRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); +export const needRequirementSetRequiredSkillsItemSourceQuoteOneMax = 300; + + +export const needRequirementSetRequiredSkillsItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementSetRequiredSkillsItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetRequiredSkillsMax = 30; + +export const needRequirementSetDesiredSkillsItemNameMax = 100; + + +export const needRequirementSetDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementSetDesiredSkillsItemTaxonomyCodeOneMax = 64; + + +export const needRequirementSetDesiredSkillsItemTaxonomyCodeOneRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); +export const needRequirementSetDesiredSkillsItemSourceQuoteOneMax = 300; + + +export const needRequirementSetDesiredSkillsItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementSetDesiredSkillsItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetDesiredSkillsMax = 30; + +export const needRequirementSetTasksItemTextMax = 300; + + +export const needRequirementSetTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementSetTasksItemSourceQuoteOneMax = 300; + + +export const needRequirementSetTasksItemSourceExtractionVersionOneMax = 64; + + +export const needRequirementSetTasksItemSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetTasksMax = 20; + +export const needRequirementSetDomainValueOneMax = 100; + + +export const needRequirementSetDomainValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementSetDomainSourceOneQuoteOneMax = 300; + + +export const needRequirementSetDomainSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetDomainSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetWorkFormatsValueMax = 3; + +export const needRequirementSetWorkFormatsSourceOneQuoteOneMax = 300; + + +export const needRequirementSetWorkFormatsSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetWorkFormatsSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetLocationValueOneMax = 100; + + +export const needRequirementSetLocationValueOneRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needRequirementSetLocationSourceOneQuoteOneMax = 300; + + +export const needRequirementSetLocationSourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetLocationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needRequirementSetSalaryValueOneSalaryFromMin = 1000; +export const needRequirementSetSalaryValueOneSalaryFromMax = 100000000; +export const needRequirementSetSalaryValueOneSalaryFromMultipleOf = 1000; + +export const needRequirementSetSalaryValueOneSalaryToMin = 1000; +export const needRequirementSetSalaryValueOneSalaryToMax = 100000000; +export const needRequirementSetSalaryValueOneSalaryToMultipleOf = 1000; + +export const needRequirementSetSalarySourceOneQuoteOneMax = 300; + + +export const needRequirementSetSalarySourceOneExtractionVersionOneMax = 64; + + +export const needRequirementSetSalarySourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedRequirementSet = zod.object({ + "specialization": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetSpecializationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetSpecializationSourceOneExtractionVersionOneMax).regex(needRequirementSetSpecializationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "grade": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetGradeSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetGradeSourceOneExtractionVersionOneMax).regex(needRequirementSetGradeSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one.'), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needRequirementSetRequiredSkillsItemNameMax).regex(needRequirementSetRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "taxonomy_code": zod.union([zod.string().min(1).max(needRequirementSetRequiredSkillsItemTaxonomyCodeOneMax).regex(needRequirementSetRequiredSkillsItemTaxonomyCodeOneRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.'),zod.null()]), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetRequiredSkillsItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetRequiredSkillsItemSourceExtractionVersionOneMax).regex(needRequirementSetRequiredSkillsItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.')).max(needRequirementSetRequiredSkillsMax).describe('Required skills; each has weight 2 in skill coverage. Only confirmed skills count.'), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needRequirementSetDesiredSkillsItemNameMax).regex(needRequirementSetDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "taxonomy_code": zod.union([zod.string().min(1).max(needRequirementSetDesiredSkillsItemTaxonomyCodeOneMax).regex(needRequirementSetDesiredSkillsItemTaxonomyCodeOneRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.'),zod.null()]), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetDesiredSkillsItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetDesiredSkillsItemSourceExtractionVersionOneMax).regex(needRequirementSetDesiredSkillsItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.')).max(needRequirementSetDesiredSkillsMax).describe('Desired skills; each has weight 1 in skill coverage. Only confirmed skills count.'), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(needRequirementSetTasksItemTextMax).regex(needRequirementSetTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetTasksItemSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetTasksItemSourceExtractionVersionOneMax).regex(needRequirementSetTasksItemSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One work task of the team with its confirmation state and provenance.')).max(needRequirementSetTasksMax).describe('Work tasks of the team in the order given.'), + "domain": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needRequirementSetDomainValueOneMax).regex(needRequirementSetDomainValueOneRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetDomainSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetDomainSourceOneExtractionVersionOneMax).regex(needRequirementSetDomainSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Business domain of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "work_formats": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needRequirementSetWorkFormatsValueMax).nullable(), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetWorkFormatsSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetWorkFormatsSourceOneExtractionVersionOneMax).regex(needRequirementSetWorkFormatsSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Work formats that the employer offers, with their confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a known value lists one to three formats.'), + "location": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.string().min(1).max(needRequirementSetLocationValueOneMax).regex(needRequirementSetLocationValueOneRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetLocationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetLocationSourceOneExtractionVersionOneMax).regex(needRequirementSetLocationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Place of work with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. Readiness requires a confirmed place only when the confirmed work formats include `office` or `hybrid`.'), + "salary": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.object({ + "salary_from": zod.int().min(needRequirementSetSalaryValueOneSalaryFromMin).max(needRequirementSetSalaryValueOneSalaryFromMax).multipleOf(needRequirementSetSalaryValueOneSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needRequirementSetSalaryValueOneSalaryToMin).max(needRequirementSetSalaryValueOneSalaryToMax).multipleOf(needRequirementSetSalaryValueOneSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needRequirementSetSalarySourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needRequirementSetSalarySourceOneExtractionVersionOneMax).regex(needRequirementSetSalarySourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Salary range that the employer offers, with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the server never substitutes zero, a market estimate, or a range from another need.') +}).describe('Requirements of one need version, each with its confirmation state and provenance. Read-only; requests change them through the fields of NeedCreate and NeedUpdate.') + +export type NeedRequirementSet = zod.input; +export type NeedRequirementSetOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSalary.zod.ts b/frontend/src/shared/api/schemas/need/needSalary.zod.ts new file mode 100644 index 0000000..3c8ab7a --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSalary.zod.ts @@ -0,0 +1,43 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSalaryValueOneSalaryFromMin = 1000; +export const needSalaryValueOneSalaryFromMax = 100000000; +export const needSalaryValueOneSalaryFromMultipleOf = 1000; + +export const needSalaryValueOneSalaryToMin = 1000; +export const needSalaryValueOneSalaryToMax = 100000000; +export const needSalaryValueOneSalaryToMultipleOf = 1000; + +export const needSalarySourceOneQuoteOneMax = 300; + + +export const needSalarySourceOneExtractionVersionOneMax = 64; + + +export const needSalarySourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedSalary = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.object({ + "salary_from": zod.int().min(needSalaryValueOneSalaryFromMin).max(needSalaryValueOneSalaryFromMax).multipleOf(needSalaryValueOneSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needSalaryValueOneSalaryToMin).max(needSalaryValueOneSalaryToMax).multipleOf(needSalaryValueOneSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needSalarySourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needSalarySourceOneExtractionVersionOneMax).regex(needSalarySourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Salary range that the employer offers, with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`. A text without a salary leaves it unknown; the server never substitutes zero, a market estimate, or a range from another need.') + +export type NeedSalary = zod.input; +export type NeedSalaryOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSalaryInput.zod.ts b/frontend/src/shared/api/schemas/need/needSalaryInput.zod.ts new file mode 100644 index 0000000..fa5a7dd --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSalaryInput.zod.ts @@ -0,0 +1,30 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSalaryInputValueSalaryFromMin = 1000; +export const needSalaryInputValueSalaryFromMax = 100000000; +export const needSalaryInputValueSalaryFromMultipleOf = 1000; + +export const needSalaryInputValueSalaryToMin = 1000; +export const needSalaryInputValueSalaryToMax = 100000000; +export const needSalaryInputValueSalaryToMultipleOf = 1000; + + +export const NeedSalaryInput = zod.object({ + "value": zod.object({ + "salary_from": zod.int().min(needSalaryInputValueSalaryFromMin).max(needSalaryInputValueSalaryFromMax).multipleOf(needSalaryInputValueSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needSalaryInputValueSalaryToMin).max(needSalaryInputValueSalaryToMax).multipleOf(needSalaryInputValueSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`.') + +export type NeedSalaryInput = zod.input; +export type NeedSalaryInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSkill.zod.ts b/frontend/src/shared/api/schemas/need/needSkill.zod.ts new file mode 100644 index 0000000..9dd13e6 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSkill.zod.ts @@ -0,0 +1,38 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSkillNameMax = 100; + + +export const needSkillNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needSkillTaxonomyCodeOneMax = 64; + + +export const needSkillTaxonomyCodeOneRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); +export const needSkillSourceQuoteOneMax = 300; + + +export const needSkillSourceExtractionVersionOneMax = 64; + + +export const needSkillSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedSkill = zod.object({ + "name": zod.string().min(1).max(needSkillNameMax).regex(needSkillNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "taxonomy_code": zod.union([zod.string().min(1).max(needSkillTaxonomyCodeOneMax).regex(needSkillTaxonomyCodeOneRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.'),zod.null()]), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needSkillSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needSkillSourceExtractionVersionOneMax).regex(needSkillSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One required or desired skill of the need. `taxonomy_code` is null for a skill that the platform taxonomy does not know: the server keeps the name as given, never maps it to a guessed code, and counts it as not covered in category recommendations.') + +export type NeedSkill = zod.input; +export type NeedSkillOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSkillInput.zod.ts b/frontend/src/shared/api/schemas/need/needSkillInput.zod.ts new file mode 100644 index 0000000..457254f --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSkillInput.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSkillInputNameMax = 100; + + +export const needSkillInputNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedSkillInput = zod.object({ + "name": zod.string().min(1).max(needSkillInputNameMax).regex(needSkillInputNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.') + +export type NeedSkillInput = zod.input; +export type NeedSkillInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSkillOverlap.zod.ts b/frontend/src/shared/api/schemas/need/needSkillOverlap.zod.ts new file mode 100644 index 0000000..8746ee2 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSkillOverlap.zod.ts @@ -0,0 +1,32 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSkillOverlapShareMin = 0; +export const needSkillOverlapShareMax = 1; + +export const needSkillOverlapCoveredSkillsItemMax = 100; + + +export const needSkillOverlapCoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needSkillOverlapCoveredSkillsMax = 60; + +export const needSkillOverlapUncoveredSkillsItemMax = 100; + + +export const needSkillOverlapUncoveredSkillsItemRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needSkillOverlapUncoveredSkillsMax = 60; + + +export const NeedSkillOverlap = zod.object({ + "share": zod.number().min(needSkillOverlapShareMin).max(needSkillOverlapShareMax).describe('Weighted share from 0 to 1, rounded to two decimals.'), + "covered_skills": zod.array(zod.string().min(1).max(needSkillOverlapCoveredSkillsItemMax).regex(needSkillOverlapCoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needSkillOverlapCoveredSkillsMax).describe('Confirmed skills of the need that the category covers.'), + "uncovered_skills": zod.array(zod.string().min(1).max(needSkillOverlapUncoveredSkillsItemMax).regex(needSkillOverlapUncoveredSkillsItemRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.')).max(needSkillOverlapUncoveredSkillsMax).describe('Confirmed skills of the need that the category does not cover, including skills without a taxonomy code.') +}).describe('Skill coverage of a category: the weighted share of the confirmed skills of the need that the category taxonomy covers, with weight 2 for a required and 1 for a desired skill.') + +export type NeedSkillOverlap = zod.input; +export type NeedSkillOverlapOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSourceQuote.zod.ts b/frontend/src/shared/api/schemas/need/needSourceQuote.zod.ts new file mode 100644 index 0000000..b9eef69 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSourceQuote.zod.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedSourceQuoteMax = 300; + + +export const NeedSourceQuote = zod.string().min(1).max(NeedSourceQuoteMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.') + +export type NeedSourceQuote = zod.input; +export type NeedSourceQuoteOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSourceText.zod.ts b/frontend/src/shared/api/schemas/need/needSourceText.zod.ts new file mode 100644 index 0000000..0011624 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSourceText.zod.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedSourceTextMax = 10000; + + +export const NeedSourceText = zod.string().min(1).max(NeedSourceTextMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).') + +export type NeedSourceText = zod.input; +export type NeedSourceTextOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSpecialization.zod.ts b/frontend/src/shared/api/schemas/need/needSpecialization.zod.ts new file mode 100644 index 0000000..b9c0658 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSpecialization.zod.ts @@ -0,0 +1,29 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSpecializationSourceOneQuoteOneMax = 300; + + +export const needSpecializationSourceOneExtractionVersionOneMax = 64; + + +export const needSpecializationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedSpecialization = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needSpecializationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needSpecializationSourceOneExtractionVersionOneMax).regex(needSpecializationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.') + +export type NeedSpecialization = zod.input; +export type NeedSpecializationOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSpecializationInput.zod.ts b/frontend/src/shared/api/schemas/need/needSpecializationInput.zod.ts new file mode 100644 index 0000000..e2e1059 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSpecializationInput.zod.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedSpecializationInput = zod.object({ + "value": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the specialization in a request; see NeedUpdate for the rules of `status`.') + +export type NeedSpecializationInput = zod.input; +export type NeedSpecializationInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSummary.zod.ts b/frontend/src/shared/api/schemas/need/needSummary.zod.ts new file mode 100644 index 0000000..4eedf3e --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSummary.zod.ts @@ -0,0 +1,71 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needSummaryTitleMax = 200; + + +export const needSummaryTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const needSummarySpecializationSourceOneQuoteOneMax = 300; + + +export const needSummarySpecializationSourceOneExtractionVersionOneMax = 64; + + +export const needSummarySpecializationSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needSummaryGradeSourceOneQuoteOneMax = 300; + + +export const needSummaryGradeSourceOneExtractionVersionOneMax = 64; + + +export const needSummaryGradeSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); +export const needSummaryReadinessMissingFieldsItemQuestionMax = 300; + +export const needSummaryReadinessMissingFieldsMax = 9; + + +export const NeedSummary = zod.object({ + "id": zod.uuid().describe('Identifier of the need.'), + "vacancy_id": zod.uuid().nullable().describe('Linked vacancy, or null.'), + "title": zod.string().min(1).max(needSummaryTitleMax).regex(needSummaryTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "specialization": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needSummarySpecializationSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needSummarySpecializationSourceOneExtractionVersionOneMax).regex(needSummarySpecializationSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target specialization of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`.'), + "grade": zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.union([zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'),zod.null()]), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needSummaryGradeSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needSummaryGradeSourceOneExtractionVersionOneMax).regex(needSummaryGradeSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Target grade of the need with its confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a text that names no grade leaves the grade unknown instead of assuming one.'), + "readiness": zod.object({ + "status": zod.enum(['complete', 'incomplete']).describe('`complete` when every critical field has a confirmed value, otherwise `incomplete`.'), + "missing_fields": zod.array(zod.object({ + "field": zod.enum(['specialization', 'grade', 'required_skills', 'desired_skills', 'tasks', 'domain', 'work_formats', 'location', 'salary']).describe('Name of a need field, equal to its property name in NeedRequirementSet and in the request bodies. Adding a value is a contract change.'), + "reason": zod.enum(['unknown', 'unconfirmed']).describe('Why a critical field is missing: `unknown`, the field has no value, or `unconfirmed`, it has only an extracted value or, for required skills, only extracted items that wait for confirmation.'), + "question": zod.string().min(1).max(needSummaryReadinessMissingFieldsItemQuestionMax).describe('Specific Russian question about the missing value, for example which grade is needed. Plain text; the client shows it as text, never as HTML.') +}).describe('One critical field that has no confirmed value, with a specific question that the client shows next to the field.')).max(needSummaryReadinessMissingFieldsMax).describe('Critical fields without a confirmed value, each at most once, in the order of NeedFieldName. Empty exactly when `status` is `complete`.') +}).describe('Completeness of the critical fields, computed by the server for the current version. The critical fields are `specialization`, `grade`, `required_skills` (at least one confirmed skill), `work_formats`, `salary`, and `location` when the confirmed work formats include `office` or `hybrid`. An incomplete need is still a valid saved need; each later operation, such as search or an invitation, states which readiness it requires.'), + "created_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'), + "updated_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.') +}).describe('Need in a list: its identity, current version, target category fields, and readiness. Read the need for the requirements and the recommendations.') + +export type NeedSummary = zod.input; +export type NeedSummaryOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needSupplyBand.zod.ts b/frontend/src/shared/api/schemas/need/needSupplyBand.zod.ts new file mode 100644 index 0000000..cb7f5db --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needSupplyBand.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedSupplyBand = zod.enum(['fewer_than_5', 'from_5_to_29', '30_or_more']).describe('Number of available candidates of the category in the allowed detail: `fewer_than_5`, `from_5_to_29`, or `30_or_more`. Smaller groups are never counted exactly.') + +export type NeedSupplyBand = zod.input; +export type NeedSupplyBandOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needTask.zod.ts b/frontend/src/shared/api/schemas/need/needTask.zod.ts new file mode 100644 index 0000000..f816b8d --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needTask.zod.ts @@ -0,0 +1,33 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needTaskTextMax = 300; + + +export const needTaskTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needTaskSourceQuoteOneMax = 300; + + +export const needTaskSourceExtractionVersionOneMax = 64; + + +export const needTaskSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedTask = zod.object({ + "text": zod.string().min(1).max(needTaskTextMax).regex(needTaskTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.'), + "source": zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needTaskSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needTaskSourceExtractionVersionOneMax).regex(needTaskSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') +}).describe('One work task of the team with its confirmation state and provenance.') + +export type NeedTask = zod.input; +export type NeedTaskOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needTaskInput.zod.ts b/frontend/src/shared/api/schemas/need/needTaskInput.zod.ts new file mode 100644 index 0000000..3986288 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needTaskInput.zod.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needTaskInputTextMax = 300; + + +export const needTaskInputTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedTaskInput = zod.object({ + "text": zod.string().min(1).max(needTaskInputTextMax).regex(needTaskInputTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput.') + +export type NeedTaskInput = zod.input; +export type NeedTaskInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needTaskText.zod.ts b/frontend/src/shared/api/schemas/need/needTaskText.zod.ts new file mode 100644 index 0000000..9104263 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needTaskText.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedTaskTextMax = 300; + + +export const NeedTaskTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedTaskText = zod.string().min(1).max(NeedTaskTextMax).regex(NeedTaskTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.') + +export type NeedTaskText = zod.input; +export type NeedTaskTextOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needTitle.zod.ts b/frontend/src/shared/api/schemas/need/needTitle.zod.ts new file mode 100644 index 0000000..8682a89 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needTitle.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedTitleMax = 200; + + +export const NeedTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const NeedTitle = zod.string().min(1).max(NeedTitleMax).regex(NeedTitleRegExp).describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.') + +export type NeedTitle = zod.input; +export type NeedTitleOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needUpdate.zod.ts b/frontend/src/shared/api/schemas/need/needUpdate.zod.ts new file mode 100644 index 0000000..06a0474 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needUpdate.zod.ts @@ -0,0 +1,103 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + + +export const needUpdateTitleMax = 200; + + +export const needUpdateTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateSourceTextOneMax = 10000; + +export const needUpdateRequiredSkillsItemNameMax = 100; + + +export const needUpdateRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateRequiredSkillsMax = 30; + +export const needUpdateDesiredSkillsItemNameMax = 100; + + +export const needUpdateDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateDesiredSkillsMax = 30; + +export const needUpdateTasksItemTextMax = 300; + + +export const needUpdateTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateTasksMax = 20; + +export const needUpdateDomainOneValueMax = 100; + + +export const needUpdateDomainOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateWorkFormatsOneValueMax = 3; + +export const needUpdateLocationOneValueMax = 100; + + +export const needUpdateLocationOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const needUpdateSalaryOneValueSalaryFromMin = 1000; +export const needUpdateSalaryOneValueSalaryFromMax = 100000000; +export const needUpdateSalaryOneValueSalaryFromMultipleOf = 1000; + +export const needUpdateSalaryOneValueSalaryToMin = 1000; +export const needUpdateSalaryOneValueSalaryToMax = 100000000; +export const needUpdateSalaryOneValueSalaryToMultipleOf = 1000; + + +export const NeedUpdate = zod.object({ + "expected_version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "title": zod.string().min(1).max(needUpdateTitleMax).regex(needUpdateTitleRegExp).exactOptional().describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "vacancy_id": zod.uuid().nullish().describe('Vacancy of the same organization to link, or null to unlink.'), + "source_text": zod.union([zod.string().min(1).max(needUpdateSourceTextOneMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).'),zod.null()]).exactOptional(), + "specialization": zod.union([zod.object({ + "value": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the specialization in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "grade": zod.union([zod.object({ + "value": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the grade in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needUpdateRequiredSkillsItemNameMax).regex(needUpdateRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(needUpdateRequiredSkillsMax).exactOptional(), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(needUpdateDesiredSkillsItemNameMax).regex(needUpdateDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(needUpdateDesiredSkillsMax).exactOptional(), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(needUpdateTasksItemTextMax).regex(needUpdateTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput.')).max(needUpdateTasksMax).exactOptional(), + "domain": zod.union([zod.object({ + "value": zod.string().min(1).max(needUpdateDomainOneValueMax).regex(needUpdateDomainOneValueRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the domain in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "work_formats": zod.union([zod.object({ + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needUpdateWorkFormatsOneValueMax), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set.'),zod.null()]).exactOptional(), + "location": zod.union([zod.object({ + "value": zod.string().min(1).max(needUpdateLocationOneValueMax).regex(needUpdateLocationOneValueRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the place of work in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "salary": zod.union([zod.object({ + "value": zod.object({ + "salary_from": zod.int().min(needUpdateSalaryOneValueSalaryFromMin).max(needUpdateSalaryOneValueSalaryFromMax).multipleOf(needUpdateSalaryOneValueSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(needUpdateSalaryOneValueSalaryToMin).max(needUpdateSalaryOneValueSalaryToMax).multipleOf(needUpdateSalaryOneValueSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`.'),zod.null()]).exactOptional() +}).describe('Change of a need over the version the client read. Each field present in the body replaces that field as a whole; an absent field stays unchanged. Nested objects and lists are not merged: a field decision and each list are replaced entirely, and a stored item missing from a sent list is deleted. A nullable field sent as null becomes unknown, or unlinked for `vacancy_id`; a skill or task list sent empty deletes every item; a list sent as null fails validation. A field decision `{value, status}` and a list item follow the same rules: `confirmed` with the stored value confirms it and keeps its origin and quote, and `confirmed` with another value sets a confirmed manual value; `extracted` keeps a stored suggestion unconfirmed and is allowed only with exactly the stored suggested value, otherwise it answers 400 with the pointer of that `status`, such as `/grade/status` or `/required_skills/0/status`. A client that sends back an unchanged form therefore confirms nothing by accident: it sends each suggestion with `extracted`, or leaves the field out. Sending a different `source_text` extracts again: new suggestions replace only the `extracted` values and items of fields not named in this body; confirmed values are never overwritten, a suggested skill whose name is already in either skill list is skipped, and a suggestion that a member deleted is not proposed again for this need. Unknown fields are rejected, so a request cannot set membership, a role, a provenance, readiness, a recommendation or its score, or a candidate\'s salary minimum.') + +export type NeedUpdate = zod.input; +export type NeedUpdateOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needValueOrigin.zod.ts b/frontend/src/shared/api/schemas/need/needValueOrigin.zod.ts new file mode 100644 index 0000000..15e6c7e --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needValueOrigin.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedValueOrigin = zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.') + +export type NeedValueOrigin = zod.input; +export type NeedValueOriginOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needValueSource.zod.ts b/frontend/src/shared/api/schemas/need/needValueSource.zod.ts new file mode 100644 index 0000000..54ee945 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needValueSource.zod.ts @@ -0,0 +1,25 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needValueSourceQuoteOneMax = 300; + + +export const needValueSourceExtractionVersionOneMax = 64; + + +export const needValueSourceExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedValueSource = zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needValueSourceQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needValueSourceExtractionVersionOneMax).regex(needValueSourceExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.') + +export type NeedValueSource = zod.input; +export type NeedValueSourceOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needValueStatus.zod.ts b/frontend/src/shared/api/schemas/need/needValueStatus.zod.ts new file mode 100644 index 0000000..58f07bc --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needValueStatus.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedValueStatus = zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.') + +export type NeedValueStatus = zod.input; +export type NeedValueStatusOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needVersion.zod.ts b/frontend/src/shared/api/schemas/need/needVersion.zod.ts new file mode 100644 index 0000000..b1452e5 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needVersion.zod.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + + + +export const NeedVersion = zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.') + +export type NeedVersion = zod.input; +export type NeedVersionOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needVersionLabel.zod.ts b/frontend/src/shared/api/schemas/need/needVersionLabel.zod.ts new file mode 100644 index 0000000..a2ee0f9 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needVersionLabel.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const NeedVersionLabelMax = 64; + + +export const NeedVersionLabelRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedVersionLabel = zod.string().min(1).max(NeedVersionLabelMax).regex(NeedVersionLabelRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.') + +export type NeedVersionLabel = zod.input; +export type NeedVersionLabelOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needWorkFormats.zod.ts b/frontend/src/shared/api/schemas/need/needWorkFormats.zod.ts new file mode 100644 index 0000000..51b2d41 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needWorkFormats.zod.ts @@ -0,0 +1,31 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needWorkFormatsValueMax = 3; + +export const needWorkFormatsSourceOneQuoteOneMax = 300; + + +export const needWorkFormatsSourceOneExtractionVersionOneMax = 64; + + +export const needWorkFormatsSourceOneExtractionVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$'); + +export const NeedWorkFormats = zod.object({ + "status": zod.enum(['confirmed', 'extracted', 'unknown']).describe('Confirmation state of one need field.\n\n- confirmed: a member of the organization entered the value or confirmed it. Only confirmed values feed readiness, category recommendations, search, and invitations.\n- extracted: the server proposed the value from the need text or an import, and nobody has confirmed it yet. It is a suggestion: it never feeds search or recommendations and never counts as an answer in readiness.\n- unknown: the field has no value. `value` and `source` are null. The server never fills an unknown field with a default or a guess, such as a Senior grade, the remote format, or a zero salary.'), + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needWorkFormatsValueMax).nullable(), + "source": zod.union([zod.object({ + "origin": zod.enum(['manual', 'extracted_from_text', 'imported']).describe('Where the value of a field or item came from. The server sets it; a request never sends it.\n\n- manual: a member of the organization typed the value in the form. `quote`, `extraction_version`, and `extracted_in_version` are null.\n- extracted_from_text: the server extracted the value from `source_text`, with the deterministic rules and dictionary or, planned, with the ML service. `extraction_version` names the extractor version.\n- imported: planned; the value was copied from a linked vacancy or an import. No MVP operation produces it.\n\nConfirming an extracted value keeps its origin and quote; changing the value makes it `manual`. Adding a value is a contract change.'), + "quote": zod.union([zod.string().min(1).max(needWorkFormatsSourceOneQuoteOneMax).describe('Exact excerpt of the `source_text` that the value was extracted from, so a reviewer can check it. It may contain line breaks. Plain text; clients show it as text, never as HTML.'),zod.null()]).describe('Excerpt of the need text that supports the value, or null for a manual value and for an extracted value that the extractor did not tie to one excerpt.'), + "extracted_in_version": zod.union([zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'),zod.null()]).describe('Need version whose `source_text` the value was extracted from and the quote is an excerpt of, or null for a manual value. A confirmed value keeps it after the text changes, so its quote may be absent from the current `source_text`.'), + "extraction_version": zod.union([zod.string().min(1).max(needWorkFormatsSourceOneExtractionVersionOneMax).regex(needWorkFormatsSourceOneExtractionVersionOneRegExp).describe('Opaque identifier of a published extractor or algorithm version, for example `need-rules.2026-10.1`. Clients show it as text and never parse it.'),zod.null()]).describe('Extractor version for an extracted or imported value, or null for a manual value.') +}).describe('Provenance of a value: its origin, the quote it was extracted from, the need version whose text the quote belongs to, and the extractor version. Read-only; the server derives it and a request cannot set it.'),zod.null()]) +}).describe('Work formats that the employer offers, with their confirmation state and provenance. `value` and `source` are null exactly when `status` is `unknown`; a known value lists one to three formats.') + +export type NeedWorkFormats = zod.input; +export type NeedWorkFormatsOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/needWorkFormatsInput.zod.ts b/frontend/src/shared/api/schemas/need/needWorkFormatsInput.zod.ts new file mode 100644 index 0000000..ffefda2 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/needWorkFormatsInput.zod.ts @@ -0,0 +1,18 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const needWorkFormatsInputValueMax = 3; + + +export const NeedWorkFormatsInput = zod.object({ + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(needWorkFormatsInputValueMax), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set.') + +export type NeedWorkFormatsInput = zod.input; +export type NeedWorkFormatsInputOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/pageInfo.zod.ts b/frontend/src/shared/api/schemas/need/pageInfo.zod.ts similarity index 100% rename from frontend/src/shared/api/schemas/pageInfo.zod.ts rename to frontend/src/shared/api/schemas/need/pageInfo.zod.ts diff --git a/frontend/src/shared/api/schemas/need/rubAmount.zod.ts b/frontend/src/shared/api/schemas/need/rubAmount.zod.ts new file mode 100644 index 0000000..7220805 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/rubAmount.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const RubAmountMin = 1000; +export const RubAmountMax = 100000000; +export const RubAmountMultipleOf = 1000; + + +export const RubAmount = zod.int().min(RubAmountMin).max(RubAmountMax).multipleOf(RubAmountMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.') + +export type RubAmount = zod.input; +export type RubAmountOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/salaryPeriod.zod.ts b/frontend/src/shared/api/schemas/need/salaryPeriod.zod.ts new file mode 100644 index 0000000..7980464 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/salaryPeriod.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const SalaryPeriod = zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.') + +export type SalaryPeriod = zod.input; +export type SalaryPeriodOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/salaryRange.zod.ts b/frontend/src/shared/api/schemas/need/salaryRange.zod.ts new file mode 100644 index 0000000..7ce6db5 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/salaryRange.zod.ts @@ -0,0 +1,27 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const salaryRangeSalaryFromMin = 1000; +export const salaryRangeSalaryFromMax = 100000000; +export const salaryRangeSalaryFromMultipleOf = 1000; + +export const salaryRangeSalaryToMin = 1000; +export const salaryRangeSalaryToMax = 100000000; +export const salaryRangeSalaryToMultipleOf = 1000; + + +export const SalaryRange = zod.object({ + "salary_from": zod.int().min(salaryRangeSalaryFromMin).max(salaryRangeSalaryFromMax).multipleOf(salaryRangeSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(salaryRangeSalaryToMin).max(salaryRangeSalaryToMax).multipleOf(salaryRangeSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.') + +export type SalaryRange = zod.input; +export type SalaryRangeOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/salaryTaxBasis.zod.ts b/frontend/src/shared/api/schemas/need/salaryTaxBasis.zod.ts new file mode 100644 index 0000000..3443dd1 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/salaryTaxBasis.zod.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const SalaryTaxBasis = zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') + +export type SalaryTaxBasis = zod.input; +export type SalaryTaxBasisOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/skillName.zod.ts b/frontend/src/shared/api/schemas/need/skillName.zod.ts new file mode 100644 index 0000000..18645e5 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/skillName.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const SkillNameMax = 100; + + +export const SkillNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); + +export const SkillName = zod.string().min(1).max(SkillNameMax).regex(SkillNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.') + +export type SkillName = zod.input; +export type SkillNameOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/skillTaxonomyCode.zod.ts b/frontend/src/shared/api/schemas/need/skillTaxonomyCode.zod.ts new file mode 100644 index 0000000..b2b0a0f --- /dev/null +++ b/frontend/src/shared/api/schemas/need/skillTaxonomyCode.zod.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + +export const SkillTaxonomyCodeMax = 64; + + +export const SkillTaxonomyCodeRegExp = new RegExp('^[a-z0-9][a-z0-9_.+#-]*$'); + +export const SkillTaxonomyCode = zod.string().min(1).max(SkillTaxonomyCodeMax).regex(SkillTaxonomyCodeRegExp).describe('Code of a skill in the platform skill taxonomy, for example `postgresql`. The server assigns it from the taxonomy; clients never send it and never derive it from the name.') + +export type SkillTaxonomyCode = zod.input; +export type SkillTaxonomyCodeOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/need/updateOrganizationNeedBody.zod.ts b/frontend/src/shared/api/schemas/need/updateOrganizationNeedBody.zod.ts new file mode 100644 index 0000000..95c5207 --- /dev/null +++ b/frontend/src/shared/api/schemas/need/updateOrganizationNeedBody.zod.ts @@ -0,0 +1,103 @@ +/** + * Generated by orval 🍺 + * Do not edit manually. + * Lincodex API + * OpenAPI spec version: 0.1.0 + */ +import * as zod from 'zod'; + + +export const updateOrganizationNeedBodyTitleMax = 200; + + +export const updateOrganizationNeedBodyTitleRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodySourceTextOneMax = 10000; + +export const updateOrganizationNeedBodyRequiredSkillsItemNameMax = 100; + + +export const updateOrganizationNeedBodyRequiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodyRequiredSkillsMax = 30; + +export const updateOrganizationNeedBodyDesiredSkillsItemNameMax = 100; + + +export const updateOrganizationNeedBodyDesiredSkillsItemNameRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodyDesiredSkillsMax = 30; + +export const updateOrganizationNeedBodyTasksItemTextMax = 300; + + +export const updateOrganizationNeedBodyTasksItemTextRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodyTasksMax = 20; + +export const updateOrganizationNeedBodyDomainOneValueMax = 100; + + +export const updateOrganizationNeedBodyDomainOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodyWorkFormatsOneValueMax = 3; + +export const updateOrganizationNeedBodyLocationOneValueMax = 100; + + +export const updateOrganizationNeedBodyLocationOneValueRegExp = new RegExp('^\\S(?:.*\\S)?$'); +export const updateOrganizationNeedBodySalaryOneValueSalaryFromMin = 1000; +export const updateOrganizationNeedBodySalaryOneValueSalaryFromMax = 100000000; +export const updateOrganizationNeedBodySalaryOneValueSalaryFromMultipleOf = 1000; + +export const updateOrganizationNeedBodySalaryOneValueSalaryToMin = 1000; +export const updateOrganizationNeedBodySalaryOneValueSalaryToMax = 100000000; +export const updateOrganizationNeedBodySalaryOneValueSalaryToMultipleOf = 1000; + + +export const UpdateOrganizationNeedBody = zod.object({ + "expected_version": zod.int().min(1).describe('Version of an employer need. Creation makes version 1, and every committed change of the need advances it by exactly one, including a change made by the server, such as a planned asynchronous ML suggestion. Each version is an immutable snapshot of the need. `requirements_version` names the version whose confirmed requirements are current, so a change that leaves them unchanged creates a need version without a new requirements version.'), + "title": zod.string().min(1).max(updateOrganizationNeedBodyTitleMax).regex(updateOrganizationNeedBodyTitleRegExp).exactOptional().describe('Short name of the need inside the organization, for example "Backend for the payments team". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "vacancy_id": zod.uuid().nullish().describe('Vacancy of the same organization to link, or null to unlink.'), + "source_text": zod.union([zod.string().min(1).max(updateOrganizationNeedBodySourceTextOneMax).describe('Free description of the team\'s tasks as the employer wrote or pasted it. The server extracts proposed requirements from it; the text itself is never a requirement. It may contain line breaks. Plain text; clients show it as text, never as HTML. It describes the job and must not contain personal data of candidates. The server stores it as written: it may contain requirements that discriminate by a protected characteristic, and the extractor never turns such a requirement into a need field. Exclusions, the requirements that a candidate must not meet, are planned as a separate additive field with the Labor Code article 64 check (TASK-182).'),zod.null()]).exactOptional(), + "specialization": zod.union([zod.object({ + "value": zod.enum(['backend', 'frontend', 'mobile', 'network_engineer', 'devops_sre', 'data_analyst', 'ds_ml', 'information_security', 'qa']).describe('Stable code of a specialization. A category is a specialization together with a confirmed grade; programming languages and the technology stack are separate attributes and never form a category of their own, so Backend with Go is the category `backend`, not `go`. Algorithms is a shared assessment module, not a specialization, and has no code here.\n\n- backend: Backend (development).\n- frontend: Frontend (development).\n- mobile: Mobile (development).\n- network_engineer: Network Engineer (infrastructure).\n- devops_sre: DevOps/SRE (infrastructure).\n- data_analyst: Data Analyst (data).\n- ds_ml: DS/ML (data).\n- information_security: Information security (security).\n- qa: QA (quality).\n\nAdding a value is a contract change; renaming or removing one is a breaking change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the specialization in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "grade": zod.union([zod.object({ + "value": zod.enum(['intern', 'junior', 'middle', 'senior']).describe('Grade of the MVP scale in ascending order: `intern`, `junior`, `middle`, `senior`. The same codes describe a self-assessed grade, which the candidate states, and a confirmed grade, which only an assessment result establishes. Lead and Architect are planned after the MVP; adding a value is a contract change.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the grade in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "required_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(updateOrganizationNeedBodyRequiredSkillsItemNameMax).regex(updateOrganizationNeedBodyRequiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(updateOrganizationNeedBodyRequiredSkillsMax).exactOptional(), + "desired_skills": zod.array(zod.object({ + "name": zod.string().min(1).max(updateOrganizationNeedBodyDesiredSkillsItemNameMax).regex(updateOrganizationNeedBodyDesiredSkillsItemNameRegExp).describe('Name of a skill or technology as the employer gave it, for example Go, PostgreSQL, or Temporal. It has no leading or trailing whitespace and no line breaks. The server compares names without regard to letter case. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One skill of a list in a request. A name that equals, without regard to letter case, a skill of the current version in either skill list refers to that skill and keeps its origin, quote, and taxonomy code; this is how an extracted skill is confirmed or moved between the required and desired lists. Any other name is a new manual skill. `status` follows the rules of NeedUpdate: `extracted` for a name that is not a stored suggestion answers 400 validation_failed with the pointer of that `status`, for example `/required_skills/2/status`. A name repeated within or across the two skill lists answers 400 with the pointer of the later `name`.')).max(updateOrganizationNeedBodyDesiredSkillsMax).exactOptional(), + "tasks": zod.array(zod.object({ + "text": zod.string().min(1).max(updateOrganizationNeedBodyTasksItemTextMax).regex(updateOrganizationNeedBodyTasksItemTextRegExp).describe('One work task of the team, for example "Move the payout service to an event model". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('One task of the list in a request. A text equal to a task of the current version refers to that task and keeps its origin and quote; any other text is a new manual task. `status` and repeated texts follow the rules of NeedSkillInput.')).max(updateOrganizationNeedBodyTasksMax).exactOptional(), + "domain": zod.union([zod.object({ + "value": zod.string().min(1).max(updateOrganizationNeedBodyDomainOneValueMax).regex(updateOrganizationNeedBodyDomainOneValueRegExp).describe('Business domain of the work, for example payments or logistics, as free text. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the domain in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "work_formats": zod.union([zod.object({ + "value": zod.array(zod.enum(['remote', 'office', 'hybrid']).describe('Acceptable work format: `remote`, `office`, or `hybrid`.')).min(1).max(updateOrganizationNeedBodyWorkFormatsOneValueMax), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the work formats in a request; see NeedUpdate for the rules of `status`. Formats are compared as a set.'),zod.null()]).exactOptional(), + "location": zod.union([zod.object({ + "value": zod.string().min(1).max(updateOrganizationNeedBodyLocationOneValueMax).regex(updateOrganizationNeedBodyLocationOneValueRegExp).describe('Place of work for the office or hybrid format, for example a city, as free text. It describes the employer\'s office, never a candidate\'s address. Plain text without line breaks; clients show it as text, never as HTML.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the place of work in a request; see NeedUpdate for the rules of `status`.'),zod.null()]).exactOptional(), + "salary": zod.union([zod.object({ + "value": zod.object({ + "salary_from": zod.int().min(updateOrganizationNeedBodySalaryOneValueSalaryFromMin).max(updateOrganizationNeedBodySalaryOneValueSalaryFromMax).multipleOf(updateOrganizationNeedBodySalaryOneValueSalaryFromMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "salary_to": zod.int().min(updateOrganizationNeedBodySalaryOneValueSalaryToMin).max(updateOrganizationNeedBodySalaryOneValueSalaryToMax).multipleOf(updateOrganizationNeedBodySalaryOneValueSalaryToMultipleOf).describe('Amount of money in whole rubles. A salary bound is positive and a multiple of 1000, the step that PRD FR13 sets for the bounds of a salary range and for the bids of the sealed final.'), + "currency": zod.enum(['RUB']).describe('ISO 4217 currency code. The MVP accepts only RUB; adding a value is a contract change.'), + "period": zod.enum(['month']).describe('Pay period of a salary amount. The MVP uses only `month`; adding a value is a contract change.'), + "tax_basis": zod.enum(['net', 'gross']).describe('Tax basis of a salary amount: `net`, the amount paid out after personal income tax, or `gross`, the amount before it. The basis is always explicit; amounts in different bases are never compared directly.') +}).describe('Salary range `[A; B]` in whole rubles with its base: the currency, the pay period, and the tax basis (PRD FR13). The schema requires every field, bounds that are positive multiples of 1000, and the known currency, period, and basis. The server checks the cross-field rules in integer arithmetic: `salary_from < salary_to`, and a width `(B - A) / ((A + B) / 2)` from 10% to 40% inclusive, that is `20 * (B - A) >= A + B` and `5 * (B - A) <= A + B`. A violation answers 400 validation_failed with the pointer of `salary_to` in the request, for example `/salary/value/salary_to`. For example, `[95000; 105000]` has a width of exactly 10% and `[80000; 120000]` exactly 40%; both are accepted. The rules are the same for a need and an invitation.'), + "status": zod.enum(['confirmed', 'extracted']).describe('Confirmation state of a list item, and the decision that a request sends for a field or an item: `confirmed` or `extracted`, with the meaning of NeedValueStatus. A request sends `confirmed` to confirm a suggestion or to set a manual value, and `extracted` only to keep a stored suggestion unconfirmed with exactly its stored value. An item is never `unknown`; a list with no confirmed item is what readiness reports as missing.') +}).describe('Decision about the salary range in a request; see NeedUpdate for the rules of `status` and SalaryRange for the rules of the range, whose pointers are under `/salary/value`.'),zod.null()]).exactOptional() +}).describe('Change of a need over the version the client read. Each field present in the body replaces that field as a whole; an absent field stays unchanged. Nested objects and lists are not merged: a field decision and each list are replaced entirely, and a stored item missing from a sent list is deleted. A nullable field sent as null becomes unknown, or unlinked for `vacancy_id`; a skill or task list sent empty deletes every item; a list sent as null fails validation. A field decision `{value, status}` and a list item follow the same rules: `confirmed` with the stored value confirms it and keeps its origin and quote, and `confirmed` with another value sets a confirmed manual value; `extracted` keeps a stored suggestion unconfirmed and is allowed only with exactly the stored suggested value, otherwise it answers 400 with the pointer of that `status`, such as `/grade/status` or `/required_skills/0/status`. A client that sends back an unchanged form therefore confirms nothing by accident: it sends each suggestion with `extracted`, or leaves the field out. Sending a different `source_text` extracts again: new suggestions replace only the `extracted` values and items of fields not named in this body; confirmed values are never overwritten, a suggested skill whose name is already in either skill list is skipped, and a suggestion that a member deleted is not proposed again for this need. Unknown fields are rejected, so a request cannot set membership, a role, a provenance, readiness, a recommendation or its score, or a candidate\'s salary minimum.') + +export type UpdateOrganizationNeedBody = zod.input; +export type UpdateOrganizationNeedBodyOutput = zod.output; diff --git a/frontend/src/shared/api/schemas/candidate/workFormat.zod.ts b/frontend/src/shared/api/schemas/workFormat.zod.ts similarity index 100% rename from frontend/src/shared/api/schemas/candidate/workFormat.zod.ts rename to frontend/src/shared/api/schemas/workFormat.zod.ts