feat(consent): add versioned append-only consent ledger C1-C5

This commit is contained in:
shira committed 2026-10-06 14:52:33 +03:00
1 parent 008254e44a
commit de49f93b0b
64 files changed
+9244 -132

No files matched your search

@@ -0,0 +1,145 @@
import { describe, expect, expectTypeOf, it } from "vitest";
import { listMyConsents } from "./endpoints/consent/consent";
import { ConsentRecord, ConsentRecordList, ListMyConsentsParams } from "./schemas";
// These tests pin the generated consent ledger contract that the consent
// screen (TASK-065) consumes. They fail when regeneration lets a record lose
// its purpose, text version, state, or revocation, accepts a C4 scope
// without fields, or adds a field that would carry the text hash, another
// subject, or a contact value into the read model.
const contactConsent = {
id: "01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a80",
purpose: "c4",
state: "active",
text_version: "c4-2026-10-01",
source: "invitation_acceptance",
granted_at: "2026-10-06T10:15:00Z",
revoked_at: null,
revocation_source: null,
organization: { id: "01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01", name: "ООО Пример Платежи" },
fields: ["email"],
invitation_id: "01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e6f",
invitation_terms_version: 3,
} as const;
const revokedPublication = {
id: "01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60",
purpose: "c2",
state: "revoked",
text_version: "c2-2026-10-01",
source: "consent_settings",
granted_at: "2026-10-02T09:00:00Z",
revoked_at: "2026-10-04T18:30:00Z",
revocation_source: "consent_settings",
organization: null,
fields: null,
invitation_id: null,
invitation_terms_version: null,
} as const;
const page = {
items: [contactConsent, revokedPublication],
page: { has_more: false, next_cursor: null },
} as const;
describe("generated ConsentRecordList", () => {
it("accepts a C4 record with its scope and an unscoped revoked record", () => {
expect(ConsentRecordList.parse(page)).toEqual(page);
});
it.each([
["an unknown purpose", { purpose: "c6" }, "purpose"],
["an unknown state", { state: "pending" }, "state"],
["an empty text version", { text_version: "" }, "text_version"],
["a text version with a space", { text_version: "c4 2026" }, "text_version"],
["an unknown source", { source: "import" }, "source"],
["an empty field set", { fields: [] }, "fields"],
[
"more than four fields",
{ fields: ["email", "phone", "telegram", "full_name", "email"] },
"fields",
],
["a terms version below 1", { invitation_terms_version: 0 }, "invitation_terms_version"],
])("rejects a record with %s", (_case, change, field) => {
const result = ConsentRecord.safeParse({ ...contactConsent, ...change });
expect(result.success).toBe(false);
// A value can break several rules of its field, such as both the
// length and the pattern; no other field is reported.
expect(new Set(result.error?.issues.map((issue) => issue.path.join("/")))).toEqual(
new Set([field]),
);
});
it.each([
"purpose",
"state",
"text_version",
"granted_at",
"revoked_at",
"revocation_source",
"organization",
"fields",
] as const)("requires %s, null included where it is nullable", (field) => {
const record: Partial<Record<string, unknown>> = { ...revokedPublication };
delete record[field];
expect(ConsentRecord.safeParse(record).success).toBe(false);
});
it("rejects an unknown contact kind", () => {
expect(ConsentRecord.safeParse({ ...contactConsent, fields: ["address"] }).success).toBe(false);
});
it("drops a text hash or a subject that a response would add", () => {
const parsed = ConsentRecord.parse({
...contactConsent,
text_hash: "3c48591d8d098a4538f5e013dfcf406e",
subject_id: "01928f7a-0000-7000-8000-00000000c0de",
email: "candidate@example.com",
});
// Generated Zod strips unknown keys; the server never sends them.
expect(parsed).not.toHaveProperty("text_hash");
expect(parsed).not.toHaveProperty("subject_id");
expect(parsed).not.toHaveProperty("email");
});
});
describe("generated ListMyConsentsParams", () => {
it("accepts the state filter and the page parameters", () => {
expect(ListMyConsentsParams.parse({ state: "active", limit: 50 })).toEqual({
state: "active",
limit: 50,
});
expect(ListMyConsentsParams.parse({})).toEqual({ limit: 20 });
});
it("rejects an unknown state", () => {
expect(ListMyConsentsParams.safeParse({ state: "granted" }).success).toBe(false);
});
});
type PrivateKey =
| "text_hash"
| "hash"
| "subject_id"
| "user_id"
| "account_id"
| "email"
| "phone"
| "telegram"
| "full_name";
it("exposes the read model only for the caller's own consents, without hashes or contacts", () => {
expectTypeOf<Extract<keyof ConsentRecord, PrivateKey>>().toEqualTypeOf<never>();
expectTypeOf<ConsentRecord["fields"]>().toEqualTypeOf<
("full_name" | "email" | "phone" | "telegram")[] | null
>();
// The subject comes from the session: the operation takes no account,
// user, or subject parameter.
expectTypeOf<keyof ListMyConsentsParams>().toEqualTypeOf<"state" | "limit" | "cursor">();
expectTypeOf(listMyConsents).parameter(0).toEqualTypeOf<ListMyConsentsParams | undefined>();
expectTypeOf(listMyConsents).returns.resolves.toEqualTypeOf<ConsentRecordList>();
});
@@ -0,0 +1,47 @@
/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
import {
faker
} from '@faker-js/faker';
import {
fakeFromPattern
} from '../../mock-pattern';
import {
HttpResponse,
http
} from 'msw';
import type {
RequestHandlerOptions
} from 'msw';
import type {
ConsentOrganization,
ConsentRecordList
} from '../../schemas';
export const getListMyConsentsResponseConsentOrganizationMock = (overrideResponse: Partial<ConsentOrganization> = {}): ConsentOrganization => ({...{id: faker.string.uuid(), name: faker.string.alpha({length: {min: 1, max: 200}})}, ...overrideResponse});
export const getListMyConsentsResponseMock = (overrideResponse: Partial<Extract<ConsentRecordList, object>> = {}): ConsentRecordList => ({items: Array.from({ length: faker.number.int({min: 1, max: 100}) }, (_, i) => i + 1).map(() => ({id: faker.string.uuid(), purpose: faker.helpers.arrayElement(['c1','c2','c3','c4','c5'] as const), state: faker.helpers.arrayElement(['active','superseded','revoked'] as const), text_version: fakeFromPattern("^[A-Za-z0-9._-]+$", {minLength: 1, maxLength: 64}), source: faker.helpers.arrayElement(['registration','consent_settings','invitation_acceptance'] as const), granted_at: faker.date.past().toISOString().slice(0, 19) + 'Z', revoked_at: faker.helpers.arrayElement([faker.date.past().toISOString().slice(0, 19) + 'Z',null,]), revocation_source: faker.helpers.arrayElement([faker.helpers.arrayElement(['consent_settings','support_request'] as const),null,]), organization: faker.helpers.arrayElement([{...getListMyConsentsResponseConsentOrganizationMock()},null,]), fields: faker.helpers.arrayElement([faker.helpers.arrayElements(['full_name','email','phone','telegram'] as const), null]), invitation_id: faker.helpers.arrayElement([faker.string.uuid(), null]), invitation_terms_version: faker.helpers.arrayElement([faker.number.int({min: 1}),null,])})), page: {has_more: faker.datatype.boolean(), next_cursor: faker.helpers.arrayElement([fakeFromPattern("^[A-Za-z0-9_-]+$", {minLength: 1, maxLength: 512}), null])}, ...overrideResponse})
export const getListMyConsentsMockHandler = (overrideResponse?: ConsentRecordList | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ConsentRecordList> | ConsentRecordList), options?: RequestHandlerOptions) => {
return http.get('*/api/v1/me/consents', async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
return HttpResponse.json(overrideResponse !== undefined
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
: getListMyConsentsResponseMock(),
{ status: 200
})
}, options)
}
export const getConsentMock = () => [
getListMyConsentsMockHandler()
]
@@ -0,0 +1,166 @@
/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
import {
useQuery
} from '@tanstack/react-query';
import type {
DataTag,
DefinedInitialDataOptions,
DefinedUseQueryResult,
QueryClient,
QueryFunction,
QueryKey,
UndefinedInitialDataOptions,
UseQueryOptions,
UseQueryResult
} from '@tanstack/react-query';
import type {
ConsentRecordList,
ListMyConsentsParams,
Problem
} from '../../schemas';
import { apiRequest } from '../../client';
import type { ErrorType } from '../../client';
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
const withQueryKey = <T extends object, K>(query: T, queryKey: K): T & { queryKey: K } => {
const result = { queryKey } as T & { queryKey: K };
for (const key of Object.keys(query)) {
// The explicit queryKey always wins, matching the previous
// `{ ...query, queryKey }` spread where it was set last.
if (key === 'queryKey') continue;
Object.defineProperty(result, key, {
enumerable: true,
configurable: true,
get: () => (query as Record<string, unknown>)[key],
});
}
return result;
};
export const getListMyConsentsUrl = (params?: ListMyConsentsParams,) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
});
const stringifiedParams = normalizedParams.toString();
return stringifiedParams.length > 0 ? `/api/v1/me/consents?${stringifiedParams}` : `/api/v1/me/consents`
}
/**
* Requires the session cookie of a candidate or an employer account. The subject comes from the session, never from a request parameter, so the response holds only the caller's own consents: no request can name another account, and records of other accounts are never listed. Returns a page of the consent ledger of the account, newest grant first with the identifier as the tie-breaker, with cursor pagination.
*
* The ledger is append-only. Every grant is a record with its purpose, the accepted text version, the source, and the grant time; the server also stores the hash of exactly the text the subject saw. A newer text version of the same purpose is a new record, and the earlier one becomes `superseded` without any change. A revocation stamps every unrevoked record of the purpose, and for c4 of one organization, once; a later grant is a new record. Purposes are independent.
*
* Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history (TASK-088).
*
* Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag (TASK-063 and TASK-064); c1 is given at registration and c4 only in AcceptMyInvitation.
*
* Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed.
* @summary List the consents of the current account with their history.
*/
export const listMyConsents = async (params?: ListMyConsentsParams, options?: Parameters<typeof apiRequest>[1]): Promise<ConsentRecordList> => {
return apiRequest<ConsentRecordList>(getListMyConsentsUrl(params),
{
...options,
method: 'GET'
}
);}
export const getListMyConsentsQueryKey = (params?: ListMyConsentsParams,) => {
return [
`/api/v1/me/consents`, ...(params ? [params] : [])
] as const;
}
export const getListMyConsentsQueryOptions = <TData = Awaited<ReturnType<typeof listMyConsents>>, TError = ErrorType<Problem>>(params?: ListMyConsentsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getListMyConsentsQueryKey(params);
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMyConsents>>> = ({ signal }) => listMyConsents(params, { signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type ListMyConsentsQueryResult = NonNullable<Awaited<ReturnType<typeof listMyConsents>>>
export type ListMyConsentsQueryError = ErrorType<Problem>
export function useListMyConsents<TData = Awaited<ReturnType<typeof listMyConsents>>, TError = ErrorType<Problem>>(
params: undefined | ListMyConsentsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyConsents>>,
TError,
Awaited<ReturnType<typeof listMyConsents>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyConsents<TData = Awaited<ReturnType<typeof listMyConsents>>, TError = ErrorType<Problem>>(
params?: ListMyConsentsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof listMyConsents>>,
TError,
Awaited<ReturnType<typeof listMyConsents>>
> , 'initialData'
>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useListMyConsents<TData = Awaited<ReturnType<typeof listMyConsents>>, TError = ErrorType<Problem>>(
params?: ListMyConsentsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary List the consents of the current account with their history.
*/
export function useListMyConsents<TData = Awaited<ReturnType<typeof listMyConsents>>, TError = ErrorType<Problem>>(
params?: ListMyConsentsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMyConsents>>, TError, TData>>, request?: SecondParameter<typeof apiRequest>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getListMyConsentsQueryOptions(params,options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return withQueryKey(query, queryOptions.queryKey);
}
@@ -1,6 +1,7 @@
export { getAssessmentMock } from './assessment/assessment.msw'
export { getCandidateMock } from './candidate/candidate.msw'
export { getCatalogMock } from './catalog/catalog.msw'
export { getConsentMock } from './consent/consent.msw'
export { getHealthMock } from './health/health.msw'
export { getIdentityMock } from './identity/identity.msw'
export { getInvitationMock } from './invitation/invitation.msw'
@@ -1,6 +1,7 @@
export * from './assessment/assessment';
export * from './candidate/candidate';
export * from './catalog/catalog';
export * from './consent/consent';
export * from './health/health';
export * from './identity/identity';
export * from './invitation/invitation';
@@ -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 consentOrganizationNameMax = 200;
export const ConsentOrganization = zod.object({
"id": zod.uuid().describe('Identifier of the organization.'),
"name": zod.string().min(1).max(consentOrganizationNameMax).describe('Name of the organization in the consent text at the time of the consent. Plain text; clients show it as text, never as HTML.')
}).describe('Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the shown consent text carried at the time of the consent, and the stored text hash proves that text with this name; a later rename of the organization does not change it, so it can differ from the current name.')
export type ConsentOrganization = zod.input<typeof ConsentOrganization>;
export type ConsentOrganizationOutput = zod.output<typeof ConsentOrganization>;
@@ -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 ConsentPurposeCode = zod.enum(['c1', 'c2', 'c3', 'c4', 'c5']).describe('One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.\n\n- c1: processing of personal data, given at registration.\n- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.\n- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.\n- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.\n- c5: import of FSP results.\n\nConsentPurpose lists the subset whose text the client may read before an account exists.')
export type ConsentPurposeCode = zod.input<typeof ConsentPurposeCode>;
export type ConsentPurposeCodeOutput = zod.output<typeof ConsentPurposeCode>;
@@ -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 consentRecordTextVersionOneMax = 64;
export const consentRecordTextVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$');
export const consentRecordOrganizationOneNameMax = 200;
export const consentRecordFieldsMax = 4;
export const ConsentRecord = zod.object({
"id": zod.uuid().describe('Identifier of the record.'),
"purpose": zod.enum(['c1', 'c2', 'c3', 'c4', 'c5']).describe('One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.\n\n- c1: processing of personal data, given at registration.\n- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.\n- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.\n- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.\n- c5: import of FSP results.\n\nConsentPurpose lists the subset whose text the client may read before an account exists.'),
"state": zod.enum(['active', 'superseded', 'revoked']).describe('State of a consent record, computed from the ledger.\n\n- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.\n- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.\n- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.'),
"text_version": zod.string().min(1).max(consentRecordTextVersionOneMax).regex(consentRecordTextVersionOneRegExp).describe('Identifier of the published consent text that the user saw and accepted. The server stores the acceptance with this version and the hash of its text; the client never sends or receives the hash.').describe('Version of the consent text that the subject accepted.'),
"source": zod.enum(['registration', 'consent_settings', 'invitation_acceptance']).describe('Where the subject gave the consent.\n\n- registration: the c1 acceptance of RegisterAccount.\n- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).\n- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.\n\nA c4 given when sending an application (PRD Q9) is planned as an additional value.'),
"granted_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.'),
"revoked_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('Moment of the revocation, or null unless `state` is `revoked`.'),
"revocation_source": zod.union([zod.enum(['consent_settings', 'support_request']).describe('Who recorded a revocation.\n\n- consent_settings: the subject revoked the consent in the product.\n- support_request: an operator recorded a revocation that the subject requested through support.'),zod.null()]).describe('Who recorded the revocation, or null unless `state` is `revoked`.'),
"organization": zod.union([zod.object({
"id": zod.uuid().describe('Identifier of the organization.'),
"name": zod.string().min(1).max(consentRecordOrganizationOneNameMax).describe('Name of the organization in the consent text at the time of the consent. Plain text; clients show it as text, never as HTML.')
}).describe('Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the shown consent text carried at the time of the consent, and the stored text hash proves that text with this name; a later rename of the organization does not change it, so it can differ from the current name.'),zod.null()]).describe('Organization that a c4 consent allows to read the fields, with the name the consent text showed, or null for every other purpose.'),
"fields": zod.array(zod.enum(['full_name', 'email', 'phone', 'telegram']).describe('Kind of personal data that the consent C4 can disclose to one organization (PRD FR01 and FR12). The candidate selects each kind separately; one kind never implies another.\n\n- full_name: the full name from the profile.\n- email: the contact email address from the profile.\n- phone: the contact phone number from the profile.\n- telegram: the Telegram username from the profile.\n\nThe value formats are those of ContactDisclosure: a single-line full name of up to 200 characters, an E.164 phone number, and a Telegram username with the leading @. The profile contract (FR02, TASK-066) must store contacts in the same formats, so a disclosure never has to convert or drop a stored value. The FSP results of FR14, which need their own explicit permission, are planned as additional kinds. Adding a value is a contract change.')).min(1).max(consentRecordFieldsMax).nullable().describe('Contact fields that a c4 consent covers, or null for every other purpose. One kind never implies another.'),
"invitation_id": zod.uuid().nullable().describe('Invitation whose acceptance gave a c4 consent, or null for every other purpose.'),
"invitation_terms_version": zod.union([zod.int().min(1).describe('Version of the terms of an invitation. The terms of a version are an immutable snapshot: every committed change of the terms, in the draft or by the one raise of the upper salary bound after sending, creates the next terms version, and a change of anything else keeps it. An acceptance names the terms version it accepts, and the consent C4 and the contact grant record it.'),zod.null()]).describe('Terms version that the acceptance accepted, or null for every other purpose.')
}).describe('One record of the consent ledger as its subject reads it: the purpose, the text version the subject accepted, where and when the consent was given, its state, and the revocation. A c4 record also names the organization, the contact fields, and the invitation with its terms version; these fields are null for every other purpose. The server also stores the SHA-256 hash of exactly the text the subject saw, which a client never sends or receives.')
export type ConsentRecord = zod.input<typeof ConsentRecord>;
export type ConsentRecordOutput = zod.output<typeof ConsentRecord>;
@@ -0,0 +1,50 @@
/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
import * as zod from 'zod';
export const consentRecordListItemsItemTextVersionOneMax = 64;
export const consentRecordListItemsItemTextVersionOneRegExp = new RegExp('^[A-Za-z0-9._-]+$');
export const consentRecordListItemsItemOrganizationOneNameMax = 200;
export const consentRecordListItemsItemFieldsMax = 4;
export const consentRecordListItemsMax = 100;
export const consentRecordListPageNextCursorMax = 512;
export const consentRecordListPageNextCursorRegExp = new RegExp('^[A-Za-z0-9_-]+$');
export const ConsentRecordList = zod.object({
"items": zod.array(zod.object({
"id": zod.uuid().describe('Identifier of the record.'),
"purpose": zod.enum(['c1', 'c2', 'c3', 'c4', 'c5']).describe('One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.\n\n- c1: processing of personal data, given at registration.\n- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.\n- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.\n- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.\n- c5: import of FSP results.\n\nConsentPurpose lists the subset whose text the client may read before an account exists.'),
"state": zod.enum(['active', 'superseded', 'revoked']).describe('State of a consent record, computed from the ledger.\n\n- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.\n- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.\n- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.'),
"text_version": zod.string().min(1).max(consentRecordListItemsItemTextVersionOneMax).regex(consentRecordListItemsItemTextVersionOneRegExp).describe('Identifier of the published consent text that the user saw and accepted. The server stores the acceptance with this version and the hash of its text; the client never sends or receives the hash.').describe('Version of the consent text that the subject accepted.'),
"source": zod.enum(['registration', 'consent_settings', 'invitation_acceptance']).describe('Where the subject gave the consent.\n\n- registration: the c1 acceptance of RegisterAccount.\n- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).\n- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.\n\nA c4 given when sending an application (PRD Q9) is planned as an additional value.'),
"granted_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.'),
"revoked_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('Moment of the revocation, or null unless `state` is `revoked`.'),
"revocation_source": zod.union([zod.enum(['consent_settings', 'support_request']).describe('Who recorded a revocation.\n\n- consent_settings: the subject revoked the consent in the product.\n- support_request: an operator recorded a revocation that the subject requested through support.'),zod.null()]).describe('Who recorded the revocation, or null unless `state` is `revoked`.'),
"organization": zod.union([zod.object({
"id": zod.uuid().describe('Identifier of the organization.'),
"name": zod.string().min(1).max(consentRecordListItemsItemOrganizationOneNameMax).describe('Name of the organization in the consent text at the time of the consent. Plain text; clients show it as text, never as HTML.')
}).describe('Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the shown consent text carried at the time of the consent, and the stored text hash proves that text with this name; a later rename of the organization does not change it, so it can differ from the current name.'),zod.null()]).describe('Organization that a c4 consent allows to read the fields, with the name the consent text showed, or null for every other purpose.'),
"fields": zod.array(zod.enum(['full_name', 'email', 'phone', 'telegram']).describe('Kind of personal data that the consent C4 can disclose to one organization (PRD FR01 and FR12). The candidate selects each kind separately; one kind never implies another.\n\n- full_name: the full name from the profile.\n- email: the contact email address from the profile.\n- phone: the contact phone number from the profile.\n- telegram: the Telegram username from the profile.\n\nThe value formats are those of ContactDisclosure: a single-line full name of up to 200 characters, an E.164 phone number, and a Telegram username with the leading @. The profile contract (FR02, TASK-066) must store contacts in the same formats, so a disclosure never has to convert or drop a stored value. The FSP results of FR14, which need their own explicit permission, are planned as additional kinds. Adding a value is a contract change.')).min(1).max(consentRecordListItemsItemFieldsMax).nullable().describe('Contact fields that a c4 consent covers, or null for every other purpose. One kind never implies another.'),
"invitation_id": zod.uuid().nullable().describe('Invitation whose acceptance gave a c4 consent, or null for every other purpose.'),
"invitation_terms_version": zod.union([zod.int().min(1).describe('Version of the terms of an invitation. The terms of a version are an immutable snapshot: every committed change of the terms, in the draft or by the one raise of the upper salary bound after sending, creates the next terms version, and a change of anything else keeps it. An acceptance names the terms version it accepts, and the consent C4 and the contact grant record it.'),zod.null()]).describe('Terms version that the acceptance accepted, or null for every other purpose.')
}).describe('One record of the consent ledger as its subject reads it: the purpose, the text version the subject accepted, where and when the consent was given, its state, and the revocation. A c4 record also names the organization, the contact fields, and the invitation with its terms version; these fields are null for every other purpose. The server also stores the SHA-256 hash of exactly the text the subject saw, which a client never sends or receives.')).max(consentRecordListItemsMax).describe('Records of the page.'),
"page": zod.object({
"has_more": zod.boolean().describe('Whether another page follows this one.'),
"next_cursor": zod.string().min(1).max(consentRecordListPageNextCursorMax).regex(consentRecordListPageNextCursorRegExp).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 consent ledger of the current account, newest grant first.')
export type ConsentRecordList = zod.input<typeof ConsentRecordList>;
export type ConsentRecordListOutput = zod.output<typeof ConsentRecordList>;
@@ -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 ConsentRevocationSource = zod.enum(['consent_settings', 'support_request']).describe('Who recorded a revocation.\n\n- consent_settings: the subject revoked the consent in the product.\n- support_request: an operator recorded a revocation that the subject requested through support.')
export type ConsentRevocationSource = zod.input<typeof ConsentRevocationSource>;
export type ConsentRevocationSourceOutput = zod.output<typeof ConsentRevocationSource>;
@@ -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 ConsentSource = zod.enum(['registration', 'consent_settings', 'invitation_acceptance']).describe('Where the subject gave the consent.\n\n- registration: the c1 acceptance of RegisterAccount.\n- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).\n- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.\n\nA c4 given when sending an application (PRD Q9) is planned as an additional value.')
export type ConsentSource = zod.input<typeof ConsentSource>;
export type ConsentSourceOutput = zod.output<typeof ConsentSource>;
@@ -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 ConsentState = zod.enum(['active', 'superseded', 'revoked']).describe('State of a consent record, computed from the ledger.\n\n- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.\n- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.\n- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.')
export type ConsentState = zod.input<typeof ConsentState>;
export type ConsentStateOutput = zod.output<typeof ConsentState>;
@@ -0,0 +1,15 @@
/**
* Generated by orval 🍺
* Do not edit manually.
* Lincodex API
* OpenAPI spec version: 0.1.0
*/
export * from './consentOrganization.zod';
export * from './consentPurposeCode.zod';
export * from './consentRecord.zod';
export * from './consentRecordList.zod';
export * from './consentRevocationSource.zod';
export * from './consentSource.zod';
export * from './consentState.zod';
export * from './listMyConsentsParams.zod';
@@ -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 listMyConsentsParamsLimitDefault = 20;
export const listMyConsentsParamsLimitMax = 100;
export const listMyConsentsParamsCursorMax = 512;
export const listMyConsentsParamsCursorRegExp = new RegExp('^[A-Za-z0-9_-]+$');
export const ListMyConsentsParams = zod.object({
"state": zod.enum(['active', 'superseded', 'revoked']).exactOptional().describe('State of a consent record, computed from the ledger.\n\n- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.\n- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.\n- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.'),
"limit": zod.int().min(1).max(listMyConsentsParamsLimitMax).default(listMyConsentsParamsLimitDefault),
"cursor": zod.string().min(1).max(listMyConsentsParamsCursorMax).regex(listMyConsentsParamsCursorRegExp).exactOptional()
})
export type ListMyConsentsParams = zod.input<typeof ListMyConsentsParams>;
export type ListMyConsentsParamsOutput = zod.output<typeof ListMyConsentsParams>;
+3
View File
@@ -6,9 +6,11 @@
*/
export * from './consentTextVersion.zod';
export * from './contactFieldKind.zod';
export * from './currencyCode.zod';
export * from './emailAddress.zod';
export * from './gradeCode.zod';
export * from './invitationTermsVersion.zod';
export * from './needLocationName.zod';
export * from './needTaskText.zod';
export * from './needVersion.zod';
@@ -29,6 +31,7 @@ export * from './workFormat.zod';
export * from './assessment';
export * from './candidate';
export * from './catalog';
export * from './consent';
export * from './health';
export * from './identity';
export * from './invitation';
@@ -18,7 +18,6 @@ export * from './contactConsentAcceptance.zod';
export * from './contactConsentOffer.zod';
export * from './contactConsentText.zod';
export * from './contactDisclosure.zod';
export * from './contactFieldKind.zod';
export * from './contactFullName.zod';
export * from './contactGrant.zod';
export * from './contactGrantState.zod';
@@ -56,7 +55,6 @@ export * from './invitationSalaryRaise.zod';
export * from './invitationState.zod';
export * from './invitationTeamDescription.zod';
export * from './invitationTerms.zod';
export * from './invitationTermsVersion.zod';
export * from './invitationVersion.zod';
export * from './listMyInvitationsParams.zod';
export * from './listOrganizationInvitationsParams.zod';