@memori.ai/memori-react 7.4.0 โ 7.4.2
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/CHANGELOG.md +14 -0
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.d.ts +1 -2
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +2 -2
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/helpers/error.js +16 -0
- package/dist/helpers/error.js.map +1 -1
- package/dist/helpers/statistics.d.ts +1 -12
- package/dist/helpers/statistics.js +1 -165
- package/dist/helpers/statistics.js.map +1 -1
- package/dist/locales/en.json +32 -16
- package/dist/locales/it.json +18 -2
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.d.ts +1 -2
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +2 -2
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/helpers/error.js +16 -0
- package/esm/helpers/error.js.map +1 -1
- package/esm/helpers/statistics.d.ts +1 -12
- package/esm/helpers/statistics.js +0 -156
- package/esm/helpers/statistics.js.map +1 -1
- package/esm/locales/en.json +32 -16
- package/esm/locales/it.json +18 -2
- package/package.json +2 -2
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +1 -2
- package/src/components/MemoriWidget/MemoriWidget.tsx +0 -1
- package/src/components/StartPanel/StartPanel.test.tsx +6 -1
- package/src/components/StartPanel/StartPanel.tsx +1 -1
- package/src/helpers/error.ts +17 -0
- package/src/helpers/statistics.ts +1 -195
- package/src/locales/en.json +33 -16
- package/src/locales/it.json +19 -2
- package/src/helpers/statistics.test.ts +0 -213
|
@@ -1,126 +1,3 @@
|
|
|
1
|
-
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
2
|
-
const { deleteSession, getStatistics, initSession } = memoriApiClient();
|
|
3
|
-
const conversionTable = {
|
|
4
|
-
totalReceivers: 0.2,
|
|
5
|
-
receiversWithMemories: 0.4,
|
|
6
|
-
totalMemories: 0.2,
|
|
7
|
-
publicMemories: 0.4,
|
|
8
|
-
memoriesWithMedia: 0.4,
|
|
9
|
-
totalQuestions: 0.2,
|
|
10
|
-
publicQuestions: 0.3,
|
|
11
|
-
questionsWithMoreThanOneAnswer: 0.4,
|
|
12
|
-
totalStories: 0.2,
|
|
13
|
-
publicStories: 0.4,
|
|
14
|
-
storiesWithDate: 0.5,
|
|
15
|
-
storiesWithPlace: 0.4,
|
|
16
|
-
storiesWithDateAndPlace: 0.6,
|
|
17
|
-
unansweredQuestions: 0,
|
|
18
|
-
successfulCorrelations: 0,
|
|
19
|
-
failedCorrelations: 0,
|
|
20
|
-
};
|
|
21
|
-
export const BADGES_MAP = new Map([
|
|
22
|
-
[0, '๐'],
|
|
23
|
-
[10, '๐น'],
|
|
24
|
-
[20, '๐'],
|
|
25
|
-
[30, '๐ฐ'],
|
|
26
|
-
[40, '๐ก'],
|
|
27
|
-
[50, '๐'],
|
|
28
|
-
[60, '๐
'],
|
|
29
|
-
[70, '๐ฅ'],
|
|
30
|
-
[80, '๐ฅ'],
|
|
31
|
-
[90, '๐ฅ'],
|
|
32
|
-
[100, '๐ฅ'],
|
|
33
|
-
[110, '๐'],
|
|
34
|
-
[120, '๐ค'],
|
|
35
|
-
[130, '๐พ'],
|
|
36
|
-
[150, '๐'],
|
|
37
|
-
[180, '๐'],
|
|
38
|
-
[200, '๐'],
|
|
39
|
-
[250, '๐งก'],
|
|
40
|
-
[300, '๐'],
|
|
41
|
-
[350, '๐'],
|
|
42
|
-
[400, '๐'],
|
|
43
|
-
[450, '๐'],
|
|
44
|
-
[500, '๐ค'],
|
|
45
|
-
[550, 'โค๏ธ'],
|
|
46
|
-
[600, '๐ง '],
|
|
47
|
-
]);
|
|
48
|
-
export const getBadge = (points) => {
|
|
49
|
-
const unlockedBadges = Array.from(BADGES_MAP.keys()).filter((k) => k <= points);
|
|
50
|
-
if (unlockedBadges.length > 0) {
|
|
51
|
-
const lastBadge = unlockedBadges[unlockedBadges.length - 1];
|
|
52
|
-
return BADGES_MAP.get(lastBadge);
|
|
53
|
-
}
|
|
54
|
-
return '';
|
|
55
|
-
};
|
|
56
|
-
export const getNextBadge = (badge) => {
|
|
57
|
-
if (badge === '๐') {
|
|
58
|
-
return { points: 10, badge: '๐น' };
|
|
59
|
-
}
|
|
60
|
-
let nextBadgePoints;
|
|
61
|
-
let nextBadge;
|
|
62
|
-
let currentSeen = false;
|
|
63
|
-
for (const [key, value] of BADGES_MAP) {
|
|
64
|
-
if (currentSeen) {
|
|
65
|
-
nextBadgePoints = key;
|
|
66
|
-
nextBadge = value;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
if (value === badge) {
|
|
70
|
-
currentSeen = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return nextBadge && nextBadgePoints
|
|
74
|
-
? {
|
|
75
|
-
points: nextBadgePoints,
|
|
76
|
-
badge: nextBadge,
|
|
77
|
-
}
|
|
78
|
-
: undefined;
|
|
79
|
-
};
|
|
80
|
-
export const getPointsForBadge = (badge) => {
|
|
81
|
-
let points = 0;
|
|
82
|
-
for (const [key, value] of BADGES_MAP) {
|
|
83
|
-
if (value === badge) {
|
|
84
|
-
points = key;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return points;
|
|
89
|
-
};
|
|
90
|
-
export const getPointsFromStats = (stats) => {
|
|
91
|
-
let points = 0;
|
|
92
|
-
Object.entries(stats).forEach(stat => {
|
|
93
|
-
if (stat[0] in conversionTable) {
|
|
94
|
-
points += stat[1] * conversionTable[stat[0]];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
return Math.trunc(points);
|
|
98
|
-
};
|
|
99
|
-
export const getGamificationLevel = (points) => {
|
|
100
|
-
const roundedPoints = Math.round(points);
|
|
101
|
-
const badge = getBadge(roundedPoints);
|
|
102
|
-
const pointsForCurrentBadge = getPointsForBadge(badge);
|
|
103
|
-
const nextBadge = getNextBadge(badge);
|
|
104
|
-
return {
|
|
105
|
-
points: roundedPoints,
|
|
106
|
-
badge,
|
|
107
|
-
pointsForCurrentBadge,
|
|
108
|
-
nextBadge,
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
export const getGamificationLevelByStats = (stats) => {
|
|
112
|
-
const floatPoints = getPointsFromStats(stats);
|
|
113
|
-
const points = Math.round(floatPoints);
|
|
114
|
-
const badge = getBadge(points);
|
|
115
|
-
const pointsForCurrentBadge = getPointsForBadge(badge);
|
|
116
|
-
const nextBadge = getNextBadge(badge);
|
|
117
|
-
return {
|
|
118
|
-
points,
|
|
119
|
-
badge,
|
|
120
|
-
pointsForCurrentBadge,
|
|
121
|
-
nextBadge,
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
1
|
const groupBy = (array, predicate) => array.reduce((acc, value) => {
|
|
125
2
|
if (!acc[predicate(value)]) {
|
|
126
3
|
acc[predicate(value)] = [];
|
|
@@ -168,37 +45,4 @@ export const eventLogGroupUsersByDate = (eventLogs) => {
|
|
|
168
45
|
});
|
|
169
46
|
return userLogs;
|
|
170
47
|
};
|
|
171
|
-
export const getMemoriUnansQuestions = async (memori) => {
|
|
172
|
-
var _a, _b;
|
|
173
|
-
if (memori.privacyType === 'SECRET' || !memori.isGiver)
|
|
174
|
-
return 0;
|
|
175
|
-
try {
|
|
176
|
-
if (!memori.giverTag && !!((_a = memori.receivedInvitations) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
177
|
-
let giverInvitation = memori.receivedInvitations.find((i) => i.type === 'GIVER' && i.state === 'ACCEPTED');
|
|
178
|
-
if (giverInvitation) {
|
|
179
|
-
memori.giverTag = giverInvitation.tag;
|
|
180
|
-
memori.giverPIN = giverInvitation.pin;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const { sessionID, currentState, ...response } = await initSession({
|
|
184
|
-
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
185
|
-
password: memori.secretToken,
|
|
186
|
-
tag: memori.giverTag,
|
|
187
|
-
pin: memori.giverPIN,
|
|
188
|
-
});
|
|
189
|
-
if (response.resultCode !== 0 || !sessionID) {
|
|
190
|
-
return 0;
|
|
191
|
-
}
|
|
192
|
-
const { statistics, ...resp } = await getStatistics(sessionID);
|
|
193
|
-
await deleteSession(sessionID);
|
|
194
|
-
if (statistics && resp.resultCode === 0) {
|
|
195
|
-
return statistics.unansweredQuestions;
|
|
196
|
-
}
|
|
197
|
-
return 0;
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
console.log(e);
|
|
201
|
-
return 0;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
48
|
//# sourceMappingURL=statistics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.js","sourceRoot":"","sources":["../../src/helpers/statistics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statistics.js","sourceRoot":"","sources":["../../src/helpers/statistics.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,CAAI,KAAU,EAAE,SAA2B,EAAE,EAAE,CAC7D,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;IAC1B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;QAC1B,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;KAC5B;IACD,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAA4B,CAAC,CAAC;AAEnC,MAAM,gBAAgB,GAAG,CAAC,IAAgB,EAA6B,EAAE;IACvE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAC9B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,cAAc,IAAI,GAAG,CAAC,SAAS,KAAK,IAAI,CAClE,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CACrC,CAAC,GAA8B,EAAE,CAAC,EAAE,EAAE;QACpC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAmB,CAAC,EAAE;YAC/B,GAAG,CAAC,CAAC,CAAC,SAAmB,CAAC,GAAG,CAAC,CAAC;SAChC;QACD,GAAG,CAAC,CAAC,CAAC,SAAmB,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAc,EAAE;IAC5E,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrC,GAAG,KAAK;QACR,SAAS,EAAE,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;YACvC,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;KACrC,CAAC,CAAC,CAAC;IACJ,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAe,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC1D,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,IAAI,mBAAmB,GAAG,CAAC,CAAC;QAC5B,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YACnD,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACrB,mBAAmB,IAAI,CAAC,CAAC;aAC1B;SACF;QACD,OAAO;YACL,SAAS,EAAE,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;gBACvC,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,mBAAmB;YACnB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM;SAC5C,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/esm/locales/en.json
CHANGED
|
@@ -275,22 +275,23 @@
|
|
|
275
275
|
"SESSION_NOT_FOUND": "Session not found",
|
|
276
276
|
"SESSION_IS_NOT_ADMINISTRATIVE": "Non-administrative session",
|
|
277
277
|
"SESSION_EXPIRED": "Session expired",
|
|
278
|
-
"MEMORI_MISSING_CONFIGURATION": "
|
|
279
|
-
"MEMORI_CONFIGURATION_NOT_FOUND": "
|
|
280
|
-
"MEMORI_INVALID_PRIVACY_TYPE": "
|
|
281
|
-
"MEMORI_MISSING_PASSWORD": "
|
|
282
|
-
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "
|
|
283
|
-
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "
|
|
284
|
-
"MEMORI_INVALID_VOICE_TYPE": "
|
|
285
|
-
"MEMORI_MISSING_NAME": "
|
|
286
|
-
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "
|
|
287
|
-
"MEMORI_INVALID_ID": "
|
|
288
|
-
"MEMORI_NAME_ALREADY_USED": "
|
|
289
|
-
"MEMORI_INVALID_PIN": "
|
|
290
|
-
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "
|
|
291
|
-
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "
|
|
278
|
+
"MEMORI_MISSING_CONFIGURATION": "Twin: missing configuration",
|
|
279
|
+
"MEMORI_CONFIGURATION_NOT_FOUND": "Twin: configuration not found",
|
|
280
|
+
"MEMORI_INVALID_PRIVACY_TYPE": "Twin: invalid privacy type",
|
|
281
|
+
"MEMORI_MISSING_PASSWORD": "Twin: missing password",
|
|
282
|
+
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "Twin: total number of invalid recovery tokens",
|
|
283
|
+
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "Twin: minimum number of invalid recovery tokens",
|
|
284
|
+
"MEMORI_INVALID_VOICE_TYPE": "Twin: invalid voice type",
|
|
285
|
+
"MEMORI_MISSING_NAME": "Twin: missing name",
|
|
286
|
+
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "Twin: missing password or recovery token",
|
|
287
|
+
"MEMORI_INVALID_ID": "Twin: invalid ID",
|
|
288
|
+
"MEMORI_NAME_ALREADY_USED": "Twin name already in use",
|
|
289
|
+
"MEMORI_INVALID_PIN": "Twin: Invalid PIN",
|
|
290
|
+
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Twin: TAG and PIN change require separate operations",
|
|
291
|
+
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Twin: no password required when public",
|
|
292
292
|
"MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Deep Thought requires completions to be enabled",
|
|
293
293
|
"MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "The expert group requires completions to be enabled",
|
|
294
|
+
"MEMORI_INVALID_COMPLETION_CONFIG": "Twin: invalid completions configuration",
|
|
294
295
|
"MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Transfer: missing destination user",
|
|
295
296
|
"MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Transfer: invalid destination user ID",
|
|
296
297
|
"MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT": "Transfer: invalid destination user data",
|
|
@@ -399,7 +400,22 @@
|
|
|
399
400
|
"BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_HASH_TYPE": "Badge assignment: recipient hash type unknown",
|
|
400
401
|
"BADGE_ASSIGNMENT_WRONG_RECIPIENT_IDENTITY": "Badge assignment: incorrect recipient identity",
|
|
401
402
|
"BADGE_NOT_FOUND": "Badge not found",
|
|
402
|
-
"OUTCOME_NO_DCM_CONFIGURED": "
|
|
403
|
-
"OUTCOME_USER_BADGES_DISABLED": "
|
|
403
|
+
"OUTCOME_NO_DCM_CONFIGURED": "Outcome: no DCM configured",
|
|
404
|
+
"OUTCOME_USER_BADGES_DISABLED": "Outcome: user badges disabled",
|
|
405
|
+
"COMPLETION_CONFIG_MISSING_NAME": "Completions configuration: missing name",
|
|
406
|
+
"COMPLETION_CONFIG_MISSING_PROVIDER": "Completions configuration: missing provider",
|
|
407
|
+
"COMPLETION_CONFIG_MISSING_ENDPOINT": "Completions configuration: missing endpoint",
|
|
408
|
+
"COMPLETION_CONFIG_MISSING_API_KEY": "Completions configuration: missing API key",
|
|
409
|
+
"COMPLETION_CONFIG_MISSING_MODEL": "Completions configuration: missing model",
|
|
410
|
+
"COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED": "Completions configuration: at least one completions type must be specified",
|
|
411
|
+
"COMPLETION_CONFIG_INVALID_PURPOSE": "Completions configuration: invalid completions type",
|
|
412
|
+
"COMPLETION_CONFIG_INVALID_ENDPOINT": "Completions configuration: invalid endpoint",
|
|
413
|
+
"COMPLETION_CONFIG_INCONSISTENT_ENDPOINT": "Completions configuration: inconsistent endpoint",
|
|
414
|
+
"COMPLETION_CONFIG_INVALID_PROVIDER": "Completions configuration: invalid provider",
|
|
415
|
+
"COMPLETION_CONFIG_NOT_FOUND": "Completions configuration: not found",
|
|
416
|
+
"COMPLETION_CONFIG_NOT_ACCESSIBLE": "Completions configuration: not accessible",
|
|
417
|
+
"COMPLETION_CONFIG_NAME_RESERVED": "Completions configuration: name reserved",
|
|
418
|
+
"COMPLETION_CONFIG_NAME_ALREADY_EXISTS": "Completions configuration: name already exists",
|
|
419
|
+
"COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED": "Completions configuration: visibility change not allowed"
|
|
404
420
|
}
|
|
405
421
|
}
|
package/esm/locales/it.json
CHANGED
|
@@ -290,6 +290,7 @@
|
|
|
290
290
|
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Memori: password non richiesta su Memori pubblico",
|
|
291
291
|
"MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Pensiero Profondo richiede l'abilitazione delle completions",
|
|
292
292
|
"MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "Il gruppo di esperti richiede l'abilitazione delle completions",
|
|
293
|
+
"MEMORI_INVALID_COMPLETION_CONFIG": "Memori: configurazione completions non valida",
|
|
293
294
|
"MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Trasferimento: utente di destinazione mancante",
|
|
294
295
|
"MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Trasferimento: ID utente di destinazione non valido",
|
|
295
296
|
"MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT": "Trasferimento: dati utente di destinazione non validi",
|
|
@@ -398,7 +399,22 @@
|
|
|
398
399
|
"BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_HASH_TYPE": "Assegnazione badge: tipo hash destinatario sconosciuto",
|
|
399
400
|
"BADGE_ASSIGNMENT_WRONG_RECIPIENT_IDENTITY": "Assegnazione badge: identitร destinatario errata",
|
|
400
401
|
"BADGE_NOT_FOUND": "Badge non trovato",
|
|
401
|
-
"OUTCOME_NO_DCM_CONFIGURED": "
|
|
402
|
-
"OUTCOME_USER_BADGES_DISABLED": "
|
|
402
|
+
"OUTCOME_NO_DCM_CONFIGURED": "Outcome: nessun DCM configurato",
|
|
403
|
+
"OUTCOME_USER_BADGES_DISABLED": "Outcome: badge utente disabilitati",
|
|
404
|
+
"COMPLETION_CONFIG_MISSING_NAME": "Configurazione completions: nome mancante",
|
|
405
|
+
"COMPLETION_CONFIG_MISSING_PROVIDER": "Configurazione completions: provider mancante",
|
|
406
|
+
"COMPLETION_CONFIG_MISSING_ENDPOINT": "Configurazione completions: endpoint mancante",
|
|
407
|
+
"COMPLETION_CONFIG_MISSING_API_KEY": "Configurazione completions: API key mancante",
|
|
408
|
+
"COMPLETION_CONFIG_MISSING_MODEL": "Configurazione completions: modello mancante",
|
|
409
|
+
"COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED": "Configurazione completions: almeno un tipo di completions deve essere specificato",
|
|
410
|
+
"COMPLETION_CONFIG_INVALID_PURPOSE": "Configurazione completions: tipo di completions non valido",
|
|
411
|
+
"COMPLETION_CONFIG_INVALID_ENDPOINT": "Configurazione completions: endpoint non valido",
|
|
412
|
+
"COMPLETION_CONFIG_INCONSISTENT_ENDPOINT": "Configurazione completions: endpoint incoerente",
|
|
413
|
+
"COMPLETION_CONFIG_INVALID_PROVIDER": "Configurazione completions: provider non valido",
|
|
414
|
+
"COMPLETION_CONFIG_NOT_FOUND": "Configurazione completions: non trovata",
|
|
415
|
+
"COMPLETION_CONFIG_NOT_ACCESSIBLE": "Configurazione completions: non accessibile",
|
|
416
|
+
"COMPLETION_CONFIG_NAME_RESERVED": "Configurazione completions: nome riservato",
|
|
417
|
+
"COMPLETION_CONFIG_NAME_ALREADY_EXISTS": "Configurazione completions: nome giร esistente",
|
|
418
|
+
"COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED": "Configurazione completions: cambiamento visibilitร non consentito"
|
|
403
419
|
}
|
|
404
420
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "7.4.
|
|
2
|
+
"version": "7.4.2",
|
|
3
3
|
"name": "@memori.ai/memori-react",
|
|
4
4
|
"author": "Memori Srl",
|
|
5
5
|
"main": "dist/index.js",
|
|
@@ -292,7 +292,7 @@
|
|
|
292
292
|
},
|
|
293
293
|
"dependencies": {
|
|
294
294
|
"@headlessui/react": "1.7.4",
|
|
295
|
-
"@memori.ai/memori-api-client": "^5.
|
|
295
|
+
"@memori.ai/memori-api-client": "^5.1.1",
|
|
296
296
|
"@react-three/drei": "8.20.2",
|
|
297
297
|
"@react-three/fiber": "7.0.25",
|
|
298
298
|
"classnames": "2.3.2",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import Tooltip from '../ui/Tooltip';
|
|
3
3
|
import Warning from '../icons/Warning';
|
|
4
|
-
import { Tenant } from '@memori.ai/memori-api-client/dist/types';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
|
|
7
6
|
type Status =
|
|
@@ -13,7 +12,7 @@ type Status =
|
|
|
13
12
|
|
|
14
13
|
export interface Props {
|
|
15
14
|
forceStatus?: Status;
|
|
16
|
-
provider?:
|
|
15
|
+
provider?: string;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
const initProviderStatus = (
|
|
@@ -229,7 +229,12 @@ it('renders StartPanel with completion provider down unchanged', () => {
|
|
|
229
229
|
<StartPanel
|
|
230
230
|
memori={{
|
|
231
231
|
...memori,
|
|
232
|
-
|
|
232
|
+
completionConfigForQuestionAnswering: {
|
|
233
|
+
completionConfigID: '1',
|
|
234
|
+
configName: 'openai-gpt-4',
|
|
235
|
+
provider: 'OpenAI',
|
|
236
|
+
model: 'gpt-4',
|
|
237
|
+
},
|
|
233
238
|
}}
|
|
234
239
|
tenant={tenant}
|
|
235
240
|
language="it"
|
package/src/helpers/error.ts
CHANGED
|
@@ -63,6 +63,7 @@ const errors = {
|
|
|
63
63
|
MEMORI_NO_PASSWORD_WHEN_PUBLIC: -214,
|
|
64
64
|
MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS: -215,
|
|
65
65
|
MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS: -216,
|
|
66
|
+
MEMORI_INVALID_COMPLETION_CONFIG: -217,
|
|
66
67
|
|
|
67
68
|
MEMORI_TRANSFER_MISSING_DESTINATION_USER: -231,
|
|
68
69
|
MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID: -232,
|
|
@@ -195,6 +196,22 @@ const errors = {
|
|
|
195
196
|
|
|
196
197
|
OUTCOME_NO_DCM_CONFIGURED: -2071,
|
|
197
198
|
OUTCOME_USER_BADGES_DISABLED: -2072,
|
|
199
|
+
|
|
200
|
+
COMPLETION_CONFIG_MISSING_NAME: -2401,
|
|
201
|
+
COMPLETION_CONFIG_MISSING_PROVIDER: -2402,
|
|
202
|
+
COMPLETION_CONFIG_MISSING_ENDPOINT: -2403,
|
|
203
|
+
COMPLETION_CONFIG_MISSING_API_KEY: -2404,
|
|
204
|
+
COMPLETION_CONFIG_MISSING_MODEL: -2405,
|
|
205
|
+
COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED: -2406,
|
|
206
|
+
COMPLETION_CONFIG_INVALID_PURPOSE: -2411,
|
|
207
|
+
COMPLETION_CONFIG_INVALID_ENDPOINT: -2412,
|
|
208
|
+
COMPLETION_CONFIG_INCONSISTENT_ENDPOINT: -2413,
|
|
209
|
+
COMPLETION_CONFIG_INVALID_PROVIDER: -2414,
|
|
210
|
+
COMPLETION_CONFIG_NOT_FOUND: -2421,
|
|
211
|
+
COMPLETION_CONFIG_NOT_ACCESSIBLE: -2422,
|
|
212
|
+
COMPLETION_CONFIG_NAME_RESERVED: -2441,
|
|
213
|
+
COMPLETION_CONFIG_NAME_ALREADY_EXISTS: -2442,
|
|
214
|
+
COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED: -2443,
|
|
198
215
|
};
|
|
199
216
|
|
|
200
217
|
export const BACKEND_ERRORS = new Map<number, string>(
|
|
@@ -1,158 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Stats,
|
|
3
|
-
GamificationLevel,
|
|
4
|
-
EventLog,
|
|
5
|
-
UsersLog,
|
|
6
|
-
Memori,
|
|
7
|
-
Invitation,
|
|
8
|
-
} from '@memori.ai/memori-api-client/dist/types';
|
|
9
|
-
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
10
|
-
|
|
11
|
-
const { deleteSession, getStatistics, initSession } = memoriApiClient();
|
|
12
|
-
|
|
13
|
-
const conversionTable: { [key: string]: number } = {
|
|
14
|
-
totalReceivers: 0.2,
|
|
15
|
-
receiversWithMemories: 0.4,
|
|
16
|
-
totalMemories: 0.2,
|
|
17
|
-
publicMemories: 0.4,
|
|
18
|
-
memoriesWithMedia: 0.4,
|
|
19
|
-
totalQuestions: 0.2,
|
|
20
|
-
publicQuestions: 0.3,
|
|
21
|
-
questionsWithMoreThanOneAnswer: 0.4,
|
|
22
|
-
totalStories: 0.2,
|
|
23
|
-
publicStories: 0.4,
|
|
24
|
-
storiesWithDate: 0.5,
|
|
25
|
-
storiesWithPlace: 0.4,
|
|
26
|
-
storiesWithDateAndPlace: 0.6,
|
|
27
|
-
unansweredQuestions: 0,
|
|
28
|
-
successfulCorrelations: 0,
|
|
29
|
-
failedCorrelations: 0,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const BADGES_MAP: Map<number, string> = new Map([
|
|
33
|
-
[0, '๐'],
|
|
34
|
-
[10, '๐น'],
|
|
35
|
-
[20, '๐'],
|
|
36
|
-
[30, '๐ฐ'],
|
|
37
|
-
[40, '๐ก'],
|
|
38
|
-
[50, '๐'],
|
|
39
|
-
[60, '๐
'],
|
|
40
|
-
[70, '๐ฅ'],
|
|
41
|
-
[80, '๐ฅ'],
|
|
42
|
-
[90, '๐ฅ'],
|
|
43
|
-
[100, '๐ฅ'],
|
|
44
|
-
[110, '๐'],
|
|
45
|
-
[120, '๐ค'],
|
|
46
|
-
[130, '๐พ'],
|
|
47
|
-
[150, '๐'],
|
|
48
|
-
[180, '๐'],
|
|
49
|
-
[200, '๐'],
|
|
50
|
-
[250, '๐งก'],
|
|
51
|
-
[300, '๐'],
|
|
52
|
-
[350, '๐'],
|
|
53
|
-
[400, '๐'],
|
|
54
|
-
[450, '๐'],
|
|
55
|
-
[500, '๐ค'],
|
|
56
|
-
[550, 'โค๏ธ'],
|
|
57
|
-
[600, '๐ง '],
|
|
58
|
-
]);
|
|
59
|
-
|
|
60
|
-
export const getBadge = (points: number): string => {
|
|
61
|
-
const unlockedBadges = Array.from(BADGES_MAP.keys()).filter(
|
|
62
|
-
(k: number) => k <= points
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (unlockedBadges.length > 0) {
|
|
66
|
-
const lastBadge = unlockedBadges[unlockedBadges.length - 1];
|
|
67
|
-
return BADGES_MAP.get(lastBadge) as string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return '';
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const getNextBadge = (
|
|
74
|
-
badge: string
|
|
75
|
-
): { points: number; badge: string } | undefined => {
|
|
76
|
-
if (badge === '๐') {
|
|
77
|
-
return { points: 10, badge: '๐น' };
|
|
78
|
-
}
|
|
79
|
-
let nextBadgePoints;
|
|
80
|
-
let nextBadge;
|
|
81
|
-
|
|
82
|
-
let currentSeen = false;
|
|
83
|
-
for (const [key, value] of BADGES_MAP) {
|
|
84
|
-
if (currentSeen) {
|
|
85
|
-
nextBadgePoints = key;
|
|
86
|
-
nextBadge = value;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (value === badge) {
|
|
91
|
-
currentSeen = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return nextBadge && nextBadgePoints
|
|
96
|
-
? {
|
|
97
|
-
points: nextBadgePoints,
|
|
98
|
-
badge: nextBadge,
|
|
99
|
-
}
|
|
100
|
-
: undefined;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const getPointsForBadge = (badge: string): number => {
|
|
104
|
-
let points = 0;
|
|
105
|
-
|
|
106
|
-
for (const [key, value] of BADGES_MAP) {
|
|
107
|
-
if (value === badge) {
|
|
108
|
-
points = key;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return points;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const getPointsFromStats = (stats: Stats): number => {
|
|
117
|
-
let points = 0;
|
|
118
|
-
Object.entries(stats).forEach(stat => {
|
|
119
|
-
if (stat[0] in conversionTable) {
|
|
120
|
-
points += stat[1] * conversionTable[stat[0]];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return Math.trunc(points);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const getGamificationLevel = (points: number): GamificationLevel => {
|
|
127
|
-
const roundedPoints = Math.round(points);
|
|
128
|
-
const badge = getBadge(roundedPoints);
|
|
129
|
-
const pointsForCurrentBadge = getPointsForBadge(badge);
|
|
130
|
-
const nextBadge = getNextBadge(badge);
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
points: roundedPoints,
|
|
134
|
-
badge,
|
|
135
|
-
pointsForCurrentBadge,
|
|
136
|
-
nextBadge,
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const getGamificationLevelByStats = (
|
|
141
|
-
stats: Stats
|
|
142
|
-
): GamificationLevel => {
|
|
143
|
-
const floatPoints = getPointsFromStats(stats);
|
|
144
|
-
const points = Math.round(floatPoints);
|
|
145
|
-
const badge = getBadge(points);
|
|
146
|
-
const pointsForCurrentBadge = getPointsForBadge(badge);
|
|
147
|
-
const nextBadge = getNextBadge(badge);
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
points,
|
|
151
|
-
badge,
|
|
152
|
-
pointsForCurrentBadge,
|
|
153
|
-
nextBadge,
|
|
154
|
-
};
|
|
155
|
-
};
|
|
1
|
+
import { EventLog, UsersLog } from '@memori.ai/memori-api-client/dist/types';
|
|
156
2
|
|
|
157
3
|
const groupBy = <T>(array: T[], predicate: (v: T) => string) =>
|
|
158
4
|
array.reduce((acc, value) => {
|
|
@@ -210,43 +56,3 @@ export const eventLogGroupUsersByDate = (eventLogs: EventLog[]): UsersLog[] => {
|
|
|
210
56
|
});
|
|
211
57
|
return userLogs;
|
|
212
58
|
};
|
|
213
|
-
|
|
214
|
-
export const getMemoriUnansQuestions = async (memori: Memori) => {
|
|
215
|
-
if (memori.privacyType === 'SECRET' || !memori.isGiver) return 0;
|
|
216
|
-
try {
|
|
217
|
-
if (!memori.giverTag && !!memori.receivedInvitations?.length) {
|
|
218
|
-
let giverInvitation = memori.receivedInvitations.find(
|
|
219
|
-
(i: Invitation) => i.type === 'GIVER' && i.state === 'ACCEPTED'
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
if (giverInvitation) {
|
|
223
|
-
memori.giverTag = giverInvitation.tag;
|
|
224
|
-
memori.giverPIN = giverInvitation.pin;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const { sessionID, currentState, ...response } = await initSession({
|
|
229
|
-
memoriID: memori.engineMemoriID ?? '',
|
|
230
|
-
password: memori.secretToken,
|
|
231
|
-
tag: memori.giverTag,
|
|
232
|
-
pin: memori.giverPIN,
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
if (response.resultCode !== 0 || !sessionID) {
|
|
236
|
-
return 0;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const { statistics, ...resp } = await getStatistics(sessionID);
|
|
240
|
-
|
|
241
|
-
await deleteSession(sessionID);
|
|
242
|
-
|
|
243
|
-
if (statistics && resp.resultCode === 0) {
|
|
244
|
-
return statistics.unansweredQuestions;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return 0;
|
|
248
|
-
} catch (e) {
|
|
249
|
-
console.log(e);
|
|
250
|
-
return 0;
|
|
251
|
-
}
|
|
252
|
-
};
|
package/src/locales/en.json
CHANGED
|
@@ -280,22 +280,23 @@
|
|
|
280
280
|
"SESSION_IS_NOT_ADMINISTRATIVE": "Non-administrative session",
|
|
281
281
|
"SESSION_EXPIRED": "Session expired",
|
|
282
282
|
|
|
283
|
-
"MEMORI_MISSING_CONFIGURATION": "
|
|
284
|
-
"MEMORI_CONFIGURATION_NOT_FOUND": "
|
|
285
|
-
"MEMORI_INVALID_PRIVACY_TYPE": "
|
|
286
|
-
"MEMORI_MISSING_PASSWORD": "
|
|
287
|
-
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "
|
|
288
|
-
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "
|
|
289
|
-
"MEMORI_INVALID_VOICE_TYPE": "
|
|
290
|
-
"MEMORI_MISSING_NAME": "
|
|
291
|
-
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "
|
|
292
|
-
"MEMORI_INVALID_ID": "
|
|
293
|
-
"MEMORI_NAME_ALREADY_USED": "
|
|
294
|
-
"MEMORI_INVALID_PIN": "
|
|
295
|
-
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "
|
|
296
|
-
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "
|
|
283
|
+
"MEMORI_MISSING_CONFIGURATION": "Twin: missing configuration",
|
|
284
|
+
"MEMORI_CONFIGURATION_NOT_FOUND": "Twin: configuration not found",
|
|
285
|
+
"MEMORI_INVALID_PRIVACY_TYPE": "Twin: invalid privacy type",
|
|
286
|
+
"MEMORI_MISSING_PASSWORD": "Twin: missing password",
|
|
287
|
+
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "Twin: total number of invalid recovery tokens",
|
|
288
|
+
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "Twin: minimum number of invalid recovery tokens",
|
|
289
|
+
"MEMORI_INVALID_VOICE_TYPE": "Twin: invalid voice type",
|
|
290
|
+
"MEMORI_MISSING_NAME": "Twin: missing name",
|
|
291
|
+
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "Twin: missing password or recovery token",
|
|
292
|
+
"MEMORI_INVALID_ID": "Twin: invalid ID",
|
|
293
|
+
"MEMORI_NAME_ALREADY_USED": "Twin name already in use",
|
|
294
|
+
"MEMORI_INVALID_PIN": "Twin: Invalid PIN",
|
|
295
|
+
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Twin: TAG and PIN change require separate operations",
|
|
296
|
+
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Twin: no password required when public",
|
|
297
297
|
"MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Deep Thought requires completions to be enabled",
|
|
298
298
|
"MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "The expert group requires completions to be enabled",
|
|
299
|
+
"MEMORI_INVALID_COMPLETION_CONFIG": "Twin: invalid completions configuration",
|
|
299
300
|
|
|
300
301
|
"MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Transfer: missing destination user",
|
|
301
302
|
"MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Transfer: invalid destination user ID",
|
|
@@ -426,7 +427,23 @@
|
|
|
426
427
|
|
|
427
428
|
"BADGE_NOT_FOUND": "Badge not found",
|
|
428
429
|
|
|
429
|
-
"OUTCOME_NO_DCM_CONFIGURED": "
|
|
430
|
-
"OUTCOME_USER_BADGES_DISABLED": "
|
|
430
|
+
"OUTCOME_NO_DCM_CONFIGURED": "Outcome: no DCM configured",
|
|
431
|
+
"OUTCOME_USER_BADGES_DISABLED": "Outcome: user badges disabled",
|
|
432
|
+
|
|
433
|
+
"COMPLETION_CONFIG_MISSING_NAME": "Completions configuration: missing name",
|
|
434
|
+
"COMPLETION_CONFIG_MISSING_PROVIDER": "Completions configuration: missing provider",
|
|
435
|
+
"COMPLETION_CONFIG_MISSING_ENDPOINT": "Completions configuration: missing endpoint",
|
|
436
|
+
"COMPLETION_CONFIG_MISSING_API_KEY": "Completions configuration: missing API key",
|
|
437
|
+
"COMPLETION_CONFIG_MISSING_MODEL": "Completions configuration: missing model",
|
|
438
|
+
"COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED": "Completions configuration: at least one completions type must be specified",
|
|
439
|
+
"COMPLETION_CONFIG_INVALID_PURPOSE": "Completions configuration: invalid completions type",
|
|
440
|
+
"COMPLETION_CONFIG_INVALID_ENDPOINT": "Completions configuration: invalid endpoint",
|
|
441
|
+
"COMPLETION_CONFIG_INCONSISTENT_ENDPOINT": "Completions configuration: inconsistent endpoint",
|
|
442
|
+
"COMPLETION_CONFIG_INVALID_PROVIDER": "Completions configuration: invalid provider",
|
|
443
|
+
"COMPLETION_CONFIG_NOT_FOUND": "Completions configuration: not found",
|
|
444
|
+
"COMPLETION_CONFIG_NOT_ACCESSIBLE": "Completions configuration: not accessible",
|
|
445
|
+
"COMPLETION_CONFIG_NAME_RESERVED": "Completions configuration: name reserved",
|
|
446
|
+
"COMPLETION_CONFIG_NAME_ALREADY_EXISTS": "Completions configuration: name already exists",
|
|
447
|
+
"COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED": "Completions configuration: visibility change not allowed"
|
|
431
448
|
}
|
|
432
449
|
}
|