Capability first · transport second

ApiModelDatabase.js

Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoint records, and request lifecycle events.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
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

JavaScript
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

BindingFormDeclaration or signatureParameter syntax
API_MODEL_EVENTSvariable · valuevariable API_MODEL_EVENTS
API_MODEL_ERRORSvariable · valuevariable API_MODEL_ERRORS
defaultdefault · classclass ApiModelDatabase extends EventTarget
appendParametersfunctionfunction appendParameters(url,parameters={})url,parameters={}
publicEndpointfunctionfunction publicEndpoint(url)url
CallableKindExact public signatureParameter syntax
ApiModelDatabase.setEndpointpublic-membersetEndpoint(value)value
ApiModelDatabase.fetchpublic-memberasync fetch(parameters={},context={},optionsValue={})parameters={},context={},optionsValue={}
ApiModelDatabase.cachedpublic-memberasync cached(parameters={},optionsValue={})parameters={},optionsValue={}
MemberKindExact public declarationParameter syntax
ApiModelDatabase.constructorconstructorconstructor({endpoint:source,parser=value=>value,fetchImpl=globalThis.fetch,cache=null,request={}}={}){endpoint:source,parser=value=>value,fetchImpl=globalThis.fetch,cache=null,request={}}={}
ApiModelDatabase.addEventListenermethodaddEventListener(type,listener,options)type,listener,options
ApiModelDatabase.removeEventListenermethodremoveEventListener(type,listener,options)type,listener,options
ApiModelDatabase.onmethodon(type,listener,options)type,listener,options
ApiModelDatabase.dispatchEventmethoddispatchEvent(value)value
ApiModelDatabase.setEndpointmethodsetEndpoint(value)value
ApiModelDatabase.fetchasync methodasync fetch(parameters={},context={},optionsValue={})parameters={},context={},optionsValue={}
ApiModelDatabase.cachedasync methodasync cached(parameters={},optionsValue={})parameters={},optionsValue={}
ApiModelDatabase.disposemethoddispose()
ApiModelDatabase.destroymethoddestroy()

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

JavaScript
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);

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.