Skip to content

Types

View as Markdown

The types are exported by @vimine/sdk (and by /server) and mirror the OpenAPI document: field names are the JSON ones. The complete shapes are in the API reference; here the main ones.

type Scope =
| 'profile:read' | 'profile:write'
| 'membership:read' | 'membership:request' | 'statuto:accept' | 'network:manage'
| 'memberships:read' | 'verify:read'
| 'identity:signup' | 'enroll:write' | 'checkins:write' | 'webhooks:manage'
| 'events:read' | 'registrations:read' | 'registrations:write';
type MembershipStatus = 'pending' | 'active' | 'suspended' | 'revoked' | 'rejected';
/** What the card is worth right now. */
type MembershipVerdict = 'valid' | 'expired' | 'not_yet_valid' | 'statuto_required' | 'inactive';
interface Me {
sub: string; // identifier for your association (vms_…)
email: string;
email_verified: boolean;
first_name: string | null;
last_name: string | null;
phone: string | null;
dob: string | null; // YYYY-MM-DD
gender: 'M' | 'F' | null; // demographic only: it is not cross-checked against the code
birthplace: string | null; // comune (born in Italy) or city, free text (born abroad)
birth_country: string | null; // ISO 3166-1 alpha-2
codicefiscale: string | null; // optional: a person may have none
codicefiscale_check: CodiceFiscaleCheck | null; // how the person is identified; null = not yet
locale: Locale | null; // the language the person chose; null = never chosen
updated_at: string | null;
}
/** A language Vimine speaks. Wherever the API takes one it also takes a regional tag (`en-GB` → `en`, `zh-TW` → `zh-Hant`) and reduces it. */
type Locale = 'it' | 'en' | 'zh-Hans' | 'zh-Hant' | 'fr' | 'es' | 'de' | 'pt-BR';
interface LocaleParam { locale?: Locale | string } // ?locale= of the reads — see the Languages guide
/** How a person is identified: by a fiscal code OR by date, place and country of birth — never neither. */
type CodiceFiscaleCheck = 'matched' | 'mismatch_confirmed' | 'absent';
interface MeUpdate { // PATCH /v1/me
phone?: string | null;
dob?: string | null;
gender?: 'M' | 'F' | null;
birthplace?: string | null;
birth_country?: string | null; // ISO 3166-1 alpha-2
codicefiscale?: string | null; // may be added later, or set back to null
codicefiscale_confirmed?: boolean; // write-only: the person confirms a code that disagrees (after a `confirmable: true`)
locale?: Locale | null; // null clears the choice; 422 `unsupported` for a language Vimine does not speak
}
interface Membership {
id: string;
status: MembershipStatus;
verdict: MembershipVerdict;
subdate: string | null;
issued_at: string | null;
expires_at: string | null;
membership_type: { uid: string; cod: string; name: string } | null;
statuto: {
current_version: number | null;
current_sha256: string | null;
accepted_version_id: string | null;
accepted_at: string | null;
pending: boolean; // a newer statuto was published since the member accepted one
overdue: boolean; // … and the window to re-accept it has elapsed
};
pending_reasons: Array<'approval' | 'payment'>; // why it is still pending, in order: admission, then the fee
payment_open: boolean; // may the fee be paid now? (admission opens payment)
valid_from: string | null; // when the card becomes usable (the association's interval)
usable: boolean; // the card counts at the door right now
quota: { amount: number; currency: string; paid: boolean } | null;
payment_instructions: string | null;
expires_in_days: number | null;
renewal: { window_open: boolean; requested_at: string | null }; // self-service renewal: open 60 days before expiry
network_opt_in: boolean;
card: { token: string; nbf: number; exp: number } | null; // the vmt_… token of the QR and its window (unix s)
}
interface Card { token: string; nbf: number; exp: number; status: MembershipStatus }
interface MembershipRequest { // POST /v1/me/membership
membership_type?: string; // uid; optional when the association offers exactly one
accept_statuto: { version: number; sha256?: string };
}
type MembershipRequestResult =
| { created: true; status: 'pending'; id: string }
| { already_requested: true; status: MembershipStatus };
interface MembershipEvents {
items: Array<{ from: MembershipStatus | null; to: MembershipStatus; reason: string | null; changed_at: string; channel: string }>;
next_cursor: string | null;
}
interface StatutoInfo {
uid: string;
version: number;
approvaldate: string | null;
sha256: string | null;
content: string | null;
document_url: string | null;
accepted: boolean;
accepted_at: string | null;
overdue: boolean;
}
interface Connection {
client_id: string;
name: string;
kind: 'public' | 'native' | 'confidential' | 'first_party';
scopes: Scope[];
granted_at: string;
}
interface Verification {
status: 'active' | 'inactive';
valid_until?: string;
valid_from?: string; // with reason 'not_yet_valid': the card is genuine and active, and becomes usable from here
reason?: 'expired' | 'invalid' | 'not_yet_valid';
}
type AdmissionModel = 'board' | 'provisional' | 'automatic'; // how the association admits its members
interface AssociationPublicConfig {
aps: {
slug: string; name: string;
picture_url: string | null;
citta: string | null; provincia: string | null;
enroll_enabled: boolean;
accepting_requests: boolean; // enrolment is on AND there is room for one more member, right now
invitation_only: boolean; // private beta: takes only the people it invited (accepting_requests is false)
// how the association admits its members — tell an applicant up front. board: the board decides, the fee after;
// provisional: admitted at once, ratified later; automatic: active as soon as the conditions are met.
// delay_hours: hours between admission and a USABLE card (0 = at once)
admission: { model: AdmissionModel; delay_hours: number };
approval_required: boolean; // deprecated: true when admission.model is 'board' — read `admission`
payment_instructions: string | null; // how to pay the fee, when the association published it
member_address: MemberAddressPolicy; // whether the association collects its members' address — of every member or of nobody
// activities of general interest (art. 5 of the Third Sector Code): letter, wording, which is prevalent
activity_sectors: Array<{ cod: string; description: string; prevalent: boolean }>;
// registered in the RUNTS per the official lists, else null
registry: {
section: 'APS' | 'ODV' | 'EF' | 'IS' | 'RA' | 'SOMS' | 'ALTRI' | null;
number: string | null; registered_on: string | null; checked_on: string | null;
} | null;
};
membership_types: Array<{
uid: string; cod: string; name: string; description: string | null;
quota_amount: number | null; currency: string;
expiry_model: 'solar_year' | 'rolling_12' | 'rolling_24' | 'prorated_solar' | 'custom';
network_eligible: boolean;
}>;
statuto: { uid: string; version: number; approvaldate: string | null; sha256: string | null; content: string | null; document_url: string | null } | null;
}
type MemberAddressPolicy = 'none' | 'optional' | 'required';
interface FiscalCodeCheck {
code: string; first_name?: string; last_name?: string; gender?: 'M' | 'F'; date?: string; place?: string;
country?: string; // country of birth: for a person born abroad the code holds the state only, and `place` is not compared
}
type FiscalCodeMismatch = 'lastName' | 'firstName' | 'gender' | 'date' | 'place';
type FiscalCodeHint = 'names_swapped';
interface FiscalCodeResult {
valid: boolean;
error: 'invalid' | 'mismatch' | null; // 'invalid': structure or check character; 'mismatch': it disagrees with the data sent
mismatches: FiscalCodeMismatch[];
hints: FiscalCodeHint[];
birth_date: string | null; // the date of birth the code holds (YYYY-MM-DD)
birth_country: string | null; // the country of birth the code holds (IT for a comune)
}
interface CardKeys { keys: Array<{ kty: string; crv: string; x: string; kid: string; use: string; alg: string }> }
interface MembershipStatusInfo { // GET /v1/memberships/{id}/status
id: string;
status: MembershipStatus;
verdict: MembershipVerdict;
valid_until: string | null;
membership_type: { cod: string } | null;
}
interface SignupInput { // POST /v1/signup
email: string;
first_name: string;
last_name: string;
phone?: string | null;
dob?: string | null; // YYYY-MM-DD
gender?: 'M' | 'F' | null;
birthplace?: string | null;
birth_country?: string | null; // ISO 3166-1 alpha-2 — for a person born abroad: the code holds the state only
codicefiscale?: string | null;
codicefiscale_confirmed?: boolean; // the person confirms a code that disagrees (422 `codicefiscale_mismatch` with `confirmable: true`)
accept_terms?: LegalRef; // the account terms accepted on your site — optional, the in-force version
acknowledge_privacy?: LegalRef; // the platform privacy notice read on your site — optional, same rule
}
interface EnrollInput extends SignupInput { // POST /v1/enroll
codicefiscale?: string | null; // optional: a fiscal code OR dob + birthplace + birth_country, never neither
address?: MemberAddress; // residence or domicile, when `aps.member_address` is not `none`
membership_type?: string; // optional when there is exactly one type
accept_statuto: { version: number; sha256?: string };
privacy_notice?: { version: number; sha256?: string }; // required when the association publishes a notice
}
interface MemberAddress {
kind?: 'residence' | 'domicile'; // default 'residence'
line: string; // street and number
postal_code?: string | null;
city: string;
province?: string | null; // Italian addresses only (two letters)
country?: string; // ISO 3166-1 alpha-2, default 'IT'
}
interface EnrollIdentification { // POST /v1/enroll/confirm after a 409 identification_required
dob?: string; birthplace?: string; birth_country?: string; codicefiscale?: string; codicefiscale_confirmed?: boolean;
}
interface CardCheckinResult { // POST /v1/checkins for a card
kind: 'card';
verdict: MembershipVerdict;
status: MembershipStatus;
membership_id: string;
valid_until: string | null;
valid_from: string | null;
identity_check: IdentityCheck | null; // a note for whoever staffs the gate: not part of `verdict`, it restricts nothing
checked_in_at: string;
}
/** 'pending': a document is still to be looked at; 'verified': looked at; 'flagged': looked at, and it did not agree. */
type IdentityCheck = 'pending' | 'verified' | 'flagged';
interface FieldError { // one entry of `VimineError.errors`
field?: string; code?: string; message?: string;
mismatches?: FiscalCodeMismatch[]; hints?: FiscalCodeHint[]; confirmable?: boolean; // `codicefiscale_mismatch` only
}
interface LegalRef { version: string; sha256?: string } // accept_terms / acknowledge_privacy (optional, in-force version)
interface MyAcceptances { // GET /v1/me/acceptances (legal:read)
items: AcceptanceRecord[]; // at, action, channel, kind, title, version, sha256, rendered_sha256, locale, association
pending: { platform: PendingDocument[]; privacy_notice: PendingDocument | null };
}
interface AcceptanceInput { kind: string; version: string | number; sha256?: string } // POST /v1/me/acceptances (legal:accept)
interface Accepted { status: 'accepted' } // the answer, always the same
interface EnrollConfirmResult { // POST /v1/enroll/confirm
status: MembershipStatus;
already: boolean; // already had a membership or a request
pending_reasons: Array<'approval' | 'payment'>; // in order: the admission first, then the fee
payment_open: boolean;
valid_from: string | null;
association: { name: string; slug: string };
event?: EnrolledPlace | null; // only for a link that began on the enrolment page opened from an event: what became of the place
}
interface EnrolledPlace { // the place asked for with the membership request (guide Events › Someone who is not a member yet)
slug: string; title: string; starts_at: string; timezone: string; place: string | null;
registration_type: { uid: string; name: string; amount: number; currency: string };
state: 'confirmed' | 'reserved' | 'held' | 'unavailable'; // held: the request itself waits for the address to be confirmed
waiting: Array<'membership' | 'contribution'>; // what a `reserved` place waits for
reasons: string[]; // why it is `unavailable` (the eligibility reasons)
reserved_until: string | null;
payment_instructions: string | null;
already: boolean; // the place was already held
}
interface SandboxMembers { slug: string; members: Array<{ email: string; name: string; status: MembershipStatus; expires_at: string | null; statuto_accepted: boolean }> }
interface SandboxReset { password: string; members: Array<{ email: string; name: string; status: MembershipStatus }> }
interface TokenResponse {
access_token: string;
token_type: 'Bearer';
expires_in: number;
refresh_token?: string;
scope: string;
sub?: string; // absent on client tokens
}

Spec is generated from openapi/v1.json (npm run spec:types, checked in CI): every schema of the document as a type, plus Spec.operations (id → method and path). The types above remain the documented surface; Spec is for those working against the API directly.

import type { Spec } from '@vimine/sdk';
let p: Spec.Problem; const [m, path] = Spec.operations.listMemberships;