Constructs a StandardDoipClient.
Optional default request options. The serviceInfo and authentication property can be used to provide a default serviceInfo and authentication for all requests. The options may optionally specify a "preferredProtocol", either "TCP" for native DOIP or "HTTPS" for the DOIP API for HTTP Clients. For convenience the options may specify a "baseUri", the base HTTP endpoint of a DOIP API for HTTP Clients service.
Convenience constructor for a StandardDoipClient which uses the DOIP API for HTTP Clients.
The base HTTP endpoint of the DOIP API for HTTP Clients service
Optional
options: Options & { preferredProtocol?: string }Optional default request options. The authentication property can be used to provide a default authentication for all requests.
Protected
Optional
defaultDefault options for all operations performed by this client. These options can be overridden by providing options to individual method calls.
Performs a DOIP operation using a DoipRequest object.
The DOIP request to perform
Optional
options: OptionsOptional request options for this operation
A promise that resolves to a DoipResponse. The caller is responsible for closing the DoipResponse.
Performs a DOIP operation by specifying the target ID, operation ID, and optional input.
The ID of the target digital object or service
The ID of the operation to perform
Optional
input: Optional input for the operation
Optional
options: OptionsOptional request options for this operation
A promise that resolves to a DoipResponse. The caller is responsible for closing the DoipResponse.
Determines the ID for a service, based on the options given.
If options
does not specify a service ID, there may be a client default.
Defaults to service
if no other info is specified.
Optional
options: OptionsOptional request options
The ID for the service
This method creates a copy of the request and adds authentication information and attributes from the options or default options if not already present.
The DOIP request to augment
Optional
options: OptionsOptional request options
The augmented DOIP request
Sends a hello request to the service to get information about the service and verify connectivity.
Optional
options: OptionsOptional request options
A promise that resolves to a DigitalObject containing information about the service
DoipError for error responses
Retrieves a digital object by ID.
The ID of the digital object to retrieve
Optional
options: OptionsOptional request options
A promise that resolves to the retrieved DigitalObject, or null if not found
DoipError for error responses
Retrieves a list of operations that can be performed on the specified target.
The ID of the target digital object or service
Optional
options: OptionsOptional request options
A promise that resolves to an array of operation IDs
DoipError for error responses
Searches for digital objects matching the specified query and returns only their IDs.
The search query
Optional
params: QueryParamsOptional query parameters
Optional
options: OptionsOptional request options
A promise that resolves to SearchResults which among other properties is an async iterable iterator of digital object IDs The caller is responsible for closing the SearchResults.
DoipError for error responses
Searches for digital objects matching the specified query and returns the complete digital objects.
The search query
Optional
params: QueryParamsOptional query parameters
Optional
options: OptionsOptional request options
A promise that resolves to SearchResults which among other properties is an async iterable iterator of digital objects. The caller is responsible for closing the SearchResults.
DoipError for error responses
Retrieves the body of a specific element of a digital object by its ID.
The ID of the digital object
The ID of the element to retrieve
Optional
options: OptionsOptional request options
A promise that resolves to the element body, or null if not found
DoipError for error responses
// Get the bytes of a binary element payload
const elementBody = await client.retrieveElementBytes('20.500.123/1', 'attachment-binary');
if (elementBody) {
const buffer = await elementBody.arrayBuffer();
const bytes = new Uint8Array(buffer);
console.log(`length: ${bytes.length}`);
// process bytes
}
// Get text from a text element body
const elementBody = await client.retrieveElementBytes('20.500.123/1', 'attachment-text');
if (elementBody) {
const text = await elementBody.text();
console.log(text);
}
Retrieves a specific byte range of an element of a digital object.
The ID of the digital object
The ID of the element to retrieve
The starting byte position (inclusive)
The ending byte position (inclusive)
Optional
options: OptionsOptional request options
A promise that resolves to the partial element body, or null if not found
DoipError for error responses
// Retrieve the first 1000 bytes of a binary element body
const elementBody = await client.retrievePartialElementBytes('20.500.123/1', 'attachment-binary', 0, 999);
if (elementBody) {
const buffer = await elementBody.arrayBuffer();
const bytes = new Uint8Array(buffer);
console.log(`length: ${bytes.length}`);
}
// Retrieve bytes from the middle of a text element body
const elementBody = await client.retrievePartialElementBytes('20.500.123/1', 'text', 2, 5);
if (elementBody) {
console.log(await elementBody.text());
}
Creates a new digital object.
The digital object to create
Optional
options: OptionsOptional request options
A promise that resolves to the created digital object
DoipError for error responses
Updates an existing digital object.
The digital object to update
Optional
options: OptionsOptional request options
A promise that resolves to the updated digital object
DoipError for error responses
Static
digitalParses a DoipResponse into a DigitalObject, throwing an error if the DoipResponse does not have the expected structure.
The DOIP response to parse
The DigitalObject given by the DOIP response
Static
searchParses a DoipResponse into a SearchResults, throwing an error if the DoipResponse does not have the expected structure.
The type of items in the search results. Either string or DigitalObject.
The DOIP response to parse
The SearchResults given by the DOIP response
Optional
preferredProtocol: stringPerforms a DOIP operation.
This method must be implemented by concrete subclasses to handle the actual communication with DOIP services.
The DOIP request to perform
Optional
options: OptionsOptional request options for this operation
A promise that resolves to a DoipResponse
Closes the client and releases any resources.
This class provides an implementation of the DOIP client that can use either HTTPS or native TCP for DOIP communication, depending on the available interfaces and configuration. It automatically selects the appropriate protocol (HTTPS or TCP) based on the service information and client capabilities.
Example