@raclettejs/core 0.1.11 → 0.1.12

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 (94) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/cli.js +97 -97
  3. package/dist/cli.js.map +7 -0
  4. package/dist/index.js +4 -4
  5. package/dist/index.js.map +7 -0
  6. package/package.json +4 -3
  7. package/services/backend/package.json +1 -0
  8. package/services/backend/src/core/payload/payloadTypes.ts +7 -0
  9. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/account/routes/route.account.get.ts +1 -1
  10. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/account/routes/route.account.getAll.ts +1 -1
  11. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/composition.model.ts +5 -0
  12. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/composition.schema.ts +1 -0
  13. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/composition.service.ts +1 -1
  14. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/routes/route.composition.get.ts +1 -1
  15. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/routes/route.composition.getAll.ts +1 -1
  16. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/helpers/payload.ts +6 -2
  17. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/routes/route.interactionLink.get.ts +1 -1
  18. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/routes/route.interactionLink.getAll.ts +1 -1
  19. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/project/routes/route.project.get.ts +1 -1
  20. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/project/routes/route.project.getAll.ts +1 -1
  21. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/index.ts +2 -1
  22. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/routes/route.tag.get.ts +1 -1
  23. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/routes/route.tag.getAll.ts +6 -2
  24. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/tag.service.ts +22 -1
  25. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/routes/route.user.get.ts +1 -1
  26. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/routes/route.user.getAll.ts +1 -1
  27. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/routes/route.user.remove.ts +3 -0
  28. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/user.service.ts +1 -2
  29. package/services/backend/src/corePlugins/raclette__core/frontend/generated-config.ts +12 -12
  30. package/services/backend/src/domains/index.ts +3 -0
  31. package/services/backend/src/domains/system/collections.service.ts +119 -0
  32. package/services/backend/src/domains/system/index.ts +8 -0
  33. package/services/backend/src/domains/system/routes/index.ts +5 -0
  34. package/services/backend/src/domains/system/routes/route.collection.getAll.ts +61 -0
  35. package/services/backend/src/domains/system/routes/route.collection.remove.ts +93 -0
  36. package/services/backend/src/types/custom-fastify.d.ts +1 -0
  37. package/services/backend/src/utils/request.utils.ts +28 -1
  38. package/services/backend/yarn.lock +11 -2
  39. package/services/frontend/package.json +1 -0
  40. package/services/frontend/src/core/constants/ApiClient.ts +6 -1
  41. package/services/frontend/src/core/lib/data/dataApi.ts +8 -1
  42. package/services/frontend/src/core/lib/data/fetchDataHandler.ts +58 -27
  43. package/services/frontend/src/core/lib/data/queryApi.ts +29 -8
  44. package/services/frontend/src/core/lib/data/responseTypeHandler.ts +27 -4
  45. package/services/frontend/src/core/lib/data/writeDataHandler.ts +1 -1
  46. package/services/frontend/src/core/lib/dataHelper.ts +8 -1
  47. package/services/frontend/src/core/lib/easteregg.ts +1 -1
  48. package/services/frontend/src/core/lib/eventEmitter.ts +1 -0
  49. package/services/frontend/src/core/lib/eventWhitelist.ts +11 -1
  50. package/services/frontend/src/core/lib/logger.ts +11 -3
  51. package/services/frontend/src/core/lib/userNotifier.ts +17 -17
  52. package/services/frontend/src/core/main.ts +3 -3
  53. package/services/frontend/src/core/setup/plugin-system/api/wrappers.ts +18 -1
  54. package/services/frontend/src/core/setup/plugin-system/registration/index.ts +1 -1
  55. package/services/frontend/src/core/setup/socketClient.ts +2 -2
  56. package/services/frontend/src/core/setup/socketEvents.ts +2 -2
  57. package/services/frontend/src/core/store/reducers/compositions/selectors.ts +2 -2
  58. package/services/frontend/src/core/store/reducers/data/index.ts +1 -1
  59. package/services/frontend/src/core/store/reducers/data/reducers.ts +3 -3
  60. package/services/frontend/src/core/store/reducers/queries/effects.ts +20 -1
  61. package/services/frontend/src/core/store/reducers/queries/index.ts +1 -0
  62. package/services/frontend/src/core/store/reducers/queries/reducers.ts +28 -1
  63. package/services/frontend/src/core/store/reducers/queriesCache/queryCacheHelper.ts +5 -4
  64. package/services/frontend/src/core/store/reducers/queriesCache/reducers.ts +4 -3
  65. package/services/frontend/src/core/store/state.ts +1 -1
  66. package/services/frontend/src/core/types/ApiClient.ts +1 -1
  67. package/services/frontend/src/core/types/DataApi.ts +4 -0
  68. package/services/frontend/src/core/types/Queries.ts +1 -0
  69. package/services/frontend/src/orchestrator/ProductOrchestrator.vue +19 -7
  70. package/services/frontend/src/orchestrator/WelcomeScreen.vue +39 -41
  71. package/services/frontend/src/orchestrator/assets/styles/tailwindStyles.css +3 -0
  72. package/services/frontend/src/orchestrator/assets/styles/themes/dark.ts +2 -2
  73. package/services/frontend/src/orchestrator/components/composition/CompositionOverlay.vue +11 -2
  74. package/services/frontend/src/orchestrator/components/composition/WidgetsLayoutLoader.vue +167 -58
  75. package/services/frontend/src/orchestrator/components/menu/DevIndicator.vue +122 -7
  76. package/services/frontend/src/orchestrator/components/menu/UserMenu.vue +38 -20
  77. package/services/frontend/src/orchestrator/components/snackbar/SnackStack.vue +17 -5
  78. package/services/frontend/src/orchestrator/composables/useCurrentComposition.ts +32 -4
  79. package/services/frontend/src/orchestrator/composables/usePageNavigation.ts +5 -1
  80. package/services/frontend/src/orchestrator/composables/usePluginApi.ts +125 -26
  81. package/services/frontend/src/orchestrator/composables/useRouteState.ts +0 -1
  82. package/services/frontend/src/orchestrator/composables/useVueQueryObservableHelper.ts +2 -0
  83. package/services/frontend/src/orchestrator/composables/useVueWriteOperationHelper.ts +5 -3
  84. package/services/frontend/src/orchestrator/composables/useWidgets/helperFunctions.ts +4 -1
  85. package/services/frontend/src/orchestrator/helpers/loginUserNotifications.ts +1 -1
  86. package/services/frontend/src/orchestrator/helpers/uiHelper.ts +1 -1
  87. package/services/frontend/src/orchestrator/i18n/de-DE.json +1 -0
  88. package/services/frontend/src/orchestrator/i18n/en-EU.json +1 -0
  89. package/services/frontend/src/orchestrator/i18n/sk.json +1 -0
  90. package/services/frontend/src/orchestrator/router/routeParserHelper.ts +4 -1
  91. package/services/frontend/src/orchestrator/router/routeStore.ts +78 -11
  92. package/services/frontend/tsconfig.app.json +1 -0
  93. package/services/frontend/yarn.lock +5 -0
  94. package/yarn.lock +4 -4
@@ -1,5 +1,8 @@
1
1
  import log from "@racletteCore/lib/logger"
2
- import { promisifyActionResolve } from "@racletteCore/lib/dataHelper"
2
+ import {
3
+ promisifyActionResolve,
4
+ markDataAsModified,
5
+ } from "@racletteCore/lib/dataHelper"
3
6
  import { $api, $store } from "@racletteCore"
4
7
  import {
5
8
  pluginReadOperations,
@@ -10,6 +13,7 @@ import {
10
13
  getCacheQueryAndHash,
11
14
  isParentResultFresh,
12
15
  } from "@racletteCore/store/reducers/queriesCache/queryCacheHelper"
16
+ import { $eventbus } from "@racletteCore"
13
17
 
14
18
  // to be replaced with actual open search availability state
15
19
  let isOnline = true
@@ -63,7 +67,6 @@ const itemDispatcher = async (
63
67
  const { actionId, cacheKey } = actionIdentifier
64
68
  const { result, backendQueryParams } = resultObj
65
69
  const resolveId = actionId + "_resolve"
66
-
67
70
  if (remote) {
68
71
  $store.dispatch({
69
72
  type: "data/addFromServer",
@@ -81,7 +84,6 @@ const itemDispatcher = async (
81
84
  type: "queries/update",
82
85
  payload: {
83
86
  actionId,
84
- cacheKey,
85
87
  backend: backendQueryParams,
86
88
  },
87
89
  })
@@ -124,7 +126,13 @@ const cacheOperations = {
124
126
  target,
125
127
  },
126
128
  })
127
-
129
+ await $store.dispatch({
130
+ type: "queries/setCacheKey",
131
+ payload: {
132
+ cacheKey: cachedQuery.hash,
133
+ actionId,
134
+ },
135
+ })
128
136
  return { cachedQuery, actionIdentifier }
129
137
  },
130
138
 
@@ -163,8 +171,12 @@ const finishRemoteQuery = (actionIdentifier, result, params, options) => {
163
171
  if (!result.data) {
164
172
  return
165
173
  }
174
+ let resultBody = structuredClone(result.data.body)
175
+ const { type } = result.data
176
+ if (type === "dataReadModified") {
177
+ resultBody = markDataAsModified(resultBody)
178
+ }
166
179
 
167
- const resultBody = structuredClone(result.data.body)
168
180
  const resultObj = {
169
181
  result: [],
170
182
  backendQueryParams: {},
@@ -225,8 +237,20 @@ const handleRemoteRequest = async (
225
237
  try {
226
238
  const response =
227
239
  method === "GET"
228
- ? await $api.axios.get(target, config)
229
- : await $api.axios.post(target, params, config)
240
+ ? await $api.axios.get(target, config).catch((e) => {
241
+ $eventbus.emit("ui/addToSnackbar", {
242
+ message: e.response.data.message,
243
+ color: "error",
244
+ })
245
+ throw e
246
+ })
247
+ : await $api.axios.post(target, params, config).catch((e) => {
248
+ $eventbus.emit("ui/addToSnackbar", {
249
+ message: e.response.data.message,
250
+ color: "error",
251
+ })
252
+ throw e
253
+ })
230
254
 
231
255
  return {
232
256
  response,
@@ -408,14 +432,16 @@ const executeRoute = async (actionIdentifier, validTarget, params, options) => {
408
432
  params,
409
433
  options,
410
434
  controller.signal,
411
- )
435
+ ).catch((e) => {
436
+ log.error(e.error, e.message)
437
+ })
412
438
  requestControllerManager.cleanup(actionIdentifier.actionId)
413
439
  return result
414
440
  } catch (error) {
415
441
  requestControllerManager.cleanup(actionIdentifier.actionId)
416
442
 
417
443
  if (error.name === "AbortError" || error.name === "CanceledError") {
418
- console.log(
444
+ log.api(
419
445
  "HTTP request was cancelled for actionId:",
420
446
  actionIdentifier.actionId,
421
447
  )
@@ -438,29 +464,34 @@ const getData = async (actionId, target, params, options) => {
438
464
 
439
465
  // Handle plugin routing
440
466
  const { validTarget } = await handlePluginReadRoutes(actionId, target, params)
441
-
442
- // Setup cache
443
- const { cachedQuery, actionIdentifier } = await cacheOperations.setupCache(
444
- actionId,
445
- validTarget,
446
- params,
447
- options,
448
- )
449
- // Check cache
450
- if (cachedQuery?.query) {
451
- const cacheResult = await cacheOperations.handleCacheHit(
452
- cachedQuery,
453
- actionIdentifier,
467
+ if (options?.useCache !== false) {
468
+ // Setup cache
469
+ const { cachedQuery, actionIdentifier } = await cacheOperations.setupCache(
470
+ actionId,
471
+ validTarget,
472
+ params,
473
+ options,
454
474
  )
455
- if (cacheResult !== null) {
456
- return {
457
- response: "cached_" + cachedQuery.hash,
458
- result: cacheResult,
475
+ // Check cache
476
+ if (cachedQuery?.query) {
477
+ const cacheResult = await cacheOperations.handleCacheHit(
478
+ cachedQuery,
479
+ actionIdentifier,
480
+ )
481
+ if (cacheResult !== null) {
482
+ return {
483
+ response: "cached_" + cachedQuery.hash,
484
+ result: cacheResult,
485
+ }
459
486
  }
460
487
  }
488
+
489
+ // Execute route
490
+ return executeRoute(actionIdentifier, validTarget, params, options)
461
491
  }
492
+
462
493
  // Execute route
463
- return executeRoute(actionIdentifier, validTarget, params, options)
494
+ return executeRoute({ actionId }, validTarget, params, options)
464
495
  }
465
496
 
466
497
  export default getData
@@ -8,14 +8,16 @@ import type { CustomStoreActionsPayload } from "@racletteCore/types"
8
8
  import { BehaviorSubject } from "rxjs"
9
9
  import { mergeDeepRight, clone } from "ramda"
10
10
 
11
+ const callbacks = {}
11
12
  const queryApis = {}
12
13
 
13
14
  export const $queryApi = (
14
15
  actionId: string,
15
16
  target = "",
16
- { params = {}, options = {} }: CustomStoreActionsPayload = {},
17
+ { params = {}, options = {}, config = {} }: CustomStoreActionsPayload = {},
17
18
  ) => {
18
19
  if (queryApis[actionId] && !target.length) {
20
+ // Early return existing queryApi
19
21
  return queryApis[actionId]
20
22
  }
21
23
  const errorSubject$ = new BehaviorSubject(null)
@@ -24,13 +26,22 @@ export const $queryApi = (
24
26
  // check if we have a query fullfilling the needs of the one requested
25
27
  // here. If not we will update the one with this actionId
26
28
  let actionType = "queries/add"
27
-
29
+ if (!options.hasOwnProperty("useCache")) {
30
+ options.useCache = true
31
+ }
32
+ if (options.cb) {
33
+ // remove callback function to prevent it from tainting the store reducers
34
+ callbacks[actionId] = options.cb
35
+ delete options.cb
36
+ }
28
37
  $store.dispatch({
29
38
  type: actionType,
30
39
  payload: {
31
40
  actionId,
32
41
  target,
33
42
  params: cleanedParams,
43
+ options,
44
+ config,
34
45
  },
35
46
  })
36
47
  const queryApi = {
@@ -38,11 +49,21 @@ export const $queryApi = (
38
49
  response$: responseSubject$.asObservable(),
39
50
  query$: $store.select((state) => state.queries[actionId]),
40
51
  uuids$: $store.select((state) => state.queries[actionId].uuids),
41
- remove: () => {
42
- $store.dispatch({
52
+ clear: async () => {
53
+ errorSubject$.next({})
54
+ responseSubject$.next({})
55
+ await $store.dispatch({
56
+ type: "queries/updateItems",
57
+ payload: { items: {}, actionId },
58
+ })
59
+ },
60
+ remove: async () => {
61
+ await $store.dispatch({
43
62
  type: "queries/remove",
44
63
  payload: { actionId },
45
64
  })
65
+ delete callbacks[actionId]
66
+ responseSubject$.complete()
46
67
  errorSubject$.complete()
47
68
  },
48
69
  execute: async (executeParams = {}) => {
@@ -50,7 +71,7 @@ export const $queryApi = (
50
71
  errorSubject$.next(null)
51
72
  responseSubject$.next({})
52
73
  const queryParams = mergeDeepRight(cleanedParams, _executeParams)
53
- $store.dispatch({
74
+ await $store.dispatch({
54
75
  type: "queries/update",
55
76
  payload: {
56
77
  loading: true,
@@ -69,10 +90,10 @@ export const $queryApi = (
69
90
  errorSubject$.next(errorObj)
70
91
  })
71
92
  responseSubject$.next(resultData?.response)
72
- if (options.cb && typeof options.cb === "function") {
73
- options.cb(resultData)
93
+ if (callbacks[actionId] && typeof callbacks[actionId] === "function") {
94
+ callbacks[actionId](resultData)
74
95
  }
75
- if (resultData.result) {
96
+ if (resultData?.result) {
76
97
  resultData.result = await resultData.result
77
98
  }
78
99
  return resultData
@@ -4,7 +4,7 @@ import {
4
4
  transformOperationResults,
5
5
  } from "@racletteCore/lib/dataHelper"
6
6
  import * as userNotifier from "@racletteCore/lib/userNotifier"
7
- import { $store } from "@racletteCore"
7
+ import { $store, markDataAsModified } from "@racletteCore"
8
8
 
9
9
  const handledRequests = {}
10
10
  const hasBeenHandled = (requestId, appRequestCode) => {
@@ -76,16 +76,16 @@ const handler = {
76
76
 
77
77
  return data.items
78
78
  },
79
- dataPush: (
79
+ dataRead: (
80
80
  data,
81
81
  isOwnRequest,
82
- appRequestCode = "dataPush",
82
+ appRequestCode = "dataRead",
83
83
  requestId,
84
84
  direct,
85
85
  notify,
86
86
  isSystemAction,
87
87
  ) => {
88
- log.api("dataPush", {
88
+ log.api("dataRead", {
89
89
  direct,
90
90
  isOwnRequest,
91
91
  isSystemAction,
@@ -97,6 +97,29 @@ const handler = {
97
97
  $store.dispatch({ type: "data/push", payload: data.items || [] })
98
98
  return data.items
99
99
  },
100
+ dataReadModified: (
101
+ data,
102
+ isOwnRequest,
103
+ appRequestCode = "dataReadModified",
104
+ requestId,
105
+ direct,
106
+ notify,
107
+ isSystemAction,
108
+ ) => {
109
+ const modifiedData = markDataAsModified(data)
110
+
111
+ log.api("dataReadModified", {
112
+ direct,
113
+ isOwnRequest,
114
+ isSystemAction,
115
+ appRequestCode,
116
+ requestId,
117
+ modifiedData,
118
+ })
119
+
120
+ $store.dispatch({ type: "data/push", payload: modifiedData.items || [] })
121
+ return data.items
122
+ },
100
123
  dataDelete: (
101
124
  data,
102
125
  isOwnRequest,
@@ -29,7 +29,7 @@ const createAxiosConfig = (appRequestCode, pluginItemRequestConfig) => {
29
29
  const reportError = (error) => {
30
30
  const message = error?.response?.data?.message || false
31
31
 
32
- $eventbus.emit("ui_addToSnackBar", {
32
+ $eventbus.emit("ui/addToSnackbar", {
33
33
  message,
34
34
  i18n: message ? false : "core.error.noConnectionToServer",
35
35
  color: "error",
@@ -35,7 +35,13 @@ const handleDataIdPrefixing = (prefix, id) => {
35
35
 
36
36
  return prefix + id
37
37
  }
38
-
38
+ const markDataAsModified = (data) => {
39
+ const modifiedData = clone(data)
40
+ modifiedData?.items.forEach((item) => {
41
+ item._id = `m_${item._id}`
42
+ })
43
+ return modifiedData
44
+ }
39
45
  const debounceHelper = (time = 500) => {
40
46
  let debounceTimer = false
41
47
 
@@ -437,6 +443,7 @@ const promisifyActionResolve = (resolveId: string, callback?: Function) => {
437
443
  })
438
444
  }
439
445
  export {
446
+ markDataAsModified,
440
447
  promisifyActionResolve,
441
448
  capitalize,
442
449
  handleDataIdPrefixing,
@@ -14,7 +14,7 @@ const eggMe = (egg) => {
14
14
  }
15
15
 
16
16
  return eggs[egg](() => {
17
- $eventbus.emit("ui_addToSnackBar", {
17
+ $eventbus.emit("ui/addToSnackbar", {
18
18
  i18n: "core.eggcontrols." + egg,
19
19
  color: "info",
20
20
  })
@@ -74,6 +74,7 @@ class EventEmitter {
74
74
  if (!this.isValid(event)) {
75
75
  return false
76
76
  }
77
+ log.event(`Emit sent for ${event}`, args)
77
78
  if (typeof this.events[event] === "object") {
78
79
  this.events[event].forEach((listener) => listener.apply(this, args))
79
80
  }
@@ -11,13 +11,23 @@
11
11
  * - use speaking event names, even though they are longer
12
12
  * - distinguish between a information and request (e.g. store_dispatch is a request to the store)
13
13
  */
14
- const eventWhitelist = [
14
+ const legacyEventWhitelist = [
15
15
  "socket_joinRoom",
16
16
  "socket_leaveRoom",
17
17
  "socket_dataUpdated",
18
18
  "ui_setupProject",
19
19
  "ui_addToSnackBar",
20
20
  ]
21
+ const eventWhitelist = legacyEventWhitelist.concat([
22
+ "forms/init",
23
+ "forms/validate",
24
+ "widgets/reset/workingState",
25
+ "ui/addToSnackbar",
26
+ "ui/setupProject",
27
+ "socket/data/update",
28
+ "socket/join/room",
29
+ "socket/leave/room",
30
+ ])
21
31
  const eventWildcards = [
22
32
  "query_deleted",
23
33
  "store_actionResolved",
@@ -217,7 +217,7 @@ class Logger {
217
217
 
218
218
  error(
219
219
  title: string,
220
- message?: LogMessage,
220
+ message?: LogMessage | any,
221
221
  level: LogLevel = LogLevel.NoLogging,
222
222
  ): void {
223
223
  this.log(message, "error", title, level)
@@ -247,8 +247,16 @@ class Logger {
247
247
  * Create a plugin-specific logger
248
248
  */
249
249
  plugin(pluginKey: string): PluginLogger {
250
- return (title: string, message?: LogMessage, level?: LogLevel): void => {
251
- this.log(message, "plugin", `${pluginKey} - ${title}`, level)
250
+ return (
251
+ title: string,
252
+ message?: LogMessage | any,
253
+ level?: LogLevel,
254
+ ): void => {
255
+ if (title === "error") {
256
+ this.error(`plugin ${pluginKey} - ${message.error}`, message)
257
+ } else {
258
+ this.log(message, "plugin", `${pluginKey} - ${title}`, level)
259
+ }
252
260
  }
253
261
  }
254
262
  }
@@ -35,7 +35,7 @@ const setServerDisconnected = () => {
35
35
  const dataCreate = (isAnswerToOwnRequest, isSystemAction, items) => {
36
36
  items.forEach((item) => {
37
37
  if (isAnswerToOwnRequest) {
38
- $eventbus.emit("ui_addToSnackBar", {
38
+ $eventbus.emit("ui/addToSnackbar", {
39
39
  i18n: "core.dataCreate$displayName$type",
40
40
  content: { displayName: item._displayName, type: item._type },
41
41
  color: "success",
@@ -61,7 +61,7 @@ const dataCreate = (isAnswerToOwnRequest, isSystemAction, items) => {
61
61
  const dataUpdate = (isAnswerToOwnRequest, isSystemAction, items) => {
62
62
  items.forEach((item) => {
63
63
  if (isAnswerToOwnRequest) {
64
- $eventbus.emit("ui_addToSnackBar", {
64
+ $eventbus.emit("ui/addToSnackbar", {
65
65
  i18n: "core.dataUpdate$displayName$type",
66
66
  content: { displayName: item._displayName, type: item._type },
67
67
  color: "success",
@@ -89,7 +89,7 @@ const projectUpdate = (isAnswerToOwnRequest, isSystemAction, items) => {
89
89
  const displayValues = item._source
90
90
 
91
91
  if (isAnswerToOwnRequest) {
92
- $eventbus.emit("ui_addToSnackBar", {
92
+ $eventbus.emit("ui/addToSnackbar", {
93
93
  i18n: "core.projectUpdate$shorttitle",
94
94
  content: { shorttitle: displayValues.shorttitle },
95
95
  color: "success",
@@ -111,20 +111,20 @@ const projectUpdate = (isAnswerToOwnRequest, isSystemAction, items) => {
111
111
  }
112
112
  })
113
113
 
114
- $eventbus.emit("ui_addToSnackBar", {
114
+ $eventbus.emit("ui/addToSnackbar", {
115
115
  i18n: "core.reloadPageHint",
116
116
  color: "info",
117
117
  })
118
118
  }
119
119
 
120
120
  const projectConfigUpdate = (isAnswerToOwnRequest, isSystemAction, items) =>
121
- $eventbus.emit("ui_addToSnackBar", {
121
+ $eventbus.emit("ui/addToSnackbar", {
122
122
  i18n: "core.reloadPageHint",
123
123
  color: "info",
124
124
  })
125
125
 
126
126
  const userConfigUpdate = (isAnswerToOwnRequest, isSystemAction, items) =>
127
- $eventbus.emit("ui_addToSnackBar", {
127
+ $eventbus.emit("ui/addToSnackbar", {
128
128
  i18n: "core.reloadPageHint",
129
129
  color: "info",
130
130
  })
@@ -132,7 +132,7 @@ const userConfigUpdate = (isAnswerToOwnRequest, isSystemAction, items) =>
132
132
  const dataDelete = (isAnswerToOwnRequest, isSystemAction, deletedItems) =>
133
133
  deletedItems.forEach((item) => {
134
134
  if (isAnswerToOwnRequest) {
135
- $eventbus.emit("ui_addToSnackBar", {
135
+ $eventbus.emit("ui/addToSnackbar", {
136
136
  i18n: "core.dataDelete$displayName$type",
137
137
  content: { displayName: item._displayName, type: item._type },
138
138
  color: "success",
@@ -157,7 +157,7 @@ const dataDelete = (isAnswerToOwnRequest, isSystemAction, deletedItems) =>
157
157
  const dataMove = (isAnswerToOwnRequest, isSystemAction, items) => {
158
158
  items.forEach((item) => {
159
159
  if (isAnswerToOwnRequest) {
160
- $eventbus.emit("ui_addToSnackBar", {
160
+ $eventbus.emit("ui/addToSnackbar", {
161
161
  i18n: "core.dataMove$displayName$type",
162
162
  content: { displayName: item._displayName, type: item._type },
163
163
  color: "success",
@@ -207,7 +207,7 @@ const checkToken = (payload) => {
207
207
  },
208
208
  color: "green",
209
209
  }
210
- $eventbus.emit("ui_addToSnackBar", message)
210
+ $eventbus.emit("ui/addToSnackbar", message)
211
211
  $store.dispatch({
212
212
  type: "notifications/add",
213
213
  payload: {
@@ -222,7 +222,7 @@ const checkToken = (payload) => {
222
222
  i18n: "core.authentication." + response.code,
223
223
  color: "error",
224
224
  }
225
- $eventbus.emit("ui_addToSnackBar", message)
225
+ $eventbus.emit("ui/addToSnackbar", message)
226
226
  $store.dispatch({
227
227
  type: "notifications/add",
228
228
  payload: {
@@ -245,7 +245,7 @@ const checkToken = (payload) => {
245
245
  color: "error",
246
246
  }
247
247
  }
248
- $eventbus.emit("ui_addToSnackBar", message)
248
+ $eventbus.emit("ui/addToSnackbar", message)
249
249
  $store.dispatch({
250
250
  type: "notifications/add",
251
251
  payload: {
@@ -257,7 +257,7 @@ const checkToken = (payload) => {
257
257
  }
258
258
  }
259
259
  const newVersionAvailable = () =>
260
- $eventbus.emit("ui_addToSnackBar", {
260
+ $eventbus.emit("ui/addToSnackbar", {
261
261
  i18n: "core.versionUpdate",
262
262
  color: "info",
263
263
  timeout: -1,
@@ -271,7 +271,7 @@ const dataMergeResponse = (isAnswerToOwnRequest, res) => {
271
271
 
272
272
  if (currentOperation.failure) {
273
273
  Object.keys(currentOperation.failure).forEach((type) =>
274
- $eventbus.emit("ui_addToSnackBar", {
274
+ $eventbus.emit("ui/addToSnackbar", {
275
275
  i18n: "core.dataSync." + operation + ".$docCountOf$docTypeHaveFailed",
276
276
  content: {
277
277
  docCount: currentOperation.failure[type],
@@ -283,7 +283,7 @@ const dataMergeResponse = (isAnswerToOwnRequest, res) => {
283
283
  }
284
284
  if (currentOperation.success) {
285
285
  Object.keys(currentOperation.success).forEach((type) =>
286
- $eventbus.emit("ui_addToSnackBar", {
286
+ $eventbus.emit("ui/addToSnackbar", {
287
287
  i18n:
288
288
  "core.dataSync." +
289
289
  operation +
@@ -306,7 +306,7 @@ const dataMergeResponse = (isAnswerToOwnRequest, res) => {
306
306
  res.totals.failed > 0 &&
307
307
  res.totals.succeeded > 0
308
308
  ) {
309
- $eventbus.emit("ui_addToSnackBar", {
309
+ $eventbus.emit("ui/addToSnackbar", {
310
310
  i18n: "core.dataSync.$docCountOf$docTypeHaveFailed$docCount1HaveSucceeded",
311
311
  content: {
312
312
  docCount: res.totals.failed,
@@ -321,13 +321,13 @@ const dataMergeResponse = (isAnswerToOwnRequest, res) => {
321
321
  const add = (message: string | string[], color = "info") => {
322
322
  if (Array.isArray(message)) {
323
323
  message.forEach((text) =>
324
- $eventbus.emit("ui_addToSnackBar", {
324
+ $eventbus.emit("ui/addToSnackbar", {
325
325
  message: text,
326
326
  color,
327
327
  } satisfies SnackbarMessage),
328
328
  )
329
329
  } else {
330
- $eventbus.emit("ui_addToSnackBar", {
330
+ $eventbus.emit("ui/addToSnackbar", {
331
331
  message,
332
332
  color,
333
333
  } satisfies SnackbarMessage)
@@ -93,10 +93,10 @@ const createRacletteApp = async (
93
93
  store.dispatch({ type: "user/set", payload: user })
94
94
 
95
95
  // does the core really need to communicate with itself via eventbus?
96
- eventbus.emit("socket_joinRoom")
96
+ eventbus.emit("socket/join/room")
97
97
 
98
98
  return new Promise<CreateAppResponse>(async (resolve, reject) => {
99
- eventbus.on("ui_setupProject", (spaceId: string) => {
99
+ eventbus.on("ui/setupProject", (spaceId: string) => {
100
100
  resolve({
101
101
  authenticated: true,
102
102
  setupComplete: true,
@@ -152,7 +152,7 @@ const generateLoginCallback =
152
152
 
153
153
  store.dispatch({ type: "user/set", payload: response.data.user })
154
154
 
155
- eventbus.emit("socket_joinRoom")
155
+ eventbus.emit("socket/join/room")
156
156
 
157
157
  // Return success with token & redirect function
158
158
  return {
@@ -27,12 +27,29 @@ export const wrapFileApi = (
27
27
  }
28
28
 
29
29
  export const wrapEventbusApi = (
30
+ plugin: RegisteredPlugin,
30
31
  $eventbus: any,
31
32
  pluginApi: Partial<PluginApi>,
32
33
  ): any => {
33
34
  if ($eventbus && !pluginApi.$eventbus) {
34
35
  const $pluginEventbus = new EventEmitter(false, false)
35
- $pluginEventbus.global = $eventbus
36
+ $pluginEventbus.global = {
37
+ on: (event: string, listener: Function) => {
38
+ return $eventbus.on(event, listener)
39
+ },
40
+ once: (event: string, listener: Function) => {
41
+ return $eventbus.once(event, listener)
42
+ },
43
+ emit: (event: string, payload: object) => {
44
+ return $eventbus.emit(event, {
45
+ sender: plugin.pluginKey,
46
+ data: payload,
47
+ })
48
+ },
49
+ isValid: (event: string) => {
50
+ return $eventbus.isValid(event)
51
+ },
52
+ }
36
53
  return $pluginEventbus
37
54
  }
38
55
  return pluginApi
@@ -113,7 +113,7 @@ export const loadAndRegisterPlugin = async (
113
113
 
114
114
  if (corePluginApi.$eventbus) {
115
115
  currentPlugin.initEventbus = () =>
116
- wrapEventbusApi(corePluginApi.$eventbus, pluginApi)
116
+ wrapEventbusApi(plugin, corePluginApi.$eventbus, pluginApi)
117
117
  }
118
118
 
119
119
  const handleOperations = handlePluginOperations(
@@ -6,7 +6,7 @@ import log from "@racletteCore/lib/logger"
6
6
  import { getUserToken } from "./sessionHandler"
7
7
  import configService from "@racletteCore/lib/configService"
8
8
  const registerSocketClient = ($socket, $eventbus) => {
9
- $eventbus.on("socket_joinRoom", (roomId?: string) => {
9
+ $eventbus.on("socket/join/room", (roomId?: string) => {
10
10
  const { requireAuthentication } = configService.getConfig()?.global ?? {
11
11
  requireAuthentication: true,
12
12
  }
@@ -25,7 +25,7 @@ const registerSocketClient = ($socket, $eventbus) => {
25
25
  $socket.emit("join", { roomId, token })
26
26
  })
27
27
 
28
- $eventbus.on("socket_leaveRoom", (roomId) => {
28
+ $eventbus.on("socket/leave/room", (roomId) => {
29
29
  log.socket("emitLeave", { roomId })
30
30
  $socket.emit("leave", roomId)
31
31
  })
@@ -206,7 +206,7 @@ const registerSocketEvents = ($socket, $store, $eventbus) => {
206
206
  })
207
207
  await setupSpace(compositions, interactionLinks, projectConfig)
208
208
 
209
- $eventbus.emit("ui_setupProject", roomId)
209
+ $eventbus.emit("ui/setupProject", roomId)
210
210
  })
211
211
  // Reset all store states which are project dependent.
212
212
  $store.dispatch({
@@ -263,7 +263,7 @@ const registerSocketEvents = ($socket, $store, $eventbus) => {
263
263
  isOwnRequest: appSessionId === $socket.appSessionId,
264
264
  })
265
265
  handleServerItem(payload, true, false)
266
- $eventbus.emit("socket_dataUpdated", { offline: false, body })
266
+ $eventbus.emit("socket/data/update", { offline: false, body })
267
267
  })
268
268
 
269
269
  /**
@@ -21,8 +21,8 @@ type LocaleObject = {
21
21
  // TODO: outsource to a better place
22
22
  const getLocalizedName = (localeObject: LocaleObject) => {
23
23
  const locale = $store.getState(["ui", "locale"])
24
-
25
- const localeName = localeObject[locale]
24
+ const localeName =
25
+ localeObject[locale] || localeObject[locale.split("-")?.[0]]
26
26
 
27
27
  if (localeName) {
28
28
  return localeName
@@ -6,7 +6,7 @@ import reducerFromMap from "@racletteCore/lib/reducerFromMap"
6
6
  const reducerMap = {
7
7
  init: reducers.init,
8
8
  projectInit: reducers.projectInit,
9
- "data/push": reducers.dataPush,
9
+ "data/push": reducers.dataRead,
10
10
  "data/create": reducers.dataCreate,
11
11
  "data/update": reducers.dataUpdate,
12
12
  "data/deleteFromCache": reducers.deleteFromCache,