@codee-sh/medusa-plugin-automations 1.0.7 → 1.0.9
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/.medusa/server/src/admin/_chunks/{__admin-extensions__-Cc5RhzDh → __admin-extensions__-BV7n9V1I} +210 -120
- package/.medusa/server/src/admin/_chunks/{__admin-extensions__-BgrPyL-G → __admin-extensions__-BZrUHl9N} +211 -121
- package/.medusa/server/src/admin/_chunks/{base-config-D8uDn9uc → base-config-CbWD1XMk} +1 -1
- package/.medusa/server/src/admin/_chunks/{base-config-zK3z6k14 → base-config-D0IqhDVr} +1 -1
- package/.medusa/server/src/admin/index.js +1 -1
- package/.medusa/server/src/admin/index.mjs +1 -1
- package/.medusa/server/src/api/middlewares.js +1 -1
- package/.medusa/server/src/modules/mpn-automation/migrations/Migration20251222121805.js +14 -0
- package/.medusa/server/src/modules/mpn-automation/models/mpn_automation_trigger.js +2 -2
- package/.medusa/server/src/modules/mpn-automation/services/base-action-service.js +1 -1
- package/.medusa/server/src/modules/mpn-automation/services/email-action-service.js +20 -7
- package/.medusa/server/src/modules/mpn-automation/services/slack-action-service.js +27 -18
- package/.medusa/server/src/modules/mpn-automation/types/modules/index.js +148 -1
- package/.medusa/server/src/modules/mpn-automation/types/modules/inventory/inventory.js +48 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/order/helpers.js +28 -0
- package/.medusa/server/src/{templates/slack/product-variant → modules/mpn-automation/types/modules/order}/index.js +2 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/order/order.js +561 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product/helpers.js +9 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product/product.js +89 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-category/product-category.js +31 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-tag/product-tag.js +19 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-type/product-type.js +19 -2
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-variant/product-variant.js +51 -2
- package/.medusa/server/src/modules/mpn-automation/types/types.js +1 -1
- package/.medusa/server/src/providers/slack/service.js +26 -16
- package/.medusa/server/src/subscribers/inventory-level-updated.js +2 -2
- package/.medusa/server/src/subscribers/mpn.automation.action.email.executed.js +1 -2
- package/.medusa/server/src/subscribers/order-updated.js +36 -0
- package/.medusa/server/src/utils/types/index.js +1 -2
- package/.medusa/server/src/workflows/index.js +2 -1
- package/.medusa/server/src/workflows/inventory/steps/get-inventory-level-by-id.js +3 -3
- package/.medusa/server/src/workflows/mpn-automation/index.js +2 -2
- package/.medusa/server/src/workflows/mpn-automation/run-automation.js +53 -10
- package/.medusa/server/src/workflows/mpn-automation/steps/create-automation.js +1 -1
- package/.medusa/server/src/workflows/mpn-automation/steps/edit-automation.js +1 -1
- package/.medusa/server/src/workflows/mpn-automation/steps/index.js +3 -2
- package/.medusa/server/src/workflows/mpn-automation/steps/retrieve-automation-triggers-by-event.js +1 -1
- package/.medusa/server/src/workflows/mpn-automation/steps/run-automation-actions.js +1 -1
- package/.medusa/server/src/workflows/mpn-automation/steps/validate-trigger-throttle.js +78 -0
- package/.medusa/server/src/workflows/mpn-automation/steps/validate-triggers-rules.js +31 -0
- package/.medusa/server/src/workflows/mpn-automation/validate-triggers-by-event.js +38 -0
- package/.medusa/server/src/workflows/notifications/steps/send-slack.js +1 -1
- package/.medusa/server/src/workflows/order/get-order-by-id.js +23 -0
- package/.medusa/server/src/{templates/slack/product → workflows/order}/index.js +2 -2
- package/.medusa/server/src/workflows/order/steps/get-order-by-id.js +40 -0
- package/.medusa/server/src/{templates/slack/inventory-level → workflows/order/steps}/index.js +2 -2
- package/.medusa/server/src/workflows/product/steps/get-product-by-id.js +3 -3
- package/package.json +2 -2
- package/.medusa/server/src/templates/slack/inventory-level/inventory-level.js +0 -95
- package/.medusa/server/src/templates/slack/inventory-level/translations/en.json +0 -18
- package/.medusa/server/src/templates/slack/inventory-level/translations/index.js +0 -15
- package/.medusa/server/src/templates/slack/inventory-level/translations/pl.json +0 -18
- package/.medusa/server/src/templates/slack/product/product.js +0 -54
- package/.medusa/server/src/templates/slack/product/translations/en.json +0 -18
- package/.medusa/server/src/templates/slack/product/translations/index.js +0 -15
- package/.medusa/server/src/templates/slack/product/translations/pl.json +0 -13
- package/.medusa/server/src/templates/slack/product-variant/product-variant.js +0 -54
- package/.medusa/server/src/templates/slack/product-variant/translations/en.json +0 -18
- package/.medusa/server/src/templates/slack/product-variant/translations/index.js +0 -15
- package/.medusa/server/src/templates/slack/product-variant/translations/pl.json +0 -13
- package/.medusa/server/src/templates/slack/types.js +0 -3
- package/.medusa/server/src/workflows/mpn-automation/steps/validate-automation-triggers.js +0 -31
- package/.medusa/server/src/workflows/mpn-automation/validate-automation-triggers-by-event.js +0 -38
|
@@ -729,8 +729,14 @@ var NestedClose = (props) => {
|
|
|
729
729
|
keyName,
|
|
730
730
|
parentValue
|
|
731
731
|
});
|
|
732
|
-
if (
|
|
733
|
-
|
|
732
|
+
if (shouldExpandNodeInitially && collapsed === false) {
|
|
733
|
+
if (expands[expandKey] === void 0 && !shouldExpand) {
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
} else {
|
|
737
|
+
if (expands[expandKey] === void 0 && shouldExpand) {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
734
740
|
}
|
|
735
741
|
var len = Object.keys(value).length;
|
|
736
742
|
if (isExpanded || len === 0) {
|
|
@@ -1701,8 +1707,14 @@ var KeyValues = (props) => {
|
|
|
1701
1707
|
keyName,
|
|
1702
1708
|
parentValue
|
|
1703
1709
|
});
|
|
1704
|
-
if (
|
|
1705
|
-
|
|
1710
|
+
if (shouldExpandNodeInitially && collapsed === false) {
|
|
1711
|
+
if (expands[expandKey] === void 0 && !shouldExpand) {
|
|
1712
|
+
return null;
|
|
1713
|
+
}
|
|
1714
|
+
} else {
|
|
1715
|
+
if (expands[expandKey] === void 0 && shouldExpand) {
|
|
1716
|
+
return null;
|
|
1717
|
+
}
|
|
1706
1718
|
}
|
|
1707
1719
|
if (isExpanded) {
|
|
1708
1720
|
return null;
|
|
@@ -2290,7 +2302,7 @@ var JsonView = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
2290
2302
|
value,
|
|
2291
2303
|
children,
|
|
2292
2304
|
collapsed = false,
|
|
2293
|
-
shouldExpandNodeInitially
|
|
2305
|
+
shouldExpandNodeInitially,
|
|
2294
2306
|
indentWidth = 15,
|
|
2295
2307
|
displayObjectSize = true,
|
|
2296
2308
|
shortenTextAfterLength = 30,
|
|
@@ -2316,7 +2328,7 @@ var JsonView = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
2316
2328
|
value,
|
|
2317
2329
|
objectSortKeys,
|
|
2318
2330
|
indentWidth,
|
|
2319
|
-
shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially :
|
|
2331
|
+
shouldExpandNodeInitially: collapsed === false ? shouldExpandNodeInitially : void 0,
|
|
2320
2332
|
displayObjectSize,
|
|
2321
2333
|
collapsed,
|
|
2322
2334
|
enableClipboard,
|
|
@@ -5339,6 +5351,11 @@ function AutomationsGeneralForm({
|
|
|
5339
5351
|
React.useMemo(() => {
|
|
5340
5352
|
return (availableActionsData == null ? void 0 : availableActionsData.actions) || [];
|
|
5341
5353
|
}, [availableActionsData]);
|
|
5354
|
+
const triggerType = useWatch({
|
|
5355
|
+
control: form.control,
|
|
5356
|
+
name: "general.trigger_type"
|
|
5357
|
+
});
|
|
5358
|
+
const showIntervalField = triggerType === "event" || triggerType === "schedule";
|
|
5342
5359
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 max-w-2xl mx-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
5343
5360
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
5344
5361
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "name", className: "block", children: "Name" }),
|
|
@@ -5483,6 +5500,50 @@ function AutomationsGeneralForm({
|
|
|
5483
5500
|
] })
|
|
5484
5501
|
}
|
|
5485
5502
|
)
|
|
5503
|
+
] }),
|
|
5504
|
+
showIntervalField && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
5505
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5506
|
+
ui.Label,
|
|
5507
|
+
{
|
|
5508
|
+
htmlFor: "interval_seconds",
|
|
5509
|
+
className: "block",
|
|
5510
|
+
children: triggerType === "schedule" ? "Interval (seconds)" : "Throttle (seconds)"
|
|
5511
|
+
}
|
|
5512
|
+
),
|
|
5513
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5514
|
+
Controller,
|
|
5515
|
+
{
|
|
5516
|
+
name: "general.interval_seconds",
|
|
5517
|
+
control: form.control,
|
|
5518
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5519
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5520
|
+
ui.Input,
|
|
5521
|
+
{
|
|
5522
|
+
...field,
|
|
5523
|
+
type: "number",
|
|
5524
|
+
min: 0,
|
|
5525
|
+
placeholder: triggerType === "schedule" ? "Run every X seconds" : "Minimum seconds between executions",
|
|
5526
|
+
value: field.value ?? "",
|
|
5527
|
+
onChange: (e2) => {
|
|
5528
|
+
const value = e2.target.value;
|
|
5529
|
+
field.onChange(
|
|
5530
|
+
value === "" ? null : Number(value)
|
|
5531
|
+
);
|
|
5532
|
+
}
|
|
5533
|
+
}
|
|
5534
|
+
),
|
|
5535
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5536
|
+
ui.Text,
|
|
5537
|
+
{
|
|
5538
|
+
size: "small",
|
|
5539
|
+
className: "text-ui-fg-subtle",
|
|
5540
|
+
children: triggerType === "schedule" ? "How often to run this automation" : "Optional: Limit how often this automation can run for the same target (e.g., 3600 = max once per hour)"
|
|
5541
|
+
}
|
|
5542
|
+
),
|
|
5543
|
+
fieldState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: fieldState.error.message })
|
|
5544
|
+
] })
|
|
5545
|
+
}
|
|
5546
|
+
)
|
|
5486
5547
|
] })
|
|
5487
5548
|
] }) }) });
|
|
5488
5549
|
}
|
|
@@ -9128,7 +9189,7 @@ const baseAutomationFormSchema = objectType({
|
|
|
9128
9189
|
description: stringType().min(1, "Description is required").min(3, "Description must be at least 3 characters"),
|
|
9129
9190
|
trigger_type: enumType(["event", "schedule", "manual"]),
|
|
9130
9191
|
event_name: stringType().min(1, "Event name is required"),
|
|
9131
|
-
|
|
9192
|
+
interval_seconds: numberType().nullable(),
|
|
9132
9193
|
active: booleanType()
|
|
9133
9194
|
}),
|
|
9134
9195
|
rules: objectType({
|
|
@@ -9253,7 +9314,7 @@ function AutomationsCreateForm() {
|
|
|
9253
9314
|
description: "",
|
|
9254
9315
|
trigger_type: "event",
|
|
9255
9316
|
event_name: "",
|
|
9256
|
-
|
|
9317
|
+
interval_seconds: null,
|
|
9257
9318
|
active: false
|
|
9258
9319
|
},
|
|
9259
9320
|
rules: {
|
|
@@ -9272,7 +9333,7 @@ function AutomationsCreateForm() {
|
|
|
9272
9333
|
description: "",
|
|
9273
9334
|
trigger_type: "event",
|
|
9274
9335
|
event_name: "",
|
|
9275
|
-
|
|
9336
|
+
interval_seconds: null,
|
|
9276
9337
|
active: false
|
|
9277
9338
|
},
|
|
9278
9339
|
rules: {
|
|
@@ -9291,7 +9352,7 @@ function AutomationsCreateForm() {
|
|
|
9291
9352
|
description: data.general.description,
|
|
9292
9353
|
trigger_type: data.general.trigger_type,
|
|
9293
9354
|
event_name: data.general.event_name,
|
|
9294
|
-
|
|
9355
|
+
interval_seconds: data.general.interval_seconds,
|
|
9295
9356
|
active: data.general.active
|
|
9296
9357
|
};
|
|
9297
9358
|
await createAutomation({
|
|
@@ -17081,6 +17142,133 @@ function RuleValueInput({
|
|
|
17081
17142
|
}
|
|
17082
17143
|
);
|
|
17083
17144
|
}
|
|
17145
|
+
function RuleItem({
|
|
17146
|
+
control,
|
|
17147
|
+
index,
|
|
17148
|
+
eventAttributes,
|
|
17149
|
+
onRemove
|
|
17150
|
+
}) {
|
|
17151
|
+
const selectedAttributeValue = useWatch({
|
|
17152
|
+
control,
|
|
17153
|
+
name: `rules.items.${index}.attribute`
|
|
17154
|
+
});
|
|
17155
|
+
const operatorValue = useWatch({
|
|
17156
|
+
control,
|
|
17157
|
+
name: `rules.items.${index}.operator`
|
|
17158
|
+
});
|
|
17159
|
+
const selectedAttribute = selectedAttributeValue && eventAttributes.length ? eventAttributes.find(
|
|
17160
|
+
(attr) => attr.value === selectedAttributeValue
|
|
17161
|
+
) : null;
|
|
17162
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-4 border rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
17163
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col gap-2", children: [
|
|
17164
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17165
|
+
Controller,
|
|
17166
|
+
{
|
|
17167
|
+
name: `rules.items.${index}.attribute`,
|
|
17168
|
+
control,
|
|
17169
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17170
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Attribute" }),
|
|
17171
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17172
|
+
ui.Select,
|
|
17173
|
+
{
|
|
17174
|
+
value: field.value ?? "",
|
|
17175
|
+
onValueChange: (value) => {
|
|
17176
|
+
field.onChange(value);
|
|
17177
|
+
},
|
|
17178
|
+
children: [
|
|
17179
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "Select the attribute" }) }),
|
|
17180
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: eventAttributes.map((attribute, attrIndex) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17181
|
+
ui.Select.Item,
|
|
17182
|
+
{
|
|
17183
|
+
value: attribute.value || "",
|
|
17184
|
+
children: [
|
|
17185
|
+
attribute.label,
|
|
17186
|
+
" ",
|
|
17187
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-500", children: [
|
|
17188
|
+
"(",
|
|
17189
|
+
attribute.value,
|
|
17190
|
+
")"
|
|
17191
|
+
] })
|
|
17192
|
+
]
|
|
17193
|
+
},
|
|
17194
|
+
attribute.value || `attr-${index}-${attrIndex}`
|
|
17195
|
+
)) })
|
|
17196
|
+
]
|
|
17197
|
+
},
|
|
17198
|
+
`attribute-${index}-${eventAttributes.length}`
|
|
17199
|
+
),
|
|
17200
|
+
fieldState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: fieldState.error.message }),
|
|
17201
|
+
(selectedAttribute == null ? void 0 : selectedAttribute.description) && /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { className: "mt-1", children: selectedAttribute.description })
|
|
17202
|
+
] })
|
|
17203
|
+
}
|
|
17204
|
+
),
|
|
17205
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17206
|
+
Controller,
|
|
17207
|
+
{
|
|
17208
|
+
name: `rules.items.${index}.operator`,
|
|
17209
|
+
control,
|
|
17210
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Operator" }),
|
|
17212
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17213
|
+
ui.Select,
|
|
17214
|
+
{
|
|
17215
|
+
value: field.value ?? "",
|
|
17216
|
+
onValueChange: (value) => {
|
|
17217
|
+
field.onChange(value);
|
|
17218
|
+
},
|
|
17219
|
+
children: [
|
|
17220
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "Select the operator" }) }),
|
|
17221
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: OPERATOR_TYPES.map((operator, opIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17222
|
+
ui.Select.Item,
|
|
17223
|
+
{
|
|
17224
|
+
value: operator.value,
|
|
17225
|
+
children: operator.label
|
|
17226
|
+
},
|
|
17227
|
+
operator.value || `op-${opIndex}`
|
|
17228
|
+
)) })
|
|
17229
|
+
]
|
|
17230
|
+
},
|
|
17231
|
+
`operator-${index}-${eventAttributes.length}-${field.value ?? ""}`
|
|
17232
|
+
),
|
|
17233
|
+
fieldState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: fieldState.error.message })
|
|
17234
|
+
] })
|
|
17235
|
+
}
|
|
17236
|
+
),
|
|
17237
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17238
|
+
RuleValueInput,
|
|
17239
|
+
{
|
|
17240
|
+
control,
|
|
17241
|
+
name: `rules.items.${index}.rule_values.0.value`,
|
|
17242
|
+
operator: operatorValue
|
|
17243
|
+
}
|
|
17244
|
+
),
|
|
17245
|
+
(selectedAttribute == null ? void 0 : selectedAttribute.examples) && selectedAttribute.examples.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-0", children: [
|
|
17246
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-gray-600 mb-1", children: "Examples:" }),
|
|
17247
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: selectedAttribute.examples.map(
|
|
17248
|
+
(example, exampleIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17249
|
+
"span",
|
|
17250
|
+
{
|
|
17251
|
+
className: "inline-flex items-center px-2 py-1 rounded-md bg-gray-100 text-xs text-gray-700",
|
|
17252
|
+
children: example
|
|
17253
|
+
},
|
|
17254
|
+
`example-${index}-${exampleIndex}`
|
|
17255
|
+
)
|
|
17256
|
+
) })
|
|
17257
|
+
] })
|
|
17258
|
+
] }),
|
|
17259
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17260
|
+
ui.Button,
|
|
17261
|
+
{
|
|
17262
|
+
type: "button",
|
|
17263
|
+
variant: "secondary",
|
|
17264
|
+
size: "small",
|
|
17265
|
+
onClick: onRemove,
|
|
17266
|
+
className: "mt-2",
|
|
17267
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
17268
|
+
}
|
|
17269
|
+
)
|
|
17270
|
+
] }) });
|
|
17271
|
+
}
|
|
17084
17272
|
function AutomationsRulesForm({
|
|
17085
17273
|
form,
|
|
17086
17274
|
isOpen
|
|
@@ -17131,110 +17319,12 @@ function AutomationsRulesForm({
|
|
|
17131
17319
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 max-w-2xl mx-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
17132
17320
|
fields.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-500 text-center py-4", children: 'No rules added yet. Click "Add Item" to create a new rule.' }),
|
|
17133
17321
|
fields.map((field, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17134
|
-
|
|
17322
|
+
RuleItem,
|
|
17135
17323
|
{
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
Controller,
|
|
17141
|
-
{
|
|
17142
|
-
name: `rules.items.${index}.attribute`,
|
|
17143
|
-
control: form.control,
|
|
17144
|
-
render: ({ field: field2, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17145
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Attribute" }),
|
|
17146
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17147
|
-
ui.Select,
|
|
17148
|
-
{
|
|
17149
|
-
value: field2.value ?? "",
|
|
17150
|
-
onValueChange: (value) => {
|
|
17151
|
-
field2.onChange(value);
|
|
17152
|
-
},
|
|
17153
|
-
children: [
|
|
17154
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "Select the attribute" }) }),
|
|
17155
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: eventAttributes.map(
|
|
17156
|
-
(attribute, attrIndex) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17157
|
-
ui.Select.Item,
|
|
17158
|
-
{
|
|
17159
|
-
value: attribute.value || "ss",
|
|
17160
|
-
children: [
|
|
17161
|
-
attribute.label,
|
|
17162
|
-
" ",
|
|
17163
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-500", children: [
|
|
17164
|
-
"(",
|
|
17165
|
-
attribute.value,
|
|
17166
|
-
")"
|
|
17167
|
-
] })
|
|
17168
|
-
]
|
|
17169
|
-
},
|
|
17170
|
-
attribute.value || `attr-${index}-${attrIndex}`
|
|
17171
|
-
)
|
|
17172
|
-
) })
|
|
17173
|
-
]
|
|
17174
|
-
},
|
|
17175
|
-
`attribute-${index}-${eventAttributes.length}`
|
|
17176
|
-
),
|
|
17177
|
-
fieldState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: fieldState.error.message })
|
|
17178
|
-
] })
|
|
17179
|
-
}
|
|
17180
|
-
),
|
|
17181
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17182
|
-
Controller,
|
|
17183
|
-
{
|
|
17184
|
-
name: `rules.items.${index}.operator`,
|
|
17185
|
-
control: form.control,
|
|
17186
|
-
render: ({ field: field2, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17187
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Operator" }),
|
|
17188
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17189
|
-
ui.Select,
|
|
17190
|
-
{
|
|
17191
|
-
value: field2.value ?? "",
|
|
17192
|
-
onValueChange: (value) => {
|
|
17193
|
-
field2.onChange(value);
|
|
17194
|
-
},
|
|
17195
|
-
children: [
|
|
17196
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "Select the operator" }) }),
|
|
17197
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: OPERATOR_TYPES.map(
|
|
17198
|
-
(operator, opIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17199
|
-
ui.Select.Item,
|
|
17200
|
-
{
|
|
17201
|
-
value: operator.value,
|
|
17202
|
-
children: operator.label
|
|
17203
|
-
},
|
|
17204
|
-
operator.value || `op-${opIndex}`
|
|
17205
|
-
)
|
|
17206
|
-
) })
|
|
17207
|
-
]
|
|
17208
|
-
},
|
|
17209
|
-
`operator-${index}-${eventAttributes.length}-${field2.value ?? ""}`
|
|
17210
|
-
),
|
|
17211
|
-
fieldState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 text-sm", children: fieldState.error.message })
|
|
17212
|
-
] })
|
|
17213
|
-
}
|
|
17214
|
-
),
|
|
17215
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17216
|
-
RuleValueInput,
|
|
17217
|
-
{
|
|
17218
|
-
control: form.control,
|
|
17219
|
-
name: `rules.items.${index}.rule_values.0.value`,
|
|
17220
|
-
operator: form.watch(
|
|
17221
|
-
`rules.items.${index}.operator`
|
|
17222
|
-
)
|
|
17223
|
-
}
|
|
17224
|
-
)
|
|
17225
|
-
] }),
|
|
17226
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17227
|
-
ui.Button,
|
|
17228
|
-
{
|
|
17229
|
-
type: "button",
|
|
17230
|
-
variant: "secondary",
|
|
17231
|
-
size: "small",
|
|
17232
|
-
onClick: () => handleRemoveRule(index),
|
|
17233
|
-
className: "mt-2",
|
|
17234
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
17235
|
-
}
|
|
17236
|
-
)
|
|
17237
|
-
] })
|
|
17324
|
+
control: form.control,
|
|
17325
|
+
index,
|
|
17326
|
+
eventAttributes,
|
|
17327
|
+
onRemove: () => handleRemoveRule(index)
|
|
17238
17328
|
},
|
|
17239
17329
|
(field == null ? void 0 : field.id) ?? `rule-${index}`
|
|
17240
17330
|
)),
|
|
@@ -17254,7 +17344,7 @@ function AutomationsRulesForm({
|
|
|
17254
17344
|
] }) }) });
|
|
17255
17345
|
}
|
|
17256
17346
|
const templateLoaders = {
|
|
17257
|
-
BaseConfigComponent: () => Promise.resolve().then(() => require("./base-config-
|
|
17347
|
+
BaseConfigComponent: () => Promise.resolve().then(() => require("./base-config-CbWD1XMk"))
|
|
17258
17348
|
};
|
|
17259
17349
|
async function loadTemplateComponent(key) {
|
|
17260
17350
|
const loader = templateLoaders[key];
|
|
@@ -17565,7 +17655,7 @@ function AutomationsEditForm({
|
|
|
17565
17655
|
description: "",
|
|
17566
17656
|
trigger_type: "event",
|
|
17567
17657
|
event_name: "",
|
|
17568
|
-
|
|
17658
|
+
interval_seconds: null,
|
|
17569
17659
|
active: false
|
|
17570
17660
|
},
|
|
17571
17661
|
rules: {
|
|
@@ -17589,7 +17679,7 @@ function AutomationsEditForm({
|
|
|
17589
17679
|
description: trigger.description || "",
|
|
17590
17680
|
trigger_type: trigger.trigger_type || "event",
|
|
17591
17681
|
event_name: trigger.event_name || "",
|
|
17592
|
-
|
|
17682
|
+
interval_seconds: trigger.interval_seconds || null,
|
|
17593
17683
|
active: trigger.active || false
|
|
17594
17684
|
},
|
|
17595
17685
|
rules: {
|
|
@@ -17633,7 +17723,7 @@ function AutomationsEditForm({
|
|
|
17633
17723
|
description: "",
|
|
17634
17724
|
trigger_type: "event",
|
|
17635
17725
|
event_name: "",
|
|
17636
|
-
|
|
17726
|
+
interval_seconds: null,
|
|
17637
17727
|
active: false
|
|
17638
17728
|
},
|
|
17639
17729
|
rules: {
|
|
@@ -17654,7 +17744,7 @@ function AutomationsEditForm({
|
|
|
17654
17744
|
description: data.general.description,
|
|
17655
17745
|
trigger_type: data.general.trigger_type,
|
|
17656
17746
|
event_name: data.general.event_name,
|
|
17657
|
-
|
|
17747
|
+
interval_seconds: data.general.interval_seconds,
|
|
17658
17748
|
active: data.general.active
|
|
17659
17749
|
};
|
|
17660
17750
|
await editAutomation({
|
|
@@ -17897,7 +17987,7 @@ const AutomationsList = () => {
|
|
|
17897
17987
|
const columns = React.useMemo(
|
|
17898
17988
|
() => [
|
|
17899
17989
|
columnHelper.accessor("to", {
|
|
17900
|
-
header: "Name and
|
|
17990
|
+
header: "Name and descriptions",
|
|
17901
17991
|
cell: ({ row }) => {
|
|
17902
17992
|
var _a, _b, _c;
|
|
17903
17993
|
const tooltip = `Device (DB) ID:
|
|
@@ -17921,7 +18011,7 @@ const AutomationsList = () => {
|
|
|
17921
18011
|
}
|
|
17922
18012
|
)
|
|
17923
18013
|
] }),
|
|
17924
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
18014
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-normal text-xs max-w-[180px] min-w-[180px]", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row == null ? void 0 : row.original) == null ? void 0 : _c.description }) })
|
|
17925
18015
|
] }) });
|
|
17926
18016
|
}
|
|
17927
18017
|
}),
|