@iobroker/db-objects-file 7.2.3-alpha.9-20260711-3ea5f3c89 → 7.2.3

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.
Files changed (25) hide show
  1. package/build/cjs/index.js +3 -5
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/lib/objects/objectsInMemFileDB.d.ts +59 -288
  4. package/build/cjs/lib/objects/objectsInMemFileDB.js +109 -225
  5. package/build/cjs/lib/objects/objectsInMemFileDB.js.map +3 -3
  6. package/build/cjs/lib/objects/objectsInMemServerClass.d.ts +8 -41
  7. package/build/cjs/lib/objects/objectsInMemServerClass.js +2 -27
  8. package/build/cjs/lib/objects/objectsInMemServerClass.js.map +3 -3
  9. package/build/cjs/lib/objects/objectsInMemServerRedis.d.ts +30 -50
  10. package/build/cjs/lib/objects/objectsInMemServerRedis.js +37 -72
  11. package/build/cjs/lib/objects/objectsInMemServerRedis.js.map +4 -4
  12. package/build/esm/lib/objects/objectsInMemFileDB.d.ts +59 -288
  13. package/build/esm/lib/objects/objectsInMemFileDB.d.ts.map +1 -1
  14. package/build/esm/lib/objects/objectsInMemFileDB.js +126 -228
  15. package/build/esm/lib/objects/objectsInMemFileDB.js.map +1 -1
  16. package/build/esm/lib/objects/objectsInMemServerClass.d.ts +8 -41
  17. package/build/esm/lib/objects/objectsInMemServerClass.d.ts.map +1 -1
  18. package/build/esm/lib/objects/objectsInMemServerClass.js +1 -25
  19. package/build/esm/lib/objects/objectsInMemServerClass.js.map +1 -1
  20. package/build/esm/lib/objects/objectsInMemServerRedis.d.ts +30 -50
  21. package/build/esm/lib/objects/objectsInMemServerRedis.d.ts.map +1 -1
  22. package/build/esm/lib/objects/objectsInMemServerRedis.js +70 -89
  23. package/build/esm/lib/objects/objectsInMemServerRedis.js.map +1 -1
  24. package/build/tsconfig.build.tsbuildinfo +1 -1
  25. package/package.json +7 -7
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,21 +16,20 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var index_exports = {};
21
- __export(index_exports, {
19
+ var esm_exports = {};
20
+ __export(esm_exports, {
22
21
  Client: () => import_db_objects_redis.Client,
23
22
  ObjectsInMemoryFileDB: () => import_objectsInMemFileDB.ObjectsInMemoryFileDB,
24
23
  Server: () => import_objectsInMemServerClass.ObjectsInMemoryServerClass,
25
24
  getDefaultPort: () => getDefaultPort
26
25
  });
27
- module.exports = __toCommonJS(index_exports);
26
+ module.exports = __toCommonJS(esm_exports);
28
27
  var import_objectsInMemFileDB = require("./lib/objects/objectsInMemFileDB.js");
29
28
  var import_db_objects_redis = require("@iobroker/db-objects-redis");
30
29
  var import_objectsInMemServerClass = require("./lib/objects/objectsInMemServerClass.js");
31
30
  function getDefaultPort() {
32
31
  return 9001;
33
32
  }
34
- __name(getDefaultPort, "getDefaultPort");
35
33
  // Annotate the CommonJS export names for ESM import in node:
36
34
  0 && (module.exports = {
37
35
  Client,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export { ObjectsInMemoryFileDB } from './lib/objects/objectsInMemFileDB.js';\nexport { Client } from '@iobroker/db-objects-redis';\nexport { ObjectsInMemoryServerClass as Server } from './lib/objects/objectsInMemServerClass.js';\n\n/**\n * Get the default port of the objects db\n */\nexport function getDefaultPort(): number {\n return 9001;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAAA,gCAAsC;AACtC,8BAAuB;AACvB,qCAAqD;AAK/C,SAAU,iBAAc;AAC1B,SAAO;AACX;AAFgB;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAAA,gCAAsC;AACtC,8BAAuB;AACvB,qCAAqD;AAK/C,SAAU,iBAAc;AAC1B,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,137 +1,32 @@
1
- /**
2
- * Object DB in memory - Server
3
- *
4
- * Copyright 2013-2026 bluefox <dogafox@gmail.com>
5
- *
6
- * MIT License
7
- *
8
- */
9
- import fs from 'fs-extra';
10
- import { InMemoryFileDB, type FileDbSettings, type MetaObject } from '@iobroker/db-base';
11
- /** Options accepted by the file access methods (or, for writes, a mime type string) */
12
- interface FileAccessOptions {
13
- /** Access control list / permission context (cleared internally before use) */
14
- acl?: {
15
- owner: ioBroker.ObjectIDs.User;
16
- ownerGroup: ioBroker.ObjectIDs.Group;
17
- file: {
18
- read?: boolean;
19
- write?: boolean;
20
- permissions?: number;
21
- };
22
- } | null;
23
- /** User that owns a newly created file, or the user whose access is being checked */
24
- user?: ioBroker.ObjectIDs.User;
25
- /** Group that owns a newly created file */
26
- group?: ioBroker.ObjectIDs.Group;
27
- /** Groups the requesting user belongs to (used for permission checks) */
28
- groups?: ioBroker.ObjectIDs.Group[];
29
- /** File permission bitmask for a newly created file */
30
- mode?: number;
31
- /** Explicit mime type to store with the file */
32
- mimeType?: string;
33
- /** Bypass the in-memory file cache and read from disk */
34
- noFileCache?: boolean;
35
- /** Whether directory listings should be filtered by the user's permissions */
36
- filter?: boolean;
37
- }
38
- interface Subscription {
39
- pattern: string;
40
- regex: RegExp;
41
- }
42
- interface SubscriptionClient {
43
- _subscribe?: Record<string, Subscription[]>;
44
- }
45
- /** Metadata stored alongside a file */
46
- export interface FileOptions {
47
- /** Timestamp (ms) when the file was created */
48
- createdAt?: number;
49
- /** Access control list of the file */
50
- acl: ioBroker.FileACL;
51
- /** The mime type of the file */
52
- mimeType: string;
53
- /** Whether the file content is binary */
54
- binary?: boolean;
55
- /** Timestamp (ms) when the file was last modified */
56
- modifiedAt?: number;
57
- /** File system stats of the file */
58
- stats?: fs.Stats;
59
- }
60
1
  /**
61
2
  * This class inherits InMemoryFileDB class and adds all relevant logic for objects
62
3
  * including the available methods for use by js-controller directly
63
4
  */
64
- export declare class ObjectsInMemoryFileDB<THandler extends SubscriptionClient> extends InMemoryFileDB<ioBroker.AnyObject | ioBroker.DesignObject, THandler> {
65
- private readonly META_ID;
66
- protected readonly fileOptions: {
67
- [id: string]: {
68
- [fileName: string]: FileOptions;
69
- };
70
- };
71
- private readonly files;
72
- private writeTimer;
73
- private writeIds;
74
- protected readonly defaultNewAcl: {
75
- object: number;
76
- state: number;
77
- file: number;
78
- owner: ioBroker.ObjectIDs.User;
79
- ownerGroup: ioBroker.ObjectIDs.Group;
80
- } | null;
81
- private readonly writeFileInterval;
82
- protected readonly objectsDir: string;
83
- private existingMetaObjects;
84
- /**
85
- * @param settings Settings for the objects database
86
- */
87
- constructor(settings: FileDbSettings<ioBroker.AnyObject | ioBroker.DesignObject>);
88
- /**
89
- * Normalize a file name by collapsing slashes and backslashes into a single forward slash
90
- *
91
- * @param name The file name to normalize
92
- */
93
- _normalizeFilename(name: string): string;
94
- /**
95
- * Schedule writing the file settings (_data.json) to disk
96
- *
97
- * @param id The object ID whose file settings should be saved, or a boolean used as the force flag
98
- * @param force If true, write the settings immediately instead of debounced
99
- */
100
- _saveFileSettings(id?: string | boolean, force?: boolean): void;
101
- /**
102
- * Load the file settings (_data.json) for the given object ID into memory
103
- *
104
- * @param id The object ID whose file settings should be loaded
105
- */
106
- _loadFileSettings(id: string): void;
107
- /**
108
- * Synchronize the in-memory file metadata with the files actually present on disk (server only)
109
- *
110
- * @param limitId Optional object ID to limit the synchronization to
111
- */
112
- syncFileDirectory(limitId?: string): {
5
+ export class ObjectsInMemoryFileDB extends InMemoryFileDB {
6
+ constructor(settings: any);
7
+ change: any;
8
+ META_ID: string;
9
+ fileOptions: {};
10
+ files: {};
11
+ writeTimer: NodeJS.Timeout | null;
12
+ writeIds: any[];
13
+ preserveSettings: string[];
14
+ defaultNewAcl: any;
15
+ namespace: any;
16
+ writeFileInterval: number;
17
+ objectsDir: string;
18
+ existingMetaObjects: {};
19
+ _normalizeFilename(name: any): any;
20
+ _saveFileSettings(id: any, force: any): void;
21
+ _loadFileSettings(id: any): void;
22
+ syncFileDirectory(limitId: any): {
113
23
  numberSuccess: number;
114
- notifications: string[];
24
+ notifications: any[];
115
25
  };
116
- /**
117
- * Write a file into an object's file storage (used by the server)
118
- *
119
- * @param id The object ID owning the file
120
- * @param name The file name
121
- * @param data The file content
122
- * @param options Optional write options, or the mime type as a string
123
- */
124
- _writeFile(id: string, name: string, data: Buffer | string, options?: FileAccessOptions | string): void;
125
- /**
126
- * Read a file from an object's file storage (used by the server)
127
- *
128
- * @param id The object ID owning the file
129
- * @param name The file name
130
- * @param options Optional read options
131
- */
132
- _readFile(id: string, name: string, options?: FileAccessOptions): {
133
- fileContent: Buffer | string;
134
- fileMime: string;
26
+ _writeFile(id: any, name: any, data: any, options: any): void;
27
+ _readFile(id: any, name: any, options: any): {
28
+ fileContent: any;
29
+ fileMime: any;
135
30
  };
136
31
  /**
137
32
  * Check if given object exists
@@ -139,195 +34,71 @@ export declare class ObjectsInMemoryFileDB<THandler extends SubscriptionClient>
139
34
  * @param id id of the object
140
35
  * @returns if the object exists
141
36
  */
142
- _objectExists(id: string): boolean;
37
+ _objectExists(id: any): boolean;
143
38
  /**
144
39
  * Check if given file exists
145
40
  *
146
41
  * @param id id of the namespace
147
42
  * @param [name] name of the file
148
- * @returns true if the file exists
43
+ * @returns
149
44
  */
150
- _fileExists(id: string, name?: string): boolean;
45
+ _fileExists(id: any, name?: any): boolean;
151
46
  /**
152
47
  * Check if given directory exists
153
48
  *
154
49
  * @param id id of the namespace
155
50
  * @param [name] name of the directory
156
- * @returns true if the directory exists
51
+ * @returns
157
52
  */
158
- dirExists(id: string, name?: string): boolean;
159
- /**
160
- * Delete a file or directory from an object's file storage (used by the server)
161
- *
162
- * @param id The object ID owning the file
163
- * @param name The file or directory name to delete
164
- */
165
- _unlink(id: string, name: string): void;
166
- /**
167
- * List the contents of a directory in an object's file storage (used by the server)
168
- *
169
- * @param id The object ID owning the files
170
- * @param name The directory name to list
171
- * @param options Optional read options
172
- */
173
- _readDir(id: string, name: string, options?: FileAccessOptions): {
53
+ dirExists(id: any, name?: any): boolean;
54
+ _unlink(id: any, name: any): void;
55
+ _readDir(id: any, name: any, options: any): {
174
56
  file: string;
175
- stats: {
176
- size?: number;
177
- };
57
+ stats: fs.Stats;
178
58
  isDir: boolean;
179
- acl: ioBroker.EvaluatedFileACL;
180
- notExists?: boolean;
181
- virtualFile?: boolean;
182
- modifiedAt: number | undefined;
183
- createdAt: undefined | number;
59
+ acl: any;
60
+ modifiedAt: any;
61
+ createdAt: any;
184
62
  }[];
185
- /**
186
- * Rename a file or directory in an object's file storage (used by the server)
187
- *
188
- * @param id The object ID owning the file
189
- * @param oldName The current file or directory name
190
- * @param newName The new file or directory name
191
- */
192
- _rename(id: string, oldName: string, newName: string): void;
193
- /**
194
- * Create a deep clone of the given object
195
- *
196
- * @param obj The object to clone
197
- */
198
- _clone<T>(obj: T): T;
199
- /**
200
- * Subscribe a client to meta changes
201
- *
202
- * @param client The client to subscribe
203
- * @param pattern The pattern of meta IDs to subscribe to
204
- */
205
- _subscribeMeta(client: THandler, pattern: string): void;
206
- /**
207
- * Subscribe a client to object changes (used by the server)
208
- *
209
- * @param client The client to subscribe
210
- * @param pattern The pattern of object IDs to subscribe to
211
- */
212
- _subscribeConfigForClient(client: THandler, pattern: string): void;
213
- /**
214
- * Unsubscribe a client from object changes (used by the server)
215
- *
216
- * @param client The client to unsubscribe
217
- * @param pattern The pattern of object IDs to unsubscribe from
218
- */
219
- _unsubscribeConfigForClient(client: THandler, pattern: string): void;
220
- /**
221
- * Subscribe a client to file changes of an object (used by the server)
222
- *
223
- * @param client The client to subscribe
224
- * @param id The object ID owning the files
225
- * @param pattern One or more file name patterns to subscribe to
226
- */
227
- _subscribeFileForClient(client: THandler, id: string, pattern: string | string[]): void;
228
- /**
229
- * Unsubscribe a client from file changes of an object (used by the server)
230
- *
231
- * @param client The client to unsubscribe
232
- * @param id The object ID owning the files
233
- * @param pattern One or more file name patterns to unsubscribe from
234
- */
235
- _unsubscribeFileForClient(client: THandler, id: string, pattern: string | string[]): void;
236
- /**
237
- * Get a single object by its ID (used by the server)
238
- *
239
- * @param id The object ID to read
240
- */
241
- _getObject(id: string): ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | undefined;
242
- /**
243
- * Get all object IDs matching the given pattern, sorted (used by the server)
244
- *
245
- * @param pattern The pattern to match object IDs against
246
- */
247
- _getKeys(pattern: string): string[];
248
- /**
249
- * Get the values of the given object IDs (used by the server)
250
- *
251
- * @param keys The object IDs to read
252
- */
253
- _getObjects(keys: (string | null)[]): (ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | undefined)[];
254
- /**
255
- * Get the meta dictionary, creating it if it does not exist yet
256
- */
257
- _ensureMetaDict(): MetaObject;
63
+ _rename(id: any, oldName: any, newName: any): void;
64
+ _clone(obj: any): any;
65
+ _subscribeMeta(client: any, pattern: any): void;
66
+ _subscribeConfigForClient(client: any, pattern: any): void;
67
+ _unsubscribeConfigForClient(client: any, pattern: any): void;
68
+ _subscribeFileForClient(client: any, id: any, pattern: any): void;
69
+ _unsubscribeFileForClient(client: any, id: any, pattern: any): void;
70
+ _getObject(id: any): any;
71
+ _getKeys(pattern: any): string[];
72
+ _getObjects(keys: any): any;
73
+ _ensureMetaDict(): any;
258
74
  /**
259
75
  * Get value of given meta id
260
76
  *
261
- * @param id The meta ID to read
262
- * @returns the stored meta value
77
+ * @param id
78
+ * @returns
263
79
  */
264
- getMeta(id: string): string;
80
+ getMeta(id: any): any;
265
81
  /**
266
82
  * Sets given value to id in metaNamespace
267
83
  *
268
- * @param id The meta ID to write
269
- * @param value The value to store
270
- */
271
- setMeta(id: string, value: string): void;
272
- /**
273
- * Directly set an object value and publish the change (used by the server)
274
- *
275
- * @param id The object ID to set
276
- * @param obj The object to store
84
+ * @param id
85
+ * @param value
277
86
  */
278
- _setObjectDirect(id: string, obj: ioBroker.AnyObject | ioBroker.DesignObject | MetaObject): void;
87
+ setMeta(id: any, value: any): void;
88
+ _setObjectDirect(id: any, obj: any): void;
279
89
  /**
280
90
  * Delete the given object from the dataset
281
91
  *
282
92
  * @param id unique id of the object
283
93
  */
284
- _delObject(id: string): void;
285
- /**
286
- * Apply a view's map function over all objects and collect the matching rows
287
- *
288
- * @param func The view definition containing the map function
289
- * @param func.map The map function source code to apply
290
- * @param func.reduce Optional reduce function (only the built-in '_stats' is supported)
291
- * @param params Query parameters such as startkey and endkey
292
- */
293
- _applyView(func: {
294
- map: string;
295
- reduce?: '_stats';
296
- }, params?: {
297
- startkey?: string;
298
- endkey?: string;
299
- include_docs?: boolean;
300
- } | null): {
301
- rows: {
302
- id: string;
303
- value: ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | {
304
- max: ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | null;
305
- };
306
- }[];
94
+ _delObject(id: any): void;
95
+ _applyView(func: any, params: any): {
96
+ rows: never[];
307
97
  };
308
- /**
309
- * Run a predefined object view (design document) and return the matching rows (used by the server)
310
- *
311
- * @param design The design document name
312
- * @param search The view name within the design document
313
- * @param params Query parameters such as startkey and endkey
314
- */
315
- _getObjectView(design: string, search: string, params?: {
316
- startkey?: string;
317
- endkey?: string;
318
- include_docs?: boolean;
319
- } | null): {
320
- rows: {
321
- id: string;
322
- value: ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | {
323
- max: ioBroker.AnyObject | ioBroker.DesignObject | MetaObject | null;
324
- };
325
- }[];
98
+ _getObjectView(design: any, search: any, params: any): {
99
+ rows: never[];
326
100
  };
327
- /**
328
- * Destructor of the class. Called by shutting down.
329
- */
330
- destroy(): Promise<void>;
331
101
  }
332
- export {};
102
+ import { InMemoryFileDB } from '@iobroker/db-base';
103
+ import fs from 'fs-extra';
333
104
  //# sourceMappingURL=objectsInMemFileDB.d.ts.map