iobroker.influxdb 5.3.1 → 5.4.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/README.md CHANGED
@@ -300,6 +300,9 @@ SELECT mean("value") FROM "system.adapter.admin.0.memRss" WHERE $timeFilter GROU
300
300
 
301
301
  Most of these values can be pre-defined in the instance settings and are then pre-filled or used for the datapoint.
302
302
 
303
+ ## Messages for scripts and AI agents
304
+ `sendTo('influxdb.0', 'help', {})` answers `{help, commands}`: a description of all messages and of the measurement layout for AI agents (e.g. ioBroker.pi-agent) and script authors, and the list of all commands with `write: true` for the ones that change something.
305
+
303
306
  ## Access values from Javascript adapter
304
307
  The sorted values can be accessed from Javascript adapter.
305
308
 
@@ -495,7 +498,7 @@ Additionally, you can add attribute `rules: true` in a message to activate all r
495
498
  In case of errors, an array with all single error messages is returned and also a successCount to see how many entries were stored successfully.
496
499
 
497
500
  ## delete state
498
- If you want to delete entry from the Database, you can use the build in system function `delete`:
501
+ If you want to delete entry from the Database, you can use the build in system function `delete`. It deletes the values with exactly the given `ts`:
499
502
 
500
503
  ```javascript
501
504
  sendTo('influxdb.0', 'delete', [
@@ -504,6 +507,8 @@ sendTo('influxdb.0', 'delete', [
504
507
  ], result => console.log('deleted'));
505
508
  ```
506
509
 
510
+ A single entry can be sent without the list (`{id: 'mbus.0.counter.xxx', state: {ts: 1589458809352}}` or `{id: 'mbus.0.counter.xxx', ts: 1589458809352}`), several values of one data point as `{id: 'mbus.0.counter.xxx', ts: [1589458809352, 1589458809353]}`.
511
+
507
512
  To delete ALL history data for some data point execute:
508
513
 
509
514
  ```javascript
@@ -522,10 +527,16 @@ sendTo('influxdb.0', 'deleteRange', [
522
527
  ], result => console.log('deleted'));
523
528
  ```
524
529
 
525
- Time could be ms since epoch or ans string, that could be converted by javascript Date object.
530
+ A single range can be sent without the list: `{id: 'mbus.0.counter.xxx', start: 1589458809352, end: 1589458809353}`. `start` is required, `end` is optional and defaults to now.
531
+
532
+ Time could be ms since epoch or a string, that could be converted by javascript Date object. `0` is a valid time.
526
533
 
527
534
  Values will be deleted including defined limits. `ts >= start AND ts <= end`
528
535
 
536
+ Every entry needs a valid `ts` (one value) or a valid `start` (a range; `end` alone is not accepted). If one entry has neither, the adapter answers with `{success: false, error}` naming it and deletes nothing, not even the valid entries of the same message. To delete all values of a data point, use `deleteAll`.
537
+
538
+ InfluxDB 3 can only delete whole data points: there `delete` and `deleteRange` answer with an error, only `deleteAll` works.
539
+
529
540
  ## change state
530
541
  If you want to change entry's value, quality or acknowledge flag in the database, you can use the build in system function `update`:
531
542
 
@@ -721,6 +732,10 @@ sendTo('influxdb.0', 'cleanupOrphaned', {
721
732
  Placeholder for the next version (at the beginning of the line):
722
733
  ### **WORK IN PROGRESS**
723
734
  -->
735
+ ### 5.4.0 (2026-11-19)
736
+ * (GermanBluefox) Fixed: `delete` / `deleteRange` without a valid `ts` or range no longer deletes all values of the state. A single `{id, state: {start, end}}`, a state without `ts` or with `ts: 0` deleted everything (InfluxDB 1.x since 2000, 2.x since 1970, 3.x the whole table), an unparsable `start` everything up to `end`. Such a message is refused now with an error and nothing is deleted; `{id, state: {start, end}}` and `{id, start, end}` delete the range, `ts: 0` the value at 0
737
+ * (GermanBluefox) Added the message "help": a description of all messages for AI agents (e.g. pi-agent), and `common.supportedMessages.help`
738
+
724
739
  ### 5.3.1 (2026-11-17)
725
740
  * (GermanBluefox) Fixed: timed relog leaked timers and wrote the skipped value multiple times when a state was set twice in quick succession (#595)
726
741
  * (GermanBluefox) Data browser: the values of a datapoint can be exported as CSV (e.g. for Excel) or as JSON (the format of `storeState`) for the selected time range
@@ -738,9 +753,6 @@ sendTo('influxdb.0', 'cleanupOrphaned', {
738
753
  ### 5.2.0 (2026-10-24)
739
754
  * (GermanBluefox) The cleanup dialog of the statistics tab has checkboxes, so only the selected datapoints are deleted (#565)
740
755
 
741
- ### 5.1.8 (2026-10-23)
742
- * (@GermanBluefox) The timed relog (`changesRelogInterval`) starts right after the adapter start or a change of the datapoint settings, not only with the first update of the state
743
-
744
756
  [Older changelogs can be found there](CHANGELOG_OLD.md)
745
757
 
746
758
  ## License
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /**
3
+ * Parsing and validation of the time stamps of `delete`, `deleteRange` and `update`.
4
+ *
5
+ * `ts`, `start` and `end` were taken as they came, and whatever was missing, 0 or not a date fell
6
+ * through to "delete every value of the datapoint": a single `{id, state: {start, end}}` or
7
+ * `{id, state: {}}` reached `_delete` as `{ts: undefined}`, an unparsable `start` became `NaN`. That
8
+ * deleted everything since 2000 on InfluxDB 1.x, everything since 1970 on 2.x and the whole table on
9
+ * 3.x. Every entry is checked here, and `_delete` refuses an invalid range itself as well.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.toTimestamp = toTimestamp;
13
+ exports.deleteRangeProblem = deleteRangeProblem;
14
+ exports.parseDeleteRequests = parseDeleteRequests;
15
+ /** Largest distance from 1970 in ms a `Date` can hold */
16
+ const MAX_DATE_MS = 8.64e15;
17
+ function isTimestamp(value) {
18
+ return typeof value === 'number' && Number.isFinite(value) && Math.abs(value) <= MAX_DATE_MS;
19
+ }
20
+ /** A value for an error text: `NaN` and `undefined` are not readable as JSON */
21
+ function show(value) {
22
+ return typeof value === 'number' || value === undefined ? String(value) : JSON.stringify(value);
23
+ }
24
+ /**
25
+ * Time stamp in ms from a number, a numeric string, a date string or a `Date`.
26
+ *
27
+ * @param value the value of `ts`, `start` or `end` from the message
28
+ * @returns the time stamp, or `undefined` if the value is none. 0 is a valid time stamp.
29
+ */
30
+ function toTimestamp(value) {
31
+ let ts;
32
+ if (typeof value === 'number') {
33
+ ts = value;
34
+ }
35
+ else if (typeof value === 'string' && value.trim()) {
36
+ const text = value.trim();
37
+ // "1589458809352" is a number: `new Date()` would read it as a date and return NaN
38
+ ts = /^-?\d+(\.\d+)?$/.test(text) ? Number(text) : new Date(text).getTime();
39
+ }
40
+ else if (value instanceof Date) {
41
+ ts = value.getTime();
42
+ }
43
+ else {
44
+ return undefined;
45
+ }
46
+ return isTimestamp(ts) ? ts : undefined;
47
+ }
48
+ /**
49
+ * Why a range must not be deleted, or `null` if it is valid.
50
+ *
51
+ * The second line of defence in `_delete`: whatever a caller passes, a missing or invalid time stamp
52
+ * must never turn into deleting every value.
53
+ *
54
+ * @param range what the caller wants to delete
55
+ */
56
+ function deleteRangeProblem(range) {
57
+ if (!range || typeof range !== 'object') {
58
+ return 'neither "ts" nor a range given';
59
+ }
60
+ if (range.mode === 'one') {
61
+ return isTimestamp(range.ts) ? null : `invalid "ts" ${show(range.ts)}`;
62
+ }
63
+ if (range.mode === 'range') {
64
+ if (!isTimestamp(range.start)) {
65
+ return `invalid "start" ${show(range.start)}`;
66
+ }
67
+ return isTimestamp(range.end) ? null : `invalid "end" ${show(range.end)}`;
68
+ }
69
+ if (range.mode === 'all') {
70
+ return null;
71
+ }
72
+ return `unknown delete mode ${show(range.mode)}`;
73
+ }
74
+ /**
75
+ * Turn the message of `delete` or `deleteRange` into a list of requests.
76
+ *
77
+ * Both commands accept the same shapes: `{id, ts}`, `{id, start, end?}`, `{id, state: {ts}}`,
78
+ * `{id, state: {start, end?}}`, each also as a list, plus `{id, state: [...]}` and `{id, ts: [...]}`
79
+ * for several entries of one datapoint (a number in these lists is a `ts`). `ts` deletes the values
80
+ * with exactly this time stamp, `start` / `end` the values in `[start, end]`; `end` defaults to now,
81
+ * `end` without `start` is refused like in the history and sql adapters. Time stamps are ms or date
82
+ * strings, 0 is valid. An entry without ID, without `ts` or `start`, or with a value that is no time
83
+ * stamp is reported in `errors` and not returned in `requests`.
84
+ *
85
+ * @param message `msg.message` as delivered
86
+ * @param now the time stamp `end` defaults to
87
+ * @param resolveId maps an alias to the ID of the datapoint
88
+ */
89
+ function parseDeleteRequests(message, now, resolveId = id => id) {
90
+ const requests = [];
91
+ const errors = [];
92
+ const one = (id, entry) => {
93
+ if (typeof id !== 'string' || !id) {
94
+ errors.push(`No "id" given for ${show(entry)}`);
95
+ return;
96
+ }
97
+ // a plain value is a time stamp (`{id, ts: [1, 2]}`), an object carries ts or start/end
98
+ const spec = entry && typeof entry === 'object' ? entry : { ts: entry };
99
+ if (spec.ts !== undefined && spec.ts !== null) {
100
+ const ts = toTimestamp(spec.ts);
101
+ if (ts === undefined) {
102
+ errors.push(`Invalid "ts" ${show(spec.ts)} for ${id}`);
103
+ }
104
+ else {
105
+ requests.push({ id: resolveId(id), range: { mode: 'one', ts } });
106
+ }
107
+ return;
108
+ }
109
+ if (spec.start !== undefined && spec.start !== null) {
110
+ const start = toTimestamp(spec.start);
111
+ const end = spec.end === undefined || spec.end === null ? now : toTimestamp(spec.end);
112
+ if (start === undefined) {
113
+ errors.push(`Invalid "start" ${show(spec.start)} for ${id}`);
114
+ }
115
+ else if (end === undefined) {
116
+ errors.push(`Invalid "end" ${show(spec.end)} for ${id}`);
117
+ }
118
+ else {
119
+ requests.push({ id: resolveId(id), range: { mode: 'range', start, end } });
120
+ }
121
+ return;
122
+ }
123
+ if (spec.end !== undefined && spec.end !== null) {
124
+ errors.push(`"start" is missing for ${id}: a range needs "start", "end" is optional`);
125
+ return;
126
+ }
127
+ errors.push(`Neither "ts" nor "start" given for ${id}: ${show(entry)}`);
128
+ };
129
+ /** `{id, ts}` / `{id, start, end}` carry the time themselves, otherwise it is in `state` */
130
+ const timeOf = (item) => (item.ts === undefined || item.ts === null) &&
131
+ (item.start === undefined || item.start === null) &&
132
+ item.state &&
133
+ typeof item.state === 'object'
134
+ ? item.state
135
+ : item;
136
+ if (Array.isArray(message)) {
137
+ for (const item of message) {
138
+ if (!item || typeof item !== 'object') {
139
+ errors.push(`Invalid entry ${show(item)}`);
140
+ }
141
+ else {
142
+ one(item.id, timeOf(item));
143
+ }
144
+ }
145
+ }
146
+ else if (message && typeof message === 'object') {
147
+ const msg = message;
148
+ if (Array.isArray(msg.state)) {
149
+ msg.state.forEach(entry => one(msg.id, entry));
150
+ }
151
+ else if (Array.isArray(msg.ts)) {
152
+ msg.ts.forEach(ts => one(msg.id, ts));
153
+ }
154
+ else {
155
+ one(msg.id, timeOf(msg));
156
+ }
157
+ }
158
+ else {
159
+ errors.push(`Invalid call: ${show(message)}`);
160
+ }
161
+ return { requests, errors };
162
+ }
163
+ //# sourceMappingURL=deleteRequests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteRequests.js","sourceRoot":"","sources":["../../src/lib/deleteRequests.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA8BH,kCAcC;AAUD,gDAiBC;AAiBD,kDA2EC;AAvJD,yDAAyD;AACzD,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,SAAS,WAAW,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC;AACjG,CAAC;AAED,gFAAgF;AAChF,SAAS,IAAI,CAAC,KAAc;IACxB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACpG,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,KAAc;IACtC,IAAI,EAAU,CAAC;IACf,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,EAAE,GAAG,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,mFAAmF;QACnF,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,I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AAiB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ /**
3
+ * The answer of the message `help`: what the instance answers, written for an AI agent (e.g. ioBroker.pi-agent, or
4
+ * the MCP server with `send_to`) and for script authors. Keep it in sync with `processMessage` in main.ts.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.HELP = exports.COMMANDS = void 0;
8
+ /** Every command `processMessage` answers; `write` = it changes data, settings or the instance */
9
+ exports.COMMANDS = [
10
+ { command: 'help', write: false },
11
+ { command: 'getHistory', write: false },
12
+ { command: 'getEnabledDPs', write: false },
13
+ { command: 'getDatapoints', write: false },
14
+ { command: 'getRawEntries', write: false },
15
+ { command: 'getDpStatistics', write: false },
16
+ { command: 'getRetention', write: false },
17
+ { command: 'getConflictingPoints', write: false },
18
+ { command: 'features', write: false },
19
+ { command: 'flushBuffer', write: false },
20
+ { command: 'test', write: false },
21
+ { command: 'query', write: true },
22
+ { command: 'enableHistory', write: true },
23
+ { command: 'disableHistory', write: true },
24
+ { command: 'storeState', write: true },
25
+ { command: 'update', write: true },
26
+ { command: 'delete', write: true },
27
+ { command: 'deleteRange', write: true },
28
+ { command: 'deleteAll', write: true },
29
+ { command: 'cleanupOrphaned', write: true },
30
+ { command: 'resetConflictingPoints', write: true },
31
+ { command: 'destroy', write: true },
32
+ { command: 'stopInstance', write: true },
33
+ ];
34
+ exports.HELP = `ioBroker.influxdb: stores the history of the states that are enabled for it (per state in the object settings)
35
+ in InfluxDB 1.x, 2.x or 3.x (native.dbversion of system.adapter.influxdb.0). An agent can read the course of a
36
+ state (the stored values or one value per interval), list the logged states and the stored data, run a reading
37
+ query and, only on the user's request, enable or disable the logging and store, change or delete values.
38
+
39
+ Times (start, end, ts): milliseconds since 1970 or a date text such as "2026-11-19T08:00" (local time of the host).
40
+ Times in the answers are milliseconds since 1970.
41
+
42
+ Layout (for a query):
43
+ - Database (1.x, 3.x) or bucket (2.x, organization native.organization): native.dbname, default "iobroker".
44
+ - One measurement per state, named after its ID (or its setting aliasId). Field "value": float, boolean or string
45
+ (objects as JSON); the first point fixes the type (setting storageType of the state). q, ack and from are
46
+ fields; on 2.x and 3.x with native.usetags they are tags (strings). The custom tags of a state are tags.
47
+ - InfluxQL (1.x and 3.x): SELECT value FROM "hm-rpc.0.ABC.1.TEMPERATURE" WHERE time > now() - 1h; the ID in
48
+ double quotes, times as now() - 1d or '2026-11-19T08:00:00Z'.
49
+ - Flux (2.x): from(bucket: "iobroker") |> range(start: -1h) |> filter(fn: (r) => r._measurement ==
50
+ "hm-rpc.0.ABC.1.TEMPERATURE" and r._field == "value"); the value is in _value.
51
+
52
+ Commands (sendTo influxdb.0):
53
+ - getHistory {id, options: {start?, end?, aggregate?, count?, step?, ...}}: the course of one state:
54
+ {result: [{ts, val, ack?, from?, q?, id?}], step, sessionId}, on an error {result: [], error}. options is
55
+ required (may be {}).
56
+ aggregate: average (default), min, max, minmax (min and max of each interval), total, count, percentile
57
+ {percentile 0-100, default 50}, quantile {quantile 0-1, default 0.5}, integral {integralUnit in s, default 60,
58
+ 3600 gives Wh from W; integralInterpolation none (default) | linear}: one value per interval, mostly computed
59
+ by InfluxDB; none or onchange: the stored values (with their ack, q and from).
60
+ start: needed for one value per interval; without it, with none or onchange, the newest count values.
61
+ end: default now + 5000 s. count: the number of intervals (default 500); with none/onchange the number of
62
+ values (default limit on 1.x and 3.x, 500 on 2.x). step: the interval in ms instead of count.
63
+ intervalBorders: [ms, ...] ascending borders of the intervals (e.g. local days), replaces start, end and step.
64
+ limit: at most this many values or intervals (default count, else the setting limit, else 2000).
65
+ returnNewestEntries: true = the newest values instead of the oldest when count cuts. addId: true adds the id.
66
+ round: digits after the decimal point (default the setting of the instance). removeBorderValues: true drops
67
+ the values before start and after end that are added for charts. sessionId: returned as it is. ignoreNull,
68
+ ack, from and q are not read: a null is replaced by the value before.
69
+ - getEnabledDPs {}: the states this instance logs: {[id]: their settings (enabled, changesOnly, debounceTime,
70
+ blockTime, changesMinDelta, changesRelogInterval, ignoreZero, ignoreBelowNumber, ignoreAboveNumber, round,
71
+ storageType, aliasId, customTags, ...)}.
72
+ - getDatapoints {}: every measurement of the database, also the ones no longer logged: {success, result: [{id,
73
+ type: Number | String | Boolean | null}]}.
74
+ - getRawEntries {id, start?, end?, limit? (1-5000, default 100), offset? (default 0), sort? desc (default) | asc,
75
+ noTotal?}: the points exactly as stored: {id, total, limit, offset, sort, result: [{ts, val, ack, q, from}]};
76
+ noTotal: true skips the counting (total is missing then).
77
+ - getDpStatistics {start?, end?}: per measurement the number of values (a full scan, slow on a big database):
78
+ {success, result: [{id, type, count, firstTs, lastTs, cardinality (series), status}], summary: {datapoints,
79
+ values, cardinality, byStatus}}. status: active, loggingDisabled (the state exists, not logged), objectMissing.
80
+ - getRetention {}: how long the database keeps values: {result: {name, time (s, 0 = forever)}} or {error}.
81
+ - getConflictingPoints {}: the states whose values InfluxDB refused for another type; they are written directly
82
+ since: {conflictingPoints: {[id]: 1}}.
83
+ - features {}: {supportedFeatures: [update, delete, deleteRange, deleteAll, storeState, getDatapoints,
84
+ getRawEntries, getDpStatistics, cleanupOrphaned]}; 3.x without delete and deleteRange (and update with usetags).
85
+ - flushBuffer {id?}: writes the buffered values of the state (of all without id) into the database now, as
86
+ getHistory does itself: {error: null} or {error}.
87
+ - query "statement" (the message is the string itself): runs it as it is, InfluxQL on 1.x and 3.x, Flux on 2.x;
88
+ several statements separated by ";": {result: [[rows of the 1st statement], ...], ts} or {result: [], error}.
89
+ time becomes ts (ms); InfluxQL rows keep the field as "value". It runs ANY statement (also DELETE, DROP or a
90
+ Flux to()); use it only for reading.
91
+ - enableHistory {id, options?}: logs the state from now on; options = its settings as in getEnabledDPs (the
92
+ defaults of the instance otherwise): {success} or {error}.
93
+ - disableHistory {id}: stops logging the state, the stored values stay: {success} or {error}.
94
+ - storeState {id, state: {ts, val, ack?, q?, from?} or a list of them, rules?} or [{id, state, rules?}]: writes
95
+ values (through the buffer), also of a state that is not logged; ts is required, null is refused, a number as
96
+ text becomes a number; rules: true applies the logging settings (only for a logged state): {success,
97
+ successCount} or {error, errors, successCount}.
98
+ - update {id, state: {ts, val?, ack?, q?, from?}} or [{id, state}] or {id, state: [...]}: changes the stored point
99
+ with exactly this ts (not on 3.x with usetags): {success} or {success: false, error}.
100
+ - delete {id, ts} or {id, ts: [ts, ...]} or [{id, ts}]: deletes the points with exactly these ts (not on 3.x):
101
+ {success} or {success: false, error}.
102
+ - deleteRange {id, start, end?} or [{id, start, end?}] or {id, state: [{start, end?}]}: deletes the points with
103
+ start <= ts <= end (end default now; not on 3.x): {success} or {success: false, error}.
104
+ ts, start and end: ms or a date string, 0 is valid. If one entry has no valid ts or start, nothing is deleted
105
+ and error says what is missing.
106
+ - deleteAll {id} or [{id}]: deletes every value of these states (3.x: drops the measurement): {success} or
107
+ {success: false, error}.
108
+ - cleanupOrphaned {scope?: {objectMissing? (default true), loggingDisabled? (default false), ids?}, confirm?}: the
109
+ measurements of states that are not logged any more. Without confirm: true only the preview {dryRun: true,
110
+ datapoints, values, items}; with confirm: true it drops them and adds {deleted, failed}.
111
+ - resetConflictingPoints {}: empties the list of getConflictingPoints: {reset: true, conflictingPoints}.
112
+ - destroy {noRestart?}: drops the whole database (bucket), then restarts the instance (noRestart: true creates it
113
+ empty again instead): {error: null} or {error}. Every stored value is lost.
114
+ - test {config}, stopInstance: for the settings and js-controller, not for agents.
115
+
116
+ How to talk to the user:
117
+ - Find the state first (search the objects); name states by their name, give times in local time and values
118
+ with their unit.
119
+ - A state has a history only if it is or was logged (getEnabledDPs, getDatapoints). For a longer period request
120
+ one value per interval (e.g. aggregate average with start and count 24 to 200) instead of every stored value.
121
+ Prefer getHistory; write a query only for what it cannot answer, and read dbversion and dbname first.
122
+ - Send only reading statements with query (InfluxQL SELECT or SHOW, Flux without to() or another output). Any
123
+ other statement only on the user's explicit request.
124
+ - query (other than reading), delete, deleteRange, deleteAll, update, storeState, cleanupOrphaned, destroy,
125
+ resetConflictingPoints, enableHistory, disableHistory and stopInstance change the database, the settings or
126
+ the instance: never without the user's explicit request. Deleted values cannot be restored: name the state
127
+ and the range and ask for confirmation first; show the preview of cleanupOrphaned (without confirm) before
128
+ deleting; for destroy say that the whole history is lost.`;
129
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/lib/help.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kGAAkG;AACrF,QAAA,QAAQ,GAA0C;IAC3D,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;IACjC,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE;IACvC,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE;IAC1C,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE;IAC1C,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE;IAC1C,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE;IAC5C,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE;IACzC,EAAE,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,EAAE;IACjD,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;IACrC,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE;IACxC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;IACjC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;IACjC,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE;IACzC,EAAE,OAAO,EAAE,gBAAgB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