@camstack/types 1.2.562 → 1.2.563
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 +16 -0
- package/dist/addon.js +3 -2
- package/dist/addon.mjs +3 -2
- package/dist/capabilities/cluster-update.cap.d.ts +16 -0
- package/dist/capabilities/device-manager.cap.d.ts +2 -1
- package/dist/capabilities/device-search.d.ts +4 -2
- package/dist/capabilities/notification-rules.cap.d.ts +4 -0
- package/dist/capabilities/smtp-provider.cap.d.ts +2 -0
- package/dist/capabilities/switch.cap.d.ts +5 -0
- package/dist/client.js +46 -1
- package/dist/client.mjs +46 -1
- package/dist/device/cap-vocabulary/index.d.ts +1 -1
- package/dist/device/cap-vocabulary/resolve.d.ts +6 -0
- package/dist/generated/addon-api.d.ts +7 -0
- package/dist/generated/collection-array-methods.d.ts +1 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +385 -39
- package/dist/index.mjs +378 -40
- package/dist/notification/degrade-engine.d.ts +5 -0
- package/dist/notification/email-image-bytes.d.ts +26 -0
- package/dist/notification/email-mime.d.ts +52 -0
- package/dist/{sleep-Cykc2bzi.mjs → sleep-BCWQQG52.mjs} +49 -32
- package/dist/{sleep-Cb2px0Nb.js → sleep-RUgd-FgK.js} +49 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sleep = require("./sleep-
|
|
2
|
+
const require_sleep = require("./sleep-RUgd-FgK.js");
|
|
3
3
|
const require_event_category = require("./event-category-Ps2LC8dN.js");
|
|
4
4
|
const require_composed_stable_id = require("./composed-stable-id-Bp33yrYi.js");
|
|
5
5
|
const require_implemented_methods = require("./implemented-methods-CDYOCn9a.js");
|
|
@@ -46322,7 +46322,9 @@ var ClusterUpdateFailureReasonSchema = zod.z.enum([
|
|
|
46322
46322
|
"status-unreadable",
|
|
46323
46323
|
"addon-update-failed",
|
|
46324
46324
|
"addons-not-converged",
|
|
46325
|
-
"interrupted"
|
|
46325
|
+
"interrupted",
|
|
46326
|
+
"timeout-stall",
|
|
46327
|
+
"timeout-ceiling"
|
|
46326
46328
|
]);
|
|
46327
46329
|
var ClusterUpdateStepSchema = zod.z.object({
|
|
46328
46330
|
kind: ClusterUpdateStepKindSchema,
|
|
@@ -50030,9 +50032,17 @@ function forwardSourceRefs(composition) {
|
|
|
50030
50032
|
const refs = composition.features.flatMap((feature, index) => feature.kind === "fields" && require_implemented_methods.compositionFeatureEnabled(feature) ? featureForwards(feature, index).map((forward) => forward.command.source) : []);
|
|
50031
50033
|
return [...new Map(refs.map((ref) => [require_implemented_methods.compositionSourceKey(ref), ref])).values()];
|
|
50032
50034
|
}
|
|
50035
|
+
/**
|
|
50036
|
+
* `switch.toggle` is not a forward. Native-cap registration installs one
|
|
50037
|
+
* default that reads the slice and calls this provider's `setState`, and a
|
|
50038
|
+
* composed switch already forwards `setState`.
|
|
50039
|
+
*/
|
|
50040
|
+
function servedByRegistrationDefault(def, method) {
|
|
50041
|
+
return def.name === "switch" && method === "toggle";
|
|
50042
|
+
}
|
|
50033
50043
|
/** The methods a BUILT cap must give a command: served, and not answered by the composer itself. */
|
|
50034
50044
|
function commandedMethods(def) {
|
|
50035
|
-
return Object.entries(def.methods).filter(([name, m]) => m.systemOnly !== true && def.composedMethods?.[name] === void 0).map(([name]) => name);
|
|
50045
|
+
return Object.entries(def.methods).filter(([name, m]) => m.systemOnly !== true && def.composedMethods?.[name] === void 0 && !servedByRegistrationDefault(def, name)).map(([name]) => name);
|
|
50036
50046
|
}
|
|
50037
50047
|
/**
|
|
50038
50048
|
* The `commands` of a `media-player` feature served by the `remote` extension:
|
|
@@ -55428,9 +55438,15 @@ function siteZoneKey(label) {
|
|
|
55428
55438
|
var DEVICE_SEARCH_DEFAULT_LIMIT = 50;
|
|
55429
55439
|
var DEVICE_SEARCH_MAX_LIMIT = 200;
|
|
55430
55440
|
var DeviceSearchRequiresSchema = zod.z.object({
|
|
55431
|
-
/** Capability names the field wants a value of. */
|
|
55432
|
-
caps: zod.z.array(zod.z.string()).readonly(),
|
|
55433
|
-
/**
|
|
55441
|
+
/** Capability names the field wants a value of. Absent when the field wants actions only. */
|
|
55442
|
+
caps: zod.z.array(zod.z.string()).readonly().optional(),
|
|
55443
|
+
/**
|
|
55444
|
+
* Vocabulary action ids (`cover.open`) the device must offer. Compatible means
|
|
55445
|
+
* the device's bindings resolve those actions; `values` stays empty when no
|
|
55446
|
+
* cap was required. `mode` applies the same way as for `caps`.
|
|
55447
|
+
*/
|
|
55448
|
+
actions: zod.z.array(zod.z.string()).readonly().optional(),
|
|
55449
|
+
/** `any` (default): one of the named caps, and one of the named actions, is enough. `all`: every one. */
|
|
55434
55450
|
mode: zod.z.enum(["any", "all"]).optional()
|
|
55435
55451
|
});
|
|
55436
55452
|
var DeviceSearchFiltersSchema = zod.z.object({
|
|
@@ -81831,6 +81847,13 @@ var NcHistoryEntrySchema = zod.z.object({
|
|
|
81831
81847
|
error: zod.z.string().optional(),
|
|
81832
81848
|
subject: NcHistorySubjectSchema,
|
|
81833
81849
|
/**
|
|
81850
|
+
* The title and body actually sent, frozen at delivery. Absent on a row
|
|
81851
|
+
* still pending, a row suppressed before a notification was built, and a
|
|
81852
|
+
* row delivered before this field shipped.
|
|
81853
|
+
*/
|
|
81854
|
+
title: zod.z.string().optional(),
|
|
81855
|
+
body: zod.z.string().optional(),
|
|
81856
|
+
/**
|
|
81834
81857
|
* Ids of the artefacts (still, then gif, then clip) this row's successful
|
|
81835
81858
|
* delivery indexed in the artefact library — a REFERENCE, never the bytes
|
|
81836
81859
|
* (an artefact is often megabytes; this row is durable JSON rewritten on
|
|
@@ -93587,7 +93610,8 @@ var ServerUpdateActionResultSchema = zod.z.object({
|
|
|
93587
93610
|
outcome: ServerUpdateOutcomeSchema.optional(),
|
|
93588
93611
|
/**
|
|
93589
93612
|
* Stable, greppable cause for `refused` / `failed` (the engine's
|
|
93590
|
-
* `UpdateRefusalReason`, `staging-failed`,
|
|
93613
|
+
* `UpdateRefusalReason`, `staging-failed`, `timeout-stall`,
|
|
93614
|
+
* `timeout-ceiling`). `null` on success.
|
|
93591
93615
|
*/
|
|
93592
93616
|
reason: zod.z.string().nullable().optional(),
|
|
93593
93617
|
/**
|
|
@@ -93756,6 +93780,157 @@ var smokeCapability = {
|
|
|
93756
93780
|
}
|
|
93757
93781
|
};
|
|
93758
93782
|
//#endregion
|
|
93783
|
+
//#region src/notification/email-mime.ts
|
|
93784
|
+
/**
|
|
93785
|
+
* One RFC 5322 body for every mail sender.
|
|
93786
|
+
*
|
|
93787
|
+
* Gmail and the SMTP relay both call this. An HTML message with an inline image is
|
|
93788
|
+
* `multipart/related` (the HTML sits in `multipart/alternative` and references
|
|
93789
|
+
* `cid:`). A text message carries the same bytes as a normal attachment
|
|
93790
|
+
* (`multipart/mixed`). The image bytes are already in hand — a sender reads them
|
|
93791
|
+
* off a `peerBytes` ticket before calling in ({@link assembleEmailMime}).
|
|
93792
|
+
*/
|
|
93793
|
+
/** How many images one email will carry. */
|
|
93794
|
+
var EMAIL_IMAGE_MAX_COUNT = 3;
|
|
93795
|
+
/** Total image bytes one email will carry. */
|
|
93796
|
+
var EMAIL_IMAGE_MAX_TOTAL_BYTES = 5 * 1024 * 1024;
|
|
93797
|
+
/**
|
|
93798
|
+
* Where an HTML body leaves room for the inline images: under the text, above
|
|
93799
|
+
* the click link. The builder replaces it; a message with no image loses it.
|
|
93800
|
+
*/
|
|
93801
|
+
var EMAIL_IMAGE_SLOT = "<!--camstack-images-->";
|
|
93802
|
+
var EmailImagePartSchema = zod.z.object({
|
|
93803
|
+
ticket: require_sleep.PeerBytesTicketSchema,
|
|
93804
|
+
mime: zod.z.string().min(1),
|
|
93805
|
+
name: zod.z.string().min(1),
|
|
93806
|
+
contentId: zod.z.string().min(1),
|
|
93807
|
+
placement: zod.z.enum(["inline", "attachment"]),
|
|
93808
|
+
deviceId: zod.z.number().int().nonnegative().optional()
|
|
93809
|
+
});
|
|
93810
|
+
var mimeSeq = 0;
|
|
93811
|
+
function nextBoundary(kind) {
|
|
93812
|
+
mimeSeq += 1;
|
|
93813
|
+
return `camstack_${kind}_${mimeSeq.toString(36)}_${Date.now().toString(36)}`;
|
|
93814
|
+
}
|
|
93815
|
+
function encodeHeaderWord(value) {
|
|
93816
|
+
if (/^[\x20-\x7E]*$/.test(value)) return value;
|
|
93817
|
+
return `=?UTF-8?B?${Buffer.from(value, "utf8").toString("base64")}?=`;
|
|
93818
|
+
}
|
|
93819
|
+
function formatAddressList(addrs) {
|
|
93820
|
+
return (Array.isArray(addrs) ? addrs : [addrs]).join(", ");
|
|
93821
|
+
}
|
|
93822
|
+
function escapeHtml$1(value) {
|
|
93823
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
93824
|
+
}
|
|
93825
|
+
function safeToken(value, fallback) {
|
|
93826
|
+
const cleaned = value.replace(/[\r\n"]/g, "").trim();
|
|
93827
|
+
return cleaned.length > 0 ? cleaned : fallback;
|
|
93828
|
+
}
|
|
93829
|
+
function base64Body(bytes) {
|
|
93830
|
+
const b64 = Buffer.from(bytes).toString("base64");
|
|
93831
|
+
const lines = [];
|
|
93832
|
+
for (let i = 0; i < b64.length; i += 76) lines.push(b64.slice(i, i + 76));
|
|
93833
|
+
return lines.join("\r\n");
|
|
93834
|
+
}
|
|
93835
|
+
function imgTag(image) {
|
|
93836
|
+
return `<img src="cid:${escapeHtml$1(image.contentId)}" alt="">`;
|
|
93837
|
+
}
|
|
93838
|
+
function fillSlot(html, inline) {
|
|
93839
|
+
return html.replaceAll(EMAIL_IMAGE_SLOT, inline.map(imgTag).join(""));
|
|
93840
|
+
}
|
|
93841
|
+
function headerLines(input) {
|
|
93842
|
+
const lines = [`From: ${input.from}`, `To: ${formatAddressList(input.to)}`];
|
|
93843
|
+
if (input.cc !== void 0 && input.cc.length > 0) lines.push(`Cc: ${formatAddressList(input.cc)}`);
|
|
93844
|
+
if (input.bcc !== void 0 && input.bcc.length > 0) lines.push(`Bcc: ${formatAddressList(input.bcc)}`);
|
|
93845
|
+
if (input.replyTo !== void 0 && input.replyTo.length > 0) lines.push(`Reply-To: ${input.replyTo}`);
|
|
93846
|
+
lines.push(`Subject: ${encodeHeaderWord(input.subject)}`);
|
|
93847
|
+
lines.push("MIME-Version: 1.0");
|
|
93848
|
+
return lines;
|
|
93849
|
+
}
|
|
93850
|
+
function textPart(boundary, text) {
|
|
93851
|
+
return [
|
|
93852
|
+
`--${boundary}`,
|
|
93853
|
+
"Content-Type: text/plain; charset=\"UTF-8\"",
|
|
93854
|
+
"Content-Transfer-Encoding: 8bit",
|
|
93855
|
+
"",
|
|
93856
|
+
text
|
|
93857
|
+
];
|
|
93858
|
+
}
|
|
93859
|
+
function htmlPart(boundary, html) {
|
|
93860
|
+
return [
|
|
93861
|
+
`--${boundary}`,
|
|
93862
|
+
"Content-Type: text/html; charset=\"UTF-8\"",
|
|
93863
|
+
"Content-Transfer-Encoding: 8bit",
|
|
93864
|
+
"",
|
|
93865
|
+
html
|
|
93866
|
+
];
|
|
93867
|
+
}
|
|
93868
|
+
function imagePart(boundary, image) {
|
|
93869
|
+
const mime = safeToken(image.mime, "image/jpeg");
|
|
93870
|
+
const name = safeToken(image.name, "image.jpg");
|
|
93871
|
+
const disposition = image.placement === "inline" ? "inline" : "attachment";
|
|
93872
|
+
const lines = [
|
|
93873
|
+
`--${boundary}`,
|
|
93874
|
+
`Content-Type: ${mime}`,
|
|
93875
|
+
"Content-Transfer-Encoding: base64",
|
|
93876
|
+
`Content-Disposition: ${disposition}; filename="${name}"`
|
|
93877
|
+
];
|
|
93878
|
+
if (image.placement === "inline") lines.push(`Content-ID: <${safeToken(image.contentId, "image")}>`);
|
|
93879
|
+
lines.push("", base64Body(image.bytes));
|
|
93880
|
+
return lines;
|
|
93881
|
+
}
|
|
93882
|
+
function alternative(outer, text, html) {
|
|
93883
|
+
const inner = nextBoundary("alt");
|
|
93884
|
+
return [
|
|
93885
|
+
`--${outer}`,
|
|
93886
|
+
`Content-Type: multipart/alternative; boundary="${inner}"`,
|
|
93887
|
+
"",
|
|
93888
|
+
...textPart(inner, text),
|
|
93889
|
+
...htmlPart(inner, html),
|
|
93890
|
+
`--${inner}--`
|
|
93891
|
+
];
|
|
93892
|
+
}
|
|
93893
|
+
function simpleMessage(input, html) {
|
|
93894
|
+
const lines = headerLines(input);
|
|
93895
|
+
if (html !== void 0) {
|
|
93896
|
+
const boundary = nextBoundary("alt");
|
|
93897
|
+
lines.push(`Content-Type: multipart/alternative; boundary="${boundary}"`, "");
|
|
93898
|
+
lines.push(...textPart(boundary, input.text), ...htmlPart(boundary, html), `--${boundary}--`);
|
|
93899
|
+
return lines;
|
|
93900
|
+
}
|
|
93901
|
+
lines.push("Content-Type: text/plain; charset=\"UTF-8\"", "Content-Transfer-Encoding: 8bit", "", input.text);
|
|
93902
|
+
return lines;
|
|
93903
|
+
}
|
|
93904
|
+
function mixedMessage(input, html, files) {
|
|
93905
|
+
const boundary = nextBoundary("mix");
|
|
93906
|
+
const lines = headerLines(input);
|
|
93907
|
+
lines.push(`Content-Type: multipart/mixed; boundary="${boundary}"`, "");
|
|
93908
|
+
if (html !== void 0) lines.push(...alternative(boundary, input.text, html));
|
|
93909
|
+
else lines.push(...textPart(boundary, input.text));
|
|
93910
|
+
for (const image of files) lines.push(...imagePart(boundary, image));
|
|
93911
|
+
lines.push(`--${boundary}--`);
|
|
93912
|
+
return lines;
|
|
93913
|
+
}
|
|
93914
|
+
function relatedMessage(input, html, inline, attached) {
|
|
93915
|
+
const boundary = nextBoundary("rel");
|
|
93916
|
+
const lines = headerLines(input);
|
|
93917
|
+
lines.push(`Content-Type: multipart/related; boundary="${boundary}"; type="multipart/alternative"`, "", ...alternative(boundary, input.text, html));
|
|
93918
|
+
for (const image of inline) lines.push(...imagePart(boundary, image));
|
|
93919
|
+
for (const image of attached) lines.push(...imagePart(boundary, image));
|
|
93920
|
+
lines.push(`--${boundary}--`);
|
|
93921
|
+
return lines;
|
|
93922
|
+
}
|
|
93923
|
+
/** Render one mail. No I/O: the caller has already decided which images survived. */
|
|
93924
|
+
function buildRawMime(input) {
|
|
93925
|
+
const images = input.images ?? [];
|
|
93926
|
+
const inline = images.filter((image) => image.placement === "inline");
|
|
93927
|
+
const attached = images.filter((image) => image.placement === "attachment");
|
|
93928
|
+
const html = input.html !== void 0 && input.html.length > 0 ? fillSlot(input.html, inline) : void 0;
|
|
93929
|
+
if (html !== void 0 && inline.length > 0) return relatedMessage(input, html, inline, attached).join("\r\n");
|
|
93930
|
+
if (attached.length > 0 || inline.length > 0) return mixedMessage(input, html, attached.length > 0 ? attached : inline).join("\r\n");
|
|
93931
|
+
return simpleMessage(input, html).join("\r\n");
|
|
93932
|
+
}
|
|
93933
|
+
//#endregion
|
|
93759
93934
|
//#region src/capabilities/smtp-provider.cap.ts
|
|
93760
93935
|
/**
|
|
93761
93936
|
* `smtp-provider` — pluggable email delivery surface.
|
|
@@ -93766,8 +93941,8 @@ var smokeCapability = {
|
|
|
93766
93941
|
* ready provider OR target a specific addonId.
|
|
93767
93942
|
*
|
|
93768
93943
|
* The shape stays small on purpose — `sendEmail` is enough for the
|
|
93769
|
-
* 90% case.
|
|
93770
|
-
*
|
|
93944
|
+
* 90% case. An image is not a byte field on this method (D613): `images`
|
|
93945
|
+
* names `peerBytes` tickets the sender opens and folds into one MIME body.
|
|
93771
93946
|
*/
|
|
93772
93947
|
var EmailAddressSchema = zod.z.email();
|
|
93773
93948
|
/**
|
|
@@ -93794,7 +93969,12 @@ var SendEmailInputSchema = zod.z.object({
|
|
|
93794
93969
|
* for clients that strip HTML — including most spam filters). */
|
|
93795
93970
|
text: zod.z.string(),
|
|
93796
93971
|
/** Optional HTML body. Renders alongside `text` as multi-part. */
|
|
93797
|
-
html: zod.z.string().optional()
|
|
93972
|
+
html: zod.z.string().optional(),
|
|
93973
|
+
/**
|
|
93974
|
+
* Images the caller already offered over `peerBytes`. Absent = a mail with
|
|
93975
|
+
* no image. The sender opens each ticket; one it cannot read is left out.
|
|
93976
|
+
*/
|
|
93977
|
+
images: zod.z.array(EmailImagePartSchema).max(3).optional()
|
|
93798
93978
|
});
|
|
93799
93979
|
var SendEmailResultSchema = zod.z.object({
|
|
93800
93980
|
messageId: zod.z.string(),
|
|
@@ -95255,34 +95435,46 @@ var switchCapability = {
|
|
|
95255
95435
|
require_composed_stable_id.DeviceType.Light,
|
|
95256
95436
|
require_composed_stable_id.DeviceType.Fan
|
|
95257
95437
|
],
|
|
95258
|
-
methods: {
|
|
95259
|
-
|
|
95260
|
-
|
|
95261
|
-
|
|
95262
|
-
|
|
95263
|
-
|
|
95264
|
-
|
|
95265
|
-
|
|
95266
|
-
|
|
95267
|
-
|
|
95268
|
-
|
|
95269
|
-
|
|
95270
|
-
|
|
95271
|
-
|
|
95272
|
-
|
|
95273
|
-
|
|
95274
|
-
|
|
95275
|
-
|
|
95276
|
-
|
|
95277
|
-
|
|
95278
|
-
|
|
95279
|
-
|
|
95280
|
-
|
|
95281
|
-
|
|
95282
|
-
|
|
95283
|
-
|
|
95284
|
-
|
|
95285
|
-
|
|
95438
|
+
methods: {
|
|
95439
|
+
setState: require_sleep.method(zod.z.object({
|
|
95440
|
+
deviceId: zod.z.number(),
|
|
95441
|
+
on: zod.z.boolean()
|
|
95442
|
+
}), zod.z.void(), {
|
|
95443
|
+
kind: "mutation",
|
|
95444
|
+
auth: "protected",
|
|
95445
|
+
actions: [{
|
|
95446
|
+
id: "switch.on",
|
|
95447
|
+
label: require_sleep.t("Turn on", "Accendi"),
|
|
95448
|
+
phrase: require_sleep.t("Turn on {device}", "Accendi {device}"),
|
|
95449
|
+
icon: "power",
|
|
95450
|
+
effect: {
|
|
95451
|
+
field: "on",
|
|
95452
|
+
value: true
|
|
95453
|
+
},
|
|
95454
|
+
args: { on: true }
|
|
95455
|
+
}, {
|
|
95456
|
+
id: "switch.off",
|
|
95457
|
+
label: require_sleep.t("Turn off", "Spegni"),
|
|
95458
|
+
phrase: require_sleep.t("Turn off {device}", "Spegni {device}"),
|
|
95459
|
+
icon: "power-off",
|
|
95460
|
+
effect: {
|
|
95461
|
+
field: "on",
|
|
95462
|
+
value: false
|
|
95463
|
+
},
|
|
95464
|
+
args: { on: false }
|
|
95465
|
+
}]
|
|
95466
|
+
}),
|
|
95467
|
+
toggle: require_sleep.optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
|
|
95468
|
+
kind: "mutation",
|
|
95469
|
+
auth: "protected",
|
|
95470
|
+
actions: [{
|
|
95471
|
+
id: "switch.toggle",
|
|
95472
|
+
label: require_sleep.t("Toggle", "Commuta"),
|
|
95473
|
+
phrase: require_sleep.t("Toggle {device}", "Commuta {device}"),
|
|
95474
|
+
icon: "toggle-right"
|
|
95475
|
+
}]
|
|
95476
|
+
})
|
|
95477
|
+
},
|
|
95286
95478
|
events: { onStateChanged: {
|
|
95287
95479
|
data: zod.z.object({
|
|
95288
95480
|
deviceId: zod.z.number(),
|
|
@@ -124940,6 +125132,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
124940
125132
|
access: "create",
|
|
124941
125133
|
role: "viewer"
|
|
124942
125134
|
},
|
|
125135
|
+
"switch.toggle": {
|
|
125136
|
+
capName: "switch",
|
|
125137
|
+
capScope: "device",
|
|
125138
|
+
addonId: null,
|
|
125139
|
+
access: "create",
|
|
125140
|
+
role: "viewer"
|
|
125141
|
+
},
|
|
124943
125142
|
"system.debugWatch": {
|
|
124944
125143
|
capName: "system",
|
|
124945
125144
|
capScope: "system",
|
|
@@ -126591,6 +126790,16 @@ function actionsForDevice(bindings, deviceType, role) {
|
|
|
126591
126790
|
}
|
|
126592
126791
|
return out;
|
|
126593
126792
|
}
|
|
126793
|
+
/**
|
|
126794
|
+
* Whether a device offers the vocabulary actions, with the same `any` / `all`
|
|
126795
|
+
* rule a cap require uses. An empty list passes. This is the one check the
|
|
126796
|
+
* device search and the command picker share.
|
|
126797
|
+
*/
|
|
126798
|
+
function deviceOffersActions(bindings, actionIds, mode = "any", deviceType) {
|
|
126799
|
+
if (actionIds.length === 0) return true;
|
|
126800
|
+
const offered = new Set(actionsForDevice(bindings, deviceType).map((action) => action.id));
|
|
126801
|
+
return mode === "all" ? actionIds.every((id) => offered.has(id)) : actionIds.some((id) => offered.has(id));
|
|
126802
|
+
}
|
|
126594
126803
|
function resolveEnumValue(v) {
|
|
126595
126804
|
const phrase = v.phrase ?? fill(BECOMES, {
|
|
126596
126805
|
en: { value: v.label.en },
|
|
@@ -131130,6 +131339,12 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
131130
131339
|
form: "single",
|
|
131131
131340
|
optional: false
|
|
131132
131341
|
}],
|
|
131342
|
+
"smtpProvider.sendEmail": [{
|
|
131343
|
+
name: "images",
|
|
131344
|
+
form: "object-array",
|
|
131345
|
+
optional: true,
|
|
131346
|
+
itemField: "deviceId"
|
|
131347
|
+
}],
|
|
131133
131348
|
"snapshot.applyDeviceSettingsPatch": [{
|
|
131134
131349
|
name: "deviceId",
|
|
131135
131350
|
form: "single",
|
|
@@ -131296,6 +131511,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
131296
131511
|
form: "single",
|
|
131297
131512
|
optional: false
|
|
131298
131513
|
}],
|
|
131514
|
+
"switch.toggle": [{
|
|
131515
|
+
name: "deviceId",
|
|
131516
|
+
form: "single",
|
|
131517
|
+
optional: false
|
|
131518
|
+
}],
|
|
131299
131519
|
"system.debugWatch": [{
|
|
131300
131520
|
name: "deviceIds",
|
|
131301
131521
|
form: "array",
|
|
@@ -131757,6 +131977,7 @@ var SYSTEM_SCOPE_DEVICE_METHODS = [
|
|
|
131757
131977
|
"remote.sendCommand",
|
|
131758
131978
|
"remote.sendMediaCommand",
|
|
131759
131979
|
"remote.setConfig",
|
|
131980
|
+
"smtpProvider.sendEmail",
|
|
131760
131981
|
"storageAdmin.readRecords",
|
|
131761
131982
|
"streamBroker.acquireEgressTranscode",
|
|
131762
131983
|
"streamBroker.applyDeviceSettingsPatch",
|
|
@@ -134376,12 +134597,92 @@ function prepareNotification(caps, n) {
|
|
|
134376
134597
|
sound,
|
|
134377
134598
|
ttl,
|
|
134378
134599
|
tag,
|
|
134600
|
+
...n.deviceId !== void 0 ? { deviceId: n.deviceId } : {},
|
|
134379
134601
|
...n.delivery !== void 0 ? { delivery: n.delivery } : {},
|
|
134380
134602
|
bodyParts,
|
|
134381
134603
|
renderedAs
|
|
134382
134604
|
};
|
|
134383
134605
|
}
|
|
134384
134606
|
//#endregion
|
|
134607
|
+
//#region src/notification/email-image-bytes.ts
|
|
134608
|
+
function asBytes(chunk) {
|
|
134609
|
+
if (chunk instanceof Uint8Array) return chunk;
|
|
134610
|
+
if (typeof chunk === "string") return Buffer.from(chunk);
|
|
134611
|
+
throw new Error("email image: unexpected stream chunk");
|
|
134612
|
+
}
|
|
134613
|
+
async function readBody(opened, maxBytes) {
|
|
134614
|
+
if (opened.declaredBytes !== null && opened.declaredBytes > maxBytes) {
|
|
134615
|
+
opened.cancel("email image over cap");
|
|
134616
|
+
throw new Error(`attachment exceeds maxBytes (${opened.declaredBytes} > ${maxBytes})`);
|
|
134617
|
+
}
|
|
134618
|
+
const chunks = [];
|
|
134619
|
+
let total = 0;
|
|
134620
|
+
for await (const chunk of opened.stream) {
|
|
134621
|
+
const bytes = asBytes(chunk);
|
|
134622
|
+
total += bytes.byteLength;
|
|
134623
|
+
if (total > maxBytes) {
|
|
134624
|
+
opened.cancel("email image over cap");
|
|
134625
|
+
throw new Error(`attachment exceeds maxBytes (>${maxBytes})`);
|
|
134626
|
+
}
|
|
134627
|
+
chunks.push(bytes);
|
|
134628
|
+
}
|
|
134629
|
+
if (total === 0) throw new Error("email image was empty");
|
|
134630
|
+
const out = new Uint8Array(total);
|
|
134631
|
+
let offset = 0;
|
|
134632
|
+
for (const chunk of chunks) {
|
|
134633
|
+
out.set(chunk, offset);
|
|
134634
|
+
offset += chunk.byteLength;
|
|
134635
|
+
}
|
|
134636
|
+
return out;
|
|
134637
|
+
}
|
|
134638
|
+
async function readTicket(open, ticket, maxBytes) {
|
|
134639
|
+
const opened = await open(ticket);
|
|
134640
|
+
if (opened.kind === "refused") throw new Error(`email image unavailable: ${opened.code}`);
|
|
134641
|
+
return readBody(opened.body, maxBytes);
|
|
134642
|
+
}
|
|
134643
|
+
/** The images that fit. Each failure is handed to `onDropped` and skipped. */
|
|
134644
|
+
async function materializeEmailImages(images, open, onDropped) {
|
|
134645
|
+
if (images === void 0 || images.length === 0) return [];
|
|
134646
|
+
const out = [];
|
|
134647
|
+
let used = 0;
|
|
134648
|
+
for (const image of images) {
|
|
134649
|
+
const room = EMAIL_IMAGE_MAX_TOTAL_BYTES - used;
|
|
134650
|
+
if (room <= 0) {
|
|
134651
|
+
onDropped("attachment exceeds maxBytes (total cap)", image.deviceId);
|
|
134652
|
+
continue;
|
|
134653
|
+
}
|
|
134654
|
+
try {
|
|
134655
|
+
const bytes = await readTicket(open, image.ticket, room);
|
|
134656
|
+
used += bytes.byteLength;
|
|
134657
|
+
out.push({
|
|
134658
|
+
bytes,
|
|
134659
|
+
mime: image.mime,
|
|
134660
|
+
name: image.name,
|
|
134661
|
+
contentId: image.contentId,
|
|
134662
|
+
placement: image.placement
|
|
134663
|
+
});
|
|
134664
|
+
} catch (err) {
|
|
134665
|
+
onDropped(err instanceof Error ? err.message : String(err), image.deviceId);
|
|
134666
|
+
}
|
|
134667
|
+
}
|
|
134668
|
+
return out;
|
|
134669
|
+
}
|
|
134670
|
+
/** Tickets in, one MIME body out. The same call for Gmail and SMTP. */
|
|
134671
|
+
async function assembleEmailMime(input, open, onDropped) {
|
|
134672
|
+
const images = await materializeEmailImages(input.images, open, onDropped);
|
|
134673
|
+
return buildRawMime({
|
|
134674
|
+
from: input.from,
|
|
134675
|
+
to: input.to,
|
|
134676
|
+
subject: input.subject,
|
|
134677
|
+
text: input.text,
|
|
134678
|
+
...input.cc !== void 0 ? { cc: input.cc } : {},
|
|
134679
|
+
...input.bcc !== void 0 ? { bcc: input.bcc } : {},
|
|
134680
|
+
...input.replyTo !== void 0 ? { replyTo: input.replyTo } : {},
|
|
134681
|
+
...input.html !== void 0 ? { html: input.html } : {},
|
|
134682
|
+
...images.length > 0 ? { images } : {}
|
|
134683
|
+
});
|
|
134684
|
+
}
|
|
134685
|
+
//#endregion
|
|
134385
134686
|
//#region src/notification/attachment-url.ts
|
|
134386
134687
|
/** Build a {@link PublicEndpointReader} over `local-network.getAddresses`. */
|
|
134387
134688
|
function publicEndpointReaderFrom(source) {
|
|
@@ -137028,6 +137329,28 @@ var STATE_SUMMARY_VARS = [
|
|
|
137028
137329
|
systemEventKinds: [...SUMMARISABLE],
|
|
137029
137330
|
systemEventDeliveries: ["summary"]
|
|
137030
137331
|
},
|
|
137332
|
+
{
|
|
137333
|
+
name: "offlineCount",
|
|
137334
|
+
label: "Summary: how many went offline",
|
|
137335
|
+
example: "2",
|
|
137336
|
+
group: "system",
|
|
137337
|
+
families: ["rule"],
|
|
137338
|
+
fields: [...RULE_TEXT],
|
|
137339
|
+
kinds: ["system"],
|
|
137340
|
+
systemEventKinds: [...SUMMARISABLE],
|
|
137341
|
+
systemEventDeliveries: ["summary"]
|
|
137342
|
+
},
|
|
137343
|
+
{
|
|
137344
|
+
name: "onlineCount",
|
|
137345
|
+
label: "Summary: how many came back",
|
|
137346
|
+
example: "5",
|
|
137347
|
+
group: "system",
|
|
137348
|
+
families: ["rule"],
|
|
137349
|
+
fields: [...RULE_TEXT],
|
|
137350
|
+
kinds: ["system"],
|
|
137351
|
+
systemEventKinds: [...SUMMARISABLE],
|
|
137352
|
+
systemEventDeliveries: ["summary"]
|
|
137353
|
+
},
|
|
137031
137354
|
{
|
|
137032
137355
|
name: "summaryCount",
|
|
137033
137356
|
label: "Summary: items reported",
|
|
@@ -137118,6 +137441,21 @@ var NC_TEMPLATE_VARS = [
|
|
|
137118
137441
|
kinds: ["detection", "system"],
|
|
137119
137442
|
systemEventKinds: [...COMBINED_ALARM]
|
|
137120
137443
|
},
|
|
137444
|
+
{
|
|
137445
|
+
name: "headline",
|
|
137446
|
+
label: "Subject and place",
|
|
137447
|
+
description: "The default detection title: the label when one is set, otherwise the translated class, then the zone or the device. The subject alone when neither place is known.",
|
|
137448
|
+
example: "Persona — Uscio",
|
|
137449
|
+
group: "subject",
|
|
137450
|
+
families: ["rule"],
|
|
137451
|
+
fields: [...RULE_TEXT],
|
|
137452
|
+
kinds: [
|
|
137453
|
+
"detection",
|
|
137454
|
+
"occupancy",
|
|
137455
|
+
"sound",
|
|
137456
|
+
"sensor"
|
|
137457
|
+
]
|
|
137458
|
+
},
|
|
137121
137459
|
{
|
|
137122
137460
|
name: "subject",
|
|
137123
137461
|
label: "Subject sentence",
|
|
@@ -137412,7 +137750,7 @@ var NC_TEMPLATE_VARS = [
|
|
|
137412
137750
|
families: ["rule"],
|
|
137413
137751
|
fields: [...RULE_TEXT],
|
|
137414
137752
|
kinds: ["system"],
|
|
137415
|
-
systemEventKinds: ["device-command"]
|
|
137753
|
+
systemEventKinds: ["device-command", "alarm-disarmed"]
|
|
137416
137754
|
},
|
|
137417
137755
|
{
|
|
137418
137756
|
name: "deviceLabel",
|
|
@@ -146293,6 +146631,9 @@ exports.DoorbellStatusSchema = DoorbellStatusSchema;
|
|
|
146293
146631
|
exports.DraftKindSchema = DraftKindSchema;
|
|
146294
146632
|
exports.DraftSiteDeviceSchema = DraftSiteDeviceSchema;
|
|
146295
146633
|
exports.DraftSiteSchema = DraftSiteSchema;
|
|
146634
|
+
exports.EMAIL_IMAGE_MAX_COUNT = EMAIL_IMAGE_MAX_COUNT;
|
|
146635
|
+
exports.EMAIL_IMAGE_MAX_TOTAL_BYTES = EMAIL_IMAGE_MAX_TOTAL_BYTES;
|
|
146636
|
+
exports.EMAIL_IMAGE_SLOT = EMAIL_IMAGE_SLOT;
|
|
146296
146637
|
exports.EMBEDDING_MODEL_FAILED = EMBEDDING_MODEL_FAILED;
|
|
146297
146638
|
exports.EMBEDDING_REQUIREMENTS_FAILED = EMBEDDING_REQUIREMENTS_FAILED;
|
|
146298
146639
|
exports.EMBEDDING_REQUIREMENTS_UNAVAILABLE = EMBEDDING_REQUIREMENTS_UNAVAILABLE;
|
|
@@ -146335,6 +146676,7 @@ exports.EgressRateControlSchema = EgressRateControlSchema;
|
|
|
146335
146676
|
exports.EgressTranscodeRequestSchema = EgressTranscodeRequestSchema;
|
|
146336
146677
|
exports.EgressTranscodeSchema = EgressTranscodeSchema;
|
|
146337
146678
|
exports.ElementConfigStore = ElementConfigStore;
|
|
146679
|
+
exports.EmailImagePartSchema = EmailImagePartSchema;
|
|
146338
146680
|
exports.EmbeddingFailedModelSchema = EmbeddingFailedModelSchema;
|
|
146339
146681
|
exports.EmbeddingFailedRequirementSchema = EmbeddingFailedRequirementSchema;
|
|
146340
146682
|
exports.EmbeddingInfoSchema = EmbeddingInfoSchema;
|
|
@@ -148216,6 +148558,7 @@ exports.asJsonObject = require_sleep.asJsonObject;
|
|
|
148216
148558
|
exports.asNumber = require_sleep.asNumber;
|
|
148217
148559
|
exports.asRecordsError = require_sleep.asRecordsError;
|
|
148218
148560
|
exports.asString = require_sleep.asString;
|
|
148561
|
+
exports.assembleEmailMime = assembleEmailMime;
|
|
148219
148562
|
exports.assertDeviceOffers = require_sleep.assertDeviceOffers;
|
|
148220
148563
|
exports.assertInstanceUnused = assertInstanceUnused;
|
|
148221
148564
|
exports.assertOwnExportInstance = assertOwnExportInstance;
|
|
@@ -148274,6 +148617,7 @@ exports.buildNcTaxonomy = buildNcTaxonomy;
|
|
|
148274
148617
|
exports.buildNotificationTargetInstances = buildNotificationTargetInstances;
|
|
148275
148618
|
exports.buildPlusCatalogClassMap = buildPlusCatalogClassMap;
|
|
148276
148619
|
exports.buildPowerSwitch = buildPowerSwitch;
|
|
148620
|
+
exports.buildRawMime = buildRawMime;
|
|
148277
148621
|
exports.buildRepairPrompt = buildRepairPrompt;
|
|
148278
148622
|
exports.buildRoleScopes = buildRoleScopes;
|
|
148279
148623
|
exports.buildSecretRef = require_sleep.buildSecretRef;
|
|
@@ -148535,6 +148879,7 @@ exports.deviceHistoryCapability = deviceHistoryCapability;
|
|
|
148535
148879
|
exports.deviceIconKey = deviceIconKey;
|
|
148536
148880
|
exports.deviceManagerCapability = deviceManagerCapability;
|
|
148537
148881
|
exports.deviceMatchesProfile = deviceMatchesProfile;
|
|
148882
|
+
exports.deviceOffersActions = deviceOffersActions;
|
|
148538
148883
|
exports.deviceOpsCapability = require_sleep.deviceOpsCapability;
|
|
148539
148884
|
exports.deviceProviderCapability = deviceProviderCapability;
|
|
148540
148885
|
exports.deviceRefusalFromMessage = deviceRefusalFromMessage;
|
|
@@ -148950,6 +149295,7 @@ exports.markFieldEdited = markFieldEdited;
|
|
|
148950
149295
|
exports.markdownToHtmlLite = markdownToHtmlLite;
|
|
148951
149296
|
exports.markdownToText = markdownToText;
|
|
148952
149297
|
exports.maskUrlCredentials = require_sleep.maskUrlCredentials;
|
|
149298
|
+
exports.materializeEmailImages = materializeEmailImages;
|
|
148953
149299
|
exports.maxDurationMs = require_implemented_methods.maxDurationMs;
|
|
148954
149300
|
exports.mayReadLocation = mayReadLocation;
|
|
148955
149301
|
exports.mayWriteToLocation = mayWriteToLocation;
|