@smartico/public-api 0.0.313 → 0.0.315

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": "@smartico/public-api",
3
- "version": "0.0.313",
3
+ "version": "0.0.315",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -166,9 +166,11 @@ export class MissionUtils {
166
166
  return new Date(ts).getTime();
167
167
  }
168
168
 
169
- public static replaceFavGameNameTag = (task: UserAchievementTask) => {
169
+ public static replaceTagsFavMissionTask = (task: UserAchievementTask, valueToReplace: string): string => {
170
+ let result = valueToReplace || '';
171
+
170
172
  if (!task) {
171
- return task;
173
+ return result;
172
174
  }
173
175
 
174
176
  const userStateParams = (task.user_state_params || {});
@@ -176,7 +178,7 @@ export class MissionUtils {
176
178
  const userStateParamsKeys = Object.keys(userStateParams);
177
179
 
178
180
  if (userStateParamsKeys.length === 0 || !userStateOperator) {
179
- return task;
181
+ return result;
180
182
  }
181
183
 
182
184
  const operatorsMulti = ['has', '!has'];
@@ -188,7 +190,7 @@ export class MissionUtils {
188
190
  const operator = userStateOperator[k]?.op;
189
191
 
190
192
  if (operatorsMulti.includes(operator)) {
191
- const value = userStateParams[k];
193
+ const value = userStateParams[k]?.filter(v => Boolean(v));
192
194
  if (value && value.length > 0) {
193
195
  replacementValue = value.map((v: string) => {
194
196
  const cleaned = v.replace(/_/g, ' ').toLowerCase();
@@ -213,10 +215,18 @@ export class MissionUtils {
213
215
  }
214
216
  });
215
217
 
216
- if (replacementValue) {
217
- task.task_public_meta.name = task.task_public_meta.name.replace('{{suggested_games}}', replacementValue);
218
- }
218
+ if (replacementValue && result) {
219
+ result = result.replace('{{suggested_games}}', replacementValue);
220
+ }
219
221
 
222
+ return result;
223
+ }
224
+
225
+ public static replaceFavGameNameTag = (task: UserAchievementTask): UserAchievementTask => {
226
+ if (task && task.task_public_meta && task.task_public_meta.name) {
227
+ task.task_public_meta.name = MissionUtils.replaceTagsFavMissionTask(task, task.task_public_meta.name);
228
+ }
229
+
220
230
  return task;
221
231
  }
222
232
  }
@@ -1,6 +1,6 @@
1
1
  export interface AffectsProgress {
2
- affects_level:boolean,
3
- affects_leaderboard:boolean,
4
- affects_current_balance:boolean,
2
+ affects_level: boolean,
3
+ affects_leaderboard: boolean,
4
+ affects_current_balance: boolean,
5
5
  rewardPoints: number
6
6
  }