@oneuptime/common 7.0.3707 → 7.0.3708

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 (35) hide show
  1. package/Server/Services/WorkspaceNotificationRuleService.ts +205 -11
  2. package/Server/Services/WorkspaceProjectAuthTokenService.ts +1 -0
  3. package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +18 -7
  4. package/Server/Utils/Workspace/Slack/Slack.ts +352 -45
  5. package/Server/Utils/Workspace/Slack/app-manifest.json +9 -4
  6. package/Server/Utils/Workspace/WorkspaceBase.ts +31 -2
  7. package/Types/Workflow/Component.ts +1 -0
  8. package/Types/Workflow/Components/BaseModel.ts +30 -0
  9. package/Types/Workflow/Components/Manual.ts +10 -0
  10. package/Types/Workflow/Components/Schedule.ts +1 -0
  11. package/Types/Workflow/Components/Webhook.ts +26 -0
  12. package/UI/Components/Workflow/RunForm.tsx +23 -25
  13. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +136 -8
  14. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  15. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +1 -0
  16. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -1
  17. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +14 -5
  18. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
  19. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +251 -36
  20. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  21. package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +9 -4
  22. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +12 -2
  23. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
  24. package/build/dist/Types/Workflow/Components/BaseModel.js +30 -0
  25. package/build/dist/Types/Workflow/Components/BaseModel.js.map +1 -1
  26. package/build/dist/Types/Workflow/Components/Manual.js +10 -0
  27. package/build/dist/Types/Workflow/Components/Manual.js.map +1 -1
  28. package/build/dist/Types/Workflow/Components/Schedule.js +1 -0
  29. package/build/dist/Types/Workflow/Components/Schedule.js.map +1 -1
  30. package/build/dist/Types/Workflow/Components/Webhook.js +26 -0
  31. package/build/dist/Types/Workflow/Components/Webhook.js.map +1 -1
  32. package/build/dist/UI/Components/Workflow/RunForm.js +16 -14
  33. package/build/dist/UI/Components/Workflow/RunForm.js.map +1 -1
  34. package/package.json +2 -2
  35. /package/Server/Utils/Workspace/Slack/{app-manifest-temp.json → app-manifest.example.json} +0 -0
@@ -21,6 +21,13 @@ export interface WorkspaceChannel {
21
21
  }
22
22
 
23
23
  export default class WorkspaceBase {
24
+ public static async joinChannel(_data: {
25
+ authToken: string;
26
+ channelId: string;
27
+ }): Promise<void> {
28
+ throw new NotImplementedException();
29
+ }
30
+
24
31
  public static async sendPayloadBlocksToChannel(_data: {
25
32
  authToken: string;
26
33
  channelId: string;
@@ -50,7 +57,7 @@ export default class WorkspaceBase {
50
57
  workspaceUserIds: Array<string>;
51
58
  }): Promise<void> {
52
59
  for (const userId of data.workspaceUserIds) {
53
- await this.inviteUserToChannel({
60
+ await this.inviteUserToChannelByChannelName({
54
61
  authToken: data.authToken,
55
62
  channelName: data.channelName,
56
63
  workspaceUserId: userId,
@@ -58,7 +65,7 @@ export default class WorkspaceBase {
58
65
  }
59
66
  }
60
67
 
61
- public static async inviteUserToChannel(_data: {
68
+ public static async inviteUserToChannelByChannelName(_data: {
62
69
  authToken: string;
63
70
  channelName: string;
64
71
  workspaceUserId: string;
@@ -66,6 +73,12 @@ export default class WorkspaceBase {
66
73
  throw new NotImplementedException();
67
74
  }
68
75
 
76
+ public static async inviteUserToChannelByChannelId(_data: {
77
+ authToken: string;
78
+ channelId: string;
79
+ workspaceUserId: string;
80
+ }): Promise<void> {}
81
+
69
82
  public static async createChannelsIfDoesNotExist(_data: {
70
83
  authToken: string;
71
84
  channelNames: Array<string>;
@@ -83,6 +96,7 @@ export default class WorkspaceBase {
83
96
  public static async sendMessage(_data: {
84
97
  workspaceMessagePayload: WorkspaceMessagePayload;
85
98
  authToken: string; // which auth token should we use to send.
99
+ userId: string;
86
100
  }): Promise<void> {
87
101
  throw new NotImplementedException();
88
102
  }
@@ -93,6 +107,13 @@ export default class WorkspaceBase {
93
107
  throw new NotImplementedException();
94
108
  }
95
109
 
110
+ public static async getWorkspaceChannelFromChannelName(_data: {
111
+ authToken: string;
112
+ channelName: string;
113
+ }): Promise<WorkspaceChannel> {
114
+ throw new NotImplementedException();
115
+ }
116
+
96
117
  public static async createChannel(_data: {
97
118
  authToken: string;
98
119
  channelName: string;
@@ -166,4 +187,12 @@ export default class WorkspaceBase {
166
187
  }): Promise<HTTPResponse<JSONObject> | HTTPErrorResponse> {
167
188
  throw new NotImplementedException();
168
189
  }
190
+
191
+ public static async isUserInChannel(_data: {
192
+ authToken: string;
193
+ channelId: string;
194
+ userId: string;
195
+ }): Promise<boolean> {
196
+ throw new NotImplementedException();
197
+ }
169
198
  }
@@ -90,6 +90,7 @@ export default interface ComponentMetadata {
90
90
  outPorts: Array<Port>;
91
91
  tableName?: string | undefined;
92
92
  documentationLink?: Route;
93
+ runWorkflowManuallyArguments?: Array<Argument> | undefined;
93
94
  }
94
95
 
95
96
  export interface ComponentCategory {
@@ -157,6 +157,16 @@ export default class BaseModelComponent {
157
157
  iconProp: IconProp.Bolt,
158
158
  tableName: model.tableName!,
159
159
  componentType: ComponentType.Trigger,
160
+ runWorkflowManuallyArguments: [
161
+ {
162
+ type: ComponentInputType.Text,
163
+ name: `${model.singularName} ID`,
164
+ description: `Please provide the ID of the ${model.singularName}, if you wish to run this workflow manually.`,
165
+ required: true,
166
+ id: "_id",
167
+ placeholder: `ID of the ${model.singularName}`,
168
+ },
169
+ ],
160
170
  arguments: [],
161
171
  returnValues: [
162
172
  {
@@ -288,6 +298,16 @@ export default class BaseModelComponent {
288
298
  iconProp: IconProp.Bolt,
289
299
  tableName: model.tableName!,
290
300
  componentType: ComponentType.Trigger,
301
+ runWorkflowManuallyArguments: [
302
+ {
303
+ type: ComponentInputType.Text,
304
+ name: `${model.singularName} ID`,
305
+ description: `Please provide the ID of the ${model.singularName}, if you wish to run this workflow manually.`,
306
+ required: true,
307
+ id: "_id",
308
+ placeholder: `ID of the ${model.singularName}`,
309
+ },
310
+ ],
291
311
  arguments: [
292
312
  {
293
313
  type: ComponentInputType.Select,
@@ -430,6 +450,16 @@ export default class BaseModelComponent {
430
450
  iconProp: IconProp.Bolt,
431
451
  tableName: model.tableName!,
432
452
  componentType: ComponentType.Trigger,
453
+ runWorkflowManuallyArguments: [
454
+ {
455
+ type: ComponentInputType.Text,
456
+ name: `${model.singularName} ID`,
457
+ description: `Please provide the ID of the ${model.singularName}, if you wish to run this workflow manually.`,
458
+ required: true,
459
+ id: "_id",
460
+ placeholder: `ID of the ${model.singularName}`,
461
+ },
462
+ ],
433
463
  arguments: [
434
464
  {
435
465
  type: ComponentInputType.Select,
@@ -14,6 +14,16 @@ const components: Array<ComponentMetadata> = [
14
14
  iconProp: IconProp.Play,
15
15
  componentType: ComponentType.Trigger,
16
16
  arguments: [],
17
+ runWorkflowManuallyArguments: [
18
+ {
19
+ type: ComponentInputType.JSON,
20
+ name: "JSON",
21
+ description: "Enter JSON value that you need to run this workflow",
22
+ required: false,
23
+ id: "value",
24
+ placeholder: '{"key1": "value1", "key2": "value2", ....}',
25
+ },
26
+ ],
17
27
  returnValues: [
18
28
  {
19
29
  type: ComponentInputType.JSON,
@@ -13,6 +13,7 @@ const components: Array<ComponentMetadata> = [
13
13
  description: "Run this workflow on particular schedule",
14
14
  iconProp: IconProp.Clock,
15
15
  componentType: ComponentType.Trigger,
16
+ runWorkflowManuallyArguments: [],
16
17
  arguments: [
17
18
  {
18
19
  type: ComponentInputType.CronTab,
@@ -17,6 +17,32 @@ const components: Array<ComponentMetadata> = [
17
17
  componentType: ComponentType.Trigger,
18
18
  documentationLink: Route.fromString("/workflow/docs/Webhook.md"),
19
19
  arguments: [],
20
+ runWorkflowManuallyArguments: [
21
+ {
22
+ id: "request-headers",
23
+ name: "Request Headers",
24
+ description: "Request Headers for this request",
25
+ type: ComponentInputType.StringDictionary,
26
+ required: false,
27
+ placeholder: '{"header1": "value1", "header2": "value2", ....}',
28
+ },
29
+ {
30
+ id: "request-params",
31
+ name: "Request Query Params",
32
+ description: "Request Query Params for this request",
33
+ type: ComponentInputType.StringDictionary,
34
+ required: false,
35
+ placeholder: '{"query1": "value1", "query2": "value2", ....}',
36
+ },
37
+ {
38
+ id: "request-body",
39
+ name: "Request Body",
40
+ description: "Request Body",
41
+ type: ComponentInputType.JSON,
42
+ required: false,
43
+ placeholder: '{"key1": "value1", "key2": "value2", ....}',
44
+ },
45
+ ],
20
46
  returnValues: [
21
47
  {
22
48
  id: "request-headers",
@@ -3,7 +3,7 @@ import BasicForm, { FormProps } from "../Forms/BasicForm";
3
3
  import FormValues from "../Forms/Types/FormValues";
4
4
  import { componentInputTypeToFormFieldType } from "./Utils";
5
5
  import { JSONObject } from "Common/Types/JSON";
6
- import { NodeDataProp, ReturnValue } from "Common/Types/Workflow/Component";
6
+ import { Argument, NodeDataProp } from "Common/Types/Workflow/Component";
7
7
  import React, {
8
8
  FunctionComponent,
9
9
  ReactElement,
@@ -38,34 +38,32 @@ const RunForm: FunctionComponent<ComponentProps> = (
38
38
  <div className="mb-3 mt-3">
39
39
  <div className="mt-5 mb-5">
40
40
  <h2 className="text-base font-medium text-gray-500">
41
- Return Values from Trigger
41
+ Run {component.metadata.title}
42
42
  </h2>
43
43
  <p className="text-sm font-medium text-gray-400 mb-5">
44
- This workflow has a trigger to get it to run. Since this trigger
45
- returns some values to work. You can pass these return values from
46
- trigger manually and test this workflow.
44
+ {component.metadata.description}
47
45
  </p>
48
- {component.metadata.returnValues &&
49
- component.metadata.returnValues.length === 0 && (
46
+ {component.metadata.runWorkflowManuallyArguments &&
47
+ component.metadata.runWorkflowManuallyArguments.length === 0 && (
50
48
  <ErrorMessage
51
49
  message={
52
- 'This workflow trigger does not take any return values. You can run it by clicking the "Run" button below.'
50
+ 'This workflow trigger does not take any values. You can run it by clicking the "Run" button below.'
53
51
  }
54
52
  />
55
53
  )}
56
- {component.metadata.returnValues &&
57
- component.metadata.returnValues.length > 0 && (
54
+ {component.metadata.runWorkflowManuallyArguments &&
55
+ component.metadata.runWorkflowManuallyArguments.length > 0 && (
58
56
  <BasicForm
59
57
  hideSubmitButton={true}
60
58
  ref={formRef}
61
59
  initialValues={{
62
- ...(component.returnValues || {}),
60
+ ...(component.arguments || {}),
63
61
  }}
64
62
  onChange={(values: FormValues<JSONObject>) => {
65
63
  setComponent({
66
64
  ...component,
67
- returnValues: {
68
- ...((component.returnValues as JSONObject) || {}),
65
+ arguments: {
66
+ ...((component.arguments as JSONObject) || {}),
69
67
  ...((values as JSONObject) || {}),
70
68
  },
71
69
  });
@@ -74,25 +72,25 @@ const RunForm: FunctionComponent<ComponentProps> = (
74
72
  setHasFormValidationErrors(hasError);
75
73
  }}
76
74
  fields={
77
- component.metadata.returnValues &&
78
- component.metadata.returnValues.map(
79
- (returnValue: ReturnValue) => {
75
+ component.metadata.runWorkflowManuallyArguments &&
76
+ component.metadata.runWorkflowManuallyArguments.map(
77
+ (argument: Argument) => {
80
78
  return {
81
- title: `${returnValue.name}`,
79
+ title: `${argument.name}`,
82
80
 
83
81
  description: `${
84
- returnValue.required ? "Required" : "Optional"
85
- }. ${returnValue.description}`,
82
+ argument.required ? "Required" : "Optional"
83
+ }. ${argument.description}`,
86
84
  field: {
87
- [returnValue.id]: true,
85
+ [argument.id]: true,
88
86
  },
89
- required: returnValue.required,
90
- placeholder: returnValue.placeholder,
87
+ required: argument.required,
88
+ placeholder: argument.placeholder,
91
89
  ...componentInputTypeToFormFieldType(
92
- returnValue.type,
90
+ argument.type,
93
91
  component.returnValues &&
94
- component.returnValues[returnValue.id]
95
- ? component.returnValues[returnValue.id]
92
+ component.returnValues[argument.id]
93
+ ? component.returnValues[argument.id]
96
94
  : null,
97
95
  ),
98
96
  };