@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.
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.
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.
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.
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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).
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;
asyncfunction
functionaccessToken():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).
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.
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
role: "demandeur"|"defendeur"|"appelant"|"intime"|"intervenant"|"partie_adverse"|"vendeur"|"acquereur"|"cedant"|"cessionnaire"|"contrepartie"|"bailleur"|"locataire"|...16 more ...|"autre";
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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é.
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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.
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.
} elseif (
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.
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).
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:
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;
deleteenv.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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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.
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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(newError('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 = newconsole.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(newError('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
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()).
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).