Aller au contenu

Utiliser le SDK TypeScript

@lexopti/sdk est le client TypeScript de l’API. Ses opérations sont générées depuis le même contrat que l’API elle-même : chaque entrée et chaque réponse est typée, et les exemples de cette page sont vérifiés par le typage contre le paquet à la construction du portail. La référence du SDK liste chaque export.

Fenêtre de terminal
npm install @lexopti/sdk

Il tourne partout où fetch existe : Node.js 20+, Bun, Deno, environnements edge. Appelez-le depuis votre serveur uniquement : le jeton d’accès qu’il envoie est celui du membre.

import {
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
} from "@lexopti/sdk";
const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
: () =>
function getAccessToken(): Promise<string>
getAccessToken
(),
LexOptiClientOptions.locale?: "fr" | "en" | undefined

fr for French service messages; English otherwise.

locale
: "fr",
});
const
const organization: {
id: string;
name: string;
sandbox: boolean;
member: {
user_id: string;
role: string;
};
integration: {
client_id: string;
delegated_mode: boolean;
};
}
organization
= await
const lexopti: LexOptiClient
lexopti
.
organization: {
get: Client<Record<never, never>, unknown, {
id: string;
name: string;
sandbox: boolean;
member: {
user_id: string;
role: string;
};
integration: {
client_id: string;
delegated_mode: boolean;
};
}, Error>;
}
organization
.
get: Client
(input?: unknown, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
name: string;
sandbox: boolean;
member: {
user_id: string;
role: string;
};
integration: {
client_id: string;
delegated_mode: boolean;
};
}, Error>
get
();
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const organization: {
id: string;
name: string;
sandbox: boolean;
member: {
user_id: string;
role: string;
};
integration: {
client_id: string;
delegated_mode: boolean;
};
}
organization
.
name: string
name
,
const organization: {
id: string;
name: string;
sandbox: boolean;
member: {
user_id: string;
role: string;
};
integration: {
client_id: string;
delegated_mode: boolean;
};
}
organization
.
sandbox: boolean
sandbox
);
Option Par défaut Usage
accessToken obligatoire Renvoie le jeton d’accès OAuth du membre, une fois par opération (ses nouvelles tentatives le réutilisent)
baseUrl https://app.lexopti.com/v1 Un autre environnement
locale en fr pour des messages detail en français (code reste en anglais)
maxRetries 2 Combien de fois une requête échouée est relancée (nouvelles tentatives)
maxRetryWait 60000 L’attente Retry-After la plus longue, en millisecondes
fetch fetch global Un proxy ou un double de test
sleep une minuterie Comment le client attend entre deux tentatives, pour les tests

Les jetons d’accès vivent 15 minutes. accessToken est appelée une fois par opération, avant sa première tentative : rafraîchissez-y le jeton, avec le jeton de rafraîchissement conservé quand le membre a autorisé votre application (authentification).

import {
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
} from "@lexopti/sdk";
let
let current: {
token: string;
expiresAt: number;
} | null
current
: {
token: string
token
: string;
expiresAt: number
expiresAt
: number } | null = null;
async function
function accessToken(): Promise<string>
accessToken
():
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<string> {
// Rafraîchir une minute avant l’expiration.
if (!
let current: {
token: string;
expiresAt: number;
} | null
current
||
let current: {
token: string;
expiresAt: number;
}
current
.
expiresAt: number
expiresAt
- 60_000 <
var Date: DateConstructor

Enables basic storage and retrieval of dates and times.

Date
.
DateConstructor.now(): number

Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

now
()) {
const
const tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
= await
function refreshTokens(refreshToken: string): Promise<{
access_token: string;
expires_in: number;
refresh_token: string;
}>
refreshTokens
(
const stored: {
refreshToken: string;
}
stored
.
refreshToken: string
refreshToken
);
const stored: {
refreshToken: string;
}
stored
.
refreshToken: string
refreshToken
=
const tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
refresh_token: string
refresh_token
; // Le jeton de rafraîchissement change.
let current: {
token: string;
expiresAt: number;
} | null
current
= {
expiresAt: number
expiresAt
:
var Date: DateConstructor

Enables basic storage and retrieval of dates and times.

Date
.
DateConstructor.now(): number

Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

now
() +
const tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
expires_in: number
expires_in
* 1000,
token: string
token
:
const tokens: {
access_token: string;
expires_in: number;
refresh_token: string;
}
tokens
.
access_token: string
access_token
,
};
}
return
let current: {
token: string;
expiresAt: number;
}
current
.
token: string
token
;
}
const
const lexopti: LexOptiClient
lexopti
=
function createLexOptiClient(options: LexOptiClientOptions): LexOptiClient

A typed client of the LexOpti API. Every idempotent POST gets an Idempotency-Key (kept across its retries); only requests safe to repeat are retried after a failure, with jittered backoff or Retry-After. Errors are oRPC errors: problemOf(error) reads the problem details.

createLexOptiClient
({
LexOptiClientOptions.accessToken: () => Promise<string> | string

Returns the OAuth access token for each request: refresh it there when it expires (access tokens live 15 minutes).

accessToken
});
// Clients : l’identité seule, rien n’est encore analysé.
const
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
create: Client
(input: {
type: "person";
person: {
first_name: string;
last_name: string;
usage_name?: string | undefined;
birth_date?: string | undefined;
birth_city?: string | undefined;
birth_country?: string | undefined;
nationalities?: string[] | undefined;
};
address?: {
line?: string | undefined;
postal_code?: string | undefined;
city?: string | undefined;
country?: string | undefined;
} | undefined;
external_ref?: string | undefined;
} | {
type: "company";
company: {
name: string;
siren?: string | undefined;
siret?: string | undefined;
legal_form?: string | undefined;
registration_country?: string | undefined;
rcs?: string | undefined;
};
address?: {
line?: string | undefined;
postal_code?: string | undefined;
city?: string | undefined;
country?: string | undefined;
} | undefined;
external_ref?: string | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
create
({
type: "company"
type
: "company",
company: {
name: string;
siren?: string | undefined;
siret?: string | undefined;
legal_form?: string | undefined;
registration_country?: string | undefined;
rcs?: string | undefined;
}
company
: {
name: string
name
: "Durand SAS",
siren?: string | undefined
siren
: "123456789",
registration_country?: string | undefined
registration_country
: "FR",
},
address?: {
line?: string | undefined;
postal_code?: string | undefined;
city?: string | undefined;
country?: string | undefined;
} | undefined
address
: {
city?: string | undefined
city
: "Nice",
country?: string | undefined
country
: "FR" },
});
const
const same: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
same
= await
const lexopti: LexOptiClient
lexopti
.
clients: {
setExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
}, {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}, Error>;
... 7 more ...;
requestPreliminaryScreening: Client<...>;
}
clients
.
get: Client
(input: {
id: string;
expand?: ("cases" | "classification_state" | "last_check" | "open_alerts_count")[] | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
... 11 more ...;
cases?: {
...;
} | undefined;
}, Error>
get
({
id: string
id
:
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
});
// Analyses : le client et ses personnes liées (asynchrone).
const
const check: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
check
= await
const lexopti: LexOptiClient
lexopti
.
checks: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
}, {
data: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
create: Client<...>;
}
checks
.
create: Client
(input: {
client_id: string;
case_id?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}, Error>
create
({
client_id: string
client_id
:
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
});
const
const followed: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
followed
= await
const lexopti: LexOptiClient
lexopti
.
checks: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
}, {
data: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
create: Client<...>;
}
checks
.
get: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}, Error>
get
({
id: string
id
:
const check: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
check
.
id: string
id
});
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const same: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
same
.
vigilance_level: "simplified" | "standard" | "enhanced" | null
vigilance_level
,
const followed: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}
followed
.
status: "running" | "completed" | "failed"
status
);
// Dossiers et alertes.
const
const cases: {
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
cases
= await
const lexopti: LexOptiClient
lexopti
.
cases: {
setPartyExternalRef: Client<Record<never, never>, {
id: string;
external_ref: string;
party_id: string;
}, {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}, Error>;
... 10 more ...;
listDocuments: Client<...>;
}
cases
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
external_ref?: string | undefined;
ids?: string | undefined;
client_id?: string | undefined;
party_external_ref?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
...;
}[];
... 9 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
client_id?: string | undefined
client_id
:
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
});
const
const alerts: {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}
alerts
= await
const lexopti: LexOptiClient
lexopti
.
alerts: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
update: Client<...>;
}
alerts
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
... 9 more ...;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
({
client_id?: string | undefined
client_id
:
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
,
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined
status
: "pending",
});
const [
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
] =
const alerts: {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}
alerts
.
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[]
data
;
if (
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
) {
await
const lexopti: LexOptiClient
lexopti
.
alerts: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
update: Client<...>;
}
alerts
.
update: Client
(input: {
id: string;
status: "reviewed" | "dismissed" | "confirmed";
notes?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
... 8 more ...;
review_notes: string | null;
}, Error>
update
({
id: string
id
:
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
id: string
id
,
status: "reviewed" | "dismissed" | "confirmed"
status
: "reviewed",
notes?: string | undefined
notes
: "Homonyme",
});
}
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const cases: {
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[];
has_more: boolean;
next_cursor: string | null;
}
cases
.
data: {
id: string;
external_ref: string | null;
label: string | null;
type: string | null;
types: string[];
type_label: string | null;
status: "pending" | "running" | "completed" | "failed";
client_id: string | null;
client_ids: string[];
clients: {
id: string;
external_ref: string | null;
main: boolean;
}[];
parties: {
id: string;
entity_id: string;
external_ref: string | null;
role: "demandeur" | "defendeur" | "appelant" | "intime" | "intervenant" | "partie_adverse" | "vendeur" | "acquereur" | "cedant" | "cessionnaire" | "contrepartie" | "bailleur" | "locataire" | ... 16 more ... | "autre";
type: "person" | "company";
name: string;
monitoring_enabled: boolean;
}[];
... 8 more ...;
updated_at: string;
}[]
data
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
);
// Événements, par position : lire ce qui s’est passé depuis le dernier traité.
const
const events: {
data: {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: {
...;
};
}[];
has_more: boolean;
next_cursor: string | null;
}
events
= await
const lexopti: LexOptiClient
lexopti
.
events: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
type?: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined" | undefined;
after?: string | undefined;
}, {
...;
}, Error>;
}
events
.
list: Client
(input: {
limit?: number | undefined;
cursor?: string | undefined;
type?: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined" | undefined;
after?: string | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
list
({
after?: string | undefined
after
:
const lastPosition: string
lastPosition
,
limit?: number | undefined
limit
: 100 });
// Webhooks : le secret n’est répondu qu’une fois.
const
const endpoint: {
id: string;
url: string;
description: string | null;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
status: "enabled" | "disabled";
disabled_reason: "member" | ... 2 more ... | null;
created_at: string;
updated_at: string;
secret: string;
}
endpoint
= await
const lexopti: LexOptiClient
lexopti
.
webhookEndpoints: {
create: Client<Record<never, never>, {
url: string;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
description?: string | undefined;
}, {
...;
}, Error>;
... 7 more ...;
replayDelivery: Client<...>;
}
webhookEndpoints
.
create: Client
(input: {
url: string;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
description?: string | undefined;
}, options?: FriendlyClientOptions<...> | undefined) => ClientPromiseResult<...>
create
({
url: string
url
: "https://crm.example.com/lexopti/webhooks",
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[]
event_types
: ["check.completed", "alert.created"],
});
// Gardez-le dans votre coffre de secrets (Vault, AWS Secrets Manager…), jamais dans un journal.
await
const secretManager: {
save(name: string, value: string): Promise<void>;
}
secretManager
.
function save(name: string, value: string): Promise<void>
save
("lexopti-webhook-secret",
const endpoint: {
id: string;
url: string;
description: string | null;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
status: "enabled" | "disabled";
disabled_reason: "member" | ... 2 more ... | null;
created_at: string;
updated_at: string;
secret: string;
}
endpoint
.
secret: string
secret
);
await
const lexopti: LexOptiClient
lexopti
.
webhookEndpoints: {
create: Client<Record<never, never>, {
url: string;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
description?: string | undefined;
}, {
...;
}, Error>;
... 7 more ...;
replayDelivery: Client<...>;
}
webhookEndpoints
.
test: Client
(input: {
id: string;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
event_id: string | null;
type: string;
status: "pending" | "failed" | "cancelled" | "succeeded";
attempts: number;
next_attempt_at: string | null;
last_attempt_at: string | null;
last_response_status: number | null;
last_error: string | null;
replay_of: string | null;
created_at: string;
completed_at: string | null;
}, Error>
test
({
id: string
id
:
const endpoint: {
id: string;
url: string;
description: string | null;
event_types: ("check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined")[];
status: "enabled" | "disabled";
disabled_reason: "member" | ... 2 more ... | null;
created_at: string;
updated_at: string;
secret: string;
}
endpoint
.
id: string
id
});
// Un lien qui ouvre le client dans LexOpti, pour le membre.
const
const link: {
url: string;
expires_at: string;
}
link
= await
const lexopti: LexOptiClient
lexopti
.
deepLinks: {
create: Client<Record<never, never>, {
client_id?: string | undefined;
case_id?: string | undefined;
}, {
url: string;
expires_at: string;
}, Error>;
}
deepLinks
.
create: Client
(input: {
client_id?: string | undefined;
case_id?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
url: string;
expires_at: string;
}, Error>
create
({
client_id?: string | undefined
client_id
:
const client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
id: string
id
});
// Les crédits de l’organisation.
const
const usage: {
unit: "credit";
credits: {
balance: number;
frozen: number;
low_balance_threshold: number;
};
dossiers: {
active: number;
paused: number;
renewals_due: number;
renewal_credits: number;
};
subscription_active: boolean;
read_only: boolean;
}
usage
= await
const lexopti: LexOptiClient
lexopti
.
usage: {
get: Client<Record<never, never>, unknown, {
unit: "credit";
credits: {
balance: number;
frozen: number;
low_balance_threshold: number;
};
dossiers: {
active: number;
paused: number;
renewals_due: number;
renewal_credits: number;
};
subscription_active: boolean;
read_only: boolean;
}, Error>;
}
usage
.
get: Client
(input?: unknown, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
unit: "credit";
credits: {
balance: number;
frozen: number;
low_balance_threshold: number;
};
dossiers: {
active: number;
paused: number;
renewals_due: number;
renewal_credits: number;
};
subscription_active: boolean;
read_only: boolean;
}, Error>
get
();
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const events: {
data: {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: {
...;
};
}[];
has_more: boolean;
next_cursor: string | null;
}
events
.
data: {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: {
...;
};
}[]
data
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
,
const link: {
url: string;
expires_at: string;
}
link
.
url: string
url
,
const usage: {
unit: "credit";
credits: {
balance: number;
frozen: number;
low_balance_threshold: number;
};
dossiers: {
active: number;
paused: number;
renewals_due: number;
renewal_credits: number;
};
subscription_active: boolean;
read_only: boolean;
}
usage
.
credits: {
balance: number;
frozen: number;
low_balance_threshold: number;
}
credits
.
balance: number
balance
);

La référence de l’API détaille chaque champ ; chaque opération y montre d’abord son exemple TypeScript.

Les listes répondent une page à la fois. paginate parcourt toutes les pages pour vous :

import {
function paginate<Input extends {
cursor?: string;
}, Item>(list: ListOperation<Input, Item>, input: Input): AsyncGenerator<Item, void, undefined>

Every item of a list, page after page: for await (const client of paginate(lexopti.clients.list, { limit: 100 })).

@yields ― {Item} Each item of each page, in the list's order.

paginate
} from "@lexopti/sdk";
for await (const
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
of
paginate<{
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
... 8 more ...;
review_notes: string | null;
}>(list: ListOperation<...>, input: {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}): AsyncGenerator<...>

Every item of a list, page after page: for await (const client of paginate(lexopti.clients.list, { limit: 100 })).

@yields ― {Item} Each item of each page, in the list's order.

paginate
(
const lexopti: LexOptiClient
lexopti
.
alerts: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
... 9 more ...;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
update: Client<...>;
}
alerts
.
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
client_ids?: string | undefined;
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined;
}, {
data: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
... 9 more ...;
review_notes: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>
list
, {
status?: "pending" | "reviewed" | "dismissed" | "confirmed" | undefined
status
: "pending",
limit?: number | undefined
limit
: 100,
})) {
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
id: string
id
,
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
level: "simplified" | "standard" | "enhanced"
level
,
const alert: {
id: string;
client_id: string;
case_id: string | null;
entity_id: string;
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null;
status: "pending" | "reviewed" | "dismissed" | "confirmed";
level: "simplified" | "standard" | "enhanced";
change: string | null;
subject: string | null;
detail: string | null;
source_name: string;
url: string | null;
created_at: string;
reviewed_at: string | null;
review_notes: string | null;
}
alert
.
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media" | null
source
);
}

Un appel échoué lève une erreur. problemOf en lit le détail (RFC 9457) ; testez code, qui est stable, jamais le message.

import {
function problemOf(error: unknown): ProblemDetails | null

The problem details (RFC 9457) of a failed call: code is stable, branch on it; request_id names the request for LexOpti support; null for an error that did not come from the API.

problemOf
} from "@lexopti/sdk";
try {
await
const lexopti: LexOptiClient
lexopti
.
checks: {
list: Client<Record<never, never>, {
limit?: number | undefined;
cursor?: string | undefined;
client_id?: string | undefined;
}, {
data: {
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}[];
has_more: boolean;
next_cursor: string | null;
}, Error>;
get: Client<...>;
create: Client<...>;
}
checks
.
create: Client
(input: {
client_id: string;
case_id?: string | undefined;
}, options?: FriendlyClientOptions<Record<never, never>> | undefined) => ClientPromiseResult<{
id: string;
client_id: string;
status: "running" | "completed" | "failed";
sources: {
source: "international_sanctions" | "eu_sanctions" | "french_asset_freezes" | "politically_exposed_persons" | "high_risk_countries" | "bodacc_announcements" | "bodacc_insolvency" | "company_register" | "adverse_media";
entity_id: string | null;
status: "pending" | "running" | "completed" | "failed" | "skipped";
completed_at: string | null;
}[];
created_at: string;
completed_at: string | null;
}, Error>
create
({
client_id: string
client_id
: "9b2f4c1e-0d3a-4e5b-8c7d-6a1f2e3d4c5b",
});
} catch (
var error: unknown
error
) {
const
const problem: {
type: string;
title: string;
status: number;
code: string;
detail: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
request_id?: string | undefined;
} | null
problem
=
function problemOf(error: unknown): ProblemDetails | null

The problem details (RFC 9457) of a failed call: code is stable, branch on it; request_id names the request for LexOpti support; null for an error that did not come from the API.

problemOf
(
var error: unknown
error
);
if (
const problem: {
type: string;
title: string;
status: number;
code: string;
detail: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
request_id?: string | undefined;
} | null
problem
?.
code: string | undefined
code
=== "not_found") {
// Le client n’est pas dans cette organisation.
} else if (
const problem: {
type: string;
title: string;
status: number;
code: string;
detail: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
request_id?: string | undefined;
} | null
problem
?.
code: string | undefined
code
=== "quota_exceeded") {
// Les crédits de l’organisation ne peuvent pas payer le dossier du client.
} else {
throw
var error: unknown
error
;
}
}

problemOf renvoie null pour une erreur qui ne vient pas de l’API (réseau, délai dépassé). La page erreurs liste chaque code. Journalisez le request_id du problème : il désigne la requête quand vous écrivez au support LexOpti (identifiants de requête).

webhooks.verify vérifie la signature Standard Webhooks et l’horodatage, puis renvoie l’événement typé : un des types d’événements, ou webhook.test, l’envoi que déclenche webhookEndpoints.test. Donnez-lui le corps brut, avant toute lecture JSON.

import {
const webhooks: {
verify: (payload: string, headers: Headers | Record<string, string>, secret: string) => WebhookEvent;
}
webhooks
} from "@lexopti/sdk";
const
const event: WebhookEvent
event
=
const webhooks: {
verify: (payload: string, headers: Headers | Record<string, string>, secret: string) => WebhookEvent;
}
webhooks
.
verify: (payload: string, headers: Headers | Record<string, string>, secret: string) => WebhookEvent

Verifies a LexOpti webhook (Standard Webhooks) and returns its event: pass the raw body, the request headers and the endpoint secret (whsec_…). Throws when the signature or the timestamp is wrong. The event's id is the webhook-id header: deduplicate on it.

verify
(
const rawBody: string
rawBody
,
const requestHeaders: Headers
requestHeaders
,
var process: NodeJS.Process
process
.
NodeJS.Process.env: NodeJS.ProcessEnv

The process.env property returns an object containing the user environment. See environ(7).

An example of this object looks like:

{
TERM: 'xterm-256color',
SHELL: '/usr/local/bin/bash',
USER: 'maciej',
PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',
PWD: '/Users/maciej',
EDITOR: 'vim',
SHLVL: '1',
HOME: '/Users/maciej',
LOGNAME: 'maciej',
_: '/usr/local/bin/node'
}

It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other Worker threads. In other words, the following example would not work:

Terminal window
node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo

While the following will:

import { env } from 'node:process';
env.foo = 'bar';
console.log(env.foo);

Assigning a property on process.env will implicitly convert the value to a string. This behavior is deprecated. Future versions of Node.js may throw an error when the value is not a string, number, or boolean.

import { env } from 'node:process';
env.test = null;
console.log(env.test);
// => 'null'
env.test = undefined;
console.log(env.test);
// => 'undefined'

Use delete to delete a property from process.env.

import { env } from 'node:process';
env.TEST = 1;
delete env.TEST;
console.log(env.TEST);
// => undefined

On Windows operating systems, environment variables are case-insensitive.

import { env } from 'node:process';
env.TEST = 1;
console.log(env.test);
// => 1

Unless explicitly specified when creating a Worker instance, each Worker thread has its own copy of process.env, based on its parent thread's process.env, or whatever was specified as the env option to the Worker constructor. Changes to process.env will not be visible across Worker threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of process.env on a Worker instance operates in a case-sensitive manner unlike the main thread.

@since ― v0.1.27

env
.
string | undefined
LEXOPTI_WEBHOOK_SECRET
?? ""
);
if (
const event: WebhookEvent
event
.
type: WebhookEventType
type
=== "check.completed") {
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const event: WebhookEvent
event
.
data: Record<string, string>
data
.
string
client_id
,
const event: WebhookEvent
event
.
livemode: boolean
livemode
);
}

Il lève une erreur si la signature, l’horodatage ou le contenu n’est pas valide : répondez 400. Dédoublonnez sur event.id (l’en-tête webhook-id) : un envoi peut arriver deux fois.

@lexopti/sdk/contract exporte le contrat que sert l’API elle-même : ses schémas zod et leurs types, pour valider ou stocker ce que vous recevez.

import type {
type ClientDto = {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
ClientDto
,
type EventDto = {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}
EventDto
,
type Problem = {
type: string;
title: string;
status: number;
code: string;
detail: string;
request_id: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
}
Problem
} from "@lexopti/sdk/contract";
import {
const eventSchema: ZodObject<{
id: ZodString;
position: ZodString;
type: ZodEnum<{
"check.completed": "check.completed";
"check.failed": "check.failed";
"client.created": "client.created";
"client.updated": "client.updated";
"client.vigilance_level_changed": "client.vigilance_level_changed";
"client.risk_level_changed": "client.risk_level_changed";
"client.preliminary_screening_completed": "client.preliminary_screening_completed";
"classification.validated": "classification.validated";
"case.created": "case.created";
"case.updated": "case.updated";
"case.risk_level_changed": "case.risk_level_changed";
... 8 more ...;
"member.joined": "member.joined";
}>;
timestamp: ZodISODateTime;
livemode: ZodBoolean;
data: ZodRecord<...>;
}, $strip>
eventSchema
} from "@lexopti/sdk/contract";
function
function store(client: ClientDto, event: EventDto, problem: Problem | null): void
store
(
client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
:
type ClientDto = {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
ClientDto
,
event: {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}
event
:
type EventDto = {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}
EventDto
,
problem: {
type: string;
title: string;
status: number;
code: string;
detail: string;
request_id: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
} | null
problem
:
type Problem = {
type: string;
title: string;
status: number;
code: string;
detail: string;
request_id: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
}
Problem
| null) {
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
client: {
id: string;
external_ref: string | null;
type: "person" | "company";
name: string;
person: {
first_name: string | null;
last_name: string | null;
usage_name: string | null;
birth_date: string | null;
birth_city: string | null;
birth_country: string | null;
nationalities: string[];
} | null;
company: {
name: string | null;
siren: string | null;
siret: string | null;
legal_form: string | null;
registration_country: string | null;
rcs: string | null;
} | null;
address: {
line: string | null;
postal_code: string | null;
city: string | null;
country: string | null;
};
... 10 more ...;
cases?: {
...;
} | undefined;
}
client
.
risk_level: "simplified" | "standard" | "enhanced" | null
risk_level
,
event: {
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}
event
.
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined"
type
,
problem: {
type: string;
title: string;
status: number;
code: string;
detail: string;
request_id: string;
errors?: {
path: string;
message: string;
}[] | undefined;
missing?: {
entity_id: string;
name: string;
is_main_entity: boolean;
fields: string[];
}[] | undefined;
cases?: {
id: string;
name: string | null;
}[] | undefined;
} | null
problem
?.
code: string | undefined
code
);
}
const
const parsed: ZodSafeParseResult<{
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}>
parsed
=
const eventSchema: ZodObject<{
id: ZodString;
position: ZodString;
type: ZodEnum<{
"check.completed": "check.completed";
"check.failed": "check.failed";
"client.created": "client.created";
"client.updated": "client.updated";
"client.vigilance_level_changed": "client.vigilance_level_changed";
"client.risk_level_changed": "client.risk_level_changed";
"client.preliminary_screening_completed": "client.preliminary_screening_completed";
"classification.validated": "classification.validated";
"case.created": "case.created";
"case.updated": "case.updated";
"case.risk_level_changed": "case.risk_level_changed";
... 8 more ...;
"member.joined": "member.joined";
}>;
timestamp: ZodISODateTime;
livemode: ZodBoolean;
data: ZodRecord<...>;
}, $strip>
eventSchema
.
ZodType<any, any, $ZodObjectInternals<{ id: ZodString; position: ZodString; type: ZodEnum<{ "check.completed": "check.completed"; "check.failed": "check.failed"; "client.created": "client.created"; ... 16 more ...; "member.joined": "member.joined"; }>; timestamp: ZodISODateTime; livemode: ZodBoolean; data: ZodRecord<...>; }, $strip>>.safeParse(data: unknown, params?: ParseContext<$ZodIssue>): ZodSafeParseResult<{
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}>
safeParse
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any

Converts a JavaScript Object Notation (JSON) string into an object.

@param ― text A valid JSON string.

@param ― reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.

@throws ― {SyntaxError} If text is not valid JSON.

parse
("{}"));
var console: Console

The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

The module exports two specific components:

  • A Console class with methods such as console.log(), console.error() and console.warn() that can be used to write to any Node.js stream.
  • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without importing the node:console module.

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

Example using the global console:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Example using the Console class:

const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err

@see ― source

console
.
Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)

Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout

See util.format() for more information.

@since ― v0.1.100

log
(
const parsed: ZodSafeParseResult<{
id: string;
position: string;
type: "check.completed" | "check.failed" | "client.created" | "client.updated" | "client.vigilance_level_changed" | "client.risk_level_changed" | "client.preliminary_screening_completed" | "classification.validated" | "case.created" | "case.updated" | "case.risk_level_changed" | "report.generated" | "alert.created" | "alert.resolved" | "decision.pending" | "quota.exhausted" | "subscription.inactive" | "access.revoked" | "member.enrolled" | "member.joined";
timestamp: string;
livemode: boolean;
data: Record<...>;
}>
parsed
.
success: boolean
success
,
function store(client: ClientDto, event: EventDto, problem: Problem | null): void
store
);

Le client réessaie pour vous, et jamais d’une façon qui pourrait appliquer deux fois une opération.

Une requête échouée est relancée jusqu’à maxRetries fois (2 par défaut), seulement quand elle ne peut pas s’appliquer deux fois :

  • les lectures, les suppressions et les POST idempotents (cases.create, cases.launchChecks, checks.create, clients.create, clients.requestPreliminaryScreening, enrolments.create, firms.create, webhookEndpoints.create) sont relancés après une erreur réseau, un 429, ou un 500, 502, 503 ou 504 ;
  • toute autre opération (un PATCH, une session embarquée, un lien profond, un renouvellement de secret, un envoi de test, un rejeu) n’est jamais envoyée deux fois dès que le serveur a pu la recevoir : elle n’est relancée qu’après un 429 portant Retry-After, que l’API répond avant de rien faire.

Le client attend ce que demande Retry-After, en secondes ou en date HTTP, jusqu’à maxRetryWait (60 s par défaut) : prié d’attendre plus longtemps, il vous rend l’erreur plutôt que de réessayer trop tôt. Sinon il espace ses tentatives avec un aléa complet : un délai aléatoire jusqu’à 0,5 s, puis jusqu’à 1 s, 2 s… plafonné à 8 s.

Chaque POST idempotent reçoit un Idempotency-Key, conservé entre ses tentatives : une analyse lancée pendant une coupure réseau n’est lancée qu’une fois, et la nouvelle tentative reçoit la première réponse. Une requête échouée sans effet libère sa clé ; celle qui a échoué après avoir créé sa ressource répond 409 idempotency_response_unavailable avec l’identifiant de la ressource (requêtes).