@camstack/system 1.2.30 → 1.2.32
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/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.d.ts +10 -0
- package/dist/builtins/alerts/alerts.addon.js +60 -1
- package/dist/builtins/alerts/alerts.addon.mjs +60 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +135 -92
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +135 -92
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +12 -14
- package/dist/builtins/backup-orchestrator/schedule-store.d.ts +6 -6
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/index.d.ts +2 -0
- package/dist/builtins/liveness-monitor/index.js +6 -0
- package/dist/builtins/liveness-monitor/index.mjs +2 -0
- package/dist/builtins/liveness-monitor/liveness-checks.d.ts +67 -0
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.d.ts +32 -0
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +216 -0
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +212 -0
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +3 -3
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +6 -8
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -25
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -25
- package/dist/builtins/storage-orchestrator/location-store.d.ts +17 -24
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +0 -6
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +130 -121
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +130 -121
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-Dr_P0DOB.mjs → dist-BL_FHWPP.mjs} +33 -2
- package/dist/{dist-VIwdvws5.js → dist-CSs1A90r.js} +33 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +365 -224
- package/dist/index.mjs +365 -225
- package/package.json +10 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("./dist-
|
|
3
|
+
const require_dist = require("./dist-CSs1A90r.js");
|
|
4
4
|
const require_model_download_service = require("./model-download-service-hf0ookyy.js");
|
|
5
5
|
const require_manifest_python_deps = require("./manifest-python-deps-BqE5j0-O.js");
|
|
6
6
|
const require_resource_monitor = require("./resource-monitor-DNNomR-i.js");
|
|
@@ -17,6 +17,8 @@ require("./builtins/storage-orchestrator/index.js");
|
|
|
17
17
|
const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
|
|
18
18
|
const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
|
|
19
19
|
require("./builtins/alerts/index.js");
|
|
20
|
+
const require_builtins_liveness_monitor_liveness_monitor_addon = require("./builtins/liveness-monitor/liveness-monitor.addon.js");
|
|
21
|
+
require("./builtins/liveness-monitor/index.js");
|
|
20
22
|
const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
|
|
21
23
|
require("./builtins/system-config/index.js");
|
|
22
24
|
const require_builtins_local_auth_local_auth_addon = require("./builtins/local-auth/local-auth.addon.js");
|
|
@@ -2077,18 +2079,47 @@ function serializeSetting(value) {
|
|
|
2077
2079
|
valueType: "json"
|
|
2078
2080
|
};
|
|
2079
2081
|
}
|
|
2080
|
-
|
|
2082
|
+
/**
|
|
2083
|
+
* Decode a settings row back to its value.
|
|
2084
|
+
*
|
|
2085
|
+
* `raw` is `unknown`, not `string`, on purpose: the collection surface parses
|
|
2086
|
+
* any TEXT column whose value starts with `{` or `[`, so a `json` setting
|
|
2087
|
+
* arrives here ALREADY an object. Coercing it with `String(...)` first — which
|
|
2088
|
+
* is what a straight port of the `table*` version did — produced the literal
|
|
2089
|
+
* `"[object Object]"`.
|
|
2090
|
+
*/
|
|
2091
|
+
function deserializeSetting(raw, valueType) {
|
|
2092
|
+
if (valueType === "json") {
|
|
2093
|
+
if (typeof raw !== "string") return raw;
|
|
2094
|
+
try {
|
|
2095
|
+
return JSON.parse(raw);
|
|
2096
|
+
} catch {
|
|
2097
|
+
return raw;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
const value = String(raw);
|
|
2081
2101
|
switch (valueType) {
|
|
2082
2102
|
case "number": return Number(value);
|
|
2083
2103
|
case "boolean": return value === "true";
|
|
2084
|
-
case "json": try {
|
|
2085
|
-
return JSON.parse(value);
|
|
2086
|
-
} catch {
|
|
2087
|
-
return value;
|
|
2088
|
-
}
|
|
2089
2104
|
default: return value;
|
|
2090
2105
|
}
|
|
2091
2106
|
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Read an `info` blob off a row.
|
|
2109
|
+
*
|
|
2110
|
+
* The column is declared `JSON`, so the surface hands back a parsed object —
|
|
2111
|
+
* but rows written before B2 by an older build are still raw strings on disk
|
|
2112
|
+
* for as long as they go un-rewritten, and a string that fails to parse must
|
|
2113
|
+
* not take the whole record down.
|
|
2114
|
+
*/
|
|
2115
|
+
function isPlainObject(value) {
|
|
2116
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2117
|
+
}
|
|
2118
|
+
function readInfo(raw) {
|
|
2119
|
+
if (typeof raw === "string") return require_dist.parseJsonObject(raw) ?? {};
|
|
2120
|
+
if (isPlainObject(raw)) return { ...raw };
|
|
2121
|
+
return {};
|
|
2122
|
+
}
|
|
2092
2123
|
var integrationCounter = 0;
|
|
2093
2124
|
var deviceCounter = 0;
|
|
2094
2125
|
function nextIntegrationId() {
|
|
@@ -2097,52 +2128,50 @@ function nextIntegrationId() {
|
|
|
2097
2128
|
function nextDeviceId() {
|
|
2098
2129
|
return `dev_${String(++deviceCounter).padStart(4, "0")}`;
|
|
2099
2130
|
}
|
|
2100
|
-
var
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
};
|
|
2145
|
-
var INTEGRATION_SETTINGS_SCHEMA = { columns: [
|
|
2131
|
+
var INTEGRATIONS_COLUMNS = [
|
|
2132
|
+
{
|
|
2133
|
+
name: "id",
|
|
2134
|
+
type: "TEXT",
|
|
2135
|
+
primaryKey: true
|
|
2136
|
+
},
|
|
2137
|
+
{
|
|
2138
|
+
name: "addon_id",
|
|
2139
|
+
type: "TEXT",
|
|
2140
|
+
notNull: true
|
|
2141
|
+
},
|
|
2142
|
+
{
|
|
2143
|
+
name: "name",
|
|
2144
|
+
type: "TEXT",
|
|
2145
|
+
notNull: true
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
name: "enabled",
|
|
2149
|
+
type: "INTEGER",
|
|
2150
|
+
notNull: true,
|
|
2151
|
+
defaultValue: 1
|
|
2152
|
+
},
|
|
2153
|
+
{
|
|
2154
|
+
name: "info",
|
|
2155
|
+
type: "JSON",
|
|
2156
|
+
notNull: true,
|
|
2157
|
+
defaultValue: "{}"
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
name: "created_at",
|
|
2161
|
+
type: "INTEGER",
|
|
2162
|
+
notNull: true
|
|
2163
|
+
},
|
|
2164
|
+
{
|
|
2165
|
+
name: "updated_at",
|
|
2166
|
+
type: "INTEGER",
|
|
2167
|
+
notNull: true
|
|
2168
|
+
}
|
|
2169
|
+
];
|
|
2170
|
+
var INTEGRATIONS_INDEXES = [{
|
|
2171
|
+
name: "idx_integrations_addon",
|
|
2172
|
+
columns: ["addon_id"]
|
|
2173
|
+
}];
|
|
2174
|
+
var INTEGRATION_SETTINGS_COLUMNS = [
|
|
2146
2175
|
{
|
|
2147
2176
|
name: "integration_id",
|
|
2148
2177
|
type: "TEXT",
|
|
@@ -2164,76 +2193,74 @@ var INTEGRATION_SETTINGS_SCHEMA = { columns: [
|
|
|
2164
2193
|
notNull: true,
|
|
2165
2194
|
defaultValue: "string"
|
|
2166
2195
|
}
|
|
2167
|
-
]
|
|
2168
|
-
var
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
};
|
|
2236
|
-
var DEVICE_SETTINGS_SCHEMA = { columns: [
|
|
2196
|
+
];
|
|
2197
|
+
var DEVICES_COLUMNS = [
|
|
2198
|
+
{
|
|
2199
|
+
name: "id",
|
|
2200
|
+
type: "TEXT",
|
|
2201
|
+
primaryKey: true
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
name: "integration_id",
|
|
2205
|
+
type: "TEXT",
|
|
2206
|
+
notNull: true
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
name: "stable_id",
|
|
2210
|
+
type: "TEXT",
|
|
2211
|
+
notNull: true,
|
|
2212
|
+
unique: true
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
name: "type",
|
|
2216
|
+
type: "TEXT",
|
|
2217
|
+
notNull: true,
|
|
2218
|
+
defaultValue: "camera"
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "name",
|
|
2222
|
+
type: "TEXT",
|
|
2223
|
+
notNull: true
|
|
2224
|
+
},
|
|
2225
|
+
{
|
|
2226
|
+
name: "enabled",
|
|
2227
|
+
type: "INTEGER",
|
|
2228
|
+
notNull: true,
|
|
2229
|
+
defaultValue: 1
|
|
2230
|
+
},
|
|
2231
|
+
{
|
|
2232
|
+
name: "info",
|
|
2233
|
+
type: "JSON",
|
|
2234
|
+
notNull: true,
|
|
2235
|
+
defaultValue: "{}"
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
name: "created_at",
|
|
2239
|
+
type: "INTEGER",
|
|
2240
|
+
notNull: true
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
name: "updated_at",
|
|
2244
|
+
type: "INTEGER",
|
|
2245
|
+
notNull: true
|
|
2246
|
+
}
|
|
2247
|
+
];
|
|
2248
|
+
var DEVICES_INDEXES = [
|
|
2249
|
+
{
|
|
2250
|
+
name: "idx_devices_integration",
|
|
2251
|
+
columns: ["integration_id"]
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
name: "idx_devices_stable",
|
|
2255
|
+
columns: ["stable_id"],
|
|
2256
|
+
unique: true
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
name: "idx_devices_type",
|
|
2260
|
+
columns: ["type"]
|
|
2261
|
+
}
|
|
2262
|
+
];
|
|
2263
|
+
var DEVICE_SETTINGS_COLUMNS = [
|
|
2237
2264
|
{
|
|
2238
2265
|
name: "device_id",
|
|
2239
2266
|
type: "TEXT",
|
|
@@ -2255,51 +2282,80 @@ var DEVICE_SETTINGS_SCHEMA = { columns: [
|
|
|
2255
2282
|
notNull: true,
|
|
2256
2283
|
defaultValue: "string"
|
|
2257
2284
|
}
|
|
2258
|
-
]
|
|
2285
|
+
];
|
|
2286
|
+
var INTEGRATIONS = "integrations";
|
|
2287
|
+
var INTEGRATION_SETTINGS = "integration_settings";
|
|
2288
|
+
var DEVICES = "devices";
|
|
2289
|
+
var DEVICE_SETTINGS = "device_settings_kv";
|
|
2259
2290
|
var IntegrationRegistry = class {
|
|
2260
|
-
|
|
2291
|
+
store;
|
|
2261
2292
|
constructor(backend) {
|
|
2262
|
-
this.
|
|
2293
|
+
this.store = backend;
|
|
2263
2294
|
}
|
|
2264
2295
|
async initialize() {
|
|
2265
|
-
await this.
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2296
|
+
await this.store.declareCollection({
|
|
2297
|
+
collection: INTEGRATIONS,
|
|
2298
|
+
columns: INTEGRATIONS_COLUMNS,
|
|
2299
|
+
indexes: INTEGRATIONS_INDEXES
|
|
2300
|
+
});
|
|
2301
|
+
await this.store.declareCollection({
|
|
2302
|
+
collection: INTEGRATION_SETTINGS,
|
|
2303
|
+
columns: INTEGRATION_SETTINGS_COLUMNS
|
|
2304
|
+
});
|
|
2305
|
+
await this.store.declareCollection({
|
|
2306
|
+
collection: DEVICES,
|
|
2307
|
+
columns: DEVICES_COLUMNS,
|
|
2308
|
+
indexes: DEVICES_INDEXES
|
|
2309
|
+
});
|
|
2310
|
+
await this.store.declareCollection({
|
|
2311
|
+
collection: DEVICE_SETTINGS,
|
|
2312
|
+
columns: DEVICE_SETTINGS_COLUMNS
|
|
2313
|
+
});
|
|
2314
|
+
const ints = await this.store.query({
|
|
2315
|
+
collection: INTEGRATIONS,
|
|
2316
|
+
filter: {
|
|
2317
|
+
orderBy: {
|
|
2318
|
+
field: "id",
|
|
2319
|
+
direction: "desc"
|
|
2320
|
+
},
|
|
2321
|
+
limit: 1
|
|
2322
|
+
}
|
|
2323
|
+
});
|
|
2276
2324
|
if (ints[0]) {
|
|
2277
|
-
const num = parseInt(
|
|
2325
|
+
const num = parseInt(ints[0].id.replace("int_", ""), 10);
|
|
2278
2326
|
if (!isNaN(num)) integrationCounter = num;
|
|
2279
2327
|
}
|
|
2280
|
-
const devs = await this.
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2328
|
+
const devs = await this.store.query({
|
|
2329
|
+
collection: DEVICES,
|
|
2330
|
+
filter: {
|
|
2331
|
+
orderBy: {
|
|
2332
|
+
field: "id",
|
|
2333
|
+
direction: "desc"
|
|
2334
|
+
},
|
|
2335
|
+
limit: 1
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2287
2338
|
if (devs[0]) {
|
|
2288
|
-
const num = parseInt(
|
|
2339
|
+
const num = parseInt(devs[0].id.replace("dev_", ""), 10);
|
|
2289
2340
|
if (!isNaN(num)) deviceCounter = num;
|
|
2290
2341
|
}
|
|
2291
2342
|
}
|
|
2292
2343
|
async createIntegration(input) {
|
|
2293
2344
|
const id = nextIntegrationId();
|
|
2294
2345
|
const now = Math.floor(Date.now() / 1e3);
|
|
2295
|
-
await this.
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2346
|
+
await this.store.insert({
|
|
2347
|
+
collection: INTEGRATIONS,
|
|
2348
|
+
record: {
|
|
2349
|
+
id,
|
|
2350
|
+
data: {
|
|
2351
|
+
addon_id: input.addonId,
|
|
2352
|
+
name: input.name,
|
|
2353
|
+
enabled: input.enabled !== false ? 1 : 0,
|
|
2354
|
+
info: input.info ?? {},
|
|
2355
|
+
created_at: now,
|
|
2356
|
+
updated_at: now
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2303
2359
|
});
|
|
2304
2360
|
if (input.settings) await this.setIntegrationSettings(id, input.settings);
|
|
2305
2361
|
return {
|
|
@@ -2313,52 +2369,95 @@ var IntegrationRegistry = class {
|
|
|
2313
2369
|
};
|
|
2314
2370
|
}
|
|
2315
2371
|
async getIntegration(id) {
|
|
2316
|
-
const
|
|
2317
|
-
|
|
2372
|
+
const rows = await this.store.query({
|
|
2373
|
+
collection: INTEGRATIONS,
|
|
2374
|
+
filter: {
|
|
2375
|
+
where: { id },
|
|
2376
|
+
limit: 1
|
|
2377
|
+
}
|
|
2378
|
+
});
|
|
2379
|
+
return rows[0] ? this.mapIntegration(rows[0].data) : null;
|
|
2318
2380
|
}
|
|
2319
2381
|
async getIntegrationByAddonId(addonId) {
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2382
|
+
const rows = await this.store.query({
|
|
2383
|
+
collection: INTEGRATIONS,
|
|
2384
|
+
filter: {
|
|
2385
|
+
where: { addon_id: addonId },
|
|
2386
|
+
limit: 1
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
return rows[0] ? this.mapIntegration(rows[0].data) : null;
|
|
2322
2390
|
}
|
|
2323
2391
|
async listIntegrations() {
|
|
2324
|
-
return (await this.
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2392
|
+
return (await this.store.query({
|
|
2393
|
+
collection: INTEGRATIONS,
|
|
2394
|
+
filter: { orderBy: {
|
|
2395
|
+
field: "created_at",
|
|
2396
|
+
direction: "asc"
|
|
2397
|
+
} }
|
|
2398
|
+
})).map((r) => this.mapIntegration(r.data));
|
|
2328
2399
|
}
|
|
2329
2400
|
async updateIntegration(id, updates) {
|
|
2330
2401
|
const updateRow = { updated_at: Math.floor(Date.now() / 1e3) };
|
|
2331
2402
|
if (updates.name !== void 0) updateRow["name"] = updates.name;
|
|
2332
2403
|
if (updates.enabled !== void 0) updateRow["enabled"] = updates.enabled ? 1 : 0;
|
|
2333
|
-
if (updates.info !== void 0) updateRow["info"] =
|
|
2334
|
-
await this.
|
|
2404
|
+
if (updates.info !== void 0) updateRow["info"] = updates.info;
|
|
2405
|
+
await this.store.updateWhere({
|
|
2406
|
+
collection: INTEGRATIONS,
|
|
2407
|
+
filter: { where: { id } },
|
|
2408
|
+
data: updateRow
|
|
2409
|
+
});
|
|
2335
2410
|
return this.getIntegration(id);
|
|
2336
2411
|
}
|
|
2337
2412
|
async deleteIntegration(id) {
|
|
2338
2413
|
const devices = await this.listDevices(id);
|
|
2339
|
-
for (const d of devices) await this.
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2414
|
+
for (const d of devices) await this.store.deleteWhere({
|
|
2415
|
+
collection: DEVICE_SETTINGS,
|
|
2416
|
+
filter: { where: { device_id: d.id } }
|
|
2417
|
+
});
|
|
2418
|
+
await this.store.deleteWhere({
|
|
2419
|
+
collection: DEVICES,
|
|
2420
|
+
filter: { where: { integration_id: id } }
|
|
2421
|
+
});
|
|
2422
|
+
await this.store.deleteWhere({
|
|
2423
|
+
collection: INTEGRATION_SETTINGS,
|
|
2424
|
+
filter: { where: { integration_id: id } }
|
|
2425
|
+
});
|
|
2426
|
+
await this.store.deleteWhere({
|
|
2427
|
+
collection: INTEGRATIONS,
|
|
2428
|
+
filter: { where: { id } }
|
|
2429
|
+
});
|
|
2343
2430
|
return true;
|
|
2344
2431
|
}
|
|
2345
2432
|
async getIntegrationSettings(integrationId) {
|
|
2346
2433
|
const result = {};
|
|
2347
|
-
const rows = await this.
|
|
2348
|
-
|
|
2434
|
+
const rows = await this.store.query({
|
|
2435
|
+
collection: INTEGRATION_SETTINGS,
|
|
2436
|
+
filter: { where: { integration_id: integrationId } }
|
|
2437
|
+
});
|
|
2438
|
+
for (const row of rows) result[String(row.data["key"])] = deserializeSetting(row.data["value"], String(row.data["value_type"]));
|
|
2349
2439
|
return result;
|
|
2350
2440
|
}
|
|
2351
2441
|
async setIntegrationSetting(integrationId, key, value) {
|
|
2352
2442
|
const s = serializeSetting(value);
|
|
2353
|
-
await this.
|
|
2354
|
-
|
|
2355
|
-
|
|
2443
|
+
await this.store.deleteWhere({
|
|
2444
|
+
collection: INTEGRATION_SETTINGS,
|
|
2445
|
+
filter: { where: {
|
|
2446
|
+
integration_id: integrationId,
|
|
2447
|
+
key
|
|
2448
|
+
} }
|
|
2356
2449
|
});
|
|
2357
|
-
await this.
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2450
|
+
await this.store.insert({
|
|
2451
|
+
collection: INTEGRATION_SETTINGS,
|
|
2452
|
+
record: {
|
|
2453
|
+
id: `${integrationId}:${key}`,
|
|
2454
|
+
data: {
|
|
2455
|
+
integration_id: integrationId,
|
|
2456
|
+
key,
|
|
2457
|
+
value: s.value,
|
|
2458
|
+
value_type: s.valueType
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2362
2461
|
});
|
|
2363
2462
|
}
|
|
2364
2463
|
async setIntegrationSettings(integrationId, settings) {
|
|
@@ -2367,16 +2466,21 @@ var IntegrationRegistry = class {
|
|
|
2367
2466
|
async createDevice(input) {
|
|
2368
2467
|
const id = nextDeviceId();
|
|
2369
2468
|
const now = Math.floor(Date.now() / 1e3);
|
|
2370
|
-
await this.
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2469
|
+
await this.store.insert({
|
|
2470
|
+
collection: DEVICES,
|
|
2471
|
+
record: {
|
|
2472
|
+
id,
|
|
2473
|
+
data: {
|
|
2474
|
+
integration_id: input.integrationId,
|
|
2475
|
+
stable_id: input.stableId,
|
|
2476
|
+
type: input.type,
|
|
2477
|
+
name: input.name,
|
|
2478
|
+
enabled: input.enabled !== false ? 1 : 0,
|
|
2479
|
+
info: input.info ?? {},
|
|
2480
|
+
created_at: now,
|
|
2481
|
+
updated_at: now
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2380
2484
|
});
|
|
2381
2485
|
if (input.settings) await this.setDeviceSettings(id, input.settings);
|
|
2382
2486
|
return {
|
|
@@ -2392,65 +2496,101 @@ var IntegrationRegistry = class {
|
|
|
2392
2496
|
};
|
|
2393
2497
|
}
|
|
2394
2498
|
async getDevice(id) {
|
|
2395
|
-
const
|
|
2396
|
-
|
|
2499
|
+
const rows = await this.store.query({
|
|
2500
|
+
collection: DEVICES,
|
|
2501
|
+
filter: {
|
|
2502
|
+
where: { id },
|
|
2503
|
+
limit: 1
|
|
2504
|
+
}
|
|
2505
|
+
});
|
|
2506
|
+
return rows[0] ? this.mapDevice(rows[0].data) : null;
|
|
2397
2507
|
}
|
|
2398
2508
|
async getDeviceByStableId(stableId) {
|
|
2399
|
-
const
|
|
2400
|
-
|
|
2509
|
+
const rows = await this.store.query({
|
|
2510
|
+
collection: DEVICES,
|
|
2511
|
+
filter: {
|
|
2512
|
+
where: { stable_id: stableId },
|
|
2513
|
+
limit: 1
|
|
2514
|
+
}
|
|
2515
|
+
});
|
|
2516
|
+
return rows[0] ? this.mapDevice(rows[0].data) : null;
|
|
2401
2517
|
}
|
|
2402
2518
|
async listDevices(integrationId) {
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2519
|
+
return (await this.store.query({
|
|
2520
|
+
collection: DEVICES,
|
|
2521
|
+
filter: {
|
|
2522
|
+
...integrationId ? { where: { integration_id: integrationId } } : {},
|
|
2523
|
+
orderBy: {
|
|
2524
|
+
field: "created_at",
|
|
2525
|
+
direction: "asc"
|
|
2526
|
+
}
|
|
2408
2527
|
}
|
|
2409
|
-
}
|
|
2410
|
-
field: "created_at",
|
|
2411
|
-
direction: "asc"
|
|
2412
|
-
} };
|
|
2413
|
-
return (await this.backend.tableQuery?.("devices", options) ?? []).map((r) => this.mapDevice(r));
|
|
2528
|
+
})).map((r) => this.mapDevice(r.data));
|
|
2414
2529
|
}
|
|
2415
2530
|
async listCameras() {
|
|
2416
|
-
return (await this.
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2531
|
+
return (await this.store.query({
|
|
2532
|
+
collection: DEVICES,
|
|
2533
|
+
filter: {
|
|
2534
|
+
where: { type: "camera" },
|
|
2535
|
+
orderBy: {
|
|
2536
|
+
field: "created_at",
|
|
2537
|
+
direction: "asc"
|
|
2538
|
+
}
|
|
2421
2539
|
}
|
|
2422
|
-
})
|
|
2540
|
+
})).map((r) => this.mapDevice(r.data));
|
|
2423
2541
|
}
|
|
2424
2542
|
async updateDevice(id, updates) {
|
|
2425
2543
|
const updateRow = { updated_at: Math.floor(Date.now() / 1e3) };
|
|
2426
2544
|
if (updates.name !== void 0) updateRow["name"] = updates.name;
|
|
2427
2545
|
if (updates.enabled !== void 0) updateRow["enabled"] = updates.enabled ? 1 : 0;
|
|
2428
|
-
if (updates.info !== void 0) updateRow["info"] =
|
|
2429
|
-
await this.
|
|
2546
|
+
if (updates.info !== void 0) updateRow["info"] = updates.info;
|
|
2547
|
+
await this.store.updateWhere({
|
|
2548
|
+
collection: DEVICES,
|
|
2549
|
+
filter: { where: { id } },
|
|
2550
|
+
data: updateRow
|
|
2551
|
+
});
|
|
2430
2552
|
return this.getDevice(id);
|
|
2431
2553
|
}
|
|
2432
2554
|
async deleteDevice(id) {
|
|
2433
|
-
await this.
|
|
2434
|
-
|
|
2555
|
+
await this.store.deleteWhere({
|
|
2556
|
+
collection: DEVICE_SETTINGS,
|
|
2557
|
+
filter: { where: { device_id: id } }
|
|
2558
|
+
});
|
|
2559
|
+
await this.store.deleteWhere({
|
|
2560
|
+
collection: DEVICES,
|
|
2561
|
+
filter: { where: { id } }
|
|
2562
|
+
});
|
|
2435
2563
|
return true;
|
|
2436
2564
|
}
|
|
2437
2565
|
async getDeviceSettings(deviceId) {
|
|
2438
2566
|
const result = {};
|
|
2439
|
-
const rows = await this.
|
|
2440
|
-
|
|
2567
|
+
const rows = await this.store.query({
|
|
2568
|
+
collection: DEVICE_SETTINGS,
|
|
2569
|
+
filter: { where: { device_id: deviceId } }
|
|
2570
|
+
});
|
|
2571
|
+
for (const row of rows) result[String(row.data["key"])] = deserializeSetting(row.data["value"], String(row.data["value_type"]));
|
|
2441
2572
|
return result;
|
|
2442
2573
|
}
|
|
2443
2574
|
async setDeviceSetting(deviceId, key, value) {
|
|
2444
2575
|
const s = serializeSetting(value);
|
|
2445
|
-
await this.
|
|
2446
|
-
|
|
2447
|
-
|
|
2576
|
+
await this.store.deleteWhere({
|
|
2577
|
+
collection: DEVICE_SETTINGS,
|
|
2578
|
+
filter: { where: {
|
|
2579
|
+
device_id: deviceId,
|
|
2580
|
+
key
|
|
2581
|
+
} }
|
|
2448
2582
|
});
|
|
2449
|
-
await this.
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2583
|
+
await this.store.insert({
|
|
2584
|
+
collection: DEVICE_SETTINGS,
|
|
2585
|
+
record: {
|
|
2586
|
+
id: `${deviceId}:${key}`,
|
|
2587
|
+
data: {
|
|
2588
|
+
device_id: deviceId,
|
|
2589
|
+
key,
|
|
2590
|
+
value: s.value,
|
|
2591
|
+
value_type: s.valueType
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2454
2594
|
});
|
|
2455
2595
|
}
|
|
2456
2596
|
async setDeviceSettings(deviceId, settings) {
|
|
@@ -2462,7 +2602,7 @@ var IntegrationRegistry = class {
|
|
|
2462
2602
|
addonId: String(row["addon_id"]),
|
|
2463
2603
|
name: String(row["name"]),
|
|
2464
2604
|
enabled: row["enabled"] === 1,
|
|
2465
|
-
info:
|
|
2605
|
+
info: readInfo(row["info"]),
|
|
2466
2606
|
createdAt: Number(row["created_at"]),
|
|
2467
2607
|
updatedAt: Number(row["updated_at"])
|
|
2468
2608
|
};
|
|
@@ -2475,7 +2615,7 @@ var IntegrationRegistry = class {
|
|
|
2475
2615
|
type: String(row["type"]),
|
|
2476
2616
|
name: String(row["name"]),
|
|
2477
2617
|
enabled: row["enabled"] === 1,
|
|
2478
|
-
info:
|
|
2618
|
+
info: readInfo(row["info"]),
|
|
2479
2619
|
createdAt: Number(row["created_at"]),
|
|
2480
2620
|
updatedAt: Number(row["updated_at"])
|
|
2481
2621
|
};
|
|
@@ -94276,6 +94416,7 @@ exports.IntegrationRegistry = IntegrationRegistry;
|
|
|
94276
94416
|
exports.JobJournal = JobJournal;
|
|
94277
94417
|
exports.LifecycleJobEngine = LifecycleJobEngine;
|
|
94278
94418
|
exports.LifecycleStateMachine = LifecycleStateMachine;
|
|
94419
|
+
exports.LivenessMonitorAddon = require_builtins_liveness_monitor_liveness_monitor_addon.LivenessMonitorAddon;
|
|
94279
94420
|
exports.LocalAuthAddon = require_builtins_local_auth_local_auth_addon.LocalAuthAddon;
|
|
94280
94421
|
exports.LocalChildClient = require_manifest_python_deps.LocalChildClient;
|
|
94281
94422
|
exports.LocalChildRegistry = require_manifest_python_deps.LocalChildRegistry;
|