@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:438
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:454
Update an existing schema field.
Parameters
key
string
Schema key to update
newSchema
Partial<JsonSchema>
Partial schema with updated fields
Returns
Promise<void>
defineSchemas()
defineSchemas(
schemas):void
Defined in: storage/index.ts:431
Define all schemas for this storage.
Parameters
schemas
Array of schema definitions
Returns
void
getConfig()
getConfig():
Promise<SchemaConfig>
Defined in: storage/index.ts:417
Get the full schema configuration.
Returns
Promise<SchemaConfig>
Schema definitions and current values
getSchema()
getSchema(
key):JsonSchema|undefined
Defined in: storage/index.ts:463
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:372
Get a configuration value.
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:383
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:470
Check if a schema exists.
Parameters
key
string
Schema key
Returns
boolean
hasValue()
hasValue(
key):boolean
Defined in: storage/index.ts:410
Check if a configuration value exists.
Parameters
key
string
Configuration key
Returns
boolean
removeSchema()
removeSchema(
key):Promise<void>
Defined in: storage/index.ts:445
Remove a schema field.
Parameters
key
string
Schema key to remove
Returns
Promise<void>
save()
save():
Promise<void>
Defined in: storage/index.ts:484
Persist all changes to storage.
Returns
Promise<void>
setConfig()
setConfig(
newConfig):Promise<void>
Defined in: storage/index.ts:424
Set the full configuration.
Parameters
newConfig
T
New configuration values
Returns
Promise<void>
setInternalValue()
setInternalValue(
key,value):Promise<void>
Defined in: storage/index.ts:479
Set a system-internal value (e.g. _displayName) without requiring a schema and persist it.
Parameters
key
string
Internal key (typically prefixed with '_')
value
unknown
Value to set
Returns
Promise<void>
setValue()
setValue<
U>(key,newValue):Promise<void>
Defined in: storage/index.ts:392
Set a configuration value.
Type Parameters
U
U = string
Parameters
key
string
Configuration key
newValue
U
New value to set
Returns
Promise<void>
submitValue()
submitValue(
key,newValue):Promise<void|FormSubmitResponse>
Defined in: storage/index.ts:403
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