@iobroker/db-objects-redis 8.0.0-alpha.9-20261029-b65f8b5d8 → 8.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/objects/objectsInRedisClient.d.ts +37 -3
- package/build/cjs/lib/objects/objectsInRedisClient.js +313 -112
- package/build/cjs/lib/objects/objectsInRedisClient.js.map +3 -3
- package/build/cjs/lib/objects/objectsUtils.d.ts +2 -2
- package/build/cjs/lib/objects/objectsUtils.js +26 -17
- package/build/cjs/lib/objects/objectsUtils.js.map +3 -3
- package/build/esm/lib/objects/objectsInRedisClient.d.ts +37 -3
- package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInRedisClient.js +338 -120
- package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
- package/build/esm/lib/objects/objectsUtils.d.ts +2 -2
- package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsUtils.js +31 -11
- package/build/esm/lib/objects/objectsUtils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ACLObject, type FileObject, type UserContext } from '
|
|
2
|
-
import * as CONSTS from '
|
|
1
|
+
import { type ACLObject, type FileObject, type UserContext } from './objectsUtils.js';
|
|
2
|
+
import * as CONSTS from './constants.js';
|
|
3
3
|
import type { InternalLogger } from '@iobroker/js-controller-common-db/tools';
|
|
4
4
|
import type { ConnectionOptions, DbStatus } from '@iobroker/db-base/inMemFileDB';
|
|
5
5
|
type ChangeFunction = (id: string, object: ioBroker.Object | null) => void;
|
|
@@ -17,6 +17,13 @@ export interface ObjectsSettings {
|
|
|
17
17
|
primaryHostLost?: () => void;
|
|
18
18
|
/** Called when the client gets disconnected */
|
|
19
19
|
disconnected?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Adapters only: from a lost connection until this resolves true, commands and subscription replays are held.
|
|
22
|
+
* If it resolves false, nothing held is sent.
|
|
23
|
+
*/
|
|
24
|
+
fence?: () => Promise<boolean>;
|
|
25
|
+
/** Called after the system subscriptions were restored on a reconnect, events of the gap may be lost */
|
|
26
|
+
resubscribed?: () => void;
|
|
20
27
|
/** Handler for system-level object changes */
|
|
21
28
|
change?: ChangeFunction;
|
|
22
29
|
/** Handler for user-level object changes */
|
|
@@ -44,6 +51,7 @@ export interface ObjectsSettings {
|
|
|
44
51
|
* Client for the objects database backed by Redis (or the in-memory redis-protocol server)
|
|
45
52
|
*/
|
|
46
53
|
export declare class ObjectsInRedisClient {
|
|
54
|
+
#private;
|
|
47
55
|
private client;
|
|
48
56
|
private readonly fileNamespace;
|
|
49
57
|
private readonly redisNamespace;
|
|
@@ -81,6 +89,23 @@ export declare class ObjectsInRedisClient {
|
|
|
81
89
|
* Connect to the objects database and set up the change and file subscriptions
|
|
82
90
|
*/
|
|
83
91
|
connectDb(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Enable the fence after the connect, if the client was created without one
|
|
94
|
+
*
|
|
95
|
+
* @param fence resolves true if the held commands may be sent
|
|
96
|
+
*/
|
|
97
|
+
enableFence(fence: () => Promise<boolean>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Read an object without waiting for the fence, for the fence itself
|
|
100
|
+
*
|
|
101
|
+
* @param id id of the object
|
|
102
|
+
*/
|
|
103
|
+
getObjectForFence(id: string): Promise<ioBroker.AnyObject | null>;
|
|
104
|
+
/**
|
|
105
|
+
* Pub/sub sockets only receive, so after a server restart they can stay `ready` on a dead connection.
|
|
106
|
+
* Reconnecting them makes their own `ready` handlers replay the subscriptions.
|
|
107
|
+
*/
|
|
108
|
+
private reconnectSubscribers;
|
|
84
109
|
/**
|
|
85
110
|
* Get the current status of the database
|
|
86
111
|
*/
|
|
@@ -134,6 +159,14 @@ export declare class ObjectsInRedisClient {
|
|
|
134
159
|
* @param flag The access flag(s) to check for
|
|
135
160
|
*/
|
|
136
161
|
checkFileAsync(id: string, name: string | null, userContext: UserContext, flag: CONSTS.GenericAccessFlags): Promise<FileObject | null>;
|
|
162
|
+
/**
|
|
163
|
+
* Get the file rights (`acl.file`) of the meta object that owns the files, e.g. `vis-2.0`.
|
|
164
|
+
* They apply to its directories, which have no entry of their own.
|
|
165
|
+
*
|
|
166
|
+
* @param id The id of the meta object owning the files
|
|
167
|
+
* @returns The file rights of the meta object or null if it has none
|
|
168
|
+
*/
|
|
169
|
+
private _getMetaFileAcl;
|
|
137
170
|
/**
|
|
138
171
|
* Check whether the current user is allowed to access a file
|
|
139
172
|
*
|
|
@@ -1035,8 +1068,9 @@ export declare class ObjectsInRedisClient {
|
|
|
1035
1068
|
* @param id The id of the object to extend
|
|
1036
1069
|
* @param obj The partial object to merge into the existing object
|
|
1037
1070
|
* @param options The current request options including the user, or the callback
|
|
1071
|
+
* @param skipUnchanged Do not write the object and do not publish an objectChange, if the merge changes nothing but `ts`, `from` and `user`. The stored object is returned then.
|
|
1038
1072
|
*/
|
|
1039
|
-
extendObject<T extends string>(id: T, obj: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: ioBroker.ExtendObjectOptions | null): Promise<{
|
|
1073
|
+
extendObject<T extends string>(id: T, obj: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: ioBroker.ExtendObjectOptions | null, skipUnchanged?: boolean): Promise<{
|
|
1040
1074
|
id: string;
|
|
1041
1075
|
value: ioBroker.AnyObject;
|
|
1042
1076
|
}>;
|