@smartico/public-api 0.0.419 → 0.0.420
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/ActivityLog/GetActivityLogRequest.d.ts +1 -1
- package/dist/ActivityLog/PointChangeSourceType.d.ts +1 -0
- package/dist/SmarticoAPI.d.ts +4 -4
- package/dist/WSAPI/WSAPIUser.d.ts +20 -6
- package/dist/index.js +44 -21
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +44 -21
- package/dist/index.modern.mjs.map +1 -1
- package/package.json +1 -1
- package/src/ActivityLog/GetActivityLogRequest.ts +1 -3
- package/src/ActivityLog/PointChangeSourceType.ts +1 -0
- package/src/SmarticoAPI.ts +11 -2
- package/src/WSAPI/WSAPIUser.ts +37 -11
package/package.json
CHANGED
package/src/SmarticoAPI.ts
CHANGED
|
@@ -1764,6 +1764,8 @@ class SmarticoAPI {
|
|
|
1764
1764
|
endTimeSeconds: number,
|
|
1765
1765
|
limit: number,
|
|
1766
1766
|
offset: number,
|
|
1767
|
+
types?: number[],
|
|
1768
|
+
src_types?: number[],
|
|
1767
1769
|
): Promise<GetActivityLogResponse> {
|
|
1768
1770
|
const message = this.buildMessage<GetActivityLogRequest, GetActivityLogResponse>(
|
|
1769
1771
|
user_ext_id,
|
|
@@ -1773,6 +1775,8 @@ class SmarticoAPI {
|
|
|
1773
1775
|
endTimeSeconds: Math.floor(endTimeSeconds),
|
|
1774
1776
|
limit,
|
|
1775
1777
|
offset,
|
|
1778
|
+
...(types ? { types } : {}),
|
|
1779
|
+
...(src_types ? { src_types } : {}),
|
|
1776
1780
|
},
|
|
1777
1781
|
);
|
|
1778
1782
|
|
|
@@ -1786,6 +1790,7 @@ class SmarticoAPI {
|
|
|
1786
1790
|
limit: number,
|
|
1787
1791
|
offset: number,
|
|
1788
1792
|
types?: number[],
|
|
1793
|
+
src_types?: number[],
|
|
1789
1794
|
): Promise<GetActivityLogResponse> {
|
|
1790
1795
|
const message = this.buildMessage<GetActivityLogRequest, GetActivityLogResponse>(
|
|
1791
1796
|
user_ext_id,
|
|
@@ -1796,6 +1801,7 @@ class SmarticoAPI {
|
|
|
1796
1801
|
limit,
|
|
1797
1802
|
offset,
|
|
1798
1803
|
...(types ? { types } : {}),
|
|
1804
|
+
...(src_types ? { src_types } : {}),
|
|
1799
1805
|
},
|
|
1800
1806
|
);
|
|
1801
1807
|
|
|
@@ -1808,12 +1814,14 @@ class SmarticoAPI {
|
|
|
1808
1814
|
endTimeSeconds: number,
|
|
1809
1815
|
from: number = 0,
|
|
1810
1816
|
to: number = 50,
|
|
1817
|
+
types?: number[],
|
|
1818
|
+
src_types?: number[],
|
|
1811
1819
|
): Promise<TActivityLog[]> {
|
|
1812
1820
|
const limit = to - from > 50 ? 50 : to - from;
|
|
1813
1821
|
const offset = from;
|
|
1814
1822
|
|
|
1815
1823
|
return ActivityLogTransform(
|
|
1816
|
-
(await this.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).logHistory,
|
|
1824
|
+
(await this.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset, types, src_types)).logHistory,
|
|
1817
1825
|
);
|
|
1818
1826
|
}
|
|
1819
1827
|
|
|
@@ -1824,12 +1832,13 @@ class SmarticoAPI {
|
|
|
1824
1832
|
from: number = 0,
|
|
1825
1833
|
to: number = 50,
|
|
1826
1834
|
types?: number[],
|
|
1835
|
+
src_types?: number[],
|
|
1827
1836
|
): Promise<TActivityLogEntry[]> {
|
|
1828
1837
|
const limit = to - from > 50 ? 50 : to - from;
|
|
1829
1838
|
const offset = from;
|
|
1830
1839
|
|
|
1831
1840
|
return ActivityLogV2Transform(
|
|
1832
|
-
(await this.getActivityLogV2(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset, types)).logHistory,
|
|
1841
|
+
(await this.getActivityLogV2(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset, types, src_types)).logHistory,
|
|
1833
1842
|
);
|
|
1834
1843
|
}
|
|
1835
1844
|
}
|
package/src/WSAPI/WSAPIUser.ts
CHANGED
|
@@ -535,13 +535,18 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
535
535
|
* `from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
|
|
536
536
|
* are epoch seconds bounding the window the server scans.
|
|
537
537
|
*
|
|
538
|
+
* **Filtering** — optional server-side filters (SMR-52608):
|
|
539
|
+
* - `types` — {@link ActivityLogActivities} / `type_id` values (e.g. Points=3, Gems=1)
|
|
540
|
+
* - `src_types` — {@link PointChangeSourceType} / `source_type_id` values
|
|
541
|
+
* Omit both for an unfiltered window.
|
|
542
|
+
*
|
|
538
543
|
* **Subscription model (`onUpdate`)**
|
|
539
544
|
* The callback fires when the user's `ach_points_balance`,
|
|
540
545
|
* `ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
|
|
541
546
|
* wallet event lands). The pushed payload is a FIXED re-fetch of the
|
|
542
547
|
* **last 10 minutes / first 50 entries** — it does NOT honor the original
|
|
543
|
-
* call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to
|
|
544
|
-
* maintaining a long historical view must re-call `getActivityLog` with
|
|
548
|
+
* call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to` / filters.
|
|
549
|
+
* Consumers maintaining a long historical view must re-call `getActivityLog` with
|
|
545
550
|
* their own params after receiving an `onUpdate` notification.
|
|
546
551
|
*
|
|
547
552
|
* **Refresh**
|
|
@@ -565,6 +570,8 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
565
570
|
* endTimeSeconds: now,
|
|
566
571
|
* from: 0,
|
|
567
572
|
* to: 50,
|
|
573
|
+
* types: [1], // Gems only (ActivityLogActivities.Gems)
|
|
574
|
+
* src_types: [11], // Tournament wins only (PointChangeSourceType.Tournament)
|
|
568
575
|
* onUpdate: (refreshed) => {
|
|
569
576
|
* console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
|
|
570
577
|
* // If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
|
|
@@ -582,6 +589,8 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
582
589
|
endTimeSeconds,
|
|
583
590
|
from,
|
|
584
591
|
to,
|
|
592
|
+
types,
|
|
593
|
+
src_types,
|
|
585
594
|
onUpdate,
|
|
586
595
|
}: {
|
|
587
596
|
/** Window start in epoch seconds. */
|
|
@@ -592,30 +601,41 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
592
601
|
from: number;
|
|
593
602
|
/** Pagination ceiling (exclusive); server caps `to - from` at 50. */
|
|
594
603
|
to: number;
|
|
604
|
+
/** Optional — filter by {@link ActivityLogActivities} / `type_id`. */
|
|
605
|
+
types?: number[];
|
|
606
|
+
/** Optional — filter by {@link PointChangeSourceType} / `source_type_id`. */
|
|
607
|
+
src_types?: number[];
|
|
595
608
|
/** Optional push callback; payload is a fixed 10-min / 50-entry refresh on every wallet change (see Subscription model). */
|
|
596
609
|
onUpdate?: (data: TActivityLog[]) => void;
|
|
597
610
|
}): Promise<TActivityLog[]> {
|
|
598
611
|
|
|
599
|
-
const cacheKey = `${onUpdateContextKey.ActivityLog}:${startTimeSeconds}:${endTimeSeconds}:${from}:${to}`;
|
|
612
|
+
const cacheKey = `${onUpdateContextKey.ActivityLog}:${startTimeSeconds}:${endTimeSeconds}:${from}:${to}:${types?.join(',') ?? ''}:${src_types?.join(',') ?? ''}`;
|
|
600
613
|
|
|
601
614
|
if (typeof onUpdate === 'function') {
|
|
602
615
|
this.onUpdateCallback.set(onUpdateContextKey.ActivityLog, onUpdate);
|
|
603
616
|
// Remember the requested window so a push refresh re-fetches THIS window
|
|
604
617
|
// and writes the matching composite cache key (see notifyActivityLogUpdate).
|
|
605
|
-
this.activityLogOnUpdateParams = { startTimeSeconds, endTimeSeconds, from, to };
|
|
618
|
+
this.activityLogOnUpdateParams = { startTimeSeconds, endTimeSeconds, from, to, types, src_types };
|
|
606
619
|
}
|
|
607
620
|
|
|
608
621
|
return await OCache.use(
|
|
609
622
|
cacheKey,
|
|
610
623
|
ECacheContext.WSAPI,
|
|
611
|
-
() => this.api.getActivityLogT(this.userExtId, startTimeSeconds, endTimeSeconds, from, to),
|
|
624
|
+
() => this.api.getActivityLogT(this.userExtId, startTimeSeconds, endTimeSeconds, from, to, types, src_types),
|
|
612
625
|
CACHE_DATA_SEC,
|
|
613
626
|
);
|
|
614
627
|
}
|
|
615
628
|
|
|
616
629
|
/** @hidden Last window passed to `getActivityLog` with an `onUpdate`, so a push
|
|
617
630
|
* refresh re-fetches the same window and updates its matching composite cache key. */
|
|
618
|
-
private activityLogOnUpdateParams: {
|
|
631
|
+
private activityLogOnUpdateParams: {
|
|
632
|
+
startTimeSeconds: number;
|
|
633
|
+
endTimeSeconds: number;
|
|
634
|
+
from: number;
|
|
635
|
+
to: number;
|
|
636
|
+
types?: number[];
|
|
637
|
+
src_types?: number[];
|
|
638
|
+
} | undefined;
|
|
619
639
|
|
|
620
640
|
protected async notifyActivityLogUpdate() {
|
|
621
641
|
const params = this.activityLogOnUpdateParams;
|
|
@@ -630,8 +650,10 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
630
650
|
params.endTimeSeconds,
|
|
631
651
|
params.from,
|
|
632
652
|
params.to,
|
|
653
|
+
params.types,
|
|
654
|
+
params.src_types,
|
|
633
655
|
);
|
|
634
|
-
const cacheKey = `${onUpdateContextKey.ActivityLog}:${params.startTimeSeconds}:${params.endTimeSeconds}:${params.from}:${params.to}`;
|
|
656
|
+
const cacheKey = `${onUpdateContextKey.ActivityLog}:${params.startTimeSeconds}:${params.endTimeSeconds}:${params.from}:${params.to}:${params.types?.join(',') ?? ''}:${params.src_types?.join(',') ?? ''}`;
|
|
635
657
|
|
|
636
658
|
OCache.set(cacheKey, payload, ECacheContext.WSAPI);
|
|
637
659
|
|
|
@@ -652,8 +674,10 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
652
674
|
* **Pagination** — same `from` / `to` offset model as {@link getActivityLog}
|
|
653
675
|
* (server caps a single response at 50 entries).
|
|
654
676
|
*
|
|
655
|
-
* **Filtering** —
|
|
656
|
-
*
|
|
677
|
+
* **Filtering** — optional server-side filters:
|
|
678
|
+
* - `types` — {@link ActivityLogActivities} values (`type_id`)
|
|
679
|
+
* - `src_types` — {@link PointChangeSourceType} values (`source_type_id`)
|
|
680
|
+
* Omit both for all activity types / sources.
|
|
657
681
|
*
|
|
658
682
|
* @returns Array of {@link TActivityLogEntry} ordered newest-first.
|
|
659
683
|
*/
|
|
@@ -663,19 +687,21 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
663
687
|
from,
|
|
664
688
|
to,
|
|
665
689
|
types,
|
|
690
|
+
src_types,
|
|
666
691
|
}: {
|
|
667
692
|
startTimeSeconds: number;
|
|
668
693
|
endTimeSeconds: number;
|
|
669
694
|
from: number;
|
|
670
695
|
to: number;
|
|
671
696
|
types?: number[];
|
|
697
|
+
src_types?: number[];
|
|
672
698
|
}): Promise<TActivityLogEntry[]> {
|
|
673
|
-
const cacheKey = `${onUpdateContextKey.ActivityLogV2}:${startTimeSeconds}:${endTimeSeconds}:${from}:${to}:${types?.join(',') ?? ''}`;
|
|
699
|
+
const cacheKey = `${onUpdateContextKey.ActivityLogV2}:${startTimeSeconds}:${endTimeSeconds}:${from}:${to}:${types?.join(',') ?? ''}:${src_types?.join(',') ?? ''}`;
|
|
674
700
|
|
|
675
701
|
return await OCache.use(
|
|
676
702
|
cacheKey,
|
|
677
703
|
ECacheContext.WSAPI,
|
|
678
|
-
() => this.api.getActivityLogV2T(this.userExtId, startTimeSeconds, endTimeSeconds, from, to, types),
|
|
704
|
+
() => this.api.getActivityLogV2T(this.userExtId, startTimeSeconds, endTimeSeconds, from, to, types, src_types),
|
|
679
705
|
CACHE_DATA_SEC,
|
|
680
706
|
);
|
|
681
707
|
}
|