@camstack/types 1.2.435 → 1.2.436
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/CHANGELOG.md +9 -0
- package/dist/capabilities/addons.cap.d.ts +8 -0
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/notification-output.cap.d.ts +70 -0
- package/dist/client.js +49 -1
- package/dist/client.mjs +49 -1
- package/dist/composition/helpers/index.d.ts +1 -1
- package/dist/composition/helpers/source-pick.d.ts +7 -0
- package/dist/{composition-CZImLpOI.mjs → composition-DwA0uVW5.mjs} +1 -0
- package/dist/{composition-BZf_gqG7.js → composition-WNkEpwkF.js} +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +150 -10
- package/dist/index.mjs +147 -11
- package/dist/interfaces/addon.d.ts +8 -0
- package/dist/node.js +1 -1
- package/dist/node.mjs +1 -1
- package/dist/notification/delivery-params.d.ts +15 -0
- package/dist/vendor-login-proxy/index.d.ts +1 -1
- package/dist/vendor-login-proxy/url-rewrite.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sleep = require("./sleep-DHitF_e4.js");
|
|
3
3
|
const require_event_category = require("./event-category-E17zaHjN.js");
|
|
4
|
-
const require_composition = require("./composition-
|
|
4
|
+
const require_composition = require("./composition-WNkEpwkF.js");
|
|
5
5
|
const require_node_color = require("./node-color.js");
|
|
6
6
|
const require_err_msg = require("./err-msg-U7lLUMNz.js");
|
|
7
7
|
const require_enums = require("./enums.js");
|
|
@@ -15574,12 +15574,13 @@ var CHANGED = {
|
|
|
15574
15574
|
expr: "now"
|
|
15575
15575
|
};
|
|
15576
15576
|
function numeric(input) {
|
|
15577
|
+
const { alsoFrom, ...base } = input;
|
|
15577
15578
|
return {
|
|
15578
|
-
...
|
|
15579
|
+
...base,
|
|
15579
15580
|
family: "numeric",
|
|
15580
15581
|
deviceType: require_err_msg.DeviceType.Sensor,
|
|
15581
15582
|
memberDeviceType: require_err_msg.DeviceType.Sensor,
|
|
15582
|
-
memberDeviceTypes: [require_err_msg.DeviceType.Sensor],
|
|
15583
|
+
memberDeviceTypes: [require_err_msg.DeviceType.Sensor, ...alsoFrom?.deviceTypes ?? []],
|
|
15583
15584
|
activeWhen: void 0,
|
|
15584
15585
|
commandCaps: [],
|
|
15585
15586
|
baseUnit: require_sleep.baseUnitOf(input.quantity),
|
|
@@ -15587,9 +15588,10 @@ function numeric(input) {
|
|
|
15587
15588
|
accept: [{
|
|
15588
15589
|
cap: input.outputCap,
|
|
15589
15590
|
fieldPath: input.outputField
|
|
15590
|
-
}]
|
|
15591
|
+
}, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
|
|
15591
15592
|
};
|
|
15592
15593
|
}
|
|
15594
|
+
var CLIMATE_DEVICES = [require_err_msg.DeviceType.Thermostat, require_err_msg.DeviceType.Climate];
|
|
15593
15595
|
function binary(input) {
|
|
15594
15596
|
return {
|
|
15595
15597
|
...input,
|
|
@@ -15615,7 +15617,14 @@ var GROUP_TEMPLATES = [
|
|
|
15615
15617
|
quantity: "temperature",
|
|
15616
15618
|
defaultAggregate: "mean",
|
|
15617
15619
|
empty: "null",
|
|
15618
|
-
companions: [NOW$2]
|
|
15620
|
+
companions: [NOW$2],
|
|
15621
|
+
alsoFrom: {
|
|
15622
|
+
deviceTypes: CLIMATE_DEVICES,
|
|
15623
|
+
accept: {
|
|
15624
|
+
cap: "climate-control",
|
|
15625
|
+
fieldPath: "currentTemp"
|
|
15626
|
+
}
|
|
15627
|
+
}
|
|
15619
15628
|
}),
|
|
15620
15629
|
numeric({
|
|
15621
15630
|
id: "humidity",
|
|
@@ -15626,7 +15635,14 @@ var GROUP_TEMPLATES = [
|
|
|
15626
15635
|
quantity: "humidity",
|
|
15627
15636
|
defaultAggregate: "mean",
|
|
15628
15637
|
empty: "null",
|
|
15629
|
-
companions: [NOW$2]
|
|
15638
|
+
companions: [NOW$2],
|
|
15639
|
+
alsoFrom: {
|
|
15640
|
+
deviceTypes: CLIMATE_DEVICES,
|
|
15641
|
+
accept: {
|
|
15642
|
+
cap: "climate-control",
|
|
15643
|
+
fieldPath: "currentHumidity"
|
|
15644
|
+
}
|
|
15645
|
+
}
|
|
15630
15646
|
}),
|
|
15631
15647
|
numeric({
|
|
15632
15648
|
id: "pressure",
|
|
@@ -46320,6 +46336,43 @@ var NotificationActionSchema = zod.z.object({
|
|
|
46320
46336
|
*/
|
|
46321
46337
|
mode: zod.z.enum(["navigate", "background"]).optional()
|
|
46322
46338
|
});
|
|
46339
|
+
/** A delivery parameter value: what a notifier declared it takes. */
|
|
46340
|
+
var DeliveryParamValueSchema = zod.z.union([
|
|
46341
|
+
zod.z.string(),
|
|
46342
|
+
zod.z.number(),
|
|
46343
|
+
zod.z.boolean()
|
|
46344
|
+
]);
|
|
46345
|
+
/**
|
|
46346
|
+
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
46347
|
+
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
46348
|
+
* never handed one. The admin UI derives its control from this descriptor —
|
|
46349
|
+
* no editor knows a service by name.
|
|
46350
|
+
*
|
|
46351
|
+
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
46352
|
+
* run on the addon cap path).
|
|
46353
|
+
*/
|
|
46354
|
+
var DeliveryParamSchema = zod.z.object({
|
|
46355
|
+
key: zod.z.string().min(1),
|
|
46356
|
+
label: zod.z.string(),
|
|
46357
|
+
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
46358
|
+
labelKey: zod.z.string().optional(),
|
|
46359
|
+
type: zod.z.enum([
|
|
46360
|
+
"enum",
|
|
46361
|
+
"number",
|
|
46362
|
+
"boolean",
|
|
46363
|
+
"string"
|
|
46364
|
+
]),
|
|
46365
|
+
/** `enum` only: the closed set of accepted values. */
|
|
46366
|
+
options: zod.z.array(zod.z.object({
|
|
46367
|
+
value: zod.z.string(),
|
|
46368
|
+
label: zod.z.string()
|
|
46369
|
+
})).optional(),
|
|
46370
|
+
/** `number` only. */
|
|
46371
|
+
min: zod.z.number().optional(),
|
|
46372
|
+
max: zod.z.number().optional(),
|
|
46373
|
+
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
46374
|
+
default: DeliveryParamValueSchema.optional()
|
|
46375
|
+
});
|
|
46323
46376
|
/**
|
|
46324
46377
|
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
46325
46378
|
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
@@ -46342,7 +46395,13 @@ var NotificationSchema = zod.z.object({
|
|
|
46342
46395
|
tag: zod.z.string().optional(),
|
|
46343
46396
|
deviceId: zod.z.number().optional(),
|
|
46344
46397
|
eventId: zod.z.string().optional(),
|
|
46345
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
46398
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
46399
|
+
/**
|
|
46400
|
+
* Values for the parameters the target's kind DECLARES in
|
|
46401
|
+
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
46402
|
+
* declaration by the sender; a notifier reads only the keys it declared.
|
|
46403
|
+
*/
|
|
46404
|
+
delivery: zod.z.record(zod.z.string(), DeliveryParamValueSchema).optional()
|
|
46346
46405
|
});
|
|
46347
46406
|
/** One declared native severity/priority level for a kind. */
|
|
46348
46407
|
var TargetKindLevelSchema = zod.z.object({
|
|
@@ -46450,6 +46509,11 @@ var TargetKindSchema = zod.z.object({
|
|
|
46450
46509
|
*/
|
|
46451
46510
|
destinationKeys: zod.z.array(zod.z.string()).optional(),
|
|
46452
46511
|
supportsDiscovery: zod.z.boolean(),
|
|
46512
|
+
/**
|
|
46513
|
+
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
46514
|
+
* Absent = none; the rule editor then offers nothing.
|
|
46515
|
+
*/
|
|
46516
|
+
deliveryParams: zod.z.array(DeliveryParamSchema).optional(),
|
|
46453
46517
|
caps: TargetKindCapsSchema
|
|
46454
46518
|
});
|
|
46455
46519
|
/**
|
|
@@ -63687,7 +63751,9 @@ var ManifestShapeSchema = zod.z.object({
|
|
|
63687
63751
|
icon: zod.z.string().optional()
|
|
63688
63752
|
}).optional(),
|
|
63689
63753
|
protected: zod.z.boolean().optional(),
|
|
63690
|
-
removable: zod.z.boolean().optional()
|
|
63754
|
+
removable: zod.z.boolean().optional(),
|
|
63755
|
+
/** Declared Integrations-page block (mirror of `AddonDeclaration.integrationSection`). */
|
|
63756
|
+
integrationSection: zod.z.enum(["system", "providers"]).optional()
|
|
63691
63757
|
});
|
|
63692
63758
|
var AddonProcessSchema = zod.z.object({
|
|
63693
63759
|
pid: zod.z.number().optional(),
|
|
@@ -81397,6 +81463,7 @@ function evaluateAggregate(input) {
|
|
|
81397
81463
|
function sourcePickForTemplate(template) {
|
|
81398
81464
|
const valueKind = template.family === "numeric" ? "number" : template.activeWhen === void 0 ? "boolean" : "state";
|
|
81399
81465
|
return {
|
|
81466
|
+
fieldChoice: template.family === "numeric" ? "first-match" : "operator",
|
|
81400
81467
|
purpose: "member",
|
|
81401
81468
|
multiple: true,
|
|
81402
81469
|
max: 64,
|
|
@@ -81416,6 +81483,7 @@ function sourcePickForTemplate(template) {
|
|
|
81416
81483
|
/** A statistic or integral reads one field that declares history. */
|
|
81417
81484
|
function sourcePickForHistory(kind) {
|
|
81418
81485
|
return {
|
|
81486
|
+
fieldChoice: "operator",
|
|
81419
81487
|
purpose: "historised",
|
|
81420
81488
|
multiple: false,
|
|
81421
81489
|
max: 1,
|
|
@@ -81455,6 +81523,7 @@ function sourcePickForMath(kind) {
|
|
|
81455
81523
|
const multiple = kind === "sum" || kind === "expression";
|
|
81456
81524
|
const max = kind === "difference" || kind === "ratio" ? 2 : multiple ? 64 : 1;
|
|
81457
81525
|
return {
|
|
81526
|
+
fieldChoice: "operator",
|
|
81458
81527
|
purpose: "reading",
|
|
81459
81528
|
multiple: multiple || max > 1,
|
|
81460
81529
|
max,
|
|
@@ -109879,6 +109948,46 @@ function prepareNotification(caps, n) {
|
|
|
109879
109948
|
};
|
|
109880
109949
|
}
|
|
109881
109950
|
//#endregion
|
|
109951
|
+
//#region src/notification/delivery-params.ts
|
|
109952
|
+
function valueFor(param, raw) {
|
|
109953
|
+
switch (param.type) {
|
|
109954
|
+
case "enum": return typeof raw === "string" && (param.options ?? []).some((o) => o.value === raw) ? raw : void 0;
|
|
109955
|
+
case "number": {
|
|
109956
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return void 0;
|
|
109957
|
+
const floor = param.min ?? Number.NEGATIVE_INFINITY;
|
|
109958
|
+
const ceil = param.max ?? Number.POSITIVE_INFINITY;
|
|
109959
|
+
return Math.min(ceil, Math.max(floor, raw));
|
|
109960
|
+
}
|
|
109961
|
+
case "boolean": return typeof raw === "boolean" ? raw : void 0;
|
|
109962
|
+
case "string": return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
109963
|
+
}
|
|
109964
|
+
}
|
|
109965
|
+
/**
|
|
109966
|
+
* The values a rule target's `params` contribute for a kind: only declared
|
|
109967
|
+
* keys, only valid values. `undefined` when nothing survives — a notifier that
|
|
109968
|
+
* declared nothing is never handed a `delivery` block.
|
|
109969
|
+
*/
|
|
109970
|
+
function resolveDeliveryParams(declared, params) {
|
|
109971
|
+
if (declared === void 0 || params === void 0) return void 0;
|
|
109972
|
+
const out = {};
|
|
109973
|
+
for (const param of declared) {
|
|
109974
|
+
const value = valueFor(param, params[param.key]);
|
|
109975
|
+
if (value !== void 0) out[param.key] = value;
|
|
109976
|
+
}
|
|
109977
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
109978
|
+
}
|
|
109979
|
+
/** The union of several kinds' declarations; the first declaration of a key wins. */
|
|
109980
|
+
function deliveryParamsDeclaredBy(perKind) {
|
|
109981
|
+
const seen = /* @__PURE__ */ new Set();
|
|
109982
|
+
const out = [];
|
|
109983
|
+
for (const declared of perKind) for (const param of declared ?? []) {
|
|
109984
|
+
if (seen.has(param.key)) continue;
|
|
109985
|
+
seen.add(param.key);
|
|
109986
|
+
out.push(param);
|
|
109987
|
+
}
|
|
109988
|
+
return out;
|
|
109989
|
+
}
|
|
109990
|
+
//#endregion
|
|
109882
109991
|
//#region src/notification/system-event-filters.ts
|
|
109883
109992
|
/**
|
|
109884
109993
|
* WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
|
|
@@ -118189,6 +118298,29 @@ function rewriteReferer(referer, route) {
|
|
|
118189
118298
|
if (upstream === void 0) return null;
|
|
118190
118299
|
return `${upstream.scheme}://${upstream.host}${rest?.[2] ?? "/"}${url.search}`;
|
|
118191
118300
|
}
|
|
118301
|
+
function decodeFormComponent(raw) {
|
|
118302
|
+
try {
|
|
118303
|
+
return decodeURIComponent(raw.replace(/\+/g, " "));
|
|
118304
|
+
} catch {
|
|
118305
|
+
return null;
|
|
118306
|
+
}
|
|
118307
|
+
}
|
|
118308
|
+
/**
|
|
118309
|
+
* An `application/x-www-form-urlencoded` body whose field VALUES that are proxy URLs of
|
|
118310
|
+
* this attempt (absolute or root-relative) are turned back into the vendor URL they stand
|
|
118311
|
+
* for — the page's hidden inputs were rewritten on the way out (`rewriteBody`), and the
|
|
118312
|
+
* vendor must get its own URL back. Field order and every untouched pair stay byte-identical.
|
|
118313
|
+
*/
|
|
118314
|
+
function rewriteFormBody(body, route) {
|
|
118315
|
+
return body.split("&").map((pair) => {
|
|
118316
|
+
const eq = pair.indexOf("=");
|
|
118317
|
+
if (eq === -1) return pair;
|
|
118318
|
+
const value = decodeFormComponent(pair.slice(eq + 1));
|
|
118319
|
+
if (value === null || !/^(?:https?:\/\/|\/)/i.test(value)) return pair;
|
|
118320
|
+
const back = rewriteReferer(value, route);
|
|
118321
|
+
return back === null ? pair : `${pair.slice(0, eq + 1)}${encodeURIComponent(back)}`;
|
|
118322
|
+
}).join("&");
|
|
118323
|
+
}
|
|
118192
118324
|
/** Cookies the browser holds for the hub itself must never reach a vendor. */
|
|
118193
118325
|
function filterForwardedCookies(cookieHeader) {
|
|
118194
118326
|
return cookieHeader.split(";").map((part) => part.trim()).filter((part) => part.length > 0 && !part.toLowerCase().startsWith("camstack_")).join("; ");
|
|
@@ -118249,6 +118381,9 @@ function bodyKindOf(contentType) {
|
|
|
118249
118381
|
if (type.startsWith("text/") || type.includes("javascript") || type.includes("json") || type.includes("xml")) return "other";
|
|
118250
118382
|
return null;
|
|
118251
118383
|
}
|
|
118384
|
+
function isFormEncoded(contentType) {
|
|
118385
|
+
return (firstHeader(contentType) ?? "").toLowerCase().startsWith("application/x-www-form-urlencoded");
|
|
118386
|
+
}
|
|
118252
118387
|
function firstHeader(value) {
|
|
118253
118388
|
return Array.isArray(value) ? value[0] : value;
|
|
118254
118389
|
}
|
|
@@ -118379,7 +118514,7 @@ var VendorLoginProxy = class {
|
|
|
118379
118514
|
sendPlain(res, 413, "Request too large");
|
|
118380
118515
|
return;
|
|
118381
118516
|
}
|
|
118382
|
-
body = read;
|
|
118517
|
+
body = isFormEncoded(req.headers["content-type"]) ? Buffer.from(rewriteFormBody(read.toString("utf8"), route), "utf8") : read;
|
|
118383
118518
|
}
|
|
118384
118519
|
const headers = this.#requestHeaders(req, route, upstream);
|
|
118385
118520
|
const upstreamRes = await this.#fetch(target, {
|
|
@@ -118393,9 +118528,10 @@ var VendorLoginProxy = class {
|
|
|
118393
118528
|
const kind = bodyKindOf(upstreamRes.headers.get("content-type") ?? "");
|
|
118394
118529
|
const declaredLength = Number(upstreamRes.headers.get("content-length") ?? "0");
|
|
118395
118530
|
const text = kind !== null && !(declaredLength > MAX_TEXT_BODY_BYTES) && method !== "HEAD" ? await upstreamRes.text() : null;
|
|
118396
|
-
this.#logger.
|
|
118531
|
+
this.#logger.info("vendor login proxy: upstream answered", { meta: {
|
|
118397
118532
|
addonId: this.#addonId,
|
|
118398
118533
|
host: upstream.host,
|
|
118534
|
+
path: target.pathname,
|
|
118399
118535
|
status: upstreamRes.status,
|
|
118400
118536
|
method
|
|
118401
118537
|
} });
|
|
@@ -120086,6 +120222,8 @@ exports.DeclareKindResultSchema = DeclareKindResultSchema;
|
|
|
120086
120222
|
exports.DeclaredDevices = DeclaredDevices;
|
|
120087
120223
|
exports.DecodedAudioChunkSchema = require_sleep.DecodedAudioChunkSchema;
|
|
120088
120224
|
exports.DeleteIntegrationResultSchema = DeleteIntegrationResultSchema;
|
|
120225
|
+
exports.DeliveryParamSchema = DeliveryParamSchema;
|
|
120226
|
+
exports.DeliveryParamValueSchema = DeliveryParamValueSchema;
|
|
120089
120227
|
exports.DerivativeHelperSpecSchema = require_composition.DerivativeHelperSpecSchema;
|
|
120090
120228
|
exports.DetailCropConventionSchema = DetailCropConventionSchema;
|
|
120091
120229
|
exports.DetectionCatalogClassMapSchema = DetectionCatalogClassMapSchema;
|
|
@@ -121883,6 +122021,7 @@ exports.defineRecordKinds = require_sleep.defineRecordKinds;
|
|
|
121883
122021
|
exports.dehydrateConfigField = require_sleep.dehydrateConfigField;
|
|
121884
122022
|
exports.dehydrateSchema = require_sleep.dehydrateSchema;
|
|
121885
122023
|
exports.deleteAlarmProfile = deleteAlarmProfile;
|
|
122024
|
+
exports.deliveryParamsDeclaredBy = deliveryParamsDeclaredBy;
|
|
121886
122025
|
exports.derivativeDraft = derivativeDraft;
|
|
121887
122026
|
exports.derivativeUnitLabel = derivativeUnitLabel;
|
|
121888
122027
|
exports.deriveBatteryPresence = deriveBatteryPresence;
|
|
@@ -122441,6 +122580,7 @@ exports.resolveContainerPrimaryChild = resolveContainerPrimaryChild;
|
|
|
122441
122580
|
exports.resolveCoreBlockEntry = resolveCoreBlockEntry;
|
|
122442
122581
|
exports.resolveCoreBlockFiles = resolveCoreBlockFiles;
|
|
122443
122582
|
exports.resolveCreateExportSubject = resolveCreateExportSubject;
|
|
122583
|
+
exports.resolveDeliveryParams = resolveDeliveryParams;
|
|
122444
122584
|
exports.resolveDeviceControlKind = resolveDeviceControlKind;
|
|
122445
122585
|
exports.resolveDeviceProfile = resolveDeviceProfile;
|
|
122446
122586
|
exports.resolveDeviceTarget = resolveDeviceTarget;
|