Skip to main content

Class: CloudRepository

Defined in: helpers/CloudRepository.ts:102

Constructors​

new CloudRepository()​

new CloudRepository(_baseUrl): CloudRepository

Defined in: helpers/CloudRepository.ts:136

Parameters​

_baseUrl​

string = 'https://cloud.myop.dev'

Returns​

CloudRepository

Accessors​

Main​

Get Signature​

get static Main(): CloudRepository

Defined in: helpers/CloudRepository.ts:105

Returns​

CloudRepository

Methods​

enableStaticMode()​

enableStaticMode(): void

Defined in: helpers/CloudRepository.ts:300

Enable static mode for self-hosted component registries. In static mode, URLs are constructed as file paths instead of query params: ${baseUrl}/components/${componentId}/${env}.json

Returns​

void


fetchAutoFlow()​

fetchAutoFlow(componentId): Promise<IUserFlow>

Defined in: helpers/CloudRepository.ts:635

Parameters​

componentId​

string

Returns​

Promise<IUserFlow>


fetchComponent()​

fetchComponent(componentId, flowId?): Promise<undefined | IComponentConfig>

Defined in: helpers/CloudRepository.ts:685

Parameters​

componentId​

string

flowId?​

string

Returns​

Promise<undefined | IComponentConfig>

Deprecated​

Use fetchComponentV2 or fetchComponentV1 explicitly Defaults to v1 behavior for backward compatibility with existing code


fetchComponentV1()​

fetchComponentV1(componentId, flowId?): Promise<undefined | IComponentConfig>

Defined in: helpers/CloudRepository.ts:625

Fetch a v1 component from a flow

Parameters​

componentId​

string

flowId?​

string

Returns​

Promise<undefined | IComponentConfig>


fetchComponentV2()​

fetchComponentV2(componentId, environmentIdentifier?, preview?): Promise<IComponentConfig>

Defined in: helpers/CloudRepository.ts:377

Fetch a v2 component config If env/preview not specified and component was preloaded, uses preloaded params

Parameters​

componentId​

string

environmentIdentifier?​

string

preview?​

boolean

Returns​

Promise<IComponentConfig>

See​

resolveComponent — the unversioned name for this method


fetchFlow()​

fetchFlow(flowId): Promise<IUserFlow>

Defined in: helpers/CloudRepository.ts:657

Parameters​

flowId​

string

Returns​

Promise<IUserFlow>


flushLocalServes()​

flushLocalServes(): void

Defined in: helpers/CloudRepository.ts:244

Send what we have. keepalive is what makes this work at page-hide: the request outlives the document. Failure is ignored — a lost usage report must never be visible to a visitor, and the next page load will report its own.

Returns​

void


getComponentTags()​

getComponentTags(componentId, env?, preview?): string[]

Defined in: helpers/CloudRepository.ts:557

The ui: tags of an already-resolved component ([] if it has none or is not resolved yet). Synchronous, no request: tags arrive with the component itself.

Parameters​

componentId​

string

env?​

string

preview?​

boolean

Returns​

string[]


getDefaultEnvironment()​

getDefaultEnvironment(): string

Defined in: helpers/CloudRepository.ts:323

Get the current default environment

Returns​

string


getPreloadedParams()​

getPreloadedParams(componentId): undefined | { env: string; preview: boolean; }

Defined in: helpers/CloudRepository.ts:347

Get the preloaded params for a component (if preloaded) Returns undefined if not preloaded

Parameters​

componentId​

string

Returns​

undefined | { env: string; preview: boolean; }


getResolvedConfig()​

getResolvedConfig(componentId, env?, preview?): null | IComponentConfig

Defined in: helpers/CloudRepository.ts:548

Synchronous version of fetchComponentV2 — returns the config only if the fetch already completed, null otherwise.

Uses the same this.variants cache that fetchComponentV2/preloadComponents populate. Each cached Promise is tagged with a .resolved property when it settles — this method just reads that property. No separate cache.

Why this exists: React Native needs the config at render time to embed it in the WebView HTML (can't await in useState). If preloadComponents ran earlier and the fetch completed, this returns the result synchronously, skipping the WEBVIEW_READY → fetch → inject round trip entirely.

Parameters​

componentId​

string

env?​

string

preview?​

boolean

Returns​

null | IComponentConfig


hydrateComponent()​

hydrateComponent(componentId, config, env?, preview?): void

Defined in: helpers/CloudRepository.ts:608

Seed an already-resolved component config into the cache, without any network request.

The counterpart to fetchComponentV2: use it when the config was resolved somewhere else — most often on a server, then embedded in the page — so the browser can render the component with no round trip.

After hydrating, fetchComponentV2, getResolvedConfig and isPreloaded all answer for this component from memory.

Pass the same env / preview the config was resolved with; the defaults match what a plain fetchComponentV2(componentId) would have used.

Parameters​

componentId​

string

config​

IComponentConfig

env?​

string

preview?​

boolean

Returns​

void


isPreloaded()​

isPreloaded(componentId, env?, preview?): boolean

Defined in: helpers/CloudRepository.ts:333

Check if a component is already cached/preloaded (v2) If env and preview are not provided, checks if ANY version is preloaded

Parameters​

componentId​

string

env?​

string

preview?​

boolean

Returns​

boolean


resolveComponent()​

resolveComponent(componentId, env?, preview?): Promise<IComponentConfig>

Defined in: helpers/CloudRepository.ts:367

Resolve a component config: fetch it once, then serve it from this repository's cache.

This is the name to use. fetchComponentV2 is the same method under its versioned name and stays for backward compatibility — note that the unversioned fetchComponent is a deprecated v1 API and is NOT this.

Completes the trio with getResolvedConfig (synchronous read of an already-resolved config) and hydrateComponent (seed one you already hold).

Prefer the module-level preloadComponents([id]) in app code; reach for this when you need an isolated repository instance whose cache lifetime you control — a server with its own TTL, for example.

Parameters​

componentId​

string

env?​

string

preview?​

boolean

Returns​

Promise<IComponentConfig>


setEnvironment()​

setEnvironment(env): void

Defined in: helpers/CloudRepository.ts:315

Set the default environment for this CloudRepository instance

Parameters​

env​

string

Returns​

void


setQueryParams()​

setQueryParams(params): void

Defined in: helpers/CloudRepository.ts:308

Set query parameters to append to all fetch URLs (e.g. for CDN cache busting). Example: setQueryParams({ lastupdate: '11112026' })

Parameters​

params​

Record<string, string>

Returns​

void