@xoxno/types 1.0.368 → 1.0.370

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.
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Shared cache key definitions for use across xoxno-api-v2 and xoxno-az-functions.
3
+ * This ensures consistent cache keys and TTLs across all repositories.
4
+ *
5
+ * IMPORTANT: When adding/modifying cache keys:
6
+ * 1. Define the key pattern here
7
+ * 2. Update both API and az-functions to use these shared definitions
8
+ * 3. Ensure TTLs are appropriate for the data's update frequency
9
+ */
10
+ export interface CacheKeyConfig {
11
+ key: string;
12
+ ttl: number;
13
+ }
14
+ /**
15
+ * Cache key generators for commonly used patterns.
16
+ * These ensure consistent key formats across repositories.
17
+ */
18
+ export declare const CacheKeys: {
19
+ UserProfile: (address: string) => CacheKeyConfig;
20
+ UserSettings: (address: string) => CacheKeyConfig;
21
+ UserInventorySummary: (address: string, activeAuction: boolean) => CacheKeyConfig;
22
+ UserHerotag: (address: string) => CacheKeyConfig;
23
+ UserFavorite: (address: string, favoriteId: string) => CacheKeyConfig;
24
+ UserOffers: (address: string, offerType: string) => CacheKeyConfig;
25
+ UserPlacedOffersCount: (address: string, offerType: string) => CacheKeyConfig;
26
+ UserFavoriteUserAddresses: (address: string) => CacheKeyConfig;
27
+ UserFavoriteCollectionTickers: (address: string) => CacheKeyConfig;
28
+ UserFavoriteNftIdentifiers: (address: string) => CacheKeyConfig;
29
+ UserTradingSummary: (address: string) => CacheKeyConfig;
30
+ UserOwnedAndListedSummary: (address: string) => CacheKeyConfig;
31
+ UserStatistics: (hash: string) => CacheKeyConfig;
32
+ UserSearch: (filter: string) => CacheKeyConfig;
33
+ UserCount: (chain?: string[]) => CacheKeyConfig;
34
+ AddressEsdt: (address: string) => CacheKeyConfig;
35
+ UserXoxnoDropScore: (skip: number, top: number, address?: string) => CacheKeyConfig;
36
+ EmailVerificationCode: (address: string) => CacheKeyConfig;
37
+ CollectionProfile: (collection: string) => CacheKeyConfig;
38
+ CollectionStats: (collection: string) => CacheKeyConfig;
39
+ CollectionFloorPrice: (collection: string, token: string) => CacheKeyConfig;
40
+ CollectionTraitMap: (collection: string) => CacheKeyConfig;
41
+ CollectionRanks: (collection: string) => CacheKeyConfig;
42
+ CollectionMintProfile: (collection: string) => CacheKeyConfig;
43
+ CollectionMintStages: (collection: string, enabledOnly: boolean) => CacheKeyConfig;
44
+ CollectionListedCount: (collection: string) => CacheKeyConfig;
45
+ CollectionListingDistribution: (collection: string) => CacheKeyConfig;
46
+ CollectionFloorPriceByAttribute: (collection: string) => CacheKeyConfig;
47
+ CollectionHoldersDetailed: (key: string, realOwners: boolean) => CacheKeyConfig;
48
+ CollectionHoldersCount: (key: string) => CacheKeyConfig;
49
+ CollectionHoldersDocCount: (collection: string) => CacheKeyConfig;
50
+ SftTotalSupplyCount: (collection: string) => CacheKeyConfig;
51
+ CollectionProfileDocs: (hash: string) => CacheKeyConfig;
52
+ CollectionStatsDocs: (query: string) => CacheKeyConfig;
53
+ CollectionOfferDocs: (hash: string) => CacheKeyConfig;
54
+ CollectionSearch: (filter: string) => CacheKeyConfig;
55
+ CollectionTickerByTags: (creatorTag: string, collectionTag: string) => CacheKeyConfig;
56
+ CollectionListings: (collection: string) => CacheKeyConfig;
57
+ AllBannedCollections: () => CacheKeyConfig;
58
+ AllVerifiedCollections: () => CacheKeyConfig;
59
+ NftDoc: (identifier: string) => CacheKeyConfig;
60
+ NftHasOffer: (identifier: string) => CacheKeyConfig;
61
+ NftOffers: (identifier: string) => CacheKeyConfig;
62
+ NftDataDocs: (query: string) => CacheKeyConfig;
63
+ NftSearch: (filter: string) => CacheKeyConfig;
64
+ NftMetadataUrl: (url: string) => CacheKeyConfig;
65
+ NftMetadata: (identifier: string) => CacheKeyConfig;
66
+ StakingPoolDoc: (poolId: number) => CacheKeyConfig;
67
+ StakingWlNonces: (poolId: number) => CacheKeyConfig;
68
+ StakingUserReward: (address: string, poolId: number) => CacheKeyConfig;
69
+ StakingDataDocs: (query: string) => CacheKeyConfig;
70
+ StakingPoolsByCollection: (collections: string[], activePoolsOnly: boolean) => CacheKeyConfig;
71
+ StakingPoolsSummaryByCollection: () => CacheKeyConfig;
72
+ StakingProviderOwner: (provider: string) => CacheKeyConfig;
73
+ StakingCreatedDelegationContract: (address: string) => CacheKeyConfig;
74
+ StakingProviderUserRewards: (address: string, currentEpoch: number) => CacheKeyConfig;
75
+ StakingProviderEpochRewards: (provider: string, epoch: number) => CacheKeyConfig;
76
+ ClaimableRewards: (address: string, delegationContract: string) => CacheKeyConfig;
77
+ AllUserDelegations: (address: string) => CacheKeyConfig;
78
+ EgldStakingProviders: (providers: string[], withIdentityInfo?: boolean) => CacheKeyConfig;
79
+ EgldStakingProvider: (provider: string) => CacheKeyConfig;
80
+ GetLastUpdatedEpoch: (provider: string, epoch: number) => CacheKeyConfig;
81
+ LendingMarketProfileDoc: (token: string) => CacheKeyConfig;
82
+ LendingAccountProfileDoc: (identifier: string, token: string) => CacheKeyConfig;
83
+ LendingTokenEModeProfileDoc: (token: string, eModeCategory: string) => CacheKeyConfig;
84
+ LendingPoolContracts: (controllerAddress: string) => CacheKeyConfig;
85
+ LendingAllActiveAccounts: () => CacheKeyConfig;
86
+ LendingAccountAttributes: (nonce: number) => CacheKeyConfig;
87
+ LendingLiquidateablePositions: () => CacheKeyConfig;
88
+ LendingMarketIndexes: (tokens: string[]) => CacheKeyConfig;
89
+ LendingAllMarketsTokens: () => CacheKeyConfig;
90
+ LendingAccountPosition: (identifier: string) => CacheKeyConfig;
91
+ LendingFaucetClaimed: (address: string) => CacheKeyConfig;
92
+ LendingBulkOraclePrice: (tokens: string[], returnAsUsd: boolean) => CacheKeyConfig;
93
+ LendingTokenPriceAsUsd: (token: string) => CacheKeyConfig;
94
+ LendingTokenPriceAsEgld: (token: string) => CacheKeyConfig;
95
+ LendingOverallStats: () => CacheKeyConfig;
96
+ LendingTopMarketParticipants: (token: string) => CacheKeyConfig;
97
+ LendingMarketParticipantsCount: (token: string) => CacheKeyConfig;
98
+ LendingPositionLeaderboard: (hash: string) => CacheKeyConfig;
99
+ LendingEModeCategoryProfileDoc: (id: string) => CacheKeyConfig;
100
+ LendingMarketStatsGraphData: (startTime: string, endTime: string, bin: string, token?: string) => CacheKeyConfig;
101
+ LendingMarketAverageGraphData: (token: string) => CacheKeyConfig;
102
+ EventProfileDoc: (eventId: string) => CacheKeyConfig;
103
+ EventStageDoc: (eventId: string, stageId: string) => CacheKeyConfig;
104
+ EventTicketProfileDoc: (eventId: string, ticketId: string) => CacheKeyConfig;
105
+ EventGuestDoc: (eventId: string, address: string) => CacheKeyConfig;
106
+ EventStartsFromPrice: (eventId: string) => CacheKeyConfig;
107
+ EventQuestions: (eventId: string) => CacheKeyConfig;
108
+ EventVoucherDoc: (eventId: string, voucherId: string) => CacheKeyConfig;
109
+ EventUserRoleDoc: (eventId: string, address: string) => CacheKeyConfig;
110
+ EventGuestSummary: (eventId: string) => CacheKeyConfig;
111
+ EventVoucherDocByCode: (eventId: string, code: string) => CacheKeyConfig;
112
+ EventIdBySlug: (slug: string) => CacheKeyConfig;
113
+ EventReferralConfigDoc: (eventId: string, configId: string) => CacheKeyConfig;
114
+ EventReferralDoc: (eventId: string, referralCode: string) => CacheKeyConfig;
115
+ TokenDecimals: (token: string) => CacheKeyConfig;
116
+ TokenProperties: (tokenIdentifier: string) => CacheKeyConfig;
117
+ TokenData: (token: string) => CacheKeyConfig;
118
+ TokenSupply: (token: string) => CacheKeyConfig;
119
+ TokenSummary: (token: string) => CacheKeyConfig;
120
+ MvxTokenSummary: (token: string) => CacheKeyConfig;
121
+ TokenFiatPrice: (fiatCurrencies: string[], token: string) => CacheKeyConfig;
122
+ TokenUsdcValue: (token: string, timestamp: number) => CacheKeyConfig;
123
+ LpTokenInfo: (token: string) => CacheKeyConfig;
124
+ AllSwapTokens: () => CacheKeyConfig;
125
+ AllTokensMap: () => CacheKeyConfig;
126
+ AshTokenUsdValue: (token: string) => CacheKeyConfig;
127
+ AshSupportedTokens: () => CacheKeyConfig;
128
+ TokenAccountsCount: (token: string) => CacheKeyConfig;
129
+ TokensByIdentifier: (tokens: string[], returnMap: boolean) => CacheKeyConfig;
130
+ TokensByFilterString: (identifier: string[], category: string[], chain: string[]) => CacheKeyConfig;
131
+ FilteredTokenDocs: (identifier: string[], category: string[], chain: string[]) => CacheKeyConfig;
132
+ LaunchpadAllRegisteredContracts: () => CacheKeyConfig;
133
+ UserCreatorProfile: (address: string) => CacheKeyConfig;
134
+ UserCreatorProfileByTag: (creatorTag: string) => CacheKeyConfig;
135
+ UserCreatorTagRegistered: (tag: string) => CacheKeyConfig;
136
+ GetCreatorProfileByContractAddress: (contractAddress: string) => CacheKeyConfig;
137
+ MinterLocalOwner: (address: string) => CacheKeyConfig;
138
+ MinterUserMintsGlobal: (collectionTag: string, contractAddress: string, userAddress: string) => CacheKeyConfig;
139
+ MinterUserMintsPerStage: (collectionTag: string, contractAddress: string, userAddress: string, stageName: string) => CacheKeyConfig;
140
+ MinterMintShareholders: (collectionTag: string, contractAddress: string) => CacheKeyConfig;
141
+ MinterRoyaltiesShareholders: (contractAddress: string) => CacheKeyConfig;
142
+ MinterIsUserWhitelisted: (collectionTag: string, contractAddress: string, userAddress: string, stageName: string) => CacheKeyConfig;
143
+ CurrentEpoch: () => CacheKeyConfig;
144
+ EpochEndTimestamp: () => CacheKeyConfig;
145
+ ShardCount: () => CacheKeyConfig;
146
+ CurrentTokenValue: () => CacheKeyConfig;
147
+ NextRelayWalletIndex: (shard: number) => CacheKeyConfig;
148
+ AccumulatorCreators: () => CacheKeyConfig;
149
+ LowVolumeCollections: () => CacheKeyConfig;
150
+ EGLDLiquidStats: () => CacheKeyConfig;
151
+ XoxnoLiquidStats: () => CacheKeyConfig;
152
+ XoxnoLiquidApy: () => CacheKeyConfig;
153
+ ExchangeRateLiquidXOXNO: () => CacheKeyConfig;
154
+ ExchangeRateLiquidXOXNOEGLD: () => CacheKeyConfig;
155
+ SEgldExchangeRate: () => CacheKeyConfig;
156
+ FeesXOXNOEGLD: () => CacheKeyConfig;
157
+ PendingDelegateXOXNOEGLD: () => CacheKeyConfig;
158
+ VirtualEGLDReserveXOXNOEGLD: () => CacheKeyConfig;
159
+ TotalWithdrawnXOXNOEGLD: () => CacheKeyConfig;
160
+ ValidatorsLiquidXOXNOEGLD: () => CacheKeyConfig;
161
+ AprLiquidXOXNOEGLD: () => CacheKeyConfig;
162
+ PendingUnstakeXOXNOEGLD: () => CacheKeyConfig;
163
+ GovernanceVotesProviders: () => CacheKeyConfig;
164
+ GovernanceVotes: () => CacheKeyConfig;
165
+ PerpSpotBalance: (user: string, coin: string) => CacheKeyConfig;
166
+ PerpPerpBalance: (user: string, coin: string) => CacheKeyConfig;
167
+ PerpOpenOrders: (user: string) => CacheKeyConfig;
168
+ PerpFilledOrders: (user: string) => CacheKeyConfig;
169
+ PerpSpotUsers: () => CacheKeyConfig;
170
+ PerpTermsAccepted: (user: string) => CacheKeyConfig;
171
+ GetBoberBattleBiggestWinners: () => CacheKeyConfig;
172
+ GetAllBoberBattleTokens: () => CacheKeyConfig;
173
+ BoberWheelWinners: () => CacheKeyConfig;
174
+ BoberWheelConfig: () => CacheKeyConfig;
175
+ BoberWheelScheduledSpin: () => CacheKeyConfig;
176
+ BoberBattleLeaderboard: (hash: string) => CacheKeyConfig;
177
+ BoberBattleSingleLeaderboard: (hash: string) => CacheKeyConfig;
178
+ AllGroupChatIds: () => CacheKeyConfig;
179
+ GroupChatProfile: (chatId: string) => CacheKeyConfig;
180
+ ConversationDeleteTimestamp: (chatId: string, address: string) => CacheKeyConfig;
181
+ IsSenderBlockedByReceiver: (sender: string, receiver: string) => CacheKeyConfig;
182
+ UserLastReadChatMessage: (chatId: string, address: string) => CacheKeyConfig;
183
+ UserLastSentChatMessage: (chatId: string, address: string) => CacheKeyConfig;
184
+ Web2NativeWalletAddress: (userId: string) => CacheKeyConfig;
185
+ Web2UserDoc: (userId: string) => CacheKeyConfig;
186
+ LocationPolygon: (query: string) => CacheKeyConfig;
187
+ GetCountries: () => CacheKeyConfig;
188
+ PinnedNftsApiResponse: () => CacheKeyConfig;
189
+ DropsPinnedCollectionsApiResponse: () => CacheKeyConfig;
190
+ HomePinnedCollectionsApiResponse: () => CacheKeyConfig;
191
+ ListingCount: (chain?: string[]) => CacheKeyConfig;
192
+ TradingStatistics: (chain?: string[]) => CacheKeyConfig;
193
+ HatomTokenValues: () => CacheKeyConfig;
194
+ PendingExternalPayments: () => CacheKeyConfig;
195
+ TwispayCallbackProcessed: (transactionId: string) => CacheKeyConfig;
196
+ ActivityQuery: (queryHash: string) => CacheKeyConfig;
197
+ VolumeGraphData: (startTime: string, endTime: string, bin: string, collection?: string, chain?: string[]) => CacheKeyConfig;
198
+ GlobalSearch: (filter: string) => CacheKeyConfig;
199
+ DropsSearch: (filter: string) => CacheKeyConfig;
200
+ DataApiTokens: () => CacheKeyConfig;
201
+ DataApiTokenPrice: (identifier: string, dateString: string, isCurrentDate: boolean) => CacheKeyConfig;
202
+ GetAbi: (abiName: string) => CacheKeyConfig;
203
+ SuiTransactionSender: (txDigest: string) => CacheKeyConfig;
204
+ SuiObject: (objectId: string) => CacheKeyConfig;
205
+ SuiEvents: (packageId: string, startTime: number, endTime: number, eventTypes: string[]) => CacheKeyConfig;
206
+ SuiUserCoins: (userAddress: string) => CacheKeyConfig;
207
+ SuiCollectionInfo: (collectionType: string) => CacheKeyConfig;
208
+ SuiAllCollectionTypes: () => CacheKeyConfig;
209
+ SuiTokenPrices: (coinTypes: string[]) => CacheKeyConfig;
210
+ SuiQueryEventsPage: (moveEventType: string, order: "ascending" | "descending" | null | undefined, limit: number | null | undefined, cursor: {
211
+ txDigest: string;
212
+ eventSeq: string;
213
+ } | null | undefined) => CacheKeyConfig;
214
+ KustoXoxnoLiquidStats: () => CacheKeyConfig;
215
+ KustoEgldLiquidStats: () => CacheKeyConfig;
216
+ };
217
+ /**
218
+ * Cache key patterns for invalidation.
219
+ * Used by az-functions to find and delete related cache entries.
220
+ *
221
+ * @deprecated Use CacheIndexKeys with index sets instead of SCAN patterns.
222
+ * SCAN is expensive in serverless environments and causes connection saturation.
223
+ */
224
+ export declare const CachePatterns: {
225
+ UserAll: (address: string) => string;
226
+ CollectionAll: (collection: string) => string;
227
+ NftAll: (identifier: string) => string;
228
+ StakingPoolAll: (poolId: number) => string;
229
+ LendingTokenAll: (token: string) => string;
230
+ EventAll: (eventId: string) => string;
231
+ };
232
+ /**
233
+ * Index set keys for efficient cache invalidation.
234
+ *
235
+ * Instead of using SCAN to find cache keys by pattern (expensive in serverless),
236
+ * we maintain Redis SETs that track which cache keys belong to which collection/address.
237
+ *
238
+ * Usage:
239
+ * - API: When setting a cache, also SADD the key to relevant index sets
240
+ * - Azure Functions: When invalidating, use SMEMBERS to get keys from index sets
241
+ *
242
+ * This reduces O(n) SCAN operations to O(1) SMEMBERS lookups.
243
+ */
244
+ export declare const CacheIndexKeys: {
245
+ /**
246
+ * Index of all NFT query cache keys for a specific collection.
247
+ * When API caches an NFT query result, it adds the cache key to this set.
248
+ * When invalidating, az-functions reads this set instead of SCAN.
249
+ */
250
+ NftQueryByCollection: (collection: string) => string;
251
+ /**
252
+ * Index of all NFT query cache keys for a specific address (owner, seller).
253
+ */
254
+ NftQueryByAddress: (address: string) => string;
255
+ /**
256
+ * Index of all global/wildcard NFT query cache keys (explore pages).
257
+ * These are queries with no specific collection or address filter.
258
+ */
259
+ NftQueryGlobal: string;
260
+ OfferQueryByCollection: (collection: string) => string;
261
+ OfferQueryByAddress: (address: string) => string;
262
+ OfferQueryByIdentifier: (identifier: string) => string;
263
+ OfferQueryGlobal: string;
264
+ CollectionQueryByTicker: (ticker: string) => string;
265
+ CollectionStatsQueryByTicker: (ticker: string) => string;
266
+ CollectionOffersQueryByTicker: (ticker: string) => string;
267
+ CollectionQueryGlobal: string;
268
+ ActivityQueryByCollection: (collection: string) => string;
269
+ ActivityQueryByAddress: (address: string) => string;
270
+ ActivityQueryGlobal: string;
271
+ };
272
+ /**
273
+ * Metadata for cache index registration.
274
+ * When setting a cache key, this metadata determines which index sets to add it to.
275
+ */
276
+ export interface CacheIndexMetadata {
277
+ /** Collections that this cache key relates to */
278
+ collections?: string[];
279
+ /** Addresses (owners, sellers, buyers) that this cache key relates to */
280
+ addresses?: string[];
281
+ /** NFT identifiers that this cache key relates to */
282
+ identifiers?: string[];
283
+ /** True if this is a global/wildcard query (no specific filters) */
284
+ isGlobal?: boolean;
285
+ }
286
+ /**
287
+ * Type of query cache for determining which index keys to use.
288
+ */
289
+ export type CacheIndexType = 'nft' | 'offer' | 'collection' | 'activity';