@codee-sh/medusa-plugin-automations 1.0.3 → 1.0.5
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__-rqdPN7M1 → __admin-extensions__-BD2AvjDH} +76 -66
- package/.medusa/server/src/admin/_chunks/{__admin-extensions__-DIB2k6nJ → __admin-extensions__-BxUQA9oD} +76 -66
- package/.medusa/server/src/admin/_chunks/{base-config-DbRWuXsL → base-config-ON0ZG0Je} +2 -3
- package/.medusa/server/src/admin/_chunks/{base-config-ro-vFPBg → base-config-XI6iR6Jp} +2 -3
- package/.medusa/server/src/admin/index.js +1 -1
- package/.medusa/server/src/admin/index.mjs +1 -1
- package/.medusa/server/src/api/admin/mpn/automations/available-actions/route.js +4 -2
- package/.medusa/server/src/api/admin/mpn/automations/rules/route.js +1 -1
- package/.medusa/server/src/hooks/api/automations-actions/automations-actions.js +1 -3
- package/.medusa/server/src/hooks/api/automations-rules/automations-rules.js +1 -3
- package/.medusa/server/src/hooks/api/available-actions/actions.js +5 -2
- package/.medusa/server/src/hooks/api/available-events/events.js +1 -1
- package/.medusa/server/src/modules/mpn-automation/services/base-action-service.js +98 -0
- package/.medusa/server/src/modules/mpn-automation/services/email-action-service.js +81 -0
- package/.medusa/server/src/modules/mpn-automation/services/index.js +8 -2
- package/.medusa/server/src/modules/mpn-automation/services/service.js +288 -42
- package/.medusa/server/src/modules/mpn-automation/services/slack-action-service.js +48 -0
- package/.medusa/server/src/modules/mpn-automation/types/index.js +2 -1
- package/.medusa/server/src/modules/mpn-automation/types/modules/index.js +96 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/inventory/index.js +18 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/inventory/inventory.js +56 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product/index.js +18 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product/product.js +50 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-variant/index.js +18 -0
- package/.medusa/server/src/modules/mpn-automation/types/modules/product-variant/product-variant.js +30 -0
- package/.medusa/server/src/modules/mpn-automation/types/types.js +2 -136
- package/.medusa/server/src/providers/slack/service.js +6 -58
- package/.medusa/server/src/subscribers/inventory-level-updated.js +2 -1
- package/.medusa/server/src/subscribers/inventory-reservation-item-updated.js +3 -3
- package/.medusa/server/src/subscribers/mpn.automation.action.email.executed.js +6 -5
- package/.medusa/server/src/subscribers/mpn.automation.action.slack.executed.js +13 -9
- package/.medusa/server/src/subscribers/order-placed.js +9 -106
- package/.medusa/server/src/subscribers/product-updated.js +45 -0
- package/.medusa/server/src/subscribers/product-variant-updated.js +45 -0
- package/.medusa/server/src/templates/slack/inventory-level/index.js +18 -0
- package/.medusa/server/src/templates/slack/inventory-level/inventory-level.js +95 -0
- package/.medusa/server/src/templates/slack/inventory-level/translations/en.json +18 -0
- package/.medusa/server/src/templates/slack/inventory-level/translations/index.js +15 -0
- package/.medusa/server/src/templates/slack/inventory-level/translations/pl.json +18 -0
- package/.medusa/server/src/templates/slack/product/index.js +18 -0
- package/.medusa/server/src/templates/slack/product/product.js +55 -0
- package/.medusa/server/src/templates/slack/product/translations/en.json +18 -0
- package/.medusa/server/src/templates/slack/product/translations/index.js +15 -0
- package/.medusa/server/src/templates/slack/product/translations/pl.json +13 -0
- package/.medusa/server/src/templates/slack/product-variant/index.js +18 -0
- package/.medusa/server/src/templates/slack/product-variant/product-variant.js +55 -0
- package/.medusa/server/src/templates/slack/product-variant/translations/en.json +18 -0
- package/.medusa/server/src/templates/slack/product-variant/translations/index.js +15 -0
- package/.medusa/server/src/templates/slack/product-variant/translations/pl.json +13 -0
- package/.medusa/server/src/templates/slack/types.js +3 -0
- package/.medusa/server/src/utils/i18n/i18n.js +127 -0
- package/.medusa/server/src/utils/i18n/index.js +18 -0
- package/.medusa/server/src/utils/index.js +2 -1
- package/.medusa/server/src/utils/types/index.js +3 -3
- package/.medusa/server/src/utils/validate-rules.js +1 -1
- package/.medusa/server/src/workflows/index.js +3 -1
- package/.medusa/server/src/workflows/inventory/steps/get-inventory-level-by-id.js +26 -6
- package/.medusa/server/src/workflows/mpn-automation/index.js +3 -2
- package/.medusa/server/src/workflows/mpn-automation/run-automation.js +2 -1
- package/.medusa/server/src/workflows/mpn-automation/{send-email-action.js → run-email-action.js} +8 -7
- package/.medusa/server/src/workflows/mpn-automation/run-slack-action.js +67 -0
- package/.medusa/server/src/workflows/mpn-automation/steps/edit-automation-actions.js +16 -5
- 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 +3 -2
- package/.medusa/server/src/workflows/notifications/send-email.js +2 -1
- package/.medusa/server/src/workflows/notifications/send-slack.js +2 -1
- package/.medusa/server/src/workflows/notifications/steps/send-email.js +21 -8
- package/.medusa/server/src/workflows/notifications/steps/send-slack.js +25 -5
- package/.medusa/server/src/workflows/product/get-product-by-id.js +23 -0
- package/.medusa/server/src/workflows/product/index.js +18 -0
- package/.medusa/server/src/workflows/product/steps/get-product-by-id.js +80 -0
- package/.medusa/server/src/workflows/product/steps/index.js +18 -0
- package/.medusa/server/src/workflows/product-variant/get-product-variant-by-id.js +23 -0
- package/.medusa/server/src/workflows/product-variant/index.js +18 -0
- package/.medusa/server/src/workflows/product-variant/steps/get-product-variant-by-id.js +63 -0
- package/.medusa/server/src/workflows/product-variant/steps/index.js +18 -0
- package/README.md +7 -0
- package/package.json +8 -4
- package/.medusa/server/src/modules/mpn-automation/actions-handlers/base-action-handler.js +0 -32
- package/.medusa/server/src/modules/mpn-automation/actions-handlers/email-action-handler.js +0 -71
- package/.medusa/server/src/modules/mpn-automation/actions-handlers/index.js +0 -10
- package/.medusa/server/src/modules/mpn-automation/actions-handlers/slack-action-handler.js +0 -43
- package/.medusa/server/src/workflows/mpn-automation/send-slack-action.js +0 -69
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlackActionHandler = void 0;
|
|
4
|
-
const base_action_handler_1 = require("./base-action-handler");
|
|
5
|
-
class SlackActionHandler extends base_action_handler_1.BaseActionHandler {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.id = "slack";
|
|
9
|
-
this.label = "Slack";
|
|
10
|
-
this.fields = [
|
|
11
|
-
{
|
|
12
|
-
name: "templateName",
|
|
13
|
-
key: "templateName",
|
|
14
|
-
label: "Template Name",
|
|
15
|
-
type: "select",
|
|
16
|
-
required: true,
|
|
17
|
-
options: [
|
|
18
|
-
{
|
|
19
|
-
label: "Inventory Level",
|
|
20
|
-
value: "inventory-level",
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
defaultValue: "inventory-level",
|
|
24
|
-
},
|
|
25
|
-
// {
|
|
26
|
-
// name: "webhook_url",
|
|
27
|
-
// key: "webhook_url",
|
|
28
|
-
// label: "Webhook URL",
|
|
29
|
-
// type: "text" as const,
|
|
30
|
-
// required: true,
|
|
31
|
-
// },
|
|
32
|
-
// {
|
|
33
|
-
// name: "admin_url",
|
|
34
|
-
// key: "admin_url",
|
|
35
|
-
// label: "Admin URL",
|
|
36
|
-
// type: "text" as const,
|
|
37
|
-
// required: true,
|
|
38
|
-
// }
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.SlackActionHandler = SlackActionHandler;
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2stYWN0aW9uLWhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9tcG4tYXV0b21hdGlvbi9hY3Rpb25zLWhhbmRsZXJzL3NsYWNrLWFjdGlvbi1oYW5kbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLCtEQUF5RDtBQUV6RCxNQUFhLGtCQUFtQixTQUFRLHVDQUFpQjtJQUF6RDs7UUFDRSxPQUFFLEdBQUcsT0FBTyxDQUFBO1FBQ1osVUFBSyxHQUFHLE9BQU8sQ0FBQTtRQUVmLFdBQU0sR0FBa0I7WUFDdEI7Z0JBQ0UsSUFBSSxFQUFFLGNBQWM7Z0JBQ3BCLEdBQUcsRUFBRSxjQUFjO2dCQUNuQixLQUFLLEVBQUUsZUFBZTtnQkFDdEIsSUFBSSxFQUFFLFFBQWlCO2dCQUN2QixRQUFRLEVBQUUsSUFBSTtnQkFDZCxPQUFPLEVBQUU7b0JBQ1A7d0JBQ0UsS0FBSyxFQUFFLGlCQUFpQjt3QkFDeEIsS0FBSyxFQUFFLGlCQUFpQjtxQkFDekI7aUJBQ0Y7Z0JBQ0QsWUFBWSxFQUFFLGlCQUFpQjthQUNoQztZQUNELElBQUk7WUFDSix5QkFBeUI7WUFDekIsd0JBQXdCO1lBQ3hCLDBCQUEwQjtZQUMxQiwyQkFBMkI7WUFDM0Isb0JBQW9CO1lBQ3BCLEtBQUs7WUFDTCxJQUFJO1lBQ0osdUJBQXVCO1lBQ3ZCLHNCQUFzQjtZQUN0Qix3QkFBd0I7WUFDeEIsMkJBQTJCO1lBQzNCLG9CQUFvQjtZQUNwQixJQUFJO1NBQ0wsQ0FBQTtJQUNILENBQUM7Q0FBQTtBQWxDRCxnREFrQ0MifQ==
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendSlackActionWorkflow = exports.sendSlackActionWorkflowId = void 0;
|
|
4
|
-
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
-
const send_slack_1 = require("../notifications/send-slack");
|
|
6
|
-
exports.sendSlackActionWorkflowId = "send-slack-action";
|
|
7
|
-
/**
|
|
8
|
-
* Workflow wrapper for automation system that sends an email notification.
|
|
9
|
-
*
|
|
10
|
-
* This is a convenience wrapper around the universal sendEmailWorkflow,
|
|
11
|
-
* specifically designed for use with automation actions.
|
|
12
|
-
*
|
|
13
|
-
* It extracts configuration from action.config and context, then calls
|
|
14
|
-
* the universal sendEmailWorkflow.
|
|
15
|
-
*
|
|
16
|
-
* Configuration is stored in action.config:
|
|
17
|
-
* - templateName: Required - Name of the email template
|
|
18
|
-
* - to: Required - Recipient email address
|
|
19
|
-
* - locale: Optional - Locale for translations (default: "pl")
|
|
20
|
-
* - customTemplate: Optional - Path to custom template function
|
|
21
|
-
* - subject: Optional - Custom subject (otherwise uses template default)
|
|
22
|
-
* - template: Optional - Template identifier for notification (defaults to templateName)
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const { result } = await sendEmailActionWorkflow(container).run({
|
|
27
|
-
* input: {
|
|
28
|
-
* action: {
|
|
29
|
-
* id: "action_123",
|
|
30
|
-
* action_type: "email",
|
|
31
|
-
* config: {
|
|
32
|
-
* templateName: "inventory-level",
|
|
33
|
-
* to: "admin@example.com",
|
|
34
|
-
* locale: "pl"
|
|
35
|
-
* }
|
|
36
|
-
* },
|
|
37
|
-
* context: {
|
|
38
|
-
* inventory_level: {
|
|
39
|
-
* id: "il_123",
|
|
40
|
-
* stocked_quantity: 5
|
|
41
|
-
* }
|
|
42
|
-
* }
|
|
43
|
-
* }
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
exports.sendSlackActionWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.sendSlackActionWorkflowId, (input) => {
|
|
48
|
-
// Transform automation action format for sendEmailWorkflow
|
|
49
|
-
const settings = (0, workflows_sdk_1.transform)({ action: input.action, eventName: input.eventName }, (data) => {
|
|
50
|
-
const actionConfig = data?.action?.config || {};
|
|
51
|
-
const eventName = data?.eventName;
|
|
52
|
-
return {
|
|
53
|
-
template: actionConfig?.template,
|
|
54
|
-
resourceId: data?.action?.id,
|
|
55
|
-
resourceType: eventName,
|
|
56
|
-
channel: actionConfig?.channel,
|
|
57
|
-
triggerType: "mpn",
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
const result = send_slack_1.sendSlackWorkflow.runAsStep({
|
|
61
|
-
input: {
|
|
62
|
-
settings: settings,
|
|
63
|
-
context: input.context,
|
|
64
|
-
eventName: input.eventName,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
return new workflows_sdk_1.WorkflowResponse(result);
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZC1zbGFjay1hY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL21wbi1hdXRvbWF0aW9uL3NlbmQtc2xhY2stYWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFFQUswQztBQUMxQyw0REFBK0Q7QUFlbEQsUUFBQSx5QkFBeUIsR0FBRyxtQkFBbUIsQ0FBQTtBQUU1RDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBdUNHO0FBQ1UsUUFBQSx1QkFBdUIsR0FBRyxJQUFBLDhCQUFjLEVBQ25ELGlDQUF5QixFQUN6QixDQUFDLEtBQWlELEVBQUUsRUFBRTtJQUNwRCwyREFBMkQ7SUFDM0QsTUFBTSxRQUFRLEdBQUcsSUFBQSx5QkFBUyxFQUN4QixFQUFFLE1BQU0sRUFBRSxLQUFLLENBQUMsTUFBTSxFQUFFLFNBQVMsRUFBRSxLQUFLLENBQUMsU0FBUyxFQUFFLEVBQ3BELENBQUMsSUFBSSxFQUFFLEVBQUU7UUFDUCxNQUFNLFlBQVksR0FBRyxJQUFJLEVBQUUsTUFBTSxFQUFFLE1BQU0sSUFBSSxFQUFFLENBQUE7UUFDL0MsTUFBTSxTQUFTLEdBQUcsSUFBSSxFQUFFLFNBQVMsQ0FBQTtRQUVqQyxPQUFPO1lBQ0wsUUFBUSxFQUFFLFlBQVksRUFBRSxRQUFRO1lBQ2hDLFVBQVUsRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUU7WUFDNUIsWUFBWSxFQUFFLFNBQVM7WUFDdkIsT0FBTyxFQUFFLFlBQVksRUFBRSxPQUFPO1lBQzlCLFdBQVcsRUFBRSxLQUFLO1NBQ25CLENBQUE7SUFDSCxDQUFDLENBQ0YsQ0FBQTtJQUVELE1BQU0sTUFBTSxHQUFHLDhCQUFpQixDQUFDLFNBQVMsQ0FBQztRQUN6QyxLQUFLLEVBQUU7WUFDTCxRQUFRLEVBQUUsUUFBUTtZQUNsQixPQUFPLEVBQUUsS0FBSyxDQUFDLE9BQU87WUFDdEIsU0FBUyxFQUFFLEtBQUssQ0FBQyxTQUFTO1NBQzNCO0tBQ0YsQ0FBQyxDQUFBO0lBRUYsT0FBTyxJQUFJLGdDQUFnQixDQUFDLE1BQU0sQ0FBQyxDQUFBO0FBQ3JDLENBQUMsQ0FDRixDQUFBIn0=
|