@truedat/bg 8.5.2 → 8.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "8.5.2",
3
+ "version": "8.5.4",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -54,7 +54,7 @@
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.3.0",
56
56
  "@testing-library/user-event": "^14.6.1",
57
- "@truedat/test": "8.5.2",
57
+ "@truedat/test": "8.5.4",
58
58
  "identity-obj-proxy": "^3.0.0",
59
59
  "jest": "^29.7.0",
60
60
  "redux-saga-test-plan": "^4.0.6"
@@ -87,5 +87,5 @@
87
87
  "semantic-ui-react": "^3.0.0-beta.2",
88
88
  "swr": "^2.3.3"
89
89
  },
90
- "gitHead": "d0bbace3698b98e458856143676b7f631ee8e18f"
90
+ "gitHead": "75272567eb3ec948a5cdeb8346ef9cacac58267f"
91
91
  }
@@ -29,7 +29,7 @@ import { TranslationModal } from "@truedat/ai/components";
29
29
  import { useWebContext } from "@truedat/core/webContext";
30
30
 
31
31
  const SelectDynamicFormWithTranslations = lazy(
32
- () => import("@truedat/df/components/SelectDynamicFormWithTranslations")
32
+ () => import("@truedat/df/components/SelectDynamicFormWithTranslations"),
33
33
  );
34
34
 
35
35
  const ConceptForm = ({
@@ -84,8 +84,8 @@ const ConceptForm = ({
84
84
  setCanTranslate(
85
85
  _.get("data.data.status", res) === "ok" &&
86
86
  isMultilingual &&
87
- !_.isEmpty(translatableFields)
88
- )
87
+ !_.isEmpty(translatableFields),
88
+ ),
89
89
  );
90
90
  }
91
91
  };
@@ -101,7 +101,7 @@ const ConceptForm = ({
101
101
  domain_ids: [domainId],
102
102
  resource_type: "business_concept",
103
103
  }).then((res) =>
104
- setHasSuggestions(_.get("data.data.status", res) === "ok")
104
+ setHasSuggestions(_.get("data.data.status", res) === "ok"),
105
105
  );
106
106
  checkCanTranslate();
107
107
  }
@@ -172,7 +172,7 @@ const ConceptForm = ({
172
172
  defaultLang,
173
173
  i18nConcept[defaultLang]?.name,
174
174
  handleI18nNameChange,
175
- true
175
+ true,
176
176
  )
177
177
  ) : (
178
178
  <>
@@ -209,14 +209,14 @@ const ConceptForm = ({
209
209
  {renderNameField(
210
210
  defaultLang,
211
211
  i18nConcept[defaultLang]?.name,
212
- handleI18nNameChange
212
+ handleI18nNameChange,
213
213
  )}
214
214
  </Grid.Column>
215
215
  <Grid.Column>
216
216
  {renderNameField(
217
217
  altLang,
218
218
  i18nConcept[altLang]?.name,
219
- handleI18nNameChange
219
+ handleI18nNameChange,
220
220
  )}
221
221
  </Grid.Column>
222
222
  </Grid.Row>
@@ -250,7 +250,7 @@ const ConceptForm = ({
250
250
  _.flow(
251
251
  _.filter("is_required"),
252
252
  _.map("name"),
253
- _.every(isNonEmptyString)
253
+ _.every(isNonEmptyString),
254
254
  )(i18nConcept);
255
255
  const validTemplate = () =>
256
256
  _.isObject(template) && isNonEmptyString(template?.name);
@@ -290,7 +290,7 @@ const ConceptForm = ({
290
290
  const isThereAnyTranslatableField =
291
291
  _.flow(
292
292
  _.keys,
293
- _.some((key) => !_.isEmpty(i18nConcept[defaultLang]?.content?.[key]))
293
+ _.some((key) => !_.isEmpty(i18nConcept[defaultLang]?.content?.[key])),
294
294
  )(translatableFields) || !_.isEmpty(i18nConcept[defaultLang]?.name);
295
295
 
296
296
  const disableTranslationButton =
@@ -4,7 +4,7 @@ describe("selectors: getParsedEvents", () => {
4
4
  const concept = {
5
5
  template: {
6
6
  content: [
7
- { fields: [{ type: "system", name: "field_1", label: "Label" }] },
7
+ { fields: [{ type: "string", name: "field_1", label: "Label" }] },
8
8
  ],
9
9
  },
10
10
  };
@@ -83,8 +83,8 @@ describe("selectors: getParsedEvents", () => {
83
83
  resource_id: 10,
84
84
  payload: [
85
85
  {
86
- msg_key: "changed_field_without_target",
87
- msg_params: ["Label", JSON.stringify({ id: 1, name: "foo" })],
86
+ msg_key: "changed_field",
87
+ msg_params: ["Label", "foo"],
88
88
  },
89
89
  ],
90
90
  };
@@ -129,7 +129,10 @@ describe("selectors: getParsedEvents", () => {
129
129
  event: "update_concept_draft",
130
130
  resource_id: 23,
131
131
  payload: [
132
- { msg_key: "changed_field_without_target", msg_params: ["changed_field_1", null] },
132
+ {
133
+ msg_key: "changed_field_without_target",
134
+ msg_params: ["changed_field_1", null],
135
+ },
133
136
  { msg_key: "changed_field", msg_params: ["changed_field_2", "value_2"] },
134
137
  ],
135
138
  };
@@ -139,7 +142,10 @@ describe("selectors: getParsedEvents", () => {
139
142
  event: "update_concept_draft",
140
143
  resource_id: 24,
141
144
  payload: [
142
- { msg_key: "changed_field_without_target", msg_params: ["changed_field_1", null] },
145
+ {
146
+ msg_key: "changed_field_without_target",
147
+ msg_params: ["changed_field_1", null],
148
+ },
143
149
  { msg_key: "changed_field", msg_params: ["changed_field_2", "value_2"] },
144
150
  ],
145
151
  };
@@ -161,7 +167,10 @@ describe("selectors: getParsedEvents", () => {
161
167
  payload: {
162
168
  content: {
163
169
  removed: {},
164
- changed: { changed_field_1: { origin: "origin", value: "value_1" }, changed_field_2: { origin: "origin", value: "value_2" } },
170
+ changed: {
171
+ changed_field_1: { origin: "origin", value: "value_1" },
172
+ changed_field_2: { origin: "origin", value: "value_2" },
173
+ },
165
174
  added: {},
166
175
  },
167
176
  },
@@ -230,7 +239,13 @@ describe("selectors: getParsedEvents", () => {
230
239
  id: 9,
231
240
  event: "update_concept_draft",
232
241
  resource_id: 10,
233
- payload: { content: { changed: { field_1: { origin: "origin", value: { id: 1, name: "foo" } } } } },
242
+ payload: {
243
+ content: {
244
+ changed: {
245
+ field_1: { origin: "origin", value: "foo" },
246
+ },
247
+ },
248
+ },
234
249
  },
235
250
  {
236
251
  id: 10,
@@ -288,7 +303,10 @@ describe("selectors: getParsedEvents", () => {
288
303
  payload: {
289
304
  content: {
290
305
  removed: {},
291
- changed: { changed_field_1: { origin: "origin", value: null }, changed_field_2: { origin: "origin", value: "value_2" } },
306
+ changed: {
307
+ changed_field_1: { origin: "origin", value: null },
308
+ changed_field_2: { origin: "origin", value: "value_2" },
309
+ },
292
310
  added: {},
293
311
  },
294
312
  },
@@ -310,7 +328,22 @@ describe("selectors: getParsedEvents", () => {
310
328
  it("should return all the events with the new payload", () => {
311
329
  const res = getParsedEvents({ events, concept });
312
330
  expect(res).toHaveLength(14);
313
- expect(res).toEqual([r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14]);
331
+ expect(res).toEqual([
332
+ r1,
333
+ r2,
334
+ r3,
335
+ r4,
336
+ r5,
337
+ r6,
338
+ r7,
339
+ r8,
340
+ r9,
341
+ r10,
342
+ r11,
343
+ r12,
344
+ r13,
345
+ r14,
346
+ ]);
314
347
  });
315
348
 
316
349
  it("should return empty array when we have no elements", () => {
@@ -565,17 +598,40 @@ describe("selectors: getParsedEvents", () => {
565
598
  content: [
566
599
  {
567
600
  fields: [
568
- { type: "string", name: "Checkbox String", label: "Checkbox String" },
601
+ {
602
+ type: "string",
603
+ name: "Checkbox String",
604
+ label: "Checkbox String",
605
+ },
569
606
  { type: "string", name: "Date", label: "Date" },
570
607
  { type: "string", name: "Date Time", label: "Date Time" },
571
- { type: "domain", name: "Dropdown Domain", label: "Dropdown Domain" },
572
- { type: "string", name: "Dropdown Key Value", label: "Dropdown Key Value" },
573
- { type: "string", name: "Dropdown String", label: "Dropdown String" },
574
- { type: "system", name: "Dropdown System", label: "Dropdown System" },
575
- { type: "enriched_text", name: "Enrichedtext", label: "Enrichedtext" },
608
+ {
609
+ type: "domain",
610
+ name: "Dropdown Domain",
611
+ label: "Dropdown Domain",
612
+ },
613
+ {
614
+ type: "string",
615
+ name: "Dropdown Key Value",
616
+ label: "Dropdown Key Value",
617
+ },
618
+ {
619
+ type: "string",
620
+ name: "Dropdown String",
621
+ label: "Dropdown String",
622
+ },
623
+ {
624
+ type: "system",
625
+ name: "Dropdown System",
626
+ label: "Dropdown System",
627
+ },
576
628
  { type: "string", name: "Extra", label: "Extra" },
577
629
  { type: "hierarchy", name: "Hierarchy", label: "Hierarchy" },
578
- { type: "hierarchy", name: "Hierarchy multiple", label: "Hierarchy multiple" },
630
+ {
631
+ type: "hierarchy",
632
+ name: "Hierarchy multiple",
633
+ label: "Hierarchy multiple",
634
+ },
579
635
  { type: "url", name: "Links", label: "Links" },
580
636
  { type: "integer", name: "Number", label: "Number" },
581
637
  { type: "string", name: "Radio String", label: "Radio String" },
@@ -640,7 +696,10 @@ describe("selectors: getParsedEvents", () => {
640
696
  });
641
697
  expect(res[0].payload).toContainEqual({
642
698
  msg_key: "changed_field",
643
- msg_params: ["Dropdown String", JSON.stringify(["option_a", "option_b"])],
699
+ msg_params: [
700
+ "Dropdown String",
701
+ JSON.stringify(["option_a", "option_b"]),
702
+ ],
644
703
  msg_via: "single_update",
645
704
  });
646
705
  expect(res[0].payload).toContainEqual({
@@ -748,7 +807,7 @@ describe("selectors: getParsedEvents", () => {
748
807
  });
749
808
  });
750
809
 
751
- it("should NOT show values for complex field types (enriched_text, url, table, system, image)", () => {
810
+ it("should NOT show values for complex field types (url, table, system, image)", () => {
752
811
  const events = [
753
812
  {
754
813
  id: 1,
@@ -766,30 +825,6 @@ describe("selectors: getParsedEvents", () => {
766
825
  name: "System Bar",
767
826
  },
768
827
  },
769
- Enrichedtext: {
770
- origin: "user",
771
- value: {
772
- document: {
773
- data: {},
774
- nodes: [
775
- {
776
- data: {},
777
- nodes: [
778
- {
779
- marks: [],
780
- object: "text",
781
- text: "Lorem ipsum dolor sit amet",
782
- },
783
- ],
784
- object: "block",
785
- type: "paragraph",
786
- },
787
- ],
788
- object: "document",
789
- },
790
- object: "value",
791
- },
792
- },
793
828
  Links: {
794
829
  origin: "user",
795
830
  value: [
@@ -835,14 +870,6 @@ describe("selectors: getParsedEvents", () => {
835
870
  ],
836
871
  msg_via: "single_update",
837
872
  });
838
- expect(res[0].payload).toContainEqual({
839
- msg_key: "changed_field_without_target",
840
- msg_params: [
841
- "Enrichedtext",
842
- expect.stringContaining("Lorem ipsum dolor sit amet"),
843
- ],
844
- msg_via: "single_update",
845
- });
846
873
  expect(res[0].payload).toContainEqual({
847
874
  msg_key: "changed_field_without_target",
848
875
  msg_params: [
@@ -988,7 +1015,7 @@ describe("selectors: getParsedEvents", () => {
988
1015
  expect(res[0].payload).not.toContainEqual(
989
1016
  expect.objectContaining({
990
1017
  msg_key: "confidential_true",
991
- })
1018
+ }),
992
1019
  );
993
1020
  });
994
1021
  });
@@ -30,7 +30,7 @@ const getConceptFieldChanges = (
30
30
  fields,
31
31
  templateFields,
32
32
  fieldsWithoutValue,
33
- event_via
33
+ event_via,
34
34
  ) =>
35
35
  _.flow(
36
36
  _.toPairs,
@@ -38,8 +38,8 @@ const getConceptFieldChanges = (
38
38
  _.map(([k, fieldValue]) => {
39
39
  const v =
40
40
  _.isObject(fieldValue) &&
41
- !_.isNull(fieldValue) &&
42
- _.has("value", fieldValue)
41
+ !_.isNull(fieldValue) &&
42
+ _.has("value", fieldValue)
43
43
  ? fieldValue.value
44
44
  : fieldValue;
45
45
  return {
@@ -47,28 +47,26 @@ const getConceptFieldChanges = (
47
47
  msg_params: [getFieldLabel(k, templateFields), toStr(v)],
48
48
  msg_via: event_via,
49
49
  };
50
- })
50
+ }),
51
51
  )(fields);
52
52
 
53
53
  const fromValueType = (msg_key, field, value, fieldsWithoutValue) =>
54
- _.isString(value) ? msg_key :
55
- _.includes(field)(fieldsWithoutValue) ||
56
- _.isNil(value)
57
- ? msg_key + "_without_target"
58
- : msg_key;
54
+ _.includes(field)(fieldsWithoutValue) || _.isNil(value)
55
+ ? msg_key + "_without_target"
56
+ : msg_key;
59
57
 
60
58
  const getFieldLabel = (field, fields) =>
61
59
  _.flow(
62
60
  _.find((f) => _.prop("name")(f) == field),
63
61
  _.defaultTo({}),
64
- _.prop("label")
62
+ _.prop("label"),
65
63
  )(fields) || field;
66
64
 
67
65
  const getUpdateConceptEvent = (
68
66
  { payload, ...e },
69
67
  templateFields,
70
68
  fieldsWithoutValue,
71
- options = {}
69
+ options = {},
72
70
  ) => {
73
71
  if (!payload) return { ...e, payload: [] };
74
72
 
@@ -163,29 +161,27 @@ const getUpdateConceptEvent = (
163
161
  changed,
164
162
  templateFields,
165
163
  fieldsWithoutValue,
166
- event_via
164
+ event_via,
167
165
  ),
168
166
  getConceptFieldChanges(
169
167
  "added_field",
170
168
  added,
171
169
  templateFields,
172
170
  fieldsWithoutValue,
173
- event_via
171
+ event_via,
174
172
  ),
175
173
  getConceptFieldChanges(
176
174
  "removed_field",
177
175
  removed,
178
176
  templateFields,
179
177
  fieldsWithoutValue,
180
- event_via
178
+ event_via,
181
179
  ),
182
180
  ]),
183
- _.flatten
181
+ _.flatten,
184
182
  )([]);
185
183
  }
186
184
 
187
-
188
-
189
185
  if (field_config.length === 0) {
190
186
  return { ...e, payload: [{ msg_via: event_via }] };
191
187
  }
@@ -209,14 +205,16 @@ const getRelationFromConceptToFieldEvent = ({ payload, ...e }) => {
209
205
  return { ...e, payload: [{ msg_key, msg_params, msg_via: event_via }] };
210
206
  };
211
207
 
212
-
213
208
  const enrichEvent = ({ payload, ...e }, event_message_key) => {
214
209
  const { event_via, target_id, target_type, target_name } = payload;
215
210
  const msg_key = target_type
216
211
  ? `${event_message_key}_${toStr(target_type)}`
217
212
  : event_message_key;
218
213
  const msg_params = [target_name || toStr(target_id)];
219
- return { ...e, payload: [{ msg_key, msg_params: msg_params, msg_via: event_via }] };
214
+ return {
215
+ ...e,
216
+ payload: [{ msg_key, msg_params: msg_params, msg_via: event_via }],
217
+ };
220
218
  };
221
219
 
222
220
  const addEventVia = ({ payload, ...e }) => {
@@ -232,37 +230,34 @@ const getParsedEvents = createSelector(
232
230
  const templateFields = _.flow(
233
231
  _.prop("content"),
234
232
  _.map(_.prop("fields")),
235
- _.flatten
233
+ _.flatten,
236
234
  )(template);
237
235
 
238
236
  const fieldsWithoutValue = _.flow(
239
237
  _.filter((f) =>
240
238
  _.includes(_.prop("type")(f))([
241
- "enriched_text",
242
239
  "url",
243
240
  "table",
244
241
  "system",
245
242
  "image",
246
- ])
243
+ "markdown",
244
+ ]),
247
245
  ),
248
- _.map(_.prop("name"))
246
+ _.map(_.prop("name")),
249
247
  )(templateFields);
248
+
250
249
  return _.map((e) => {
251
250
  const { event } = e;
252
251
  if (event === "create_concept_draft") {
253
252
  return getNewConceptVersion(e);
254
253
  } else if (event === "update_concept_draft") {
255
- return getUpdateConceptEvent(
256
- e,
257
- templateFields,
258
- fieldsWithoutValue,
259
- { isDraft: true });
254
+ return getUpdateConceptEvent(e, templateFields, fieldsWithoutValue, {
255
+ isDraft: true,
256
+ });
260
257
  } else if (event === "update_concept") {
261
- return getUpdateConceptEvent(
262
- e,
263
- templateFields,
264
- fieldsWithoutValue,
265
- { isDraft: false });
258
+ return getUpdateConceptEvent(e, templateFields, fieldsWithoutValue, {
259
+ isDraft: false,
260
+ });
266
261
  } else if (event === "delete_concept_draft") {
267
262
  return getDeleteConceptDraftEvent(e);
268
263
  } else if (event === "new_published_version") {
@@ -296,7 +291,7 @@ const getParsedEvents = createSelector(
296
291
  return getEmptyPayloadEvent(e);
297
292
  }
298
293
  })(events);
299
- }
294
+ },
300
295
  );
301
296
 
302
297
  export { getParsedEvents };