feat(org): add organization and membership contract and storage

This commit is contained in:
shira committed 2026-10-06 15:55:29 +03:00
1 parent a0551a34b8
commit bdc5855001
90 files changed
+17545 -480

No files matched your search

+396 -1
View File
@@ -2378,7 +2378,7 @@ InvitationContactAccess:
$ref: '#/ContactFieldKind'
InvitationOrganization:
type: object
description: Organization that sent the invitation, as the candidate sees it before deciding. The organization contract (TASK-077) adds the public card; this object only names it.
description: Organization that sent the invitation, as the candidate sees it before deciding. The card that a candidate sees is `CandidateOrganizationCard` of the organization contract; returning it with the invitation is planned as an additive field, and this object only names the organization.
additionalProperties: false
required:
- id
@@ -3754,6 +3754,401 @@ NeedUpdate:
oneOf:
- $ref: '#/NeedSalaryInput'
- type: 'null'
OrganizationVersion:
type: integer
format: int64
minimum: 1
description: 'Version of the profile of an organization. Creation makes version 1, and every committed change of the profile advances it by exactly one. A change carries the version the client read as `expected_version`. Only the profile has a version: the memberships and the verification level of the organization do not advance it.'
examples:
- 2
OrganizationName:
type: string
minLength: 1
maxLength: 200
pattern: ^\S(?:[^\n\r]*\S)?$
description: Public name of the organization, for example the legal name that a candidate knows. It has no leading or trailing whitespace and no line breaks, and it is at most 200 characters because consent records keep a copy of it. Plain text; clients show it as text, never as HTML. A later rename never changes the copy that a consent record holds.
examples:
- ООО Пример Платежи
OrganizationDescription:
type: string
minLength: 1
maxLength: 2000
description: What the organization does, written for candidates. It may contain line breaks; the server stores CRLF as LF, and it refuses leading and trailing whitespace and any other control character. Plain text; clients show it as text, never as HTML.
examples:
- Платежный сервис для малого бизнеса. Разрабатываем собственное ядро проведения платежей и интеграции с банками.
OrganizationSphere:
type: string
minLength: 1
maxLength: 100
pattern: ^\S(?:.*\S)?$
description: Field of business of the organization as free text, for example "Платежи и финансовые сервисы". It has no leading or trailing whitespace and no line breaks. The product has no sphere taxonomy yet; a taxonomy code would be an additive field. Plain text; clients show it as text, never as HTML.
examples:
- Платежи и финансовые сервисы
OrganizationWebsite:
type: string
minLength: 9
maxLength: 300
pattern: ^https://[^\s/?#@]+(?:[/?#][^\s]*)?$
description: 'Public website of the organization: an https URL with a host name, without credentials. The server also refuses a port, an IP address, a host name without a dot, and `localhost`. It never fetches the address.'
examples:
- https://payments.example.com
OrganizationContactChannels:
type: object
description: Public contacts of the organization, the ones a candidate sees on its card. They are company channels, such as a careers mailbox, the website, a company phone, or a company Telegram account, and never the personal email address, phone, or messenger of an employee; personal contacts of the people of the organization stay out of this object. The server cannot tell a company address from a personal one, so the owner answers for the content, and a candidate can complain about an organization through a support case. The object is the request field and the stored value alike, so a response can be sent back unchanged; every field is required and null means not set. A change replaces the whole object, never a single field of it.
additionalProperties: false
required:
- website
- email
- phone
- telegram
properties:
website:
oneOf:
- $ref: '#/OrganizationWebsite'
- type: 'null'
email:
description: Public mailbox of the organization, such as a careers address, or null. It is stored in the form it was given.
oneOf:
- $ref: '#/EmailAddress'
- type: 'null'
phone:
description: Public phone number of the organization, or null.
oneOf:
- $ref: '#/ContactPhoneNumber'
- type: 'null'
telegram:
description: Public Telegram account of the organization, or null.
oneOf:
- $ref: '#/ContactTelegramUsername'
- type: 'null'
OrganizationRepresentative:
type: object
description: 'A person that speaks for the organization to candidates, as the owner presents them on the card. It is presentation only: a representative is not a member of the organization, has no account link, and gains no right from being listed, and a member does not become a representative by joining. It holds no contact of the person; reaching the organization goes through its public contacts. The name is personal data of an employee that the owner publishes, so the owner must have the right to do it; see the open questions in the organization section of the API guide.'
additionalProperties: false
required:
- name
- job_title
properties:
name:
type: string
minLength: 1
maxLength: 100
pattern: ^\S(?:.*\S)?$
description: Name of the person as the card shows it. It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.
job_title:
type: string
minLength: 1
maxLength: 100
pattern: ^\S(?:.*\S)?$
description: Position of the person in the organization, for example "Руководитель по подбору". It has no leading or trailing whitespace and no line breaks. Plain text; clients show it as text, never as HTML.
OrganizationVerificationLevel:
type: string
description: 'Trust level of an organization (PRD FR07). It limits the quotas of the organization and, in a planned mode, the access of candidates under 18; it never replaces the consent of a candidate.
- e0: the confirmed email of the account that created the organization. Every new organization starts here.
- e1: a corporate email, a verified domain, and a link with the organization.
- e2: a check of the requisites and of the authority of the person.
- e3: a manual check or a partner status.
The server reports e1, e2, or e3 only after a verification process has recorded it for the organization. No request of this contract sets or raises a level, and neither does an edit of the profile, the size of the profile, the number of members, or the domain of an email address. The first slice of the product uses e0 and e1; the processes for e1, e2, and e3 do not exist yet, so a client treats every level other than e0 as unavailable until they do. Adding a level is a contract change.'
enum:
- e0
- e1
- e2
- e3
OrganizationVerificationBasis:
type: string
description: 'Ground of the current verification level, the reason a cabinet can show next to it.
- confirmed_email: the confirmed email of the creating account (e0).
- corporate_domain: a corporate email and a verified domain (e1).
- requisites_and_authority: a check of the requisites and of the authority (e2).
- manual_review: a manual check by the platform (e3).
- partner_status: a partner status (e3).
Each level has its own bases, so a level and a basis that do not belong together never occur. Adding a value is a contract change.'
enum:
- confirmed_email
- corporate_domain
- requisites_and_authority
- manual_review
- partner_status
OrganizationVerification:
type: object
description: 'Verification level of an organization with its ground and the time it was set. It is read-only everywhere in this contract: the server sets it, and no request carries it. The scope of the check and the history of changes (PRD FR07) are planned as additive fields and a separate history with the first verification process.'
additionalProperties: false
required:
- level
- basis
- changed_at
properties:
level:
$ref: '#/OrganizationVerificationLevel'
basis:
$ref: '#/OrganizationVerificationBasis'
changed_at:
description: Moment the level was set to its current value; for a new organization, the creation time.
allOf:
- $ref: '#/Timestamp'
CandidateOrganizationCard:
type: object
description: 'The card of an organization as a candidate sees it: what an invitation shows before the candidate decides. The server builds it from the profile and the verification level and returns it to the owner as the preview of PRD FR07 ("through the eyes of the candidate"); a client never sends it. It holds no membership, no role, no account, no version, and no ground of the verification: a member''s email address, the number of members, and the history of the organization stay out of it. The card is the same object that the candidate side will return (planned in the invitation contract). Only a candidate who received an invitation from the organization sees it; it is not a public page, and no operation shows it to anyone else until the open question about publishing the names of representatives is decided (152-FZ). The server may leave `representatives` out, and a card without them means that the representatives are not published, not that the organization has none.'
additionalProperties: false
required:
- id
- name
- description
- sphere
- contacts
- verification_level
properties:
id:
type: string
format: uuid
description: Identifier of the organization.
name:
$ref: '#/OrganizationName'
description:
description: Description of the organization, or null.
oneOf:
- $ref: '#/OrganizationDescription'
- type: 'null'
sphere:
description: Field of business of the organization, or null.
oneOf:
- $ref: '#/OrganizationSphere'
- type: 'null'
contacts:
$ref: '#/OrganizationContactChannels'
representatives:
type:
- array
- 'null'
maxItems: 10
description: Representatives in the order the owner gave them. Absent or null means that they are not published on this card, which says nothing about whether the organization has any.
items:
$ref: '#/OrganizationRepresentative'
verification_level:
$ref: '#/OrganizationVerificationLevel'
Organization:
type: object
description: 'Organization as its members read it: the profile that the owner edits, the verification level that only the server sets, and the card that a candidate sees. It never contains a role, a membership, the members of the organization, or an account identifier, so no field of it can raise a right: the role of the caller is in `OrganizationMembership` and comes only from the membership held by the server. The profile fields repeat in `candidate_card`, which is the candidate''s view of them; the client reads the profile fields for the form and `candidate_card` for the preview.'
additionalProperties: false
required:
- id
- version
- name
- description
- sphere
- contacts
- representatives
- verification
- candidate_card
- created_at
- updated_at
properties:
id:
type: string
format: uuid
description: Identifier of the organization, the `org_id` of every organization-scoped path. It never changes.
version:
$ref: '#/OrganizationVersion'
name:
$ref: '#/OrganizationName'
description:
description: Description of the organization, or null.
oneOf:
- $ref: '#/OrganizationDescription'
- type: 'null'
sphere:
description: Field of business of the organization, or null.
oneOf:
- $ref: '#/OrganizationSphere'
- type: 'null'
contacts:
$ref: '#/OrganizationContactChannels'
representatives:
type: array
maxItems: 10
description: Representatives in the order the owner gave them.
items:
$ref: '#/OrganizationRepresentative'
verification:
$ref: '#/OrganizationVerification'
candidate_card:
$ref: '#/CandidateOrganizationCard'
created_at:
$ref: '#/Timestamp'
updated_at:
$ref: '#/Timestamp'
OrganizationCreate:
type: object
description: New organization. Only `name` is required, so a company can start with its name and complete the card later. The creating account becomes the owner of the organization; the body has no field for a role, a membership, an owner, a verification level, or a version, and unknown fields are rejected, so a request cannot set any of them. An absent `description` or `sphere`, and one sent as null, stay unset; an absent `contacts` has every contact unset; an absent `representatives` is an empty list.
additionalProperties: false
required:
- name
properties:
name:
$ref: '#/OrganizationName'
description:
oneOf:
- $ref: '#/OrganizationDescription'
- type: 'null'
sphere:
oneOf:
- $ref: '#/OrganizationSphere'
- type: 'null'
contacts:
$ref: '#/OrganizationContactChannels'
representatives:
type: array
maxItems: 10
items:
$ref: '#/OrganizationRepresentative'
OrganizationUpdate:
type: object
description: Change of the profile of an organization over the version the client read. Each field present replaces that field as a whole and an absent field stays unchanged; `contacts` and `representatives` are replaced entirely and never merged, and a representative left out of a sent list is removed. `description` and `sphere` sent as null become unset; `name`, `contacts`, and `representatives` cannot be null. The body can change the profile only. It has no field for a role, a membership, an owner, a verification level, a basis, or a card, and unknown fields are rejected, so editing the profile can neither raise a right nor raise the trust level of the organization; both change only through processes of the server.
additionalProperties: false
required:
- expected_version
properties:
expected_version:
$ref: '#/OrganizationVersion'
name:
$ref: '#/OrganizationName'
description:
oneOf:
- $ref: '#/OrganizationDescription'
- type: 'null'
sphere:
oneOf:
- $ref: '#/OrganizationSphere'
- type: 'null'
contacts:
$ref: '#/OrganizationContactChannels'
representatives:
type: array
maxItems: 10
items:
$ref: '#/OrganizationRepresentative'
OrganizationRole:
type: string
description: 'Role of a member in an organization (PRD 2.2 and the FR07 matrix). The role belongs to the membership, never to the organization or to any editable profile.
- owner: manages the organization and its members, and acts on behalf of the company.
- recruiter: leads the selection of candidates for all needs.
- hiring_manager: acts on the needs assigned to the member.
- technical_expert: refines the requirements of the assigned needs; reads no contacts and sends no invitations.
In the MVP only the owner acts, so the other roles grant nothing yet: an operation that is not open to a role answers 403 `forbidden`. The full matrix is planned, and applying it changes no field of this contract. Adding a role is a contract change.'
enum:
- owner
- recruiter
- hiring_manager
- technical_expert
MembershipState:
type: string
description: 'State of a membership. Only `active` gives access: every other state answers as if the account were no member.
- active: the member works in the organization with the role.
- suspended: access is stopped, and the owner or the platform may restore it.
- removed: the owner or the platform ended the membership. A removal by the platform is not undone by the owner or by an invitation: the acceptance of an employee invitation and the member management (TASK-082, TASK-084) must not reactivate it on their own. Who removed the member and why become additive fields of the member management.
- left: the member ended the membership.
One account has at most one membership per organization, so a former member who returns gets the same membership back in `active`, and the history of the pair is the history of its audit events (planned). The listing of this contract returns only `active` memberships; the other states are listed now so that generated clients accept them when the member management reads them. Adding a state is a contract change.'
enum:
- active
- suspended
- removed
- left
OrganizationMembership:
type: object
description: The membership of the caller in one organization. The caller is the account of the session, so the object holds no account identifier. Only the server sets the role and the state, through the operations that manage members, which are planned; no operation of this contract changes them.
additionalProperties: false
required:
- organization_id
- role
- state
- joined_at
properties:
organization_id:
type: string
format: uuid
description: Identifier of the organization.
role:
$ref: '#/OrganizationRole'
state:
$ref: '#/MembershipState'
joined_at:
description: Moment the membership was first created. A member who left and returns keeps the same value, because the pair has one membership; the moment of the latest activation is a planned additive field (`activated_at`, TASK-082).
allOf:
- $ref: '#/Timestamp'
OrganizationSummary:
type: object
description: 'An organization in the list of the caller''s organizations: what a switcher needs to name it. The profile, the contacts, and the representatives are in `Organization`.'
additionalProperties: false
required:
- id
- name
- verification_level
properties:
id:
type: string
format: uuid
description: Identifier of the organization, the `org_id` of its paths.
name:
$ref: '#/OrganizationName'
verification_level:
$ref: '#/OrganizationVerificationLevel'
MyOrganization:
type: object
description: An organization available to the caller together with the caller's membership in it.
additionalProperties: false
required:
- organization
- membership
properties:
organization:
$ref: '#/OrganizationSummary'
membership:
$ref: '#/OrganizationMembership'
MyOrganizationList:
type: object
description: One page of the organizations available to the caller, newest membership first. It holds only organizations where the caller has an `active` membership, so it is also the list of contexts the caller can work in; it never names an organization the caller cannot enter.
additionalProperties: false
required:
- items
- page
properties:
items:
type: array
maxItems: 100
description: Organizations of the page.
items:
$ref: '#/MyOrganization'
page:
$ref: '#/PageInfo'
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.