Skip to main content

KubernetesRepository

@webda/kubernetes


Class: KubernetesRepository<T>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:96

Repository storing a model as Kubernetes custom resources

The primary key is the name of the resource, the stored fields the spec, the status fields the status. The model identifier is in the webda.io/model annotation (and label): subclasses share the resources of their root model. Resources without it (created with kubectl) belong to the root model.

Writes are optimistic: a read-modify-write (update, patch, increments, collections...) replaces the resource with the resourceVersion it read and retries on conflict. Each of them runs the in-memory implementation of MemoryRepository on the read object, so the semantics are the same as the memory store. Queries list the resources (equality on label fields is filtered by the API server) and are evaluated in memory.

Extends​

  • MemoryRepository<T>

Type Parameters​

T​

T extends ModelClass

Constructors​

Constructor​

new KubernetesRepository<T>(model, pks, resources, options?, separator?): KubernetesRepository<T>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:108

Parameters​

model​

T

the model class

pks​

string[]

primary key fields

resources​

CustomResources

the custom resources of the root model

options?​

KubernetesRepositoryOptions = {}

fields mapping

separator?​

string

composite key separator

Returns​

KubernetesRepository<T>

Overrides​

MemoryRepository<T>.constructor

Properties​

[WEBDA_TEST]​

[WEBDA_TEST]: object

Defined in: models/lib/repositories/memory.d.ts:325

Test utilities - clears all stored data

clear​

clear: () => Promise<void>

Returns​

Promise<void>

Inherited from​

MemoryRepository.[WEBDA_TEST]


aggregationOptions​

protected aggregationOptions: AggregationOptions

Defined in: models/lib/repositories/abstract.d.ts:27

Aggregation fallback policy, set by the owning store through configureAggregation

Inherited from​

MemoryRepository.aggregationOptions


events​

protected events: Map<keyof InstanceType<T>[typeof WEBDA_EVENTS], Set<(data) => void>>

Defined in: models/lib/repositories/abstract.d.ts:25

Registered event listeners keyed by event name

Inherited from​

MemoryRepository.events


labelFields​

protected labelFields: string[]

Defined in: kubernetes/src/stores/kubernetesrepository.ts:98


maxListeners​

protected maxListeners: number

Defined in: models/lib/repositories/abstract.d.ts:321

Max-listeners hint kept for Node EventEmitter API compatibility. Not enforced — repositories use an unbounded Set per event.

Inherited from​

MemoryRepository.maxListeners


maxRetries​

protected maxRetries: number

Defined in: kubernetes/src/stores/kubernetesrepository.ts:99


model​

protected model: T

Defined in: models/lib/repositories/abstract.d.ts:21

Inherited from​

MemoryRepository.model


monitorOptions​

protected monitorOptions: QueryMonitorOptions

Defined in: models/lib/repositories/abstract.d.ts:29

Query monitoring options, set by the owning store through configureMonitoring

Inherited from​

MemoryRepository.monitorOptions


pks​

protected pks: string[]

Defined in: models/lib/repositories/abstract.d.ts:22

Inherited from​

MemoryRepository.pks


resources​

protected resources: CustomResources

Defined in: kubernetes/src/stores/kubernetesrepository.ts:111

the custom resources of the root model


separator​

protected separator: string

Defined in: models/lib/repositories/abstract.d.ts:23

Inherited from​

MemoryRepository.separator


statusFields​

protected statusFields: string[]

Defined in: kubernetes/src/stores/kubernetesrepository.ts:97


storage​

protected storage: Map

Defined in: models/lib/repositories/memory.d.ts:39

Inherited from​

MemoryRepository.storage


tableRoot?​

protected optional tableRoot?: ModelClass<Storable<any, any>>

Defined in: models/lib/repositories/abstract.d.ts:35

Model owning the untyped rows of the storage (the first model of the store), undefined when not known

Inherited from​

MemoryRepository.tableRoot


warnedAggregations​

protected warnedAggregations: Set<string>

Defined in: models/lib/repositories/abstract.d.ts:31

Fallback shapes already warned about

Inherited from​

MemoryRepository.warnedAggregations

Methods​

acceptedTypes()​

acceptedTypes(): string[]

Defined in: models/lib/repositories/abstract.d.ts:69

Every stored __type value of this model and its transitive subclasses, for stores filtering in their query language

Returns​

string[]

the values, empty when the model carries no Metadata

Inherited from​

MemoryRepository.acceptedTypes


aggregate()​

aggregate<G, M>(spec, params?): Promise<AggregationResult<AggregatedRow<InstanceType<T>, G, M>>>

Defined in: models/lib/repositories/abstract.d.ts:256

Keep the full generic signature here (not spec: any): concrete repositories are used directly in code and tests, and must expose the typed rows.

Type Parameters​

G​

G extends readonly _NonFunctionPropertyPaths<InstanceType<T>>[] = []

M​

M extends Record<string, MetricSpec<InstanceType<T>>> = Record<string, MetricSpec<InstanceType<T>>>

Parameters​

spec​

AggregationSpec<InstanceType<T>, G, M>

params?​

QueryParameters

Returns​

Promise<AggregationResult<AggregatedRow<InstanceType<T>, G, M>>>

Inherited from​

MemoryRepository.aggregate


aggregateInMemory()​

protected aggregateInMemory(query): Promise<Record<string, unknown>[]>

Defined in: models/lib/repositories/abstract.d.ts:301

Aggregate by streaming the filtered items

Parameters​

query​

AggregationQuery

the aggregation

Returns​

Promise<Record<string, unknown>[]>

the rows

Inherited from​

MemoryRepository.aggregateInMemory


applyAssignments()​

protected applyAssignments<O>(target, assignments): O

Defined in: models/lib/repositories/abstract.d.ts:166

Set the assignments of an UPDATE on an object, creating the intermediate objects of dotted paths

Targets were checked by parseStatement: letters, digits and _ only, no __ segment, no Object.prototype member name.

Type Parameters​

O​

O

Parameters​

target​

O

the object to change in place

assignments​

Assignment[]

the SET assignments

Returns​

O

the target

Inherited from​

MemoryRepository.applyAssignments


belongsToModel()​

belongsToModel(stored?): boolean

Defined in: models/lib/repositories/abstract.d.ts:75

Whether a stored row belongs to this model, for stores filtering in memory

Parameters​

stored?​

string

the stored __type, undefined for an untyped row

Returns​

boolean

true when the row belongs to this model (always without Metadata)

Inherited from​

MemoryRepository.belongsToModel


buildClassFilter()​

protected buildClassFilter(): string | undefined

Defined in: models/lib/repositories/memory.d.ts:186

Build the WebdaQL class-filter clause __type IN ['A', 'B', ...] covering this.model's identifier and every transitive descendant.

Returns undefined when the model carries no Metadata.

Returns​

string | undefined

the class-filter WebdaQL clause, or undefined when no Metadata

Inherited from​

MemoryRepository.buildClassFilter


buildClassFilterIdentifiers()​

protected buildClassFilterIdentifiers(): string[] | undefined

Defined in: models/lib/repositories/memory.d.ts:177

Collect the WebdaQL class-filter identifier list — this.model's identifier and every transitive descendant.

Returns undefined when the model carries no Metadata (plain unit-test classes that didn't go through Application.setModelMetadata). In that case query() skips the prepend and returns everything in storage, preserving the pre-fix behavior for those bare classes.

Returns​

string[] | undefined

the list of identifiers to match, or undefined when no Metadata

Inherited from​

MemoryRepository.buildClassFilterIdentifiers


buildItem()​

protected buildItem(data): InstanceType<T>

Defined in: models/lib/repositories/abstract.d.ts:86

Build the model instance to create from the incoming data

Primary key fields that are undefined or null are dropped from the data so a key generated by the model constructor (e.g. UuidModel) is not overwritten. Repositories must read the storage key from the returned instance.

Parameters​

data​

Helpers<InstanceType<T>>

the incoming data

Returns​

InstanceType<T>

the model instance

Inherited from​

MemoryRepository.buildItem


checkAggregationFallback()​

protected checkAggregationFallback(query, reason): Promise<void>

Defined in: models/lib/repositories/abstract.d.ts:272

Apply the fallback policy before aggregating or counting in memory

Parameters​

query​

AggregationQuery | undefined

the aggregation, undefined for a count

reason​

string

why it cannot run natively

Returns​

Promise<void>

Throws​

AggregationError AGGREGATION_NOT_NATIVE when the policy is deny

Inherited from​

MemoryRepository.checkAggregationFallback


checkCondition()​

protected checkCondition<K>(item, conditionField?, condition?): void

Defined in: models/lib/repositories/memory.d.ts:67

Verify an optimistic locking condition on an item

Type Parameters​

K​

K extends string

Parameters​

item​

InstanceType<T>

The item to check

conditionField?​

K | null

Field to validate

condition?​

any

Expected value

Returns​

void

Throws​

Error if the condition does not match

Inherited from​

MemoryRepository.checkCondition


checkItemWriteCondition()​

protected checkItemWriteCondition(item, index, itemWriteConditionField, itemWriteCondition): void

Defined in: models/lib/repositories/memory.d.ts:317

Verify a write condition on a collection item

Parameters​

item​

any[]

The array to check

index​

number

Index of the item in the array

itemWriteConditionField​

string

Field name to check on the item

itemWriteCondition​

any

Expected value for the field

Returns​

void

Throws​

Error if the condition does not match

Inherited from​

MemoryRepository.checkItemWriteCondition


collectStatementKeys()​

protected collectStatementKeys(statement): Promise<PrimaryKeyType<InstanceType<T>>[]>

Defined in: models/lib/repositories/abstract.d.ts:173

Keys of the objects matching the WHERE of a statement, collected before any change so an update changing a WHERE field cannot meet the same object twice; at most LIMIT keys

Parameters​

statement​

Query

the parsed statement

Returns​

Promise<PrimaryKeyType<InstanceType<T>>[]>

the primary keys

Inherited from​

MemoryRepository.collectStatementKeys


conditionHolds()​

protected conditionHolds(item, field, condition): boolean

Defined in: kubernetes/src/stores/kubernetesrepository.ts:286

Whether a field of an object has the expected value (dates compare with their ISO string)

Parameters​

item​

any

the object

field​

string

the field, dotted for a nested one

condition​

any

the expected value

Returns​

boolean

true when it has


configureAggregation()​

configureAggregation(options): void

Defined in: models/lib/repositories/abstract.d.ts:228

Copy the known options (fallback, maxGroups, warn); undefined values keep the current ones

Parameters​

options​

Partial<AggregationOptions>

Returns​

void

Throws​

Error when maxGroups is not a positive integer or fallback is unknown

Inherited from​

MemoryRepository.configureAggregation


configureMonitoring()​

configureMonitoring(options): void

Defined in: models/lib/repositories/abstract.d.ts:233

Configure the query monitoring policy, called by the owning store

Parameters​

options​

Partial<QueryMonitorOptions>

options to override

Returns​

void

Inherited from​

MemoryRepository.configureMonitoring


count()​

count(filter?, params?, options?): Promise<CountResult>

Defined in: models/lib/repositories/abstract.d.ts:278

Parse the filter, refuse statements, drop ORDER BY / LIMIT / OFFSET and run executeCount

Parameters​

filter?​

string

params?​

QueryParameters

options?​

CountOptions

Returns​

Promise<CountResult>

Throws​

Error when max is not a positive integer

Inherited from​

MemoryRepository.count


countInMemory()​

protected countInMemory(filter, max?): Promise<Omit<CountResult, "native">>

Defined in: models/lib/repositories/abstract.d.ts:295

Count by streaming the filtered items, stopping at max + 1

Parameters​

filter​

Expression

the filter

max?​

number

stop after max objects, undefined for an exact count

Returns​

Promise<Omit<CountResult, "native">>

the value and its relation

Inherited from​

MemoryRepository.countInMemory


create()​

create(data, save?): Promise<any>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:371

Parameters​

data​

any

save?​

boolean = true

Returns​

Promise<any>

Overrides​

MemoryRepository.create


currentTypeOf()​

protected currentTypeOf(instance, stored?): string | undefined

Defined in: models/lib/repositories/memory.d.ts:140

The __type to attach to a loaded instance: the current identifier of its class, the stored value when it is unknown or ambiguous (never rewritten to a guess), the repository model identifier for an untyped row

Parameters​

instance​

any

the loaded instance

stored?​

string

the stored __type

Returns​

string | undefined

the value to attach

Inherited from​

MemoryRepository.currentTypeOf


delete()​

delete(primaryKey, conditionField?, condition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:463

Parameters​

primaryKey​

any

conditionField?​

any

condition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.delete


deleteItemFromCollection()​

deleteItemFromCollection(primaryKey, collection, index, itemWriteConditionField?, itemWriteCondition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:443

Parameters​

primaryKey​

any

collection​

any

index​

number

itemWriteConditionField?​

any

itemWriteCondition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.deleteItemFromCollection


deleteMany()​

deleteMany(statement, params?): Promise<number>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:543

Delete the matching objects one by one: no native bulk delete

Parameters​

statement​

any

params?​

QueryParameters

Returns​

Promise<number>

Overrides​

MemoryRepository.deleteMany


deleteManyByKey()​

protected deleteManyByKey(statement, params?): Promise<number>

Defined in: models/lib/repositories/abstract.d.ts:191

Generic deleteMany: collect the matching keys (up to LIMIT), then delete them one by one with this repository's delete primitive

Used by stores without a native bulk delete. On a store repository the primitive emits no event.

Parameters​

statement​

string | Query

the DELETE statement or its parsed form

params?​

QueryParameters

values for the placeholders

Returns​

Promise<number>

the number of objects deleted

Inherited from​

MemoryRepository.deleteManyByKey


deserialize()​

deserialize(item): InstanceType<T>

Defined in: models/lib/repositories/memory.d.ts:121

Unserialize the object from a string

Beyond restoring the concrete type via @webda/serialize's $serializer.type typeKey, this also surfaces the storage envelope's __type stamp on the in-memory instance as a NON-ENUMERABLE property. The non-enumerable bit keeps __type invisible to JSON.stringify and Object.keys (so API responses and re-serialize cycles are byte-identical for the model's own fields), while still being readable via direct property access — which is exactly how WebdaQL's filter eval reads it (ComparisonExpression.getAttributeValue walks obj[name]).

Backward-compat: legacy rows written before the envelope-stamping was introduced won't carry __type. In that case we backfill from the repository's own model.Metadata.Identifier so they look like records of the parent class — which is exactly what query()'s prepended class filter expects (parent + descendants). Plain unit-test classes without Metadata get no stamp at all; their repos opt out of class filtering on the query side too (see query).

Parameters​

item​

string

the serialized string

Returns​

InstanceType<T>

the deserialized model instance

Inherited from​

MemoryRepository.deserialize


deserializeEnvelope()​

protected deserializeEnvelope(item, raw, stored?): any

Defined in: models/lib/repositories/memory.d.ts:132

Deserialize a serializer envelope

A row written under a model's former identifier (renamed, see @WebdaAlias) names a serializer that no longer exists: it is deserialized with the serializer of the class its __type resolves to.

Parameters​

item​

string

the stored string

raw​

any

the parsed envelope

stored?​

string

the stored __type

Returns​

any

the instance

Inherited from​

MemoryRepository.deserializeEnvelope


emit()​

emit<K>(event, data): Promise<void>

Defined in: models/lib/repositories/abstract.d.ts:346

Emit an event to all registered listeners and await their completion.

Type Parameters​

K​

K extends string | number | symbol

Parameters​

event​

K

The event name to emit

data​

InstanceType<T>[typeof WEBDA_EVENTS][K]

The event payload

Returns​

Promise<void>

Inherited from​

MemoryRepository.emit


excludePrimaryKey()​

excludePrimaryKey(object): any

Defined in: models/lib/repositories/abstract.d.ts:110

Parameters​

object​

any

Returns​

any

Inherited from​

MemoryRepository.excludePrimaryKey


executeAggregation()​

protected executeAggregation(query): Promise<AggregationResult<any>>

Defined in: models/lib/repositories/memory.d.ts:248

A plain MemoryRepository (MemoryStore, FileStore) aggregates its own local data: that is native. Subclasses backed by a remote database (Firestore, Dynamo, ...) inherit the fallback instead.

Parameters​

query​

AggregationQuery

Returns​

Promise<AggregationResult<any>>

Inherited from​

MemoryRepository.executeAggregation


executeCount()​

protected executeCount(filter, max?): Promise<CountResult>

Defined in: models/lib/repositories/memory.d.ts:254

A plain MemoryRepository (MemoryStore, FileStore) counts its own local data: that is native. Subclasses backed by a remote database (Firestore, Dynamo, ...) inherit the fallback instead.

Parameters​

filter​

Expression

max?​

number

Returns​

Promise<CountResult>

Inherited from​

MemoryRepository.executeCount


exists()​

exists(primaryKey): Promise<boolean>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:360

Parameters​

primaryKey​

any

Returns​

Promise<boolean>

Overrides​

MemoryRepository.exists


findModelClass()​

protected findModelClass(identifier): any

Defined in: models/lib/repositories/memory.d.ts:157

Find the class to hydrate a row typed identifier (a Webda 3 legacy form included): the resolved model when it is the repository model or one of its transitive subclasses, the repository model for an ancestor type or an unknown or ambiguous type

Parameters​

identifier​

string

stored __type

Returns​

any

the class, this.model when it carries no Metadata, or undefined for an unrelated model

Inherited from​

MemoryRepository.findModelClass


fromResource()​

fromResource(resource): InstanceType<T>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:221

Convert a custom resource to the model instance

Parameters​

resource​

CustomResource

the resource

Returns​

InstanceType<T>

the model instance


fromUID()​

fromUID(uid): ModelRefWithCreate<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:92

Return a ref from the uuid

Parameters​

uid​

string

the serialized primary key

Returns​

ModelRefWithCreate<InstanceType<T>>

a model reference with create capability

Inherited from​

MemoryRepository.fromUID


get()​

get(primaryKey): Promise<any>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:355

Parameters​

primaryKey​

any

Returns​

Promise<any>

Overrides​

MemoryRepository.get


getAllowedFields()​

getAllowedFields(): string[] | undefined

Defined in: models/lib/repositories/abstract.d.ts:138

Field paths of the model, from its metadata (Reflection and the stored, input and output schemas)

Used to validate UPDATE SET targets.

Returns​

string[] | undefined

the field names, undefined when the model carries no field metadata (no validation then)

Inherited from​

MemoryRepository.getAllowedFields


getCollectionName()​

protected getCollectionName(): string

Defined in: kubernetes/src/stores/kubernetesrepository.ts:275

Name of the stored objects, used in errors

Returns​

string

the model identifier, else the resources plural


getCompletionFields()​

getCompletionFields(): CompletionField[]

Defined in: models/lib/repositories/abstract.d.ts:143

Completion fields of the model, flattened from its schemas

Returns​

CompletionField[]

array of completion fields

Inherited from​

MemoryRepository.getCompletionFields


getMaxListeners()​

getMaxListeners(): number

Defined in: models/lib/repositories/abstract.d.ts:334

EventEmitter-compatibility shim. Returns the max-listeners hint.

Returns​

number

the current max-listeners hint

Inherited from​

MemoryRepository.getMaxListeners


getPrimaryKey()​

Call Signature​

getPrimaryKey(object, forceObject?): PrimaryKeyType<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:112

Get the primary key value for an object as a scalar or string.

Parameters​
object​

any

forceObject?​

false

Returns​

PrimaryKeyType<InstanceType<T>>

Inherited from​

MemoryRepository.getPrimaryKey

Call Signature​

getPrimaryKey(object, forceObject): PrimaryKey<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:114

Get the primary key value for an object as a structured key object.

Parameters​
object​

any

forceObject​

true

Returns​

PrimaryKey<InstanceType<T>>

Inherited from​

MemoryRepository.getPrimaryKey


getRootModel()​

getRootModel(): T

Defined in: models/lib/repositories/abstract.d.ts:47

Returns​

T

Inherited from​

MemoryRepository.getRootModel


getSync()​

protected getSync(primaryKey): InstanceType<T>

Defined in: models/lib/repositories/memory.d.ts:55

Synchronous read used by conditional writes to keep check-and-set atomic

Parameters​

primaryKey​

string | PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>

key of the item

Returns​

InstanceType<T>

the deserialized item

Inherited from​

MemoryRepository.getSync


getTableRoot()​

getTableRoot(): ModelClass<Storable<any, any>> | undefined

Defined in: models/lib/repositories/abstract.d.ts:57

Returns​

ModelClass<Storable<any, any>> | undefined

the model owning the untyped rows of the storage

Inherited from​

MemoryRepository.getTableRoot


getUID()​

getUID(object): string

Defined in: models/lib/repositories/abstract.d.ts:116

Parameters​

object​

any

Returns​

string

Inherited from​

MemoryRepository.getUID


hydratePlainRow()​

protected hydratePlainRow(raw): InstanceType<T>

Defined in: models/lib/repositories/memory.d.ts:165

Hydrate a plain JSON row as an instance of the repository model (or of the transitive subclass named by its __type; an ancestor type hydrates as the repository model), the same way document stores hydrate their rows; a row typed as an unrelated model is refused

Parameters​

raw​

any

the parsed row

Returns​

InstanceType<T>

the model instance

Inherited from​

MemoryRepository.hydratePlainRow


incrementAttribute()​

incrementAttribute<K, L>(primaryKey, info, _conditionField?, _condition?): Promise<void>

Defined in: models/lib/repositories/abstract.d.ts:124

Type Parameters​

K​

K extends string

L​

L extends string

Parameters​

primaryKey​

PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>

info​

L | { property: L; value?: number; }

_conditionField?​

K | null

_condition?​

any

Returns​

Promise<void>

Inherited from​

MemoryRepository.incrementAttribute


incrementAttributes()​

incrementAttributes(primaryKey, info, conditionField?, condition?): Promise<any>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:404

Parameters​

primaryKey​

any

info​

any

conditionField?​

any

condition?​

any

Returns​

Promise<any>

Overrides​

MemoryRepository.incrementAttributes


isPlainRow()​

protected isPlainRow(raw): boolean

Defined in: models/lib/repositories/memory.d.ts:149

Whether a stored row is a plain JSON object without a serializer envelope

Rows written by earlier versions (e.g. a v3 FileStore folder or MemoryStore persistence file) store the object itself, its type in a top-level __type.

Parameters​

raw​

any

the parsed row

Returns​

boolean

true for a plain object row

Inherited from​

MemoryRepository.isPlainRow


iterate()​

iterate(query, params?): AsyncGenerator<InstanceType<T>, any, any>

Defined in: models/lib/repositories/memory.d.ts:260

Add iterator support

Parameters​

query​

string

the query string

params?​

QueryParameters

values for the ? or :name placeholders

Returns​

AsyncGenerator<InstanceType<T>, any, any>

Inherited from​

MemoryRepository.iterate


labelSelector()​

protected labelSelector(filter): string | undefined

Defined in: kubernetes/src/stores/kubernetesrepository.ts:503

Label selector equivalent to the conditions of a filter on label fields: = and IN at the top level

It only narrows the listed resources, the whole filter is still evaluated.

Parameters​

filter​

Expression

the query filter

Returns​

string | undefined

the selector, undefined when nothing can be filtered by the API server


listKeysOfModel()​

protected listKeysOfModel(ids?): string[]

Defined in: models/lib/repositories/memory.d.ts:230

List the storage keys that may belong to this model

A storage shared by several models holds foreign entries whose key shape can be invalid for this repository: they are skipped from the stored __type before any parsing. Entries are kept when their stored __type belongs to the model (legacy forms included). Untyped entries, and entries typed as a strict ancestor of the table root, belong to the table root and its ancestors. Unreadable entries are kept so their error surfaces.

A TypeIndexedMap storage answers from its type index: only the keys of the model are visited. Any other Map-like storage is scanned, parsing every entry.

Parameters​

ids?​

string[]

class identifiers (model and subclasses), undefined to keep everything

Returns​

string[]

the keys to evaluate

Inherited from​

MemoryRepository.listKeysOfModel


matchStorage()​

protected matchStorage(statement): object[]

Defined in: models/lib/repositories/memory.d.ts:269

Keys of the stored objects of this model matching a statement's WHERE, at most LIMIT

Synchronous: the statement then runs without yielding, so no other write interleaves and an object is never met twice.

Parameters​

statement​

Query

the parsed statement

Returns​

object[]

the storage keys and their objects

Inherited from​

MemoryRepository.matchStorage


monitor()​

protected monitor<R>(operation, query, fn, details): Promise<R>

Defined in: models/lib/repositories/abstract.d.ts:247

Helper that times a query operation, catches and rethrows errors, and calls onQuery safely

Type Parameters​

R​

R

Parameters​

operation​

QueryOperation

the query operation

query​

string

the query string

fn​

() => Promise<R>

the async function to execute and time

details​

((r) => object) | ((r) => number)

optional callback to extract result count or pagination details

Returns​

Promise<R>

the result of fn

Inherited from​

MemoryRepository.monitor


mutate()​

protected mutate<R>(primaryKey, change, options): Promise<R>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:307

Read, check, change and write an object, again on conflict

The change runs on an in-memory repository holding the object read, so the memory store semantics apply.

Type Parameters​

R​

R

Parameters​

primaryKey​

any

the key

change​

(memory, key) => Promise<R>

the change, on the in-memory repository

options​

conditions and errors

condition?​

any

expected value of the field

conditionField?​

any

field of the condition on the object

itemCondition?​

any

expected value of the item field, for its error

itemConditionField?​

any

field of the condition on a collection item, for its error

missing​

"condition" | "store"

error of a missing object: condition for an UpdateConditionFailError, store for a StoreNotFoundError

Returns​

Promise<R>

the result of the change

Throws​

UpdateConditionFailError when a condition fails


off()​

off<K>(event, listener): void

Defined in: models/lib/repositories/abstract.d.ts:316

Type Parameters​

K​

K extends string | number | symbol

Parameters​

event​

K

listener​

(data) => void

Returns​

void

Inherited from​

MemoryRepository.off


on()​

on<K>(event, listener): void

Defined in: models/lib/repositories/abstract.d.ts:312

Type Parameters​

K​

K extends string | number | symbol

Parameters​

event​

K

listener​

(data) => void

Returns​

void

Inherited from​

MemoryRepository.on


once()​

once<K>(event, listener): void

Defined in: models/lib/repositories/abstract.d.ts:314

Type Parameters​

K​

K extends string | number | symbol

Parameters​

event​

K

listener​

(data) => void

Returns​

void

Inherited from​

MemoryRepository.once


parseLegacyUID()​

protected parseLegacyUID(uid): PrimaryKey<InstanceType<T>> | undefined

Defined in: models/lib/repositories/abstract.d.ts:108

Parse a uid through the model's parseLegacyUID hook

Parameters​

uid​

string

the raw storage key

Returns​

PrimaryKey<InstanceType<T>> | undefined

a key whose string form is the raw uid, or undefined when the model does not recognise it

Inherited from​

MemoryRepository.parseLegacyUID


parseStatement()​

protected parseStatement(type, statement, params?): Promise<Query>

Defined in: models/lib/repositories/abstract.d.ts:156

Parse a bulk statement and check it is of the expected type

For an UPDATE, every SET target is checked: no primary key field, no private (__) segment, no constructor/prototype segment, and a field of the model when its metadata lists them.

Parameters​

type​

"DELETE" | "UPDATE"

the expected statement type

statement​

string | Query

the statement string or its parsed form

params?​

QueryParameters

values for the placeholders of a statement string

Returns​

Promise<Query>

the parsed statement

Throws​

WebdaQLError when the statement has another type or a SET target is refused

Throws​

SyntaxError when the statement does not parse, or a SET target is not a field of the model

Inherited from​

MemoryRepository.parseStatement


parseUID()​

parseUID(uid, forceObject?): PrimaryKeyType<InstanceType<T>> | PrimaryKey<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:102

Parse a serialized primary key

A composite key that does not split into the primary key fields is offered to the model's optional static parseLegacyUID(uid) hook (see WEBDA_LEGACY_UID): the returned key keeps the raw uid as its string form so it addresses the legacy storage entry. Without a hook, or when the hook declines, the uid is rejected.

Parameters​

uid​

string

forceObject?​

boolean

Returns​

PrimaryKeyType<InstanceType<T>> | PrimaryKey<InstanceType<T>>

Inherited from​

MemoryRepository.parseUID


patch()​

patch(primaryKey, data, conditionField?, condition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:395

Parameters​

primaryKey​

any

data​

any

conditionField?​

any

condition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.patch


query()​

query(query, params?): Promise<{ continuationToken?: string; results: any[]; }>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:522

Parameters​

query​

any

params?​

QueryParameters

Returns​

Promise<{ continuationToken?: string; results: any[]; }>

Overrides​

MemoryRepository.query


read()​

protected read(key): Promise<CustomResource>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:231

Read the resource of a key

Parameters​

key​

string

the primary key as a string

Returns​

Promise<CustomResource>

the resource

Throws​

Error Not found when it does not exist


ref()​

ref(key): ModelRefWithCreate<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:122

Parameters​

key​

PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>

Returns​

ModelRefWithCreate<InstanceType<T>>

Inherited from​

MemoryRepository.ref


removeAttribute()​

removeAttribute(primaryKey, attribute, conditionField?, condition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:413

Parameters​

primaryKey​

any

attribute​

any

conditionField?​

any

condition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.removeAttribute


removeListener()​

removeListener<K>(event, listener): void

Defined in: models/lib/repositories/abstract.d.ts:329

EventEmitter-compatibility alias for off. Consumers that treat a repository as a Node EventEmitter (e.g. @webda/runtime EventIterator) call removeListener.

Type Parameters​

K​

K extends string | number | symbol

Parameters​

event​

K

the event name

listener​

(data) => void

the listener to remove

Returns​

void

Inherited from​

MemoryRepository.removeListener


resolvePath()​

protected resolvePath(item, path): object

Defined in: models/lib/repositories/memory.d.ts:296

Resolve the parent object and last key of a dotted path, creating intermediate objects

Parameters​

item​

any

root object

path​

string

dotted path

Returns​

object

the holder and the last key

holder​

holder: any

key​

key: string

Inherited from​

MemoryRepository.resolvePath


safeOnQuery()​

protected safeOnQuery(info): void

Defined in: models/lib/repositories/abstract.d.ts:238

Safely invoke the onQuery callback without throwing into the caller

Parameters​

info​

QueryExecutionInfo

query execution info

Returns​

void

Inherited from​

MemoryRepository.safeOnQuery


scratch()​

protected scratch(storage?): MemoryRepository<T>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:126

A repository holding objects in memory, with this repository's model and table root

Parameters​

storage?​

Map<string, string> = ...

the serialized objects by key

Returns​

MemoryRepository<T>

the repository


serialize()​

serialize(item): string

Defined in: models/lib/repositories/memory.d.ts:97

Serialize the object to a string

This method is used to allow switching between different serialization methods

The serialized payload is also stamped with a top-level __type field carrying the concrete model identifier when available (item.constructor.Metadata?.Identifier). This lets query() and external storage backends filter results by class without re-instantiating every item — important when a single underlying storage map is shared across a model and its subclasses (the common case in production where each registered model owns its own MemoryRepository pointing at the same Map).

The stamp lives on the serializer envelope (sibling of value / $serializer), not inside value. deserialize() re-surfaces it on the reconstructed instance as a non-enumerable __type property so WebdaQL's filter eval can read it without it ever leaking into JSON.stringify or Object.keys output — keeping API responses and re-serialize cycles byte-identical for the model's own fields.

Models that don't carry Metadata (plain unit-test classes that don't go through Application.setModelMetadata) simply skip the stamp; the resulting payload is byte-identical to the previous implementation.

Parameters​

item​

InstanceType<T>

to serialize

Returns​

string

serialized object

Inherited from​

MemoryRepository.serialize


setAttribute()​

setAttribute<K, L>(primaryKey, attribute, value, conditionField?, condition?): Promise<void>

Defined in: models/lib/repositories/abstract.d.ts:120

Type Parameters​

K​

K extends string

L​

L extends string

Parameters​

primaryKey​

string | PK<InstanceType<T>, InstanceType<T>[typeof WEBDA_PRIMARY_KEY][number]>

attribute​

K

value​

_PropertyPathType<InstanceType<T>, K>

conditionField?​

L | null

condition?​

_PropertyPathType<InstanceType<T>, L> | JSONed<_PropertyPathType<InstanceType<T>, L>>

Returns​

Promise<void>

Inherited from​

MemoryRepository.setAttribute


setMaxListeners()​

setMaxListeners(n): this

Defined in: models/lib/repositories/abstract.d.ts:340

EventEmitter-compatibility shim. Records the max-listeners hint (no enforcement).

Parameters​

n​

number

the new hint value

Returns​

this

this for chaining

Inherited from​

MemoryRepository.setMaxListeners


setTableRoot()​

setTableRoot(root?): this

Defined in: models/lib/repositories/abstract.d.ts:53

Set the model owning the untyped rows of the storage

Parameters​

root?​

ModelClass<Storable<any, any>>

the first model of the store, undefined when not known

Returns​

this

this

Inherited from​

MemoryRepository.setTableRoot


toName()​

protected toName(key): string

Defined in: kubernetes/src/stores/kubernetesrepository.ts:138

Name of the resource of a key

Parameters​

key​

string

the primary key as a string

Returns​

string

the name

Throws​

Error when the key is not a valid resource name


toResource()​

protected toResource(item, current?): CustomResource

Defined in: kubernetes/src/stores/kubernetesrepository.ts:152

Convert an object to its custom resource

Parameters​

item​

any

the model instance

current?​

CustomResource

the resource it replaces, its metadata is kept

Returns​

CustomResource

the resource

Throws​

Error when the key or a label field value is not valid for Kubernetes


toRow()​

toRow(resource): Record<string, any>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:206

The object data held by a custom resource: spec, status fields, key and model identifier

Parameters​

resource​

CustomResource

the resource

Returns​

Record<string, any>

the plain row


typeOf()​

protected typeOf(resource): string | undefined

Defined in: kubernetes/src/stores/kubernetesrepository.ts:197

Model identifier of a resource

Parameters​

resource​

CustomResource

the resource

Returns​

string | undefined

the identifier, undefined when the resource has none


typeResolver()​

protected typeResolver(): ModelTypeResolver

Defined in: models/lib/repositories/abstract.d.ts:63

Resolver of the stored __type: the installed application one when it knows the model, else the model's own hierarchy with exact identifiers only

Returns​

ModelTypeResolver

the resolver

Inherited from​

MemoryRepository.typeResolver


update()​

update(data, conditionField?, condition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:390

Parameters​

data​

any

conditionField?​

any

condition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.update


updateMany()​

updateMany(statement, params?): Promise<number>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:551

Update the matching objects one by one: no native bulk update

Parameters​

statement​

any

params?​

QueryParameters

Returns​

Promise<number>

Overrides​

MemoryRepository.updateMany


updateManyByKey()​

protected updateManyByKey(statement, params?): Promise<number>

Defined in: models/lib/repositories/abstract.d.ts:201

Generic updateMany: collect the matching keys (up to LIMIT), then patch them one by one with this repository's patch primitive. A dotted target reads the object to rewrite its top-level field.

Used by stores without a native bulk update. On a store repository the primitive emits no event.

Parameters​

statement​

string | Query

the UPDATE statement or its parsed form

params?​

QueryParameters

values for the placeholders

Returns​

Promise<number>

the number of objects updated

Inherited from​

MemoryRepository.updateManyByKey


upsert()​

upsert(data): Promise<InstanceType<T>>

Defined in: models/lib/repositories/abstract.d.ts:118

Parameters​

data​

Helpers<InstanceType<T>>

Returns​

Promise<InstanceType<T>>

Inherited from​

MemoryRepository.upsert


upsertItemToCollection()​

upsertItemToCollection(primaryKey, collection, item, index?, itemWriteConditionField?, itemWriteCondition?): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:422

Parameters​

primaryKey​

any

collection​

any

item​

any

index?​

number

itemWriteConditionField?​

any

itemWriteCondition?​

any

Returns​

Promise<void>

Overrides​

MemoryRepository.upsertItemToCollection


write()​

protected write(current, item): Promise<void>

Defined in: kubernetes/src/stores/kubernetesrepository.ts:249

Write an object over the resource it was read from: spec, labels and annotations with the read resourceVersion, then the status

The status is written with the latest resourceVersion: a concurrent status change is overwritten.

Parameters​

current​

CustomResource

the resource read

item​

any

the new object

Returns​

Promise<void>

Throws​

ApiException 409 when the resource changed since it was read


writeIfPresent()​

protected writeIfPresent(key, write): Promise<boolean>

Defined in: models/lib/repositories/abstract.d.ts:181

Run one write of the generic fallback; an object deleted since the keys were collected is skipped

Parameters​

key​

PrimaryKeyType<InstanceType<T>>

the primary key

write​

() => Promise<void>

the write

Returns​

Promise<boolean>

true when written, false when the object is gone

Throws​

the write error when the object still exists

Inherited from​

MemoryRepository.writeIfPresent


simulateFind()​

static simulateFind<T>(query, uuids, repository): Promise<{ continuationToken?: string; results: InstanceType<T>[]; }>

Defined in: models/lib/repositories/memory.d.ts:239

Allow to simulate a find on a list of uuids It is static to be reusable by other repository like FileRepository

Type Parameters​

T​

T extends ModelClass<Storable<any, any>>

Parameters​

query​

Query

the parsed query

uuids​

any[]

the list of UIDs to search

repository​

Repository<T>

the repository to fetch objects from

Returns​

Promise<{ continuationToken?: string; results: InstanceType<T>[]; }>

the query results with optional continuation token

Inherited from​

MemoryRepository.simulateFind