@orchestrator-ui/orchestrator-ui-components 7.6.0 → 8.0.0

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 (27) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +9 -9
  4. package/CHANGELOG.md +18 -0
  5. package/dist/index.d.ts +63 -45
  6. package/dist/index.js +776 -647
  7. package/dist/index.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/components/WfoBadges/WfoEngineStatusBadge/WfoEngineStatusBadge.tsx +3 -1
  10. package/src/components/WfoBadges/WfoWebsocketStatusBadge/WfoWebsocketStatusBadge.tsx +9 -3
  11. package/src/components/WfoPydanticForm/fields/WfoArrayField/WfoArrayField.tsx +1 -1
  12. package/src/components/WfoPydanticForm/fields/WfoInteger.tsx +8 -6
  13. package/src/components/WfoPydanticForm/fields/WfoObjectField/WfoObjectField.tsx +1 -1
  14. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionDetailSection.tsx +34 -3
  15. package/src/components/WfoTitleWithWebsocketBadge/WfoTitleWithWebsocketBadge.tsx +3 -2
  16. package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +57 -40
  17. package/src/components/WfoWorkflowSteps/WfoStep/useStepDetailOverride.ts +9 -0
  18. package/src/components/WfoWorkflowSteps/WfoWorkflowStepList/WfoStepListHeader.tsx +0 -1
  19. package/src/configuration/version.ts +1 -1
  20. package/src/messages/en-GB.json +2 -0
  21. package/src/messages/nl-NL.json +2 -0
  22. package/src/pages/metadata/WfoScheduleTaskFormPage.tsx +153 -35
  23. package/src/rtk/endpoints/forms.ts +1 -1
  24. package/src/rtk/endpoints/metadata/scheduledTasks.ts +9 -17
  25. package/src/rtk/endpoints/streamMessages.ts +10 -23
  26. package/src/rtk/slices/orchestratorComponentOverride.ts +5 -1
  27. package/src/utils/compareVersions.ts +1 -1
@@ -7,7 +7,6 @@ import {
7
7
  GraphqlQueryVariables,
8
8
  ScheduledTaskDefinition,
9
9
  ScheduledTasksDefinitionsResult,
10
- TaskType,
11
10
  } from '@/types';
12
11
 
13
12
  export const scheduledTasks = `
@@ -41,7 +40,7 @@ export type ScheduledTasksResponse = {
41
40
  schedules: ScheduledTaskDefinition[];
42
41
  } & BaseGraphQlResult;
43
42
 
44
- /*
43
+ /*
45
44
  https://apscheduler.readthedocs.io/en/3.x/modules/triggers/interval.html#module-apscheduler.triggers.interval
46
45
  Possible parameters:
47
46
  weeks (int) – number of weeks to wait
@@ -105,11 +104,13 @@ export type CronKwargs = {
105
104
  type Kwargs = DateKwargs | InterValKwargs | CronKwargs;
106
105
 
107
106
  export type ScheduledTaskPostPayload = {
108
- workflowId: string;
109
- workflowName: string;
110
- workflowDescription: string;
111
- type: TaskType;
112
- kwargs: Kwargs;
107
+ workflow_id: string;
108
+ workflow_name: string;
109
+ name: string;
110
+ trigger: string;
111
+ trigger_kwargs: Kwargs;
112
+ scheduled_type: string;
113
+ user_inputs: object[];
113
114
  };
114
115
 
115
116
  const scheduledTasksApi = orchestratorApi.injectEndpoints({
@@ -149,22 +150,13 @@ const scheduledTasksApi = orchestratorApi.injectEndpoints({
149
150
  }),
150
151
  createScheduledTask: builder.mutation<unknown, ScheduledTaskPostPayload>({
151
152
  query: (payload) => {
152
- const scheduleTaskPayload = {
153
- scheduled_type: 'create',
154
- name: payload.workflowDescription,
155
- workflow_name: payload.workflowName,
156
- workflow_id: payload.workflowId,
157
- trigger: payload.type,
158
- trigger_kwargs: payload.kwargs,
159
- };
160
-
161
153
  return {
162
154
  url: METADATA_SCHEDULES_ENDPOINT,
163
155
  method: 'POST',
164
156
  headers: {
165
157
  'Content-Type': 'application/json',
166
158
  },
167
- body: scheduleTaskPayload,
159
+ body: payload,
168
160
  };
169
161
  },
170
162
  extraOptions: {
@@ -1,8 +1,7 @@
1
1
  import { debounce } from 'lodash';
2
2
 
3
3
  import { getWebSocket, orchestratorApi } from '@/rtk';
4
- import type { RootState } from '@/rtk/store';
5
- import { CacheTag, CacheTagType } from '@/types';
4
+ import { CacheTag } from '@/types';
6
5
 
7
6
  const PING_INTERVAL_MS = 30000;
8
7
  const NO_PONG_RECEIVED_TIMEOUT_MS = 35000;
@@ -29,32 +28,26 @@ enum MessageTypes {
29
28
  * - It invalidates the cache entry with the tag received in the message event
30
29
  * - WfoWebsocketStatusBadge contains logic that handles automatic reconnection and their circumstances
31
30
  */
31
+
32
32
  const streamMessagesApi = orchestratorApi.injectEndpoints({
33
33
  endpoints: (build) => ({
34
- streamMessages: build.query<boolean, void>({
34
+ streamMessages: build.query<boolean, string>({
35
35
  queryFn: () => {
36
36
  return { data: true };
37
37
  },
38
- async onCacheEntryAdded(_, { cacheDataLoaded, cacheEntryRemoved, dispatch, getState, updateCachedData }) {
38
+ async onCacheEntryAdded(wsEndpoint, { cacheDataLoaded, cacheEntryRemoved, dispatch, updateCachedData }) {
39
39
  const cleanUp = () => {
40
40
  clearInterval(pingInterval);
41
41
  updateCachedData(() => false);
42
42
  };
43
43
 
44
44
  const invalidateTag = (cacheTag: CacheTag) => {
45
- if (validCacheTags.includes(cacheTag.type)) {
46
- const cacheInvalidationAction = orchestratorApi.util.invalidateTags([cacheTag]);
47
- dispatch(cacheInvalidationAction);
48
- } else {
49
- console.error(`Trying to invalidate a cache entry with an unknown tag: ${cacheTag.type}`);
50
- }
45
+ const cacheInvalidationAction = orchestratorApi.util.invalidateTags([cacheTag]);
46
+ dispatch(cacheInvalidationAction);
51
47
  };
52
48
 
53
49
  await cacheDataLoaded;
54
50
  let initialConnection = true;
55
- const state = getState() as RootState;
56
- const { orchestratorWebsocketUrl } = state.orchestratorConfig;
57
- const validCacheTags = Object.values(CacheTagType);
58
51
 
59
52
  const getDebounce = (delay: number) => {
60
53
  return debounce(() => {
@@ -68,8 +61,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
68
61
  const closeConnectionAfterFirstPing = getDebounce(INITIAL_CONNECTION_CHECK_INTERVAL_MS);
69
62
  const debounceClosingConnection = getDebounce(NO_PONG_RECEIVED_TIMEOUT_MS);
70
63
 
71
- // Starts the websocket
72
- const webSocket = await getWebSocket(orchestratorWebsocketUrl);
64
+ const webSocket = await getWebSocket(wsEndpoint);
73
65
 
74
66
  const sendPing = () => {
75
67
  if (webSocket.readyState === WebSocket.OPEN) {
@@ -82,9 +74,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
82
74
  // run less frequently at the discretion of the browser causing the websocket to disconnect
83
75
  // sometimes. WfoWebsocketStatusBadge contains logic to reconnect based on the pageVisibility api
84
76
  // to handle that situation.
85
- const pingInterval = setInterval(() => {
86
- sendPing();
87
- }, PING_INTERVAL_MS);
77
+ const pingInterval = setInterval(sendPing, PING_INTERVAL_MS);
88
78
 
89
79
  webSocket.onopen = () => {
90
80
  // Check the connection right after it is established
@@ -106,6 +96,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
106
96
  }
107
97
  return;
108
98
  }
99
+
109
100
  const message = JSON.parse(data) as WebSocketMessage;
110
101
  if (message.name === MessageTypes.invalidateCache) {
111
102
  invalidateTag(message.value);
@@ -114,17 +105,13 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
114
105
  }
115
106
  });
116
107
 
117
- webSocket.onerror = (event) => {
118
- console.error('WebSocket error', event);
119
- };
120
-
108
+ webSocket.onerror = (event) => console.error('WebSocket error', event);
121
109
  webSocket.onclose = () => {
122
110
  console.error('WebSocket closed');
123
111
  cleanUp();
124
112
  };
125
113
 
126
114
  await cacheEntryRemoved;
127
-
128
115
  webSocket.close();
129
116
  },
130
117
  }),
@@ -2,7 +2,7 @@ import { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { Slice, createSlice } from '@reduxjs/toolkit';
4
4
 
5
- import { FieldValue, RenderableFieldValue, SubscriptionDetail } from '@/types';
5
+ import { FieldValue, RenderableFieldValue, Step, SubscriptionDetail } from '@/types';
6
6
 
7
7
  export type ValueOverrideFunction = (
8
8
  fieldValue: FieldValue | RenderableFieldValue,
@@ -19,6 +19,10 @@ export type OrchestratorComponentOverride = {
19
19
  startPage?: {
20
20
  summaryCardConfigurationOverride?: (defaultItems: ReactElement[]) => ReactElement[];
21
21
  };
22
+ stepDetail?: {
23
+ stepHeader?: React.JSXElementConstructor<{ step?: Step }>;
24
+ stepBody?: React.JSXElementConstructor<{ step?: Step }>;
25
+ };
22
26
  subscriptionDetail?: {
23
27
  valueOverrides?: ValueOverrideConfiguration;
24
28
  generalSectionConfigurationOverride?: (
@@ -1,6 +1,6 @@
1
1
  import { MappedVersion } from '@/types';
2
2
 
3
- const compareVersions = (v1: string, v2: string): number => {
3
+ export const compareVersions = (v1: string, v2: string): number => {
4
4
  const parse = (v: string) => {
5
5
  const parts = v.split('.');
6
6