On this page
Overview
Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoint records, and request lifecycle events.
- Artifact
ApiModelDatabase.js· esm - Classification
public first party - Availability
Browser / native WebView / server with fetch - Normalization
Request records are normalized; fetch/provider failures remain mixed.
Import and lifecycle
import * as module from '/arcane/modules/ApiModelDatabase.js';
Each fetch performs one configured HTTP request (GET by default), may write an injected cache, updates latest, and dispatches request, success, or error events.
Application-facing behavior: APIMODELEVENTS, APIMODELERRORS, default ApiModelDatabase; setEndpoint(), fetch(), cached(), and dispose(); state-free EventTarget/on compatibility for request, success, and error occurrences.
Protocol and host implementation
HTTP(S) fetch + per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
API_MODEL_EVENTS | variable · value | variable API_MODEL_EVENTS | — |
API_MODEL_ERRORS | variable · value | variable API_MODEL_ERRORS | — |
default | default · class | class ApiModelDatabase extends EventTarget | — |
appendParameters | function | function appendParameters(url,parameters={}) | url,parameters={} |
publicEndpoint | function | function publicEndpoint(url) | url |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
ApiModelDatabase.setEndpoint | public-member | setEndpoint(value) | value |
ApiModelDatabase.fetch | public-member | async fetch(parameters={},context={},optionsValue={}) | parameters={},context={},optionsValue={} |
ApiModelDatabase.cached | public-member | async cached(parameters={},optionsValue={}) | parameters={},optionsValue={} |
| Member | Kind | Exact public declaration | Parameter syntax |
|---|---|---|---|
ApiModelDatabase.constructor | constructor | constructor({endpoint:source,parser=value=>value,fetchImpl=globalThis.fetch,cache=null,request={}}={}) | {endpoint:source,parser=value=>value,fetchImpl=globalThis.fetch,cache=null,request={}}={} |
ApiModelDatabase.addEventListener | method | addEventListener(type,listener,options) | type,listener,options |
ApiModelDatabase.removeEventListener | method | removeEventListener(type,listener,options) | type,listener,options |
ApiModelDatabase.on | method | on(type,listener,options) | type,listener,options |
ApiModelDatabase.dispatchEvent | method | dispatchEvent(value) | value |
ApiModelDatabase.setEndpoint | method | setEndpoint(value) | value |
ApiModelDatabase.fetch | async method | async fetch(parameters={},context={},optionsValue={}) | parameters={},context={},optionsValue={} |
ApiModelDatabase.cached | async method | async cached(parameters={},optionsValue={}) | parameters={},optionsValue={} |
ApiModelDatabase.dispose | method | dispose() | — |
ApiModelDatabase.destroy | method | destroy() | — |
Parameter meanings and results
ApiModelDatabase({endpoint, parser, fetchImpl, cache, request}) validates its dependencies. fetch(parameters, context) returns an ApiModelRecord after JSON parsing, while cached(parameters) returns a cached record or null.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
- api-model-request
- api-model-success
- api-model-error
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- TypeError for endpoint, parser, or fetch configuration
- HTTP, JSON, parser, and cache failures are rethrown
Availability and capabilities
Browser / native WebView / server with fetch. Request records are normalized; fetch/provider failures remain mixed.
Provider-neutral fetch adapter with no Core dependency.
Contract example
import ApiModelDatabase from '/arcane/modules/ApiModelDatabase.js';
const database=new ApiModelDatabase({
endpoint:'https://example.test/models',
fetchImpl:async()=>new Response('{"items":["alpha"]}',{status:200}),
parser:raw=>raw.items
});
console.log((await database.fetch({limit:1})).value);
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.