@raclettejs/core 0.1.1 → 0.1.3

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 (39) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +661 -1
  3. package/dist/cli.js +5 -5
  4. package/package.json +1 -1
  5. package/services/backend/src/core/crud/crudTypes.ts +5 -5
  6. package/services/backend/src/core/payload/payloadRegistrar.ts +15 -15
  7. package/services/backend/src/core/payload/payloadTypes.ts +4 -4
  8. package/services/backend/src/core/pluginSystem/pluginFastifyInstance.ts +8 -5
  9. package/services/backend/src/core/pluginSystem/pluginTypes.ts +4 -4
  10. package/services/backend/src/core/sockets/createSystemEventHandlers.ts +18 -16
  11. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/account/account.service.ts +16 -16
  12. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/account/events/index.ts +4 -4
  13. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/account/helpers/payload.ts +2 -2
  14. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/composition.service.ts +14 -14
  15. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/events/index.ts +3 -3
  16. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/composition/helpers/payload.ts +2 -2
  17. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/events/index.ts +3 -3
  18. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/helpers/payload.ts +2 -2
  19. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/interactionLink/interactionLink.service.ts +18 -18
  20. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/project/events/index.ts +4 -4
  21. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/project/helpers/payload.ts +2 -2
  22. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/project/project.service.ts +14 -14
  23. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/events/index.ts +5 -5
  24. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/helpers/payload.ts +2 -2
  25. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/tag/tag.service.ts +14 -14
  26. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/events/index.ts +4 -4
  27. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/helpers/payload.ts +2 -2
  28. package/services/backend/src/corePlugins/raclette__core/backend/datatypes/user/user.service.ts +14 -14
  29. package/services/backend/src/modules/cache/cacheManager.ts +4 -4
  30. package/services/backend/src/types/custom-fastify.d.ts +2 -2
  31. package/services/backend/src/utils/request.utils.ts +2 -2
  32. package/services/frontend/src/core/lib/data/dataApi.ts +6 -5
  33. package/services/frontend/src/core/lib/data/fetchDataHandler.ts +51 -21
  34. package/services/frontend/src/core/lib/data/queryApi.ts +20 -27
  35. package/services/frontend/src/core/setup/plugin-system/api/plugin-data.ts +17 -13
  36. package/services/frontend/src/core/types/DataApi.ts +13 -1
  37. package/services/frontend/src/orchestrator/composables/useVueQueryObservableHelper.ts +21 -11
  38. package/services/frontend/src/orchestrator/composables/useVueWriteOperationHelper.ts +27 -18
  39. package/services/frontend/src/orchestrator/types/PluginApi.ts +7 -3
@@ -1,5 +1,5 @@
1
1
  import type { Composition } from "../composition.schema"
2
- import type { ClientPayloadRequestData, PluginFastifyInstance } from "types"
2
+ import type { FrontendPayloadRequestData, PluginFastifyInstance } from "types"
3
3
 
4
4
  export const registerPayload = (fastify: PluginFastifyInstance) => {
5
5
  fastify.registerPayloadHandler<Composition>("composition", {
@@ -15,5 +15,5 @@ export const registerPayload = (fastify: PluginFastifyInstance) => {
15
15
  export const createCompositionPayload = async (
16
16
  fastify: PluginFastifyInstance,
17
17
  items: Composition[],
18
- requestData: ClientPayloadRequestData,
18
+ requestData: FrontendPayloadRequestData,
19
19
  ) => await fastify.createPayload("composition", items, requestData)
@@ -1,12 +1,12 @@
1
1
  import type { AnyInteractionLink } from "../interactionLink.schema"
2
- import type { ClientPayload } from "@c/payload/payloadTypes"
2
+ import type { FrontendPayload } from "@c/payload/payloadTypes"
3
3
  import { PluginFastifyInstance } from "types"
4
4
 
5
5
  export const registerEvents = (fastify: PluginFastifyInstance) => {
6
6
  /*
7
7
  * interactionLink created and created
8
8
  */
9
- const created = async (payload: ClientPayload<AnyInteractionLink>) => {
9
+ const created = async (payload: FrontendPayload<AnyInteractionLink>) => {
10
10
  fastify.eventbus.emit("broadcastInteractionLinkCreated", payload)
11
11
  fastify.log.info(
12
12
  `[eventbus] interactionLink broadcast created ${payload.body.items}`,
@@ -16,7 +16,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
16
16
  /*
17
17
  * interactionLink deleted
18
18
  */
19
- const deleted = async (payload: ClientPayload<AnyInteractionLink>) => {
19
+ const deleted = async (payload: FrontendPayload<AnyInteractionLink>) => {
20
20
  fastify.eventbus.emit("broadcastInteractionLinkDeleted", payload)
21
21
  fastify.log.info(
22
22
  `[eventbus] interactionLink broadcast deleted ${payload.body.items}`,
@@ -1,5 +1,5 @@
1
1
  import type { InteractionLink } from "../interactionLink.schema"
2
- import type { PluginFastifyInstance, ClientPayloadRequestData } from "types"
2
+ import type { PluginFastifyInstance, FrontendPayloadRequestData } from "types"
3
3
 
4
4
  export const registerPayload = (fastify: PluginFastifyInstance) => {
5
5
  fastify.registerPayloadHandler<InteractionLink>("interactionLink", {
@@ -17,5 +17,5 @@ export const registerPayload = (fastify: PluginFastifyInstance) => {
17
17
  export const createInteractionLinkPayload = async (
18
18
  fastify: PluginFastifyInstance,
19
19
  items: InteractionLink[],
20
- requestData: ClientPayloadRequestData,
20
+ requestData: FrontendPayloadRequestData,
21
21
  ) => await fastify.createPayload("interactionLink", items, requestData)
@@ -1,7 +1,7 @@
1
1
  import type { InteractionLink as InteractionLinkType } from "./interactionLink.schema"
2
2
  import type {
3
- ClientPayload,
4
- ClientPayloadRequestData,
3
+ FrontendPayload,
4
+ FrontendPayloadRequestData,
5
5
  } from "@c/payload/payloadTypes"
6
6
  import { v4 as uuidv4, validate } from "uuid"
7
7
  import { createInteractionLinkPayload } from "./helpers/payload"
@@ -71,10 +71,10 @@ export class InteractionLinkService {
71
71
  */
72
72
  async createInteractionLink(
73
73
  fastify: PluginFastifyInstance,
74
- requestData: ClientPayloadRequestData,
74
+ requestData: FrontendPayloadRequestData,
75
75
  interactionLinkBody: InteractionLinkBody,
76
76
  userId: string,
77
- ): Promise<ClientPayload<InteractionLinkType[]>> {
77
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
78
78
  const interactionLink = await this._createInteractionLink(
79
79
  fastify,
80
80
  interactionLinkBody,
@@ -117,9 +117,9 @@ export class InteractionLinkService {
117
117
  */
118
118
  async getAllInteractionLinks(
119
119
  fastify: PluginFastifyInstance,
120
- requestData: ClientPayloadRequestData,
120
+ requestData: FrontendPayloadRequestData,
121
121
  filters: Record<string, any> = {},
122
- ): Promise<ClientPayload<InteractionLinkType[]>> {
122
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
123
123
  const interactionLinks = await this._readAllInteractionLinks(
124
124
  fastify,
125
125
  filters,
@@ -153,9 +153,9 @@ export class InteractionLinkService {
153
153
  */
154
154
  async readInteractionLinksByComposition(
155
155
  fastify: PluginFastifyInstance,
156
- requestData: ClientPayloadRequestData,
156
+ requestData: FrontendPayloadRequestData,
157
157
  compositionId: string,
158
- ): Promise<ClientPayload<InteractionLinkType[]>> {
158
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
159
159
  const interactionLinks = await this._readInteractionLinksByComposition(
160
160
  fastify,
161
161
  compositionId,
@@ -192,9 +192,9 @@ export class InteractionLinkService {
192
192
  */
193
193
  async readInteractionLink(
194
194
  fastify: PluginFastifyInstance,
195
- requestData: ClientPayloadRequestData,
195
+ requestData: FrontendPayloadRequestData,
196
196
  id: string,
197
- ): Promise<ClientPayload<InteractionLinkType[]>> {
197
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
198
198
  const interactionLink = await this._readInteractionLink(fastify, id)
199
199
 
200
200
  return createInteractionLinkPayload(fastify, [interactionLink], requestData)
@@ -260,10 +260,10 @@ export class InteractionLinkService {
260
260
  */
261
261
  async updateInteractionLink(
262
262
  fastify: PluginFastifyInstance,
263
- requestData: ClientPayloadRequestData,
263
+ requestData: FrontendPayloadRequestData,
264
264
  id: string,
265
265
  interactionLinkBody: InteractionLinkBody,
266
- ): Promise<ClientPayload<InteractionLinkType[]>> {
266
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
267
267
  const { updated, original } = await this._updateInteractionLink(
268
268
  fastify,
269
269
  id,
@@ -314,9 +314,9 @@ export class InteractionLinkService {
314
314
  */
315
315
  async removeInteractionLink(
316
316
  fastify: PluginFastifyInstance,
317
- requestData: ClientPayloadRequestData,
317
+ requestData: FrontendPayloadRequestData,
318
318
  id: string,
319
- ): Promise<ClientPayload<InteractionLinkType[]>> {
319
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
320
320
  const interactionLink = await this._removeInteractionLink(fastify, id)
321
321
 
322
322
  const payload = await createInteractionLinkPayload(
@@ -369,9 +369,9 @@ export class InteractionLinkService {
369
369
  */
370
370
  async hardDeleteInteractionLink(
371
371
  fastify: PluginFastifyInstance,
372
- requestData: ClientPayloadRequestData,
372
+ requestData: FrontendPayloadRequestData,
373
373
  id: string,
374
- ): Promise<ClientPayload<InteractionLinkType[]>> {
374
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
375
375
  const interactionLink = await this._hardDeleteInteractionLink(fastify, id)
376
376
 
377
377
  const payload = await createInteractionLinkPayload(
@@ -420,10 +420,10 @@ export class InteractionLinkService {
420
420
  */
421
421
  async readInteractionLinksByTrigger(
422
422
  fastify: PluginFastifyInstance,
423
- requestData: ClientPayloadRequestData,
423
+ requestData: FrontendPayloadRequestData,
424
424
  triggerType: string,
425
425
  identifier: string,
426
- ): Promise<ClientPayload<InteractionLinkType[]>> {
426
+ ): Promise<FrontendPayload<InteractionLinkType[]>> {
427
427
  const interactionLinks = await this._readInteractionLinksByTrigger(
428
428
  fastify,
429
429
  triggerType,
@@ -1,12 +1,12 @@
1
1
  import type { AnyProject } from "../project.schema"
2
- import type { ClientPayload } from "@c/payload/payloadTypes"
2
+ import type { FrontendPayload } from "@c/payload/payloadTypes"
3
3
  import { PluginFastifyInstance } from "types"
4
4
 
5
5
  const registerEvents = (fastify: PluginFastifyInstance) => {
6
6
  /**
7
7
  * Project created
8
8
  */
9
- const created = async (payload: ClientPayload<AnyProject>) => {
9
+ const created = async (payload: FrontendPayload<AnyProject>) => {
10
10
  fastify.eventbus.emit("broadcastDataUpdated", payload)
11
11
  fastify.eventbus.emit("broadcastProjectCreated", payload)
12
12
  fastify.log.info(
@@ -17,7 +17,7 @@ const registerEvents = (fastify: PluginFastifyInstance) => {
17
17
  /**
18
18
  * Project updated
19
19
  */
20
- const updated = async (payload: ClientPayload<AnyProject>) => {
20
+ const updated = async (payload: FrontendPayload<AnyProject>) => {
21
21
  fastify.eventbus.emit("broadcastDataUpdated", payload)
22
22
  fastify.log.info(
23
23
  `[eventbus] project broadcast updated ${payload.body.item._id}`,
@@ -27,7 +27,7 @@ const registerEvents = (fastify: PluginFastifyInstance) => {
27
27
  /**
28
28
  * Project deleted
29
29
  */
30
- const deleted = async (payload: ClientPayload<AnyProject>) => {
30
+ const deleted = async (payload: FrontendPayload<AnyProject>) => {
31
31
  fastify.eventbus.emit("broadcastProjectDeleted", payload)
32
32
  fastify.log.info(
33
33
  `[eventbus] project broadcast deleted ${payload.body.item._id}`,
@@ -1,5 +1,5 @@
1
1
  import type { Project } from "../project.schema"
2
- import type { ClientPayloadRequestData, PluginFastifyInstance } from "types"
2
+ import type { FrontendPayloadRequestData, PluginFastifyInstance } from "types"
3
3
 
4
4
  export const registerPayload = (fastify: PluginFastifyInstance) => {
5
5
  fastify.registerPayloadHandler<Project>("project", {
@@ -15,7 +15,7 @@ export const registerPayload = (fastify: PluginFastifyInstance) => {
15
15
  export const createProjectPayload = async (
16
16
  fastify: PluginFastifyInstance,
17
17
  items: Project[],
18
- requestData: ClientPayloadRequestData,
18
+ requestData: FrontendPayloadRequestData,
19
19
  ) => {
20
20
  return await fastify.createPayload("project", items, requestData)
21
21
  }
@@ -4,8 +4,8 @@ import type {
4
4
  ProjectUpdate,
5
5
  } from "./project.schema"
6
6
  import type {
7
- ClientPayload,
8
- ClientPayloadRequestData,
7
+ FrontendPayload,
8
+ FrontendPayloadRequestData,
9
9
  } from "@c/payload/payloadTypes"
10
10
  import type { QueryOptions } from "@m/database/providers/mongodb/service"
11
11
  import { v4 as uuidv4, validate } from "uuid"
@@ -64,9 +64,9 @@ export class ProjectService {
64
64
  */
65
65
  async createProject(
66
66
  fastify: PluginFastifyInstance,
67
- requestData: ClientPayloadRequestData,
67
+ requestData: FrontendPayloadRequestData,
68
68
  projectBody: ProjectCreate,
69
- ): Promise<ClientPayload<ProjectType[]>> {
69
+ ): Promise<FrontendPayload<ProjectType[]>> {
70
70
  const project = await this._createProject(fastify, projectBody)
71
71
 
72
72
  const payload = await createProjectPayload(fastify, [project], requestData)
@@ -118,10 +118,10 @@ export class ProjectService {
118
118
  */
119
119
  async readProjects(
120
120
  fastify: PluginFastifyInstance,
121
- requestData: ClientPayloadRequestData,
121
+ requestData: FrontendPayloadRequestData,
122
122
  filter?: Record<string, any>,
123
123
  options: QueryOptions = {},
124
- ): Promise<ClientPayload<ProjectType[]>> {
124
+ ): Promise<FrontendPayload<ProjectType[]>> {
125
125
  const projects = await this._readProjects(fastify, filter, options)
126
126
 
127
127
  return createProjectPayload(fastify, projects, requestData)
@@ -171,9 +171,9 @@ export class ProjectService {
171
171
  */
172
172
  async readProject(
173
173
  fastify: PluginFastifyInstance,
174
- requestData: ClientPayloadRequestData,
174
+ requestData: FrontendPayloadRequestData,
175
175
  id: string,
176
- ): Promise<ClientPayload<ProjectType[]>> {
176
+ ): Promise<FrontendPayload<ProjectType[]>> {
177
177
  const project = await this._readProject(fastify, id)
178
178
 
179
179
  return createProjectPayload(fastify, [project], requestData)
@@ -230,11 +230,11 @@ export class ProjectService {
230
230
  */
231
231
  async updateProject(
232
232
  fastify: PluginFastifyInstance,
233
- requestData: ClientPayloadRequestData,
233
+ requestData: FrontendPayloadRequestData,
234
234
  id: string,
235
235
  projectBody: Partial<ProjectUpdate>,
236
236
  userId: string,
237
- ): Promise<ClientPayload<ProjectType[]>> {
237
+ ): Promise<FrontendPayload<ProjectType[]>> {
238
238
  const { updated, original } = await this._updateProject(
239
239
  fastify,
240
240
  id,
@@ -281,9 +281,9 @@ export class ProjectService {
281
281
  */
282
282
  async removeProject(
283
283
  fastify: PluginFastifyInstance,
284
- requestData: ClientPayloadRequestData,
284
+ requestData: FrontendPayloadRequestData,
285
285
  id: string,
286
- ): Promise<ClientPayload<ProjectType[]>> {
286
+ ): Promise<FrontendPayload<ProjectType[]>> {
287
287
  const project = await this._removeProject(fastify, id)
288
288
 
289
289
  const payload = await createProjectPayload(fastify, [project], {
@@ -330,9 +330,9 @@ export class ProjectService {
330
330
  */
331
331
  async hardDeleteProject(
332
332
  fastify: PluginFastifyInstance,
333
- requestData: ClientPayloadRequestData,
333
+ requestData: FrontendPayloadRequestData,
334
334
  id: string,
335
- ): Promise<ClientPayload<ProjectType[]>> {
335
+ ): Promise<FrontendPayload<ProjectType[]>> {
336
336
  const project = await this._hardDeleteProject(fastify, id)
337
337
 
338
338
  const payload = await createProjectPayload(fastify, [project], {
@@ -1,12 +1,12 @@
1
1
  import type { AnyTag } from "../tag.schema"
2
- import type { ClientPayload } from "@c/payload/payloadTypes"
2
+ import type { FrontendPayload } from "@c/payload/payloadTypes"
3
3
  import { PluginFastifyInstance } from "types"
4
4
 
5
5
  export const registerEvents = (fastify: PluginFastifyInstance) => {
6
6
  /*
7
7
  * tag created and created
8
8
  */
9
- const created = async (payload: ClientPayload<AnyTag>) => {
9
+ const created = async (payload: FrontendPayload<AnyTag>) => {
10
10
  fastify.eventbus.emit("broadcastDataUpdated", payload)
11
11
  fastify.eventbus.emit("broadcastTagCreated", payload)
12
12
  fastify.log.info(`[eventbus] tag broadcast created ${payload.body.items}`)
@@ -14,7 +14,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
14
14
  /*
15
15
  * tag updated and created
16
16
  */
17
- const updated = async (payload: ClientPayload<AnyTag>) => {
17
+ const updated = async (payload: FrontendPayload<AnyTag>) => {
18
18
  fastify.eventbus.emit("broadcastDataUpdated", payload)
19
19
  fastify.log.info(`[eventbus] tag broadcast updated ${payload.body.items}`)
20
20
  }
@@ -22,7 +22,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
22
22
  /*
23
23
  * makes sure child counts between tickets and tags gets updated
24
24
  */
25
- const tagArrayUpdated = async (payload: ClientPayload<AnyTag>) => {
25
+ const tagArrayUpdated = async (payload: FrontendPayload<AnyTag>) => {
26
26
  fastify.eventbus.emit("broadcastDataUpdated", payload)
27
27
  fastify.log.info(`[eventbus] tag broadcast created ${payload.body.items}`)
28
28
  }
@@ -30,7 +30,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
30
30
  /*
31
31
  * tag deleted
32
32
  */
33
- const deleted = async (payload: ClientPayload<AnyTag>) => {
33
+ const deleted = async (payload: FrontendPayload<AnyTag>) => {
34
34
  fastify.eventbus.emit("broadcastTagDeleted", payload)
35
35
  fastify.log.info(`[eventbus] tag broadcast deleted ${payload.body.items}`)
36
36
  }
@@ -1,5 +1,5 @@
1
1
  import type { Tag } from "../tag.schema"
2
- import type { ClientPayloadRequestData, PluginFastifyInstance } from "types"
2
+ import type { FrontendPayloadRequestData, PluginFastifyInstance } from "types"
3
3
 
4
4
  export const registerPayload = (fastify: PluginFastifyInstance) => {
5
5
  fastify.registerPayloadHandler<Tag>("tag", {
@@ -15,7 +15,7 @@ export const registerPayload = (fastify: PluginFastifyInstance) => {
15
15
  export const createTagPayload = async (
16
16
  fastify: PluginFastifyInstance,
17
17
  items: Tag[],
18
- requestData: ClientPayloadRequestData,
18
+ requestData: FrontendPayloadRequestData,
19
19
  ) => {
20
20
  return await fastify.createPayload("tag", items, requestData)
21
21
  }
@@ -1,7 +1,7 @@
1
1
  import type { TagCreate, Tag as TagType, TagUpdate } from "./tag.schema"
2
2
  import type {
3
- ClientPayload,
4
- ClientPayloadRequestData,
3
+ FrontendPayload,
4
+ FrontendPayloadRequestData,
5
5
  } from "@c/payload/payloadTypes"
6
6
  import type { QueryOptions } from "@m/database/providers/mongodb/service"
7
7
  import type { PluginFastifyInstance } from "types"
@@ -58,9 +58,9 @@ export class TagService {
58
58
  */
59
59
  async createTag(
60
60
  fastify: PluginFastifyInstance,
61
- requestData: ClientPayloadRequestData,
61
+ requestData: FrontendPayloadRequestData,
62
62
  tagBody: TagCreate,
63
- ): Promise<ClientPayload<TagType[]>> {
63
+ ): Promise<FrontendPayload<TagType[]>> {
64
64
  const tag = await this._createTag(fastify, tagBody)
65
65
 
66
66
  const payload = await createTagPayload(fastify, [tag], requestData)
@@ -93,9 +93,9 @@ export class TagService {
93
93
  */
94
94
  async readTag(
95
95
  fastify: PluginFastifyInstance,
96
- requestData: ClientPayloadRequestData,
96
+ requestData: FrontendPayloadRequestData,
97
97
  id: string,
98
- ): Promise<ClientPayload<TagType[]>> {
98
+ ): Promise<FrontendPayload<TagType[]>> {
99
99
  const tag = await this._readTag(fastify, id)
100
100
 
101
101
  return createTagPayload(fastify, [tag], requestData)
@@ -141,11 +141,11 @@ export class TagService {
141
141
  */
142
142
  async readTags(
143
143
  fastify: PluginFastifyInstance,
144
- requestData: ClientPayloadRequestData,
144
+ requestData: FrontendPayloadRequestData,
145
145
  filter: { id?: string; projectId?: string; isDeleted?: boolean } = {
146
146
  isDeleted: false,
147
147
  },
148
- ): Promise<ClientPayload<TagType[]>> {
148
+ ): Promise<FrontendPayload<TagType[]>> {
149
149
  try {
150
150
  if (filter.id) {
151
151
  // Get single tag
@@ -206,11 +206,11 @@ export class TagService {
206
206
  */
207
207
  async updateTag(
208
208
  fastify: PluginFastifyInstance,
209
- requestData: ClientPayloadRequestData,
209
+ requestData: FrontendPayloadRequestData,
210
210
  id: string,
211
211
  tagBody: TagUpdate,
212
212
  userId: string,
213
- ): Promise<ClientPayload<TagType[]>> {
213
+ ): Promise<FrontendPayload<TagType[]>> {
214
214
  const isLockedTag = await this.tagModel
215
215
  .findOne({ _id: id, locked: true })
216
216
  .lean()
@@ -265,9 +265,9 @@ export class TagService {
265
265
  */
266
266
  async removeTag(
267
267
  fastify: PluginFastifyInstance,
268
- requestData: ClientPayloadRequestData,
268
+ requestData: FrontendPayloadRequestData,
269
269
  id: string,
270
- ): Promise<ClientPayload<TagType[]>> {
270
+ ): Promise<FrontendPayload<TagType[]>> {
271
271
  const isLockedTag = await this.tagModel
272
272
  .findOne({ _id: id, locked: true })
273
273
  .lean()
@@ -319,9 +319,9 @@ export class TagService {
319
319
  */
320
320
  async hardDeleteTag(
321
321
  fastify: PluginFastifyInstance,
322
- requestData: ClientPayloadRequestData,
322
+ requestData: FrontendPayloadRequestData,
323
323
  id: string,
324
- ): Promise<ClientPayload<TagType[]>> {
324
+ ): Promise<FrontendPayload<TagType[]>> {
325
325
  const isLockedTag = await this.tagModel
326
326
  .findOne({ _id: id, locked: true })
327
327
  .lean()
@@ -1,12 +1,12 @@
1
1
  import type { AnyUser } from "../user.schema"
2
- import type { ClientPayload } from "@c/payload/payloadTypes"
2
+ import type { FrontendPayload } from "@c/payload/payloadTypes"
3
3
  import { PluginFastifyInstance } from "types"
4
4
 
5
5
  export const registerEvents = (fastify: PluginFastifyInstance) => {
6
6
  /*
7
7
  * user created
8
8
  */
9
- const created = async (payload: ClientPayload<AnyUser>) => {
9
+ const created = async (payload: FrontendPayload<AnyUser>) => {
10
10
  fastify.eventbus.emit("broadcastDataUpdated", payload)
11
11
  fastify.eventbus.emit("broadcastUserCreated", payload)
12
12
  fastify.log.info(`[eventbus] user broadcast created ${payload.body.items}`)
@@ -15,7 +15,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
15
15
  /*
16
16
  * user updated
17
17
  */
18
- const updated = async (payload: ClientPayload<AnyUser>) => {
18
+ const updated = async (payload: FrontendPayload<AnyUser>) => {
19
19
  fastify.eventbus.emit("broadcastDataUpdated", payload)
20
20
  fastify.log.info(`[eventbus] user broadcast updated ${payload.body.items}`)
21
21
  }
@@ -23,7 +23,7 @@ export const registerEvents = (fastify: PluginFastifyInstance) => {
23
23
  /*
24
24
  * user deleted
25
25
  */
26
- const deleted = async (payload: ClientPayload<AnyUser>) => {
26
+ const deleted = async (payload: FrontendPayload<AnyUser>) => {
27
27
  fastify.eventbus.emit("broadcastUserDeleted", payload)
28
28
  fastify.log.info(`[eventbus] user broadcast deleted ${payload.body.items}`)
29
29
  }
@@ -1,5 +1,5 @@
1
1
  import { type User, toPublicUser } from "../user.schema"
2
- import type { ClientPayloadRequestData, PluginFastifyInstance } from "types"
2
+ import type { FrontendPayloadRequestData, PluginFastifyInstance } from "types"
3
3
 
4
4
  export const registerPayload = (fastify: PluginFastifyInstance) => {
5
5
  fastify.registerPayloadHandler<User>("user", {
@@ -16,5 +16,5 @@ export const registerPayload = (fastify: PluginFastifyInstance) => {
16
16
  export const createUserPayload = async (
17
17
  fastify: PluginFastifyInstance,
18
18
  items: User[],
19
- requestData: ClientPayloadRequestData,
19
+ requestData: FrontendPayloadRequestData,
20
20
  ) => await fastify.createPayload("user", items, requestData)
@@ -5,8 +5,8 @@ import type {
5
5
  UserUpdate,
6
6
  } from "./user.schema"
7
7
  import type {
8
- ClientPayload,
9
- ClientPayloadRequestData,
8
+ FrontendPayload,
9
+ FrontendPayloadRequestData,
10
10
  } from "@c/payload/payloadTypes"
11
11
  import type { QueryOptions } from "@m/database/providers/mongodb/service"
12
12
  import type { PluginFastifyInstance } from "types"
@@ -63,9 +63,9 @@ export class UserService {
63
63
  */
64
64
  async createUser(
65
65
  fastify: PluginFastifyInstance,
66
- requestData: ClientPayloadRequestData,
66
+ requestData: FrontendPayloadRequestData,
67
67
  userBody: UserCreate,
68
- ): Promise<ClientPayload<PublicUser[]>> {
68
+ ): Promise<FrontendPayload<PublicUser[]>> {
69
69
  const user = await this._createUser(fastify, userBody)
70
70
 
71
71
  const payload = await createUserPayload(fastify, [user], requestData)
@@ -101,9 +101,9 @@ export class UserService {
101
101
  */
102
102
  async readUser(
103
103
  fastify: PluginFastifyInstance,
104
- requestData: ClientPayloadRequestData,
104
+ requestData: FrontendPayloadRequestData,
105
105
  id: string,
106
- ): Promise<ClientPayload<PublicUser[]>> {
106
+ ): Promise<FrontendPayload<PublicUser[]>> {
107
107
  const user = await this._readUser(fastify, id)
108
108
 
109
109
  return createUserPayload(fastify, [user], requestData)
@@ -166,10 +166,10 @@ export class UserService {
166
166
  */
167
167
  async readUsers(
168
168
  fastify: PluginFastifyInstance,
169
- requestData: ClientPayloadRequestData,
169
+ requestData: FrontendPayloadRequestData,
170
170
  filter: Record<string, any> = {},
171
171
  options: QueryOptions = {},
172
- ): Promise<ClientPayload<PublicUser[]>> {
172
+ ): Promise<FrontendPayload<PublicUser[]>> {
173
173
  const users = await this._readUsers(fastify, filter, options)
174
174
 
175
175
  return createUserPayload(fastify, users, requestData)
@@ -226,10 +226,10 @@ export class UserService {
226
226
  */
227
227
  async updateUser(
228
228
  fastify: PluginFastifyInstance,
229
- requestData: ClientPayloadRequestData,
229
+ requestData: FrontendPayloadRequestData,
230
230
  id: string,
231
231
  userBody: Partial<UserUpdate>,
232
- ): Promise<ClientPayload<PublicUser[]>> {
232
+ ): Promise<FrontendPayload<PublicUser[]>> {
233
233
  const { updated, original } = await this._updateUser(fastify, id, userBody)
234
234
 
235
235
  const payload = await createUserPayload(fastify, [updated], requestData)
@@ -271,9 +271,9 @@ export class UserService {
271
271
  */
272
272
  async removeUser(
273
273
  fastify: PluginFastifyInstance,
274
- requestData: ClientPayloadRequestData,
274
+ requestData: FrontendPayloadRequestData,
275
275
  id: string,
276
- ): Promise<ClientPayload<PublicUser[]>> {
276
+ ): Promise<FrontendPayload<PublicUser[]>> {
277
277
  const user = await this._removeUser(fastify, id)
278
278
 
279
279
  const payload = await createUserPayload(fastify, [user], {
@@ -325,10 +325,10 @@ export class UserService {
325
325
  */
326
326
  async updateLastProject(
327
327
  fastify: PluginFastifyInstance,
328
- requestData: ClientPayloadRequestData,
328
+ requestData: FrontendPayloadRequestData,
329
329
  userId: string,
330
330
  projectId: string,
331
- ): Promise<ClientPayload<PublicUser[]>> {
331
+ ): Promise<FrontendPayload<PublicUser[]>> {
332
332
  const user = await this._updateLastProject(fastify, userId, projectId)
333
333
 
334
334
  return createUserPayload(fastify, [user], {
@@ -39,12 +39,12 @@ export const createCacheService = (
39
39
 
40
40
  // Cache the new data if it changed or doesn't exist
41
41
  if (hasChanged) {
42
- const ttl = options.ttl ?? defaultTtl
42
+ const ttl = typeof options?.ttl === 'number' ? options.ttl : defaultTtl
43
43
 
44
- if (ttl) {
45
- await cache.setex(fullKey, ttl, serializedNewData)
46
- } else {
44
+ if (ttl < 0) {
47
45
  await cache.set(fullKey, serializedNewData)
46
+ } else {
47
+ await cache.setex(fullKey, ttl, serializedNewData)
48
48
  }
49
49
  }
50
50
 
@@ -10,7 +10,7 @@ import { Client } from "@opensearch-project/opensearch"
10
10
  import { TaskManager } from "../core/backgroundTasks/taskManagerTypes"
11
11
  import { HttpService } from "../core/http/httpTypes"
12
12
  import { UserDoc } from "@c/user/user.schema"
13
- import { ClientPayloadRequestData } from "@/utils/request.utils"
13
+ import { FrontendPayloadRequestData } from "@/utils/request.utils"
14
14
  import { FastifyRequest, FastifyReply } from "fastify"
15
15
 
16
16
  declare module "fastify" {
@@ -30,7 +30,7 @@ declare module "fastify" {
30
30
  interface FastifyRequest {
31
31
  database: Connection
32
32
  user: UserDoc
33
- requestParams: ClientPayloadRequestData
33
+ requestParams: FrontendPayloadRequestData
34
34
  }
35
35
 
36
36
  interface RouteOptions {
@@ -1,5 +1,5 @@
1
1
  import type { CommonHeaders } from "@c/validation/sharedSchemas"
2
- import type { ClientPayloadRequestData } from "types"
2
+ import type { FrontendPayloadRequestData } from "types"
3
3
  import type { FastifyContextConfig, FastifyRequest } from "fastify"
4
4
 
5
5
  export type RequestWithCommonHeaders<T = unknown> = FastifyRequest<{
@@ -10,7 +10,7 @@ export type RequestWithCommonHeaders<T = unknown> = FastifyRequest<{
10
10
  export const createRequestParams = (
11
11
  req: RequestWithCommonHeaders,
12
12
  config: FastifyContextConfig,
13
- ): ClientPayloadRequestData => {
13
+ ): FrontendPayloadRequestData => {
14
14
  return {
15
15
  appSessionId: req.headers["app-session-id"] ?? "",
16
16
  appRequestCode: req.headers["app-request-code"] ?? "",
@@ -7,7 +7,7 @@ import $queryApi from "./queryApi"
7
7
  import writeData from "./writeDataHandler"
8
8
  import type { CustomStoreActionsPayload } from "@racletteCore/types"
9
9
  import { BehaviorSubject } from "rxjs"
10
- import { clone } from "ramda"
10
+ import { clone, mergeDeepRight } from "ramda"
11
11
 
12
12
  const $writeDataApi = (
13
13
  actionId: String,
@@ -19,18 +19,18 @@ const $writeDataApi = (
19
19
  const isLoadingSubject$ = new BehaviorSubject<boolean>(false)
20
20
  const dataSubject$ = new BehaviorSubject([])
21
21
  const errorSubject$ = new BehaviorSubject(null)
22
+ const resultSubject$ = new BehaviorSubject({})
22
23
  const writeApi = {
23
24
  isLoading$: isLoadingSubject$.asObservable(),
24
25
  data$: dataSubject$.asObservable(),
25
26
  error$: errorSubject$.asObservable(),
27
+ result$: resultSubject$.asObservable(),
26
28
  execute: async (executeParams = {}) => {
27
29
  const _executeParams = clone(executeParams)
28
30
  errorSubject$.next(null)
31
+ resultSubject$.next({})
29
32
  isLoadingSubject$.next(true)
30
-
31
- const queryParams = Object.keys(_executeParams).length
32
- ? _executeParams
33
- : _params
33
+ const queryParams = mergeDeepRight(_params, _executeParams)
34
34
  if (options.responseType === "stream") {
35
35
  return writeData(actionId, operationDefinition, queryParams, options)
36
36
  }
@@ -44,6 +44,7 @@ const $writeDataApi = (
44
44
  errorSubject$.next(errorObj)
45
45
  isLoadingSubject$.next(false)
46
46
  })
47
+ resultSubject$.next(resultData)
47
48
 
48
49
  // Update both boolean and observable on success
49
50
  isLoadingSubject$.next(false)