new IdentifierService()
Service for DataONE identifier generation and reservation.
- Since:
- Source:
Extends
Methods
clearCache() → {Promise.<void>}
Clear the cache for the current user scope.
- Inherited From:
- Source:
Returns:
Promise resolving when the cache is cleared
-
Type
-
Promise.<void>
download(path, optionsopt) → {Promise.<*>}
Download data from a path with optional caching.
Parameters:
| Name |
Type |
Attributes |
Description |
path |
string
|
|
Path relative to baseUrl |
options |
object
|
<optional>
|
Options passed to
DataONEHttpClient#request (except `path`), plus cache controls.
Properties
| Name |
Type |
Attributes |
Description |
auth |
boolean
|
<optional>
|
Whether to resolve a token automatically |
useCache |
boolean
|
<optional>
|
Whether to cache responses, default
true. |
cacheKey |
string
|
<optional>
|
Cache key override |
cacheTtlMs |
number
|
null
|
<optional>
|
Cache TTL override |
|
- Inherited From:
- Source:
Returns:
Promise resolving to response data
-
Type
-
Promise.<*>
generateIdentifier(paramsopt, optionsopt) → {Promise.<DataONEHttpResponse>}
Generate a new DataONE identifier.
Parameters:
| Name |
Type |
Attributes |
Description |
params |
object
|
<optional>
|
Generation parameters.
Properties
| Name |
Type |
Attributes |
Description |
scheme |
string
|
<optional>
|
Identifier scheme. |
|
options |
object
|
<optional>
|
Request options. |
- Source:
Returns:
Parsed XML response with
identifier.
-
Type
-
Promise.<DataONEHttpResponse>
getCached(key) → {Promise.<*>}
Get a cached value scoped by the current user.
Parameters:
| Name |
Type |
Description |
key |
string
|
Cache key |
- Inherited From:
- Source:
Returns:
Promise resolving to the cached value
-
Type
-
Promise.<*>
Get a PersistentStorage instance automatically scoped by the logged in
user, using the configuration options provided to the constructor.
- Inherited From:
- Source:
Returns:
Storage instance
-
Type
-
PersistentStorage
getToken() → {Promise.<string>}
Resolve an auth token from MetacatUI when available.
- Inherited From:
- Source:
Returns:
Promise resolving to an auth token
-
Type
-
Promise.<string>
getUserName() → {Promise.<(string|null)>}
Resolve the current username from the MetacatUI app user model.
- Inherited From:
- Source:
Returns:
Promise resolving to the username, or
null if unavailable.
-
Type
-
Promise.<(string|null)>
isCached(key) → {Promise.<boolean>}
Check whether a value exists in the cache for the current user scope.
Parameters:
| Name |
Type |
Description |
key |
string
|
Cache key |
- Inherited From:
- Source:
Returns:
Promise resolving to whether the value is
cached.
-
Type
-
Promise.<boolean>
removeCached(key) → {Promise.<void>}
Remove a cached value for the current user scope.
Parameters:
| Name |
Type |
Description |
key |
string
|
Cache key |
- Inherited From:
- Source:
Returns:
Promise resolving when removal completes
-
Type
-
Promise.<void>
Send a request via the DataONEHttpClient.
Parameters:
| Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
Request options passed to
DataONEHttpClient#request, plus auth controls.
Properties
| Name |
Type |
Attributes |
Description |
path |
string
|
|
Path relative to baseUrl |
auth |
boolean
|
<optional>
|
Whether to resolve a token automatically |
|
- Inherited From:
- Source:
Returns:
Promise resolving to the
response.
-
Type
-
Promise.<DataONEHttpResponse>
requestWithClient(client, optionsopt) → {Promise.<DataONEHttpResponse>}
Send a request through a specific DataONEHttpClient instance.
Parameters:
| Name |
Type |
Attributes |
Description |
client |
DataONEHttpClient
|
|
Client instance to use |
options |
object
|
<optional>
|
Request options |
- Inherited From:
- Source:
Throws:
-
When client is invalid or the request fails
-
-
Type
-
Error
Returns:
Promise resolving to the
response.
-
Type
-
Promise.<DataONEHttpResponse>
reserveIdentifier(pid, optionsopt) → {Promise.<DataONEHttpResponse>}
Reserve an existing identifier.
Parameters:
| Name |
Type |
Attributes |
Description |
pid |
string
|
|
Identifier to reserve. |
options |
object
|
<optional>
|
Request options. |
- Source:
Returns:
Parsed XML response with
identifier.
-
Type
-
Promise.<DataONEHttpResponse>
resolveToken(authopt) → {Promise.<(string|null)>}
Determine the token to use, if any, for a request.
Parameters:
| Name |
Type |
Attributes |
Description |
auth |
boolean
|
<optional>
|
Whether to use authentication for this request
If set to false, no token will be used. If true, getToken() will be
called. When undefined, defaultAuth is used. |
- Inherited From:
- Source:
Returns:
Promise resolving to the token, or null
if no auth.
-
Type
-
Promise.<(string|null)>
scopeKey() → {Promise.<string>}
If user is logged in, get a key based on their username; otherwise,
return a "public" scope key.
- Inherited From:
- Source:
Returns:
Promise resolving to the scope key
-
Type
-
Promise.<string>
sendIdentifierRequest(path, body, context, optionsopt) → {Promise.<DataONEHttpResponse>}
Execute an identifier endpoint request and normalize the XML response.
Parameters:
| Name |
Type |
Attributes |
Description |
path |
string
|
|
Identifier endpoint path. |
body |
FormData
|
|
Request payload. |
context |
string
|
|
Error/parse context. |
options |
object
|
<optional>
|
Request options. |
- Source:
Returns:
Parsed identifier response.
-
Type
-
Promise.<DataONEHttpResponse>
sendParsedIdentifierRequest(params) → {Promise.<DataONEHttpResponse>}
Send a request whose body is a DataONE identifier response and parse the
returned XML. Shared by services that POST/PUT and read back an
identifier (e.g. IdentifierService, ObjectService).
Parameters:
| Name |
Type |
Description |
params |
object
|
Request params
Properties
|
- Inherited From:
- Source:
Throws:
-
When the request or identifier parsing fails
-
-
Type
-
Error
Returns:
Response with parsed identifier
data.
-
Type
-
Promise.<DataONEHttpResponse>
setCached(key, value, optionsopt) → {Promise.<*>}
Store a value in the cache for the current user scope.
Parameters:
| Name |
Type |
Attributes |
Description |
key |
string
|
|
Cache key |
value |
*
|
|
Value to store |
options |
object
|
<optional>
|
Cache scope options
Properties
| Name |
Type |
Attributes |
Description |
ttlMs |
number
|
null
|
<optional>
|
Override cache TTL in ms |
|
- Inherited From:
- Source:
Returns:
Promise resolving to the stored value
-
Type
-
Promise.<*>
shouldUseCache() → {Promise.<boolean>}
Determine whether caching is allowed for the current user scope.
- Inherited From:
- Source:
Returns:
Promise resolving to whether caching is
allowed.
-
Type
-
Promise.<boolean>
upload(path, optionsopt) → {Promise.<DataONEHttpResponse>}
Upload data to a path.
Parameters:
| Name |
Type |
Attributes |
Description |
path |
string
|
|
Path relative to baseUrl |
options |
object
|
<optional>
|
Options passed to
DataONEHttpClient#request (except `path`), plus cache controls.
Properties
| Name |
Type |
Attributes |
Description |
auth |
boolean
|
<optional>
|
Whether to resolve a token automatically |
cacheKey |
string
|
<optional>
|
Cache key override |
|
- Inherited From:
- Source:
Returns:
Promise resolving to the
response.
-
Type
-
Promise.<DataONEHttpResponse>
Build FormData for the DataONE generateIdentifier request.
Parameters:
| Name |
Type |
Attributes |
Description |
params |
object
|
<optional>
|
GenerateIdentifier params.
Properties
| Name |
Type |
Attributes |
Description |
scheme |
string
|
<optional>
|
Identifier scheme. |
fragment |
string
|
<optional>
|
Optional identifier fragment. |
|
- Source:
Throws:
-
When params is not an object or has unsupported keys
-
-
Type
-
Error
Returns:
FormData payload.
-
Type
-
FormData
Build FormData for the DataONE reserveIdentifier request.
Parameters:
| Name |
Type |
Description |
pid |
string
|
Identifier to reserve. |
- Source:
Returns:
FormData payload.
-
Type
-
FormData
isTransientIdentifierError(error) → {boolean}
Whether identifier generation failed for a transient network reason.
Callers may use this to decide whether local UUID fallback is acceptable.
Parameters:
| Name |
Type |
Description |
error |
Error
|
Identifier-service error. |
- Source:
Returns:
Whether local UUID fallback is allowed.
-
Type
-
boolean
resolveBaseUrl(baseUrlopt) → {string}
Resolve the CN DataONE API base URL for identifier operations. If no
baseUrl is provided, it is composed from the configured CN base URL and
service path in AppModel.
Parameters:
| Name |
Type |
Attributes |
Description |
baseUrl |
string
|
<optional>
|
Candidate base URL. |
- Source:
Returns:
Normalized base URL, or an empty string when unresolved.
-
Type
-
string