@openremote/or-rules 1.8.0-snapshot.20250725120001 → 1.8.0-snapshot.20250725123024

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +30 -30
  2. package/custom-elements.json +13 -13
  3. package/dist/umd/index.bundle.js +4744 -4744
  4. package/dist/umd/index.bundle.js.map +1 -1
  5. package/lib/flow-viewer/components/confirmation-dialog.js +24 -61
  6. package/lib/flow-viewer/components/connection-container.js +1 -35
  7. package/lib/flow-viewer/components/connection-line.js +28 -117
  8. package/lib/flow-viewer/components/context-menu.js +45 -140
  9. package/lib/flow-viewer/components/editor-workspace.js +20 -282
  10. package/lib/flow-viewer/components/flow-editor.js +47 -160
  11. package/lib/flow-viewer/components/flow-node-socket.js +31 -146
  12. package/lib/flow-viewer/components/flow-node.js +29 -192
  13. package/lib/flow-viewer/components/internal-picker.js +54 -271
  14. package/lib/flow-viewer/components/node-menu-item.js +32 -132
  15. package/lib/flow-viewer/components/node-panel.js +60 -104
  16. package/lib/flow-viewer/components/notification-dialog.js +23 -55
  17. package/lib/flow-viewer/components/popup-modal.js +54 -113
  18. package/lib/flow-viewer/components/rule-browser.js +30 -119
  19. package/lib/flow-viewer/components/selectable-element.js +1 -71
  20. package/lib/flow-viewer/components/selection-box.js +15 -119
  21. package/lib/flow-viewer/components/top-bar.js +49 -116
  22. package/lib/flow-viewer/components/workspace-contextmenu-options.js +5 -128
  23. package/lib/flow-viewer/components/writable-dropdown.js +5 -51
  24. package/lib/flow-viewer/converters/node-converter.js +1 -10
  25. package/lib/flow-viewer/flow-viewer.js +1 -19
  26. package/lib/flow-viewer/models/camera.js +1 -2
  27. package/lib/flow-viewer/models/context-menu-button.js +1 -2
  28. package/lib/flow-viewer/models/light-node-collection.js +1 -2
  29. package/lib/flow-viewer/models/status.js +1 -8
  30. package/lib/flow-viewer/node-structure/copy.machine.js +1 -34
  31. package/lib/flow-viewer/node-structure/identity.assigner.js +1 -10
  32. package/lib/flow-viewer/node-structure/identity.dom.link.js +1 -4
  33. package/lib/flow-viewer/node-structure/index.js +1 -5
  34. package/lib/flow-viewer/node-structure/socket.type.matcher.js +1 -50
  35. package/lib/flow-viewer/node-structure/utils.js +1 -109
  36. package/lib/flow-viewer/services/copy-paste-manager.js +1 -59
  37. package/lib/flow-viewer/services/exporter.js +1 -67
  38. package/lib/flow-viewer/services/input.js +1 -80
  39. package/lib/flow-viewer/services/integration.js +1 -27
  40. package/lib/flow-viewer/services/modal.js +8 -29
  41. package/lib/flow-viewer/services/project.js +1 -222
  42. package/lib/flow-viewer/services/shortcuts.js +1 -63
  43. package/lib/flow-viewer/styles/editor-workspace-style.js +53 -55
  44. package/lib/flow-viewer/styles/flow-node-style.js +93 -95
  45. package/lib/flow-viewer/styles/picker-styles.js +29 -31
  46. package/lib/flow-viewer/utils.js +1 -49
  47. package/lib/index.js +56 -953
  48. package/lib/json-viewer/forms/or-rule-form-alarm.js +18 -91
  49. package/lib/json-viewer/forms/or-rule-form-email-message.js +12 -51
  50. package/lib/json-viewer/forms/or-rule-form-localized.js +43 -269
  51. package/lib/json-viewer/forms/or-rule-form-push-notification.js +63 -152
  52. package/lib/json-viewer/forms/or-rule-form-webhook.js +101 -296
  53. package/lib/json-viewer/modals/or-rule-alarm-modal.js +17 -173
  54. package/lib/json-viewer/modals/or-rule-notification-modal.js +11 -196
  55. package/lib/json-viewer/modals/or-rule-radial-modal.js +17 -142
  56. package/lib/json-viewer/modals/or-rule-webhook-modal.js +8 -78
  57. package/lib/json-viewer/or-rule-action-alarm.js +5 -97
  58. package/lib/json-viewer/or-rule-action-attribute.js +33 -235
  59. package/lib/json-viewer/or-rule-action-notification.js +56 -465
  60. package/lib/json-viewer/or-rule-action-webhook.js +18 -49
  61. package/lib/json-viewer/or-rule-asset-query.js +126 -849
  62. package/lib/json-viewer/or-rule-condition.js +29 -216
  63. package/lib/json-viewer/or-rule-json-viewer.js +34 -393
  64. package/lib/json-viewer/or-rule-then-otherwise.js +113 -609
  65. package/lib/json-viewer/or-rule-trigger-query.js +57 -227
  66. package/lib/json-viewer/or-rule-when.js +126 -343
  67. package/lib/or-rule-group-viewer.js +12 -106
  68. package/lib/or-rule-text-viewer.js +22 -133
  69. package/lib/or-rule-tree.js +57 -601
  70. package/lib/or-rule-validity.js +62 -373
  71. package/lib/or-rule-viewer.js +81 -361
  72. package/lib/style.js +64 -89
  73. package/package.json +11 -11
@@ -1,235 +1,33 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- import { css, html, LitElement } from "lit";
17
- import { customElement, property } from "lit/decorators.js";
18
- import { getAssetIdsFromQuery, getAssetTypeFromQuery } from "../index";
19
- import { AssetModelUtil } from "@openremote/model";
20
- import { Util } from "@openremote/core";
21
- import "@openremote/or-attribute-input";
22
- import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
23
- import i18next from "i18next";
24
- import { OrRulesJsonRuleChangedEvent } from "./or-rule-json-viewer";
25
- import { translate } from "@openremote/or-translate";
26
- import { ifDefined } from "lit/directives/if-defined.js";
27
- import { when } from "lit/directives/when.js";
28
- // language=CSS
29
- const style = css `
30
- :host {
31
- display: flex;
32
- align-items: center;
33
-
34
- flex-wrap: wrap;
35
- }
36
-
37
- :host > * {
38
- margin: 0 3px 6px;
39
- }
40
-
41
- .min-width {
42
- min-width: 200px;
43
- }
44
- `;
45
- let OrRuleActionAttribute = class OrRuleActionAttribute extends translate(i18next)(LitElement) {
46
- static get styles() {
47
- return style;
48
- }
49
- shouldUpdate(_changedProperties) {
50
- if (_changedProperties.has("action")) {
51
- this._assets = undefined;
52
- }
53
- return super.shouldUpdate(_changedProperties);
54
- }
55
- refresh() {
56
- // Clear assets
57
- this._assets = undefined;
58
- }
59
- _getAssetType() {
60
- if (!this.action.target) {
61
- return;
62
- }
63
- const query = this.action.target.assets ? this.action.target.assets : this.action.target.matchedAssets ? this.action.target.matchedAssets : undefined;
64
- return query ? getAssetTypeFromQuery(query) : undefined;
65
- }
66
- render() {
67
- if (!this.action.target) {
68
- return html ``;
69
- }
70
- const assetType = this._getAssetType();
71
- if (!assetType) {
72
- return html ``;
73
- }
74
- const query = this.action.target.assets ? this.action.target.assets : this.action.target.matchedAssets ? this.action.target.matchedAssets : undefined;
75
- const assetDescriptor = this.assetInfos ? this.assetInfos.find((assetTypeInfo) => assetTypeInfo.assetDescriptor.name === assetType) : undefined;
76
- if (!assetDescriptor) {
77
- return html ``;
78
- }
79
- if (!this._assets) {
80
- this.loadAssets(assetType);
81
- }
82
- // TODO: Add multiselect support
83
- const ids = getAssetIdsFromQuery(query);
84
- const idValue = ids && ids.length > 0 ? ids[0] : "*";
85
- const idOptions = [
86
- ["*", i18next.t("matched")]
87
- ];
88
- let searchProvider;
89
- return html `
90
-
91
- <!-- Show SELECT input with 'loading' until the assets are retrieved -->
92
- ${when((!this._assets), () => html `
93
- <or-mwc-input id="matchSelect" class="min-width" type="${InputType.SELECT}" .readonly="${true}" .label="${i18next.t('loading')}"></or-mwc-input>
94
- `, () => {
95
- var _a, _b, _c;
96
- // Set list of displayed assets, and filtering assets out if needed.
97
- // If <= 25 assets: display everything
98
- // If between 25 and 100 assets: display everything with search functionality
99
- // If > 100 assets: only display if in line with search input
100
- if (this._assets.length <= 25) {
101
- idOptions.push(...this._assets.map((asset) => [asset.id, asset.name]));
102
- }
103
- else {
104
- searchProvider = (search) => __awaiter(this, void 0, void 0, function* () {
105
- var _a;
106
- if (search) {
107
- return this._assets.filter((asset) => { var _a; return (_a = asset.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search.toLowerCase()); }).map((asset) => [asset.id, asset.name]);
108
- }
109
- else if (this._assets.length <= 100) {
110
- idOptions.push(...this._assets.map((asset) => [asset.id, asset.name]));
111
- return idOptions;
112
- }
113
- else {
114
- const asset = (_a = this._assets) === null || _a === void 0 ? void 0 : _a.find((asset) => asset.id == idValue);
115
- if (asset && idOptions.find(([id, _value]) => id == asset.id) == undefined) {
116
- idOptions.push([asset.id, asset.name]); // add selected asset if there is one.
117
- }
118
- return idOptions;
119
- }
120
- });
121
- }
122
- // Get selected asset and its descriptors
123
- const asset = idValue && idValue !== "*" ? this._assets.find(a => a.id === idValue) : undefined;
124
- const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(assetType, this.action.attributeName, asset && asset.attributes && this.action.attributeName ? asset.attributes[this.action.attributeName] : undefined);
125
- // Only RW attributes can be used in actions
126
- let attributes = [];
127
- if (asset && asset.attributes) {
128
- attributes = Object.values(asset.attributes)
129
- .map((attr) => {
130
- const label = Util.getAttributeLabel(attr, descriptors[0], assetType, false);
131
- return [attr.name, label];
132
- });
133
- }
134
- else if (assetDescriptor) {
135
- const assetTypeInfo = AssetModelUtil.getAssetTypeInfo(assetDescriptor);
136
- attributes =
137
- !assetTypeInfo || !assetTypeInfo.attributeDescriptors
138
- ? []
139
- : assetTypeInfo.attributeDescriptors.map((ad) => {
140
- const label = Util.getAttributeLabel(ad, descriptors[0], assetType, false);
141
- return [ad.name, label];
142
- });
143
- }
144
- attributes.sort(Util.sortByString((attr) => attr[1]));
145
- let attributeInput;
146
- if (this.action.attributeName) {
147
- const label = descriptors[1] && (descriptors[1].name === "boolean" /* WellknownValueTypes.BOOLEAN */) ? "" : i18next.t("value");
148
- let inputType;
149
- if ((_b = (_a = descriptors[0]) === null || _a === void 0 ? void 0 : _a.format) === null || _b === void 0 ? void 0 : _b.asSlider)
150
- inputType = InputType.NUMBER;
151
- attributeInput = html `<or-attribute-input ?compact=${descriptors[1] && (descriptors[1].name === "GEO_JSONPoint" /* WellknownValueTypes.GEOJSONPOINT */)} .inputType="${ifDefined(inputType)}" @or-attribute-input-changed="${(ev) => this.setActionAttributeValue(ev.detail.value)}" .customProvider="${(_c = this.config) === null || _c === void 0 ? void 0 : _c.inputProvider}" .label="${label}" .assetType="${assetType}" .attributeDescriptor="${descriptors[0]}" .attributeValueDescriptor="${descriptors[1]}" .value="${this.action.value}" .readonly="${this.readonly || false}"></or-attribute-input>`;
152
- }
153
- return html `
154
- <or-mwc-input id="matchSelect" class="min-width" .label="${i18next.t("asset")}" .type="${InputType.SELECT}"
155
- .options="${idOptions}" .searchProvider="${searchProvider}" .value="${idValue}" .readonly="${this.readonly || false}"
156
- @or-mwc-input-changed="${(e) => { this._assetId = (e.detail.value); this.refresh(); }}"
157
- ></or-mwc-input>
158
- ${attributes.length > 0 ? html `
159
- <or-mwc-input id="attributeSelect" class="min-width" .label="${i18next.t("attribute")}" .type="${InputType.SELECT}" @or-mwc-input-changed="${(e) => this.setActionAttributeName(e.detail.value)}" .readonly="${this.readonly || false}" ?searchable="${(attributes.length >= 25)}" .options="${attributes}" .value="${this.action.attributeName}"></or-mwc-input>
160
- ${attributeInput}
161
- ` : html `
162
- <or-translate value="No attributes with write permission"></or-translate>
163
- `}
164
- `;
165
- })}
166
- `;
167
- }
168
- set _assetId(assetId) {
169
- const assetType = this._getAssetType();
170
- if (assetId === "*") {
171
- this.action.target.assets = undefined;
172
- this.action.target = {
173
- matchedAssets: {
174
- types: [
175
- assetType || ""
176
- ]
177
- }
178
- };
179
- }
180
- else {
181
- this.action.target.matchedAssets = undefined;
182
- this.action.target = {
183
- assets: {
184
- ids: [
185
- assetId
186
- ],
187
- types: [
188
- assetType || ""
189
- ]
190
- }
191
- };
192
- }
193
- this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
194
- this.requestUpdate();
195
- }
196
- setActionAttributeName(name) {
197
- this.action.attributeName = name;
198
- this.action.value = undefined;
199
- this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
200
- this.requestUpdate();
201
- }
202
- setActionAttributeValue(value) {
203
- this.action.value = value;
204
- this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
205
- this.requestUpdate();
206
- }
207
- loadAssets(type) {
208
- this.assetProvider(type).then(assets => {
209
- this._assets = assets;
210
- });
211
- }
212
- };
213
- __decorate([
214
- property({ type: Object, attribute: false })
215
- ], OrRuleActionAttribute.prototype, "action", void 0);
216
- __decorate([
217
- property({ type: Object, attribute: false })
218
- ], OrRuleActionAttribute.prototype, "targetTypeMap", void 0);
219
- __decorate([
220
- property({ type: Object })
221
- ], OrRuleActionAttribute.prototype, "config", void 0);
222
- __decorate([
223
- property({ type: Object })
224
- ], OrRuleActionAttribute.prototype, "assetInfos", void 0);
225
- __decorate([
226
- property({ type: Object })
227
- ], OrRuleActionAttribute.prototype, "assetProvider", void 0);
228
- __decorate([
229
- property({ type: Array, attribute: false })
230
- ], OrRuleActionAttribute.prototype, "_assets", void 0);
231
- OrRuleActionAttribute = __decorate([
232
- customElement("or-rule-action-attribute")
233
- ], OrRuleActionAttribute);
234
- export { OrRuleActionAttribute };
235
- //# sourceMappingURL=or-rule-action-attribute.js.map
1
+ var __decorate=this&&this.__decorate||function(t,e,i,s){var r,a=arguments.length,o=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o},__awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(r,a){function o(t){try{u(s.next(t))}catch(t){a(t)}}function n(t){try{u(s.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?r(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(o,n)}u((s=s.apply(t,e||[])).next())})};import{css as t,html as e,LitElement as i}from"lit";import{customElement as s,property as r}from"lit/decorators.js";import{getAssetIdsFromQuery as a,getAssetTypeFromQuery as o}from"../index";import{AssetModelUtil as n}from"@openremote/model";import{Util as u}from"@openremote/core";import"@openremote/or-attribute-input";import{InputType as c}from"@openremote/or-mwc-components/or-mwc-input";import l from"i18next";import{OrRulesJsonRuleChangedEvent as d}from"./or-rule-json-viewer";import{translate as h}from"@openremote/or-translate";import{ifDefined as p}from"lit/directives/if-defined.js";import{when as m}from"lit/directives/when.js";let style=t`
2
+ :host {
3
+ display: flex;
4
+ align-items: center;
5
+
6
+ flex-wrap: wrap;
7
+ }
8
+
9
+ :host > * {
10
+ margin: 0 3px 6px;
11
+ }
12
+
13
+ .min-width {
14
+ min-width: 200px;
15
+ }
16
+ `,OrRuleActionAttribute=class extends h(l)(i){static get styles(){return style}shouldUpdate(t){return t.has("action")&&(this._assets=void 0),super.shouldUpdate(t)}refresh(){this._assets=void 0}_getAssetType(){if(!this.action.target)return;let t=this.action.target.assets?this.action.target.assets:this.action.target.matchedAssets?this.action.target.matchedAssets:void 0;return t?o(t):void 0}render(){let t;if(!this.action.target)return e``;let i=this._getAssetType();if(!i)return e``;let s=this.action.target.assets?this.action.target.assets:this.action.target.matchedAssets?this.action.target.matchedAssets:void 0,r=this.assetInfos?this.assetInfos.find(t=>t.assetDescriptor.name===i):void 0;if(!r)return e``;this._assets||this.loadAssets(i);let o=a(s),d=o&&o.length>0?o[0]:"*",h=[["*",l.t("matched")]];return e`
17
+
18
+ <!-- Show SELECT input with 'loading' until the assets are retrieved -->
19
+ ${m(!this._assets,()=>e`
20
+ <or-mwc-input id="matchSelect" class="min-width" type="${c.SELECT}" .readonly="${!0}" .label="${l.t("loading")}"></or-mwc-input>
21
+ `,()=>{var s,a,o;let m;this._assets.length<=25?h.push(...this._assets.map(t=>[t.id,t.name])):t=t=>__awaiter(this,void 0,void 0,function*(){var e;if(t)return this._assets.filter(e=>{var i;return null==(i=e.name)?void 0:i.toLowerCase().includes(t.toLowerCase())}).map(t=>[t.id,t.name]);if(this._assets.length<=100)return h.push(...this._assets.map(t=>[t.id,t.name])),h;{let t=null==(e=this._assets)?void 0:e.find(t=>t.id==d);return t&&void 0==h.find(([e,i])=>e==t.id)&&h.push([t.id,t.name]),h}});let b=d&&"*"!==d?this._assets.find(t=>t.id===d):void 0,v=n.getAttributeAndValueDescriptors(i,this.action.attributeName,b&&b.attributes&&this.action.attributeName?b.attributes[this.action.attributeName]:void 0),f=[];if(b&&b.attributes)f=Object.values(b.attributes).map(t=>{let e=u.getAttributeLabel(t,v[0],i,!1);return[t.name,e]});else if(r){let t=n.getAssetTypeInfo(r);f=t&&t.attributeDescriptors?t.attributeDescriptors.map(t=>{let e=u.getAttributeLabel(t,v[0],i,!1);return[t.name,e]}):[]}if(f.sort(u.sortByString(t=>t[1])),this.action.attributeName){let t,r=v[1]&&"boolean"===v[1].name?"":l.t("value");(null==(a=null==(s=v[0])?void 0:s.format)?void 0:a.asSlider)&&(t=c.NUMBER),m=e`<or-attribute-input ?compact=${v[1]&&"GEO_JSONPoint"===v[1].name} .inputType="${p(t)}" @or-attribute-input-changed="${t=>this.setActionAttributeValue(t.detail.value)}" .customProvider="${null==(o=this.config)?void 0:o.inputProvider}" .label="${r}" .assetType="${i}" .attributeDescriptor="${v[0]}" .attributeValueDescriptor="${v[1]}" .value="${this.action.value}" .readonly="${this.readonly||!1}"></or-attribute-input>`}return e`
22
+ <or-mwc-input id="matchSelect" class="min-width" .label="${l.t("asset")}" .type="${c.SELECT}"
23
+ .options="${h}" .searchProvider="${t}" .value="${d}" .readonly="${this.readonly||!1}"
24
+ @or-mwc-input-changed="${t=>{this._assetId=t.detail.value,this.refresh()}}"
25
+ ></or-mwc-input>
26
+ ${f.length>0?e`
27
+ <or-mwc-input id="attributeSelect" class="min-width" .label="${l.t("attribute")}" .type="${c.SELECT}" @or-mwc-input-changed="${t=>this.setActionAttributeName(t.detail.value)}" .readonly="${this.readonly||!1}" ?searchable="${f.length>=25}" .options="${f}" .value="${this.action.attributeName}"></or-mwc-input>
28
+ ${m}
29
+ `:e`
30
+ <or-translate value="No attributes with write permission"></or-translate>
31
+ `}
32
+ `})}
33
+ `}set _assetId(t){let e=this._getAssetType();"*"===t?(this.action.target.assets=void 0,this.action.target={matchedAssets:{types:[e||""]}}):(this.action.target.matchedAssets=void 0,this.action.target={assets:{ids:[t],types:[e||""]}}),this.dispatchEvent(new d),this.requestUpdate()}setActionAttributeName(t){this.action.attributeName=t,this.action.value=void 0,this.dispatchEvent(new d),this.requestUpdate()}setActionAttributeValue(t){this.action.value=t,this.dispatchEvent(new d),this.requestUpdate()}loadAssets(t){this.assetProvider(t).then(t=>{this._assets=t})}};__decorate([r({type:Object,attribute:!1})],OrRuleActionAttribute.prototype,"action",void 0),__decorate([r({type:Object,attribute:!1})],OrRuleActionAttribute.prototype,"targetTypeMap",void 0),__decorate([r({type:Object})],OrRuleActionAttribute.prototype,"config",void 0),__decorate([r({type:Object})],OrRuleActionAttribute.prototype,"assetInfos",void 0),__decorate([r({type:Object})],OrRuleActionAttribute.prototype,"assetProvider",void 0),__decorate([r({type:Array,attribute:!1})],OrRuleActionAttribute.prototype,"_assets",void 0),OrRuleActionAttribute=__decorate([s("or-rule-action-attribute")],OrRuleActionAttribute);export{OrRuleActionAttribute};