@camera.ui/sdk / storage / DeviceStorage
Interface: DeviceStorage<T>
Defined in: storage/index.ts:359
Device storage interface for plugin/camera configuration.
Provides methods to read/write configuration values and manage schemas. Each plugin and camera can have its own storage instance.
Example
this.storage.defineSchemas([
{ type: 'string', key: 'username', title: 'Username', description: 'Account username', store: true },
{ type: 'string', key: 'password', title: 'Password', description: 'Account password', format: 'password', store: true },
]);
// Get a value with default
const threshold = await storage.getValue('motionThreshold', 50);
// Set a value
await storage.setValue('motionThreshold', 75);Type Parameters
T
T extends Record<string, any> = Record<string, any>
Properties
schemas
schemas:
JsonSchema[]
Defined in: storage/index.ts:361
Current schema definitions.
values
values:
T
Defined in: storage/index.ts:363
Current configuration values.
Methods
addSchema()
addSchema(
schema):Promise<void>
Defined in: storage/index.ts:452
Add a new schema field.
Parameters
schema
Schema definition to add
Returns
Promise<void>
changeSchema()
changeSchema(
key,newSchema):Promise<void>
Defined in: storage/index.ts:475
Replace an existing schema field with a full schema.
The whole schema is replaced, individual fields are not merged. It is a no-op when no schema with that key is registered (use addSchema to add a new field). The passed key always wins.
Parameters
key
string
Schema key to replace
newSchema
Full schema definition that replaces the current one
Returns
Promise<void>
defineSchemas()
defineSchemas(
schemas):void
Defined in: storage/index.ts:445
Define all schemas for this storage.
Parameters
schemas
Array of schema definitions
Returns
void
getConfig()
getConfig():
Promise<SchemaConfig>
Defined in: storage/index.ts:427
Get the full schema configuration.
Returns
Promise<SchemaConfig>
Schema definitions and current values
getSchema()
getSchema(
key):JsonSchema|undefined
Defined in: storage/index.ts:484
Get a schema definition by key.
Parameters
key
string
Schema key
Returns
JsonSchema | undefined
Schema or undefined
getValue()
Call Signature
getValue<
U>(key):Promise<U|undefined>
Defined in: storage/index.ts:376
Get a configuration value.
If the schema declares an onGet callback, its result is returned as-is, with no fallback. Otherwise resolves in order: the stored value, then the schema default, then the provided default.
Type Parameters
U
U = string
Parameters
key
string
Configuration key
Returns
Promise<U | undefined>
Value or undefined
Call Signature
getValue<
U>(key,defaultValue):Promise<U>
Defined in: storage/index.ts:387
Get a configuration value with default.
Type Parameters
U
U = string
Parameters
key
string
Configuration key
defaultValue
U
Default if not set
Returns
Promise<U>
Value or default
hasSchema()
hasSchema(
key):boolean
Defined in: storage/index.ts:491
Check if a schema exists.
Parameters
key
string
Schema key
Returns
boolean
hasValue()
hasValue(
key):boolean
Defined in: storage/index.ts:420
Check if a configuration value exists.
Parameters
key
string
Configuration key
Returns
boolean
removeSchema()
removeSchema(
key):Promise<void>
Defined in: storage/index.ts:462
Remove a schema field.
The field's stored value is deleted along with the schema; the removal is durably persisted when the returned promise resolves.
Parameters
key
string
Schema key to remove
Returns
Promise<void>
save()
save():
Promise<void>
Defined in: storage/index.ts:510
Persist all changes to storage.
When the returned promise resolves, all values are durably persisted.
Returns
Promise<void>
setConfig()
setConfig(
newConfig):Promise<void>
Defined in: storage/index.ts:438
Merge configuration values into the current config.
Only keys present in newConfig are updated (not a full replace); arrays are replaced, not merged. Values are durably persisted before the returned promise resolves; onSet fires for each key whose value actually changed.
Parameters
newConfig
T
Configuration values to merge in
Returns
Promise<void>
setInternalValue()
setInternalValue(
key,value):Promise<void>
Defined in: storage/index.ts:503
Set a system-internal value (e.g. _displayName) without requiring a schema and persist it.
When the returned promise resolves, the value is durably persisted. Passing null or undefined deletes the key; it reads as never-set again.
Parameters
key
string
Internal key (typically prefixed with '_')
value
unknown
Value to set, or null/undefined to delete the key
Returns
Promise<void>
setValue()
setValue<
U>(key,newValue):Promise<void>
Defined in: storage/index.ts:402
Set a configuration value.
Takes effect only if a schema exists for the key. Passing null or undefined deletes the key: it reads as never-set again and the schema default applies. For a field whose schema opts into storage (store: true) the value is durably persisted before the returned promise resolves; the schema's onSet fires afterwards.
Type Parameters
U
U = string
Parameters
key
string
Configuration key
newValue
U
New value to set, or null/undefined to delete the key
Returns
Promise<void>
submitValue()
submitValue(
key,newValue):Promise<void|FormSubmitResponse>
Defined in: storage/index.ts:413
Submit a value (for submit-type schemas).
Parameters
key
string
Schema key
newValue
any
Submitted value
Returns
Promise<void | FormSubmitResponse>
Optional response with toast/schema updates