@smartico/public-api 0.0.417 → 0.0.418

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.
@@ -1,4 +1,3 @@
1
- import { UserBalanceType } from './UserBalanceType';
2
1
  /** Activity-log entry type as returned on the v2 wire (`type_id`). */
3
2
  export declare enum ActivityLogActivities {
4
3
  Gems = 1,
@@ -21,24 +20,3 @@ export declare enum ActivityLogActivities {
21
20
  Tournament = 18,
22
21
  ClanTournament = 19
23
22
  }
24
- export declare enum WalletChangeType {
25
- Add = 1,
26
- Deduct = 2,
27
- Set = 3
28
- }
29
- export declare enum LevelChangeType {
30
- Increase = 1,
31
- Decrease = 2
32
- }
33
- /** Wire ctx_1 for Mission / Badge / Task — see SMR-44986. */
34
- export declare enum AchievementChangeType {
35
- Complete = 1,
36
- Unlock = 2
37
- }
38
- /** Wire ctx_1 for Jackpot rows — SMR-44986. */
39
- export declare enum JackpotContextValue {
40
- Registration = 1,
41
- Win = 3
42
- }
43
- export declare const isWalletActivityTypeId: (typeId: number) => boolean;
44
- export declare const activityTypeIdToBalanceType: (typeId: ActivityLogActivities) => UserBalanceType;
@@ -1,26 +1,8 @@
1
- export interface ActivityLogPublicMeta {
2
- name?: string;
3
- image_url?: string;
4
- image?: string;
5
- url?: string;
6
- avatar_url?: string;
7
- avatar_id?: string;
8
- icon_url?: string;
9
- position?: number;
10
- }
11
1
  export interface ActivityLogMeta {
12
- image_url?: string;
13
- image?: string;
14
- url?: string;
15
- avatar_url?: string;
16
- avatar_id?: string;
17
- icon_url?: string;
18
2
  name?: string;
3
+ image_url?: string;
19
4
  position?: number;
20
- score?: number;
21
5
  user_points_balance_before?: number;
22
6
  points_requested?: number;
23
7
  user_points_ever?: number;
24
- public_meta?: ActivityLogPublicMeta;
25
- public_map?: ActivityLogPublicMeta;
26
8
  }
@@ -4,7 +4,5 @@ import { TActivityLog, TActivityLogEntry } from '../WSAPI/WSAPITypes';
4
4
  export interface GetActivityLogResponse extends ProtocolResponse {
5
5
  logHistory: ActivityLogEntry[];
6
6
  }
7
- /** Maps wire rows to wallet-only {@link TActivityLog} — legacy consumer contract. */
8
- export declare const ActivityLogTransform: (items: ActivityLogEntry[] | unknown[]) => TActivityLog[];
9
- /** Maps wire rows to the full v2 {@link TActivityLogEntry} shape. */
10
- export declare const ActivityLogV2Transform: (items: ActivityLogEntry[] | unknown[]) => TActivityLogEntry[];
7
+ export declare const ActivityLogTransform: (items: ActivityLogEntry[]) => TActivityLog[];
8
+ export declare const ActivityLogV2Transform: (items: any[]) => TActivityLogEntry[];
@@ -3,6 +3,5 @@ export * from './GetActivityLogResponse';
3
3
  export * from './ActivityLogEntry';
4
4
  export * from './ActivityLogActivities';
5
5
  export * from './ActivityLogMeta';
6
- export * from './ActivityLogMapper';
7
6
  export * from './PointChangeSourceType';
8
7
  export * from './UserBalanceType';
@@ -1705,7 +1705,6 @@ export interface TActivityLog {
1705
1705
  * Includes wallet changes and non-wallet activities (missions, badges, levels, …).
1706
1706
  */
1707
1707
  export interface TActivityLogEntry {
1708
- entry_key: string;
1709
1708
  create_date: number;
1710
1709
  user_ext_id: string;
1711
1710
  crm_brand_id: number;
@@ -1722,7 +1721,6 @@ export interface TActivityLogEntry {
1722
1721
  source_reference_id?: number;
1723
1722
  source_root_id?: number;
1724
1723
  is_wallet_entry: boolean;
1725
- is_level_entry?: boolean;
1726
1724
  }
1727
1725
  /**
1728
1726
  * Result of `_smartico.api.requestRaffleOptin({raffle_id, draw_id, raffle_run_id})`.
package/dist/index.js CHANGED
@@ -10339,13 +10339,6 @@ exports.BonusStatus = void 0;
10339
10339
  BonusStatus[BonusStatus["EXPIRED"] = 6] = "EXPIRED";
10340
10340
  })(exports.BonusStatus || (exports.BonusStatus = {}));
10341
10341
 
10342
- exports.UserBalanceType = void 0;
10343
- (function (UserBalanceType) {
10344
- UserBalanceType[UserBalanceType["Points"] = 0] = "Points";
10345
- UserBalanceType[UserBalanceType["Gems"] = 1] = "Gems";
10346
- UserBalanceType[UserBalanceType["Diamonds"] = 2] = "Diamonds";
10347
- })(exports.UserBalanceType || (exports.UserBalanceType = {}));
10348
-
10349
10342
  /** Activity-log entry type as returned on the v2 wire (`type_id`). */
10350
10343
  exports.ActivityLogActivities = void 0;
10351
10344
  (function (ActivityLogActivities) {
@@ -10369,394 +10362,69 @@ exports.ActivityLogActivities = void 0;
10369
10362
  ActivityLogActivities[ActivityLogActivities["Tournament"] = 18] = "Tournament";
10370
10363
  ActivityLogActivities[ActivityLogActivities["ClanTournament"] = 19] = "ClanTournament";
10371
10364
  })(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
10365
 
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
- };
10366
+ exports.UserBalanceType = void 0;
10367
+ (function (UserBalanceType) {
10368
+ UserBalanceType[UserBalanceType["Points"] = 0] = "Points";
10369
+ UserBalanceType[UserBalanceType["Gems"] = 1] = "Gems";
10370
+ UserBalanceType[UserBalanceType["Diamonds"] = 2] = "Diamonds";
10371
+ })(exports.UserBalanceType || (exports.UserBalanceType = {}));
10729
10372
 
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. */
10746
10373
  var ActivityLogTransform = function ActivityLogTransform(items) {
10747
10374
  if (!items) {
10748
10375
  return [];
10749
10376
  }
10750
- return mapActivityLogHistory(items).filter(function (entry) {
10751
- return entry.is_wallet_entry;
10752
- }).map(toTActivityLog);
10377
+ return items.map(function (item) {
10378
+ var _item$create_date$sec, _item$create_date, _item$type;
10379
+ var itemTransformed = {
10380
+ create_date: (_item$create_date$sec = (_item$create_date = item.create_date) == null ? void 0 : _item$create_date.seconds) != null ? _item$create_date$sec : item.create_date,
10381
+ user_ext_id: item.user_ext_id,
10382
+ crm_brand_id: item.crm_brand_id,
10383
+ source_type_id: item.source_type_id
10384
+ };
10385
+ item.type = (_item$type = item.type) != null ? _item$type : exports.UserBalanceType.Points;
10386
+ if (item.type === exports.UserBalanceType.Diamonds || item.type === exports.UserBalanceType.Gems) {
10387
+ itemTransformed.type = item.type;
10388
+ itemTransformed.amount = item.amount;
10389
+ itemTransformed.balance = item.balance;
10390
+ }
10391
+ if (item.type === exports.UserBalanceType.Points) {
10392
+ itemTransformed.type = exports.UserBalanceType.Points;
10393
+ itemTransformed.amount = item.points_collected;
10394
+ itemTransformed.balance = item.user_points_balance;
10395
+ itemTransformed.total_ever = item.user_points_ever;
10396
+ }
10397
+ return itemTransformed;
10398
+ });
10753
10399
  };
10754
- /** Maps wire rows to the full v2 {@link TActivityLogEntry} shape. */
10755
10400
  var ActivityLogV2Transform = function ActivityLogV2Transform(items) {
10756
10401
  if (!items) {
10757
10402
  return [];
10758
10403
  }
10759
- return mapActivityLogHistory(items);
10404
+ return items.map(function (r) {
10405
+ var _r$create_date$second, _r$create_date, _r$points_collected, _r$user_points_balanc;
10406
+ var isGems = r.type_id === exports.ActivityLogActivities.Gems || r.type === exports.UserBalanceType.Gems;
10407
+ var isDiamonds = r.type_id === exports.ActivityLogActivities.Diamonds || r.type === exports.UserBalanceType.Diamonds;
10408
+ var x = {
10409
+ create_date: (_r$create_date$second = (_r$create_date = r.create_date) == null ? void 0 : _r$create_date.seconds) != null ? _r$create_date$second : r.create_date,
10410
+ user_ext_id: r.user_ext_id,
10411
+ crm_brand_id: r.crm_brand_id,
10412
+ type: isGems ? exports.UserBalanceType.Gems : isDiamonds ? exports.UserBalanceType.Diamonds : exports.UserBalanceType.Points,
10413
+ amount: (_r$points_collected = r.points_collected) != null ? _r$points_collected : r.amount,
10414
+ balance: (_r$user_points_balanc = r.user_points_balance) != null ? _r$user_points_balanc : r.balance,
10415
+ total_ever: r.user_points_ever,
10416
+ source_type_id: r.source_type_id,
10417
+ activity_type_id: r.type_id,
10418
+ context_value_1: r.context_value_1,
10419
+ meta: r.context_value_meta,
10420
+ source_entity_name: r.source_entity_name,
10421
+ source_entity_id: r.source_entity_id,
10422
+ source_reference_id: r.source_reference_id,
10423
+ source_root_id: r.source_root_id,
10424
+ is_wallet_entry: r.type_id == null || r.type_id === exports.ActivityLogActivities.Gems || r.type_id === exports.ActivityLogActivities.Diamonds || r.type_id === exports.ActivityLogActivities.Points
10425
+ };
10426
+ return x;
10427
+ });
10760
10428
  };
10761
10429
 
10762
10430
  exports.PointChangeSourceType = void 0;
@@ -13409,7 +13077,6 @@ exports.TournamentUtils = TournamentUtils;
13409
13077
  exports.UICustomSectionTransform = UICustomSectionTransform;
13410
13078
  exports.UserAchievementTransform = UserAchievementTransform;
13411
13079
  exports.WSAPI = WSAPI;
13412
- exports.activityTypeIdToBalanceType = activityTypeIdToBalanceType;
13413
13080
  exports.avatarCustomizedTransform = avatarCustomizedTransform;
13414
13081
  exports.avatarDefinitionTransform = avatarDefinitionTransform;
13415
13082
  exports.avatarPromptTransform = avatarPromptTransform;
@@ -13419,8 +13086,6 @@ exports.drawRunTransform = drawRunTransform;
13419
13086
  exports.drawTransform = drawTransform;
13420
13087
  exports.enrichUserAchievementsWithBadgeState = enrichUserAchievementsWithBadgeState;
13421
13088
  exports.getLeaderBoardTransform = getLeaderBoardTransform;
13422
- exports.isWalletActivityTypeId = isWalletActivityTypeId;
13423
- exports.mapActivityLogHistory = mapActivityLogHistory;
13424
13089
  exports.marketsInfo = marketsInfo;
13425
13090
  exports.prizeTransform = prizeTransform;
13426
13091
  exports.quizAnswerAwayTeamReplacementText = quizAnswerAwayTeamReplacementText;
@@ -13436,7 +13101,6 @@ exports.quizSupportedSports = quizSupportedSports;
13436
13101
  exports.quizYesReplacementText = quizYesReplacementText;
13437
13102
  exports.raffleClaimPrizeResponseTransform = raffleClaimPrizeResponseTransform;
13438
13103
  exports.raffleTransform = raffleTransform;
13439
- exports.resolveWalletDisplayType = resolveWalletDisplayType;
13440
13104
  exports.ticketsTransform = ticketsTransform;
13441
13105
  exports.tournamentInfoItemTransform = tournamentInfoItemTransform;
13442
13106
  exports.winnersTransform = winnersTransform;