@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:455
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:478
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:448
Define all schemas for this storage.
Parameters ​
schemas ​
Array of schema definitions
Returns ​
void
getConfig() ​
getConfig():
Promise<SchemaConfig>
Defined in: storage/index.ts:429
Get the schema definitions and the values they own.
Internal values written with setInternalValue are left out, read them with getValue.
Returns ​
Promise<SchemaConfig>
Schema definitions and their current values
getSchema() ​
getSchema(
key):JsonSchema|undefined
Defined in: storage/index.ts:487
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:494
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:465
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:528
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:441
Merge configuration values into the current config.
Only keys present in newConfig are updated (not a full replace); arrays are replaced, not merged. Keys without a schema are ignored. 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:507
Set an internal value without a schema and persist it.
Internal values stay out of getConfig and can only be written by the plugin itself. 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>
setInternalValueSync() ​
setInternalValueSync(
key,value):void
Defined in: storage/index.ts:521
Set an internal value and write it to disk before returning.
For callbacks that must not return before the value is safe, such as the synchronous storage hook of a library. The write blocks the event loop, so use setInternalValue everywhere else. Once the call returns, the value survives a crash of the plugin. Passing null or undefined deletes the key.
Parameters ​
key ​
string
Internal key (typically prefixed with '_')
value ​
unknown
Value to set, or null/undefined to delete the key
Returns ​
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