@smartico/public-api 0.0.416 → 0.0.417

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/dist/index.js CHANGED
@@ -2233,6 +2233,7 @@ var onUpdateContextKey;
2233
2233
  onUpdateContextKey["CurrentLevel"] = "currentLevel";
2234
2234
  onUpdateContextKey["InboxUnreadCount"] = "inboxUnreadCount";
2235
2235
  onUpdateContextKey["ActivityLog"] = "activityLog";
2236
+ onUpdateContextKey["ActivityLogV2"] = "activityLogV2";
2236
2237
  onUpdateContextKey["AvatarsList"] = "avatarsList";
2237
2238
  onUpdateContextKey["AvatarsCustomized"] = "avatarsCustomized";
2238
2239
  onUpdateContextKey["AvatarPrompts"] = "avatarPrompts";
@@ -3142,6 +3143,40 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
3142
3143
  } catch (e) {
3143
3144
  return Promise.reject(e);
3144
3145
  }
3146
+ }
3147
+ /**
3148
+ * Returns the full activity log (v2) — wallet changes **and** non-wallet
3149
+ * activities (missions, badges, levels, tournaments, avatars, …).
3150
+ *
3151
+ * **Backwards compatibility**: existing integrations should keep using
3152
+ * {@link getActivityLog}, which returns wallet-only {@link TActivityLog}
3153
+ * rows with the original field contract unchanged.
3154
+ *
3155
+ * **Pagination** — same `from` / `to` offset model as {@link getActivityLog}
3156
+ * (server caps a single response at 50 entries).
3157
+ *
3158
+ * **Filtering** — pass `types` with {@link ActivityLogActivities} values to
3159
+ * request a server-side subset (e.g. missions only). Omit for all activity types.
3160
+ *
3161
+ * @returns Array of {@link TActivityLogEntry} ordered newest-first.
3162
+ */
3163
+ ;
3164
+ _proto.getActivityLogV2 = function getActivityLogV2(_ref2) {
3165
+ var startTimeSeconds = _ref2.startTimeSeconds,
3166
+ endTimeSeconds = _ref2.endTimeSeconds,
3167
+ from = _ref2.from,
3168
+ to = _ref2.to,
3169
+ types = _ref2.types;
3170
+ try {
3171
+ var _types$join;
3172
+ var _this9 = this;
3173
+ var cacheKey = onUpdateContextKey.ActivityLogV2 + ":" + startTimeSeconds + ":" + endTimeSeconds + ":" + from + ":" + to + ":" + ((_types$join = types == null ? void 0 : types.join(',')) != null ? _types$join : '');
3174
+ return Promise.resolve(OCache.use(cacheKey, exports.ECacheContext.WSAPI, function () {
3175
+ return _this9.api.getActivityLogV2T(_this9.userExtId, startTimeSeconds, endTimeSeconds, from, to, types);
3176
+ }, CACHE_DATA_SEC));
3177
+ } catch (e) {
3178
+ return Promise.reject(e);
3179
+ }
3145
3180
  };
3146
3181
  return WSAPIUser;
3147
3182
  }(WSAPIBase);
@@ -10311,32 +10346,417 @@ exports.UserBalanceType = void 0;
10311
10346
  UserBalanceType[UserBalanceType["Diamonds"] = 2] = "Diamonds";
10312
10347
  })(exports.UserBalanceType || (exports.UserBalanceType = {}));
10313
10348
 
10349
+ /** Activity-log entry type as returned on the v2 wire (`type_id`). */
10350
+ exports.ActivityLogActivities = void 0;
10351
+ (function (ActivityLogActivities) {
10352
+ ActivityLogActivities[ActivityLogActivities["Gems"] = 1] = "Gems";
10353
+ ActivityLogActivities[ActivityLogActivities["Diamonds"] = 2] = "Diamonds";
10354
+ ActivityLogActivities[ActivityLogActivities["Points"] = 3] = "Points";
10355
+ ActivityLogActivities[ActivityLogActivities["LevelChanged"] = 4] = "LevelChanged";
10356
+ ActivityLogActivities[ActivityLogActivities["Bonus"] = 5] = "Bonus";
10357
+ ActivityLogActivities[ActivityLogActivities["PrizeDrop"] = 6] = "PrizeDrop";
10358
+ ActivityLogActivities[ActivityLogActivities["Minigame"] = 7] = "Minigame";
10359
+ ActivityLogActivities[ActivityLogActivities["RaffleTicket"] = 8] = "RaffleTicket";
10360
+ ActivityLogActivities[ActivityLogActivities["Avatar"] = 9] = "Avatar";
10361
+ ActivityLogActivities[ActivityLogActivities["Task"] = 10] = "Task";
10362
+ ActivityLogActivities[ActivityLogActivities["Mission"] = 11] = "Mission";
10363
+ ActivityLogActivities[ActivityLogActivities["Badge"] = 12] = "Badge";
10364
+ ActivityLogActivities[ActivityLogActivities["TangiblePrize"] = 13] = "TangiblePrize";
10365
+ ActivityLogActivities[ActivityLogActivities["Jackpot"] = 14] = "Jackpot";
10366
+ ActivityLogActivities[ActivityLogActivities["Spin"] = 15] = "Spin";
10367
+ ActivityLogActivities[ActivityLogActivities["NoPrize"] = 16] = "NoPrize";
10368
+ ActivityLogActivities[ActivityLogActivities["Leaderboard"] = 17] = "Leaderboard";
10369
+ ActivityLogActivities[ActivityLogActivities["Tournament"] = 18] = "Tournament";
10370
+ ActivityLogActivities[ActivityLogActivities["ClanTournament"] = 19] = "ClanTournament";
10371
+ })(exports.ActivityLogActivities || (exports.ActivityLogActivities = {}));
10372
+ exports.WalletChangeType = void 0;
10373
+ (function (WalletChangeType) {
10374
+ WalletChangeType[WalletChangeType["Add"] = 1] = "Add";
10375
+ WalletChangeType[WalletChangeType["Deduct"] = 2] = "Deduct";
10376
+ WalletChangeType[WalletChangeType["Set"] = 3] = "Set";
10377
+ })(exports.WalletChangeType || (exports.WalletChangeType = {}));
10378
+ exports.LevelChangeType = void 0;
10379
+ (function (LevelChangeType) {
10380
+ LevelChangeType[LevelChangeType["Increase"] = 1] = "Increase";
10381
+ LevelChangeType[LevelChangeType["Decrease"] = 2] = "Decrease";
10382
+ })(exports.LevelChangeType || (exports.LevelChangeType = {}));
10383
+ /** Wire ctx_1 for Mission / Badge / Task — see SMR-44986. */
10384
+ exports.AchievementChangeType = void 0;
10385
+ (function (AchievementChangeType) {
10386
+ AchievementChangeType[AchievementChangeType["Complete"] = 1] = "Complete";
10387
+ AchievementChangeType[AchievementChangeType["Unlock"] = 2] = "Unlock";
10388
+ })(exports.AchievementChangeType || (exports.AchievementChangeType = {}));
10389
+ /** Wire ctx_1 for Jackpot rows — SMR-44986. */
10390
+ exports.JackpotContextValue = void 0;
10391
+ (function (JackpotContextValue) {
10392
+ JackpotContextValue[JackpotContextValue["Registration"] = 1] = "Registration";
10393
+ JackpotContextValue[JackpotContextValue["Win"] = 3] = "Win";
10394
+ })(exports.JackpotContextValue || (exports.JackpotContextValue = {}));
10395
+ var WALLET_TYPE_IDS = new Set([exports.ActivityLogActivities.Gems, exports.ActivityLogActivities.Diamonds, exports.ActivityLogActivities.Points]);
10396
+ var isWalletActivityTypeId = function isWalletActivityTypeId(typeId) {
10397
+ return WALLET_TYPE_IDS.has(typeId);
10398
+ };
10399
+ var activityTypeIdToBalanceType = function activityTypeIdToBalanceType(typeId) {
10400
+ switch (typeId) {
10401
+ case exports.ActivityLogActivities.Gems:
10402
+ return exports.UserBalanceType.Gems;
10403
+ case exports.ActivityLogActivities.Diamonds:
10404
+ return exports.UserBalanceType.Diamonds;
10405
+ default:
10406
+ return exports.UserBalanceType.Points;
10407
+ }
10408
+ };
10409
+
10410
+ var POINTS_COLLECTED_SENTINEL = -1;
10411
+ var parseCreateDate = function parseCreateDate(raw) {
10412
+ if (raw === undefined || raw === null) {
10413
+ return 0;
10414
+ }
10415
+ if (typeof raw === 'number') {
10416
+ return raw;
10417
+ }
10418
+ if (typeof raw === 'object' && raw !== null) {
10419
+ if ('seconds' in raw) {
10420
+ return Number(raw.seconds);
10421
+ }
10422
+ if ('epochSecond' in raw) {
10423
+ return Number(raw.epochSecond);
10424
+ }
10425
+ }
10426
+ if (typeof raw === 'string') {
10427
+ var ms = Date.parse(raw);
10428
+ if (!Number.isNaN(ms)) {
10429
+ return Math.floor(ms / 1000);
10430
+ }
10431
+ }
10432
+ return 0;
10433
+ };
10434
+ var readWireNumber = function readWireNumber(log) {
10435
+ for (var _iterator = _createForOfIteratorHelperLoose([].slice.call(arguments, 1)), _step; !(_step = _iterator()).done;) {
10436
+ var key = _step.value;
10437
+ var value = log[key];
10438
+ if (value !== undefined && value !== null && value !== '') {
10439
+ return Number(value);
10440
+ }
10441
+ }
10442
+ return undefined;
10443
+ };
10444
+ var normalizeWireLog = function normalizeWireLog(raw) {
10445
+ var log = _extends({}, raw);
10446
+ var explicitTypeId = readWireNumber(log, 'type_id');
10447
+ if (explicitTypeId !== undefined) {
10448
+ log.type_id = explicitTypeId;
10449
+ } else {
10450
+ var wireType = readWireNumber(log, 'type');
10451
+ if (wireType !== undefined && wireType > exports.UserBalanceType.Diamonds) {
10452
+ log.type_id = wireType;
10453
+ }
10454
+ }
10455
+ if (log.context_value_1 === undefined && log.ctx_1 !== undefined) {
10456
+ log.context_value_1 = log.ctx_1;
10457
+ }
10458
+ if (log.context_value_meta === undefined && log.ctx_meta !== undefined) {
10459
+ log.context_value_meta = log.ctx_meta;
10460
+ }
10461
+ if (log.source_reference_id === undefined && log.source_ref_id !== undefined) {
10462
+ log.source_reference_id = log.source_ref_id;
10463
+ }
10464
+ if (log.source_entity_id === undefined && log.source_root_id !== undefined) {
10465
+ log.source_entity_id = log.source_root_id;
10466
+ }
10467
+ return log;
10468
+ };
10469
+ var isActivityLogWireEntry = function isActivityLogWireEntry(log) {
10470
+ if (log.is_activity_log === true) {
10471
+ return true;
10472
+ }
10473
+ if (log.label_id !== undefined && log.label_id !== null) {
10474
+ return true;
10475
+ }
10476
+ if (log.ctx_meta !== undefined || log.context_value_meta !== undefined) {
10477
+ return true;
10478
+ }
10479
+ if (log.ctx_1 !== undefined || log.context_value_1 !== undefined) {
10480
+ return true;
10481
+ }
10482
+ if (log.user_id !== undefined && log.user_id !== null) {
10483
+ return true;
10484
+ }
10485
+ var wireTypeId = readWireNumber(log, 'type_id');
10486
+ return wireTypeId !== undefined && wireTypeId > exports.UserBalanceType.Diamonds;
10487
+ };
10488
+ var readWireBalanceType = function readWireBalanceType(log) {
10489
+ var balanceType = readWireNumber(log, 'type');
10490
+ if (balanceType === exports.UserBalanceType.Gems || balanceType === exports.UserBalanceType.Diamonds) {
10491
+ return balanceType;
10492
+ }
10493
+ return undefined;
10494
+ };
10495
+ var hasGemsOrDiamondsWalletFields = function hasGemsOrDiamondsWalletFields(log) {
10496
+ return log.amount !== undefined || log.balance !== undefined || readWireNumber(log, 'amount', 'collected_amount') !== undefined || readWireNumber(log, 'balance', 'user_balance') !== undefined;
10497
+ };
10498
+ var isGemsOrDiamondsWalletWireEntry = function isGemsOrDiamondsWalletWireEntry(log) {
10499
+ var balanceType = readWireBalanceType(log);
10500
+ return balanceType !== undefined && hasGemsOrDiamondsWalletFields(log);
10501
+ };
10502
+ var resolveWalletAmount = function resolveWalletAmount(log, isPoints) {
10503
+ var pointsCollected = readWireNumber(log, 'points_collected');
10504
+ if (isPoints && pointsCollected !== undefined && pointsCollected !== POINTS_COLLECTED_SENTINEL) {
10505
+ return pointsCollected;
10506
+ }
10507
+ if (isPoints) {
10508
+ var _amount = readWireNumber(log, 'amount', 'collected_amount');
10509
+ return _amount === undefined ? 0 : _amount;
10510
+ }
10511
+ var amount = readWireNumber(log, 'amount', 'collected_amount');
10512
+ return amount === undefined ? 0 : amount;
10513
+ };
10514
+ var resolveWalletBalance = function resolveWalletBalance(log, isPoints) {
10515
+ if (isPoints) {
10516
+ var _balance = readWireNumber(log, 'balance', 'user_points_balance', 'user_balance');
10517
+ return _balance === undefined ? 0 : _balance;
10518
+ }
10519
+ var balance = readWireNumber(log, 'balance', 'user_balance');
10520
+ return balance === undefined ? 0 : balance;
10521
+ };
10522
+ var resolveSourceTypeId = function resolveSourceTypeId(log) {
10523
+ var sourceTypeId = readWireNumber(log, 'source_type_id', 'entity_type_id');
10524
+ return sourceTypeId === undefined ? 0 : sourceTypeId;
10525
+ };
10526
+ var parseMeta = function parseMeta(contextValueMeta) {
10527
+ var _meta$public_meta;
10528
+ if (!contextValueMeta) {
10529
+ return undefined;
10530
+ }
10531
+ var meta;
10532
+ if (typeof contextValueMeta === 'object') {
10533
+ meta = contextValueMeta;
10534
+ } else if (typeof contextValueMeta === 'string') {
10535
+ try {
10536
+ meta = JSON.parse(contextValueMeta);
10537
+ } catch (_unused) {
10538
+ return undefined;
10539
+ }
10540
+ }
10541
+ if (!meta) {
10542
+ return undefined;
10543
+ }
10544
+ var nested = (_meta$public_meta = meta.public_meta) != null ? _meta$public_meta : meta.public_map;
10545
+ var pickImage = function pickImage(src) {
10546
+ var _ref, _ref2, _ref3, _ref4, _src$image_url;
10547
+ return (_ref = (_ref2 = (_ref3 = (_ref4 = (_src$image_url = src == null ? void 0 : src.image_url) != null ? _src$image_url : src == null ? void 0 : src.image) != null ? _ref4 : src == null ? void 0 : src.url) != null ? _ref3 : src == null ? void 0 : src.avatar_url) != null ? _ref2 : src == null ? void 0 : src.icon_url) != null ? _ref : src == null ? void 0 : src.avatar_id;
10548
+ };
10549
+ if (nested) {
10550
+ var _meta$name, _pickImage, _ref5, _meta$position;
10551
+ return _extends({}, meta, {
10552
+ name: (_meta$name = meta.name) != null ? _meta$name : nested.name,
10553
+ image_url: (_pickImage = pickImage(meta)) != null ? _pickImage : pickImage(nested),
10554
+ position: (_ref5 = (_meta$position = meta.position) != null ? _meta$position : nested.position) != null ? _ref5 : meta.score
10555
+ });
10556
+ }
10557
+ var topImage = pickImage(meta);
10558
+ if (topImage && meta.image_url === undefined) {
10559
+ var _meta$position2;
10560
+ return _extends({}, meta, {
10561
+ image_url: topImage,
10562
+ position: (_meta$position2 = meta.position) != null ? _meta$position2 : meta.score
10563
+ });
10564
+ }
10565
+ if (meta.score !== undefined && meta.position === undefined) {
10566
+ return _extends({}, meta, {
10567
+ position: meta.score
10568
+ });
10569
+ }
10570
+ return meta;
10571
+ };
10572
+ var isLegacyPointsEntry = function isLegacyPointsEntry(log) {
10573
+ if (isActivityLogWireEntry(log)) {
10574
+ return false;
10575
+ }
10576
+ var pointsCollected = readWireNumber(log, 'points_collected');
10577
+ return pointsCollected !== undefined && pointsCollected !== POINTS_COLLECTED_SENTINEL;
10578
+ };
10579
+ var isLegacyGemsDiamondsEntry = function isLegacyGemsDiamondsEntry(log) {
10580
+ if (isActivityLogWireEntry(log)) {
10581
+ return false;
10582
+ }
10583
+ var balanceType = readWireNumber(log, 'type');
10584
+ return (balanceType === exports.UserBalanceType.Gems || balanceType === exports.UserBalanceType.Diamonds) && log.amount !== undefined;
10585
+ };
10586
+ var isV2Entry = function isV2Entry(log) {
10587
+ return isActivityLogWireEntry(log) || log.type_id !== undefined && log.type_id !== null;
10588
+ };
10589
+ var resolveSourceEntityName = function resolveSourceEntityName(log, meta) {
10590
+ var _log$source_entity_na;
10591
+ var fromWire = (_log$source_entity_na = log.source_entity_name) != null ? _log$source_entity_na : log.source_public_name;
10592
+ if (typeof fromWire === 'string' && fromWire.length > 0) {
10593
+ return fromWire;
10594
+ }
10595
+ if (meta != null && meta.name) {
10596
+ return meta.name;
10597
+ }
10598
+ return undefined;
10599
+ };
10600
+ var buildEntryKey = function buildEntryKey(log, index) {
10601
+ var _ref6, _log$type_id, _log$source_type_id, _ref7, _log$source_entity_id, _ref8, _log$context_value_;
10602
+ return [parseCreateDate(log.create_date), (_ref6 = (_log$type_id = log.type_id) != null ? _log$type_id : log.type) != null ? _ref6 : 'legacy', (_log$source_type_id = log.source_type_id) != null ? _log$source_type_id : '', (_ref7 = (_log$source_entity_id = log.source_entity_id) != null ? _log$source_entity_id : log.source_root_id) != null ? _ref7 : '', (_ref8 = (_log$context_value_ = log.context_value_1) != null ? _log$context_value_ : log.ctx_1) != null ? _ref8 : '', index].join('-');
10603
+ };
10604
+ var mapLegacyPointsEntry = function mapLegacyPointsEntry(log, index) {
10605
+ var _log$user_ext_id, _log$crm_brand_id;
10606
+ return {
10607
+ entry_key: buildEntryKey(log, index),
10608
+ create_date: parseCreateDate(log.create_date),
10609
+ user_ext_id: String((_log$user_ext_id = log.user_ext_id) != null ? _log$user_ext_id : ''),
10610
+ crm_brand_id: Number((_log$crm_brand_id = log.crm_brand_id) != null ? _log$crm_brand_id : 0),
10611
+ type: exports.UserBalanceType.Points,
10612
+ amount: resolveWalletAmount(log, true),
10613
+ balance: resolveWalletBalance(log, true),
10614
+ total_ever: readWireNumber(log, 'user_points_ever', 'collected_ever'),
10615
+ context_value_1: readWireNumber(log, 'context_value_1', 'ctx_1'),
10616
+ source_type_id: resolveSourceTypeId(log),
10617
+ activity_type_id: exports.ActivityLogActivities.Points,
10618
+ is_wallet_entry: true
10619
+ };
10620
+ };
10621
+ var mapLegacyGemsDiamondsEntry = function mapLegacyGemsDiamondsEntry(log, index) {
10622
+ var _log$user_ext_id2, _log$crm_brand_id2;
10623
+ var wireType = readWireNumber(log, 'type');
10624
+ var activityTypeId = wireType === exports.UserBalanceType.Gems ? exports.ActivityLogActivities.Gems : exports.ActivityLogActivities.Diamonds;
10625
+ return {
10626
+ entry_key: buildEntryKey(log, index),
10627
+ create_date: parseCreateDate(log.create_date),
10628
+ user_ext_id: String((_log$user_ext_id2 = log.user_ext_id) != null ? _log$user_ext_id2 : ''),
10629
+ crm_brand_id: Number((_log$crm_brand_id2 = log.crm_brand_id) != null ? _log$crm_brand_id2 : 0),
10630
+ type: activityTypeIdToBalanceType(activityTypeId),
10631
+ amount: resolveWalletAmount(log, false),
10632
+ balance: resolveWalletBalance(log, false),
10633
+ context_value_1: readWireNumber(log, 'context_value_1', 'ctx_1'),
10634
+ source_type_id: resolveSourceTypeId(log),
10635
+ activity_type_id: activityTypeId,
10636
+ is_wallet_entry: true
10637
+ };
10638
+ };
10639
+ var mapV2Entry = function mapV2Entry(log, index) {
10640
+ var _log$user_ext_id3, _log$crm_brand_id3;
10641
+ var typeId = readWireNumber(log, 'type_id');
10642
+ var contextValue1 = readWireNumber(log, 'context_value_1', 'ctx_1');
10643
+ var meta = parseMeta(log.context_value_meta);
10644
+ var sourceEntityName = resolveSourceEntityName(log, meta);
10645
+ var sourceEntityId = readWireNumber(log, 'source_entity_id', 'source_root_id');
10646
+ var sourceReferenceId = readWireNumber(log, 'source_reference_id', 'source_ref_id');
10647
+ var sourceRootId = readWireNumber(log, 'source_root_id');
10648
+ var gemsOrDiamondsWallet = isGemsOrDiamondsWalletWireEntry(log);
10649
+ var isWalletEntry = typeId !== undefined && isWalletActivityTypeId(typeId) || gemsOrDiamondsWallet;
10650
+ var base = {
10651
+ entry_key: buildEntryKey(log, index),
10652
+ create_date: parseCreateDate(log.create_date),
10653
+ user_ext_id: String((_log$user_ext_id3 = log.user_ext_id) != null ? _log$user_ext_id3 : ''),
10654
+ crm_brand_id: Number((_log$crm_brand_id3 = log.crm_brand_id) != null ? _log$crm_brand_id3 : 0),
10655
+ source_type_id: resolveSourceTypeId(log),
10656
+ activity_type_id: typeId,
10657
+ context_value_1: contextValue1,
10658
+ meta: meta,
10659
+ source_entity_name: sourceEntityName,
10660
+ source_entity_id: sourceEntityId && sourceEntityId > 0 ? sourceEntityId : undefined,
10661
+ source_reference_id: sourceReferenceId && sourceReferenceId > 0 ? sourceReferenceId : undefined,
10662
+ source_root_id: sourceRootId && sourceRootId > 0 ? sourceRootId : undefined
10663
+ };
10664
+ if (isWalletEntry) {
10665
+ var _readWireNumber;
10666
+ var wireBalanceType = readWireBalanceType(log);
10667
+ var balanceType = wireBalanceType != null ? wireBalanceType : typeId !== undefined ? activityTypeIdToBalanceType(typeId) : exports.UserBalanceType.Points;
10668
+ var walletActivityTypeId = typeId !== undefined && isWalletActivityTypeId(typeId) ? typeId : balanceType === exports.UserBalanceType.Gems ? exports.ActivityLogActivities.Gems : balanceType === exports.UserBalanceType.Diamonds ? exports.ActivityLogActivities.Diamonds : exports.ActivityLogActivities.Points;
10669
+ var isPoints = balanceType === exports.UserBalanceType.Points;
10670
+ var totalEver = isPoints ? (_readWireNumber = readWireNumber(log, 'user_points_ever', 'collected_ever')) != null ? _readWireNumber : (meta == null ? void 0 : meta.user_points_ever) !== undefined ? Number(meta.user_points_ever) : undefined : undefined;
10671
+ return _extends({}, base, {
10672
+ activity_type_id: walletActivityTypeId,
10673
+ type: balanceType,
10674
+ amount: resolveWalletAmount(log, isPoints),
10675
+ balance: resolveWalletBalance(log, isPoints),
10676
+ total_ever: totalEver === POINTS_COLLECTED_SENTINEL ? undefined : totalEver,
10677
+ is_wallet_entry: true
10678
+ });
10679
+ }
10680
+ return _extends({}, base, {
10681
+ type: exports.UserBalanceType.Points,
10682
+ amount: 0,
10683
+ balance: 0,
10684
+ is_wallet_entry: false,
10685
+ is_level_entry: typeId === exports.ActivityLogActivities.LevelChanged
10686
+ });
10687
+ };
10688
+ var mapWireEntry = function mapWireEntry(log, index) {
10689
+ var normalized = normalizeWireLog(log);
10690
+ if (isLegacyPointsEntry(normalized)) {
10691
+ return mapLegacyPointsEntry(normalized, index);
10692
+ }
10693
+ if (isLegacyGemsDiamondsEntry(normalized)) {
10694
+ return mapLegacyGemsDiamondsEntry(normalized, index);
10695
+ }
10696
+ if (isV2Entry(normalized)) {
10697
+ return mapV2Entry(normalized, index);
10698
+ }
10699
+ return null;
10700
+ };
10701
+ var mapActivityLogHistory = function mapActivityLogHistory(logHistory) {
10702
+ var entries = [];
10703
+ (logHistory || []).forEach(function (raw, index) {
10704
+ var mapped = mapWireEntry(raw, index);
10705
+ if (mapped) {
10706
+ entries.push(mapped);
10707
+ }
10708
+ });
10709
+ return entries;
10710
+ };
10711
+ var resolveWalletDisplayType = function resolveWalletDisplayType(entry) {
10712
+ switch (entry.activity_type_id) {
10713
+ case exports.ActivityLogActivities.Gems:
10714
+ return exports.UserBalanceType.Gems;
10715
+ case exports.ActivityLogActivities.Diamonds:
10716
+ return exports.UserBalanceType.Diamonds;
10717
+ case exports.ActivityLogActivities.Points:
10718
+ return exports.UserBalanceType.Points;
10719
+ }
10720
+ switch (Number(entry.type)) {
10721
+ case exports.UserBalanceType.Gems:
10722
+ return exports.UserBalanceType.Gems;
10723
+ case exports.UserBalanceType.Diamonds:
10724
+ return exports.UserBalanceType.Diamonds;
10725
+ default:
10726
+ return exports.UserBalanceType.Points;
10727
+ }
10728
+ };
10729
+
10730
+ var toTActivityLog = function toTActivityLog(entry) {
10731
+ var row = {
10732
+ create_date: entry.create_date,
10733
+ user_ext_id: entry.user_ext_id,
10734
+ crm_brand_id: entry.crm_brand_id,
10735
+ type: resolveWalletDisplayType(entry),
10736
+ amount: entry.amount,
10737
+ balance: entry.balance,
10738
+ source_type_id: entry.source_type_id
10739
+ };
10740
+ if (entry.total_ever !== undefined) {
10741
+ row.total_ever = entry.total_ever;
10742
+ }
10743
+ return row;
10744
+ };
10745
+ /** Maps wire rows to wallet-only {@link TActivityLog} — legacy consumer contract. */
10314
10746
  var ActivityLogTransform = function ActivityLogTransform(items) {
10315
10747
  if (!items) {
10316
10748
  return [];
10317
10749
  }
10318
- return items.map(function (item) {
10319
- var _item$type;
10320
- var itemTransformed = {
10321
- create_date: item.create_date,
10322
- user_ext_id: item.user_ext_id,
10323
- crm_brand_id: item.crm_brand_id,
10324
- source_type_id: item.source_type_id
10325
- };
10326
- item.type = (_item$type = item.type) != null ? _item$type : exports.UserBalanceType.Points;
10327
- if (item.type === exports.UserBalanceType.Diamonds || item.type === exports.UserBalanceType.Gems) {
10328
- itemTransformed.type = item.type;
10329
- itemTransformed.amount = item.amount;
10330
- itemTransformed.balance = item.balance;
10331
- }
10332
- if (item.type === exports.UserBalanceType.Points) {
10333
- itemTransformed.type = exports.UserBalanceType.Points;
10334
- itemTransformed.amount = item.points_collected;
10335
- itemTransformed.balance = item.user_points_balance;
10336
- itemTransformed.total_ever = item.user_points_ever;
10337
- }
10338
- return itemTransformed;
10339
- });
10750
+ return mapActivityLogHistory(items).filter(function (entry) {
10751
+ return entry.is_wallet_entry;
10752
+ }).map(toTActivityLog);
10753
+ };
10754
+ /** Maps wire rows to the full v2 {@link TActivityLogEntry} shape. */
10755
+ var ActivityLogV2Transform = function ActivityLogV2Transform(items) {
10756
+ if (!items) {
10757
+ return [];
10758
+ }
10759
+ return mapActivityLogHistory(items);
10340
10760
  };
10341
10761
 
10342
10762
  exports.PointChangeSourceType = void 0;
@@ -12253,6 +12673,22 @@ var SmarticoAPI = /*#__PURE__*/function () {
12253
12673
  return Promise.reject(e);
12254
12674
  }
12255
12675
  };
12676
+ _proto.getActivityLogV2 = function getActivityLogV2(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset, types) {
12677
+ try {
12678
+ var _this103 = this;
12679
+ var message = _this103.buildMessage(user_ext_id, exports.ClassId.GET_POINT_HISTORY_REQUEST, _extends({
12680
+ startTimeSeconds: Math.floor(startTimeSeconds),
12681
+ endTimeSeconds: Math.floor(endTimeSeconds),
12682
+ limit: limit,
12683
+ offset: offset
12684
+ }, types ? {
12685
+ types: types
12686
+ } : {}));
12687
+ return Promise.resolve(_this103.send(message, exports.ClassId.GET_POINT_HISTORY_RESPONSE));
12688
+ } catch (e) {
12689
+ return Promise.reject(e);
12690
+ }
12691
+ };
12256
12692
  _proto.getActivityLogT = function getActivityLogT(user_ext_id, startTimeSeconds, endTimeSeconds, from, to) {
12257
12693
  if (from === void 0) {
12258
12694
  from = 0;
@@ -12261,11 +12697,29 @@ var SmarticoAPI = /*#__PURE__*/function () {
12261
12697
  to = 50;
12262
12698
  }
12263
12699
  try {
12264
- var _this103 = this;
12700
+ var _this104 = this;
12701
+ var limit = to - from > 50 ? 50 : to - from;
12702
+ var offset = from;
12703
+ return Promise.resolve(_this104.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this104$getActivityL) {
12704
+ return ActivityLogTransform(_this104$getActivityL.logHistory);
12705
+ });
12706
+ } catch (e) {
12707
+ return Promise.reject(e);
12708
+ }
12709
+ };
12710
+ _proto.getActivityLogV2T = function getActivityLogV2T(user_ext_id, startTimeSeconds, endTimeSeconds, from, to, types) {
12711
+ if (from === void 0) {
12712
+ from = 0;
12713
+ }
12714
+ if (to === void 0) {
12715
+ to = 50;
12716
+ }
12717
+ try {
12718
+ var _this105 = this;
12265
12719
  var limit = to - from > 50 ? 50 : to - from;
12266
12720
  var offset = from;
12267
- return Promise.resolve(_this103.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this103$getActivityL) {
12268
- return ActivityLogTransform(_this103$getActivityL.logHistory);
12721
+ return Promise.resolve(_this105.getActivityLogV2(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset, types)).then(function (_this105$getActivityL) {
12722
+ return ActivityLogV2Transform(_this105$getActivityL.logHistory);
12269
12723
  });
12270
12724
  } catch (e) {
12271
12725
  return Promise.reject(e);
@@ -12917,6 +13371,7 @@ exports.JoinClanErrorCode = void 0;
12917
13371
 
12918
13372
  exports.AchCategoryTransform = AchCategoryTransform;
12919
13373
  exports.ActivityLogTransform = ActivityLogTransform;
13374
+ exports.ActivityLogV2Transform = ActivityLogV2Transform;
12920
13375
  exports.AllRoundsGameBoardID = AllRoundsGameBoardID;
12921
13376
  exports.BonusItemsTransform = BonusItemsTransform;
12922
13377
  exports.CookieStore = CookieStore;
@@ -12954,6 +13409,7 @@ exports.TournamentUtils = TournamentUtils;
12954
13409
  exports.UICustomSectionTransform = UICustomSectionTransform;
12955
13410
  exports.UserAchievementTransform = UserAchievementTransform;
12956
13411
  exports.WSAPI = WSAPI;
13412
+ exports.activityTypeIdToBalanceType = activityTypeIdToBalanceType;
12957
13413
  exports.avatarCustomizedTransform = avatarCustomizedTransform;
12958
13414
  exports.avatarDefinitionTransform = avatarDefinitionTransform;
12959
13415
  exports.avatarPromptTransform = avatarPromptTransform;
@@ -12963,6 +13419,8 @@ exports.drawRunTransform = drawRunTransform;
12963
13419
  exports.drawTransform = drawTransform;
12964
13420
  exports.enrichUserAchievementsWithBadgeState = enrichUserAchievementsWithBadgeState;
12965
13421
  exports.getLeaderBoardTransform = getLeaderBoardTransform;
13422
+ exports.isWalletActivityTypeId = isWalletActivityTypeId;
13423
+ exports.mapActivityLogHistory = mapActivityLogHistory;
12966
13424
  exports.marketsInfo = marketsInfo;
12967
13425
  exports.prizeTransform = prizeTransform;
12968
13426
  exports.quizAnswerAwayTeamReplacementText = quizAnswerAwayTeamReplacementText;
@@ -12978,6 +13436,7 @@ exports.quizSupportedSports = quizSupportedSports;
12978
13436
  exports.quizYesReplacementText = quizYesReplacementText;
12979
13437
  exports.raffleClaimPrizeResponseTransform = raffleClaimPrizeResponseTransform;
12980
13438
  exports.raffleTransform = raffleTransform;
13439
+ exports.resolveWalletDisplayType = resolveWalletDisplayType;
12981
13440
  exports.ticketsTransform = ticketsTransform;
12982
13441
  exports.tournamentInfoItemTransform = tournamentInfoItemTransform;
12983
13442
  exports.winnersTransform = winnersTransform;