@indexing/jiti 0.1.13 → 0.1.14

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/types.d.ts CHANGED
@@ -2065,6 +2065,59 @@ export type NetworkTransfer = {
2065
2065
  transactionGasFee: bigint;
2066
2066
  transactionHash: string;
2067
2067
  };
2068
+ export type CacheRow = {
2069
+ value: unknown | null;
2070
+ found: boolean;
2071
+ expiresAt: number | null;
2072
+ };
2073
+ export type CacheStorage = {
2074
+ get: (namespace: string, key: string) => Promise<CacheRow | null>;
2075
+ set: (namespace: string, key: string, row: CacheRow) => Promise<void>;
2076
+ };
2077
+ export type CacheResolver = (key: string) => Promise<unknown | null>;
2078
+ export type NamespacePolicy = {
2079
+ resolve?: CacheResolver;
2080
+ ttlSeconds?: number | null;
2081
+ negativeTtlSeconds?: number;
2082
+ };
2083
+ export type JettonWalletData = {
2084
+ owner: string;
2085
+ master: string;
2086
+ };
2087
+ export function registerCacheNamespace(namespace: string, policy: NamespacePolicy): void;
2088
+ /**
2089
+ * Read an enrichment value for (namespace, key) against the injected storage. On a miss, if
2090
+ * the namespace has a registered resolver, resolve + write-through; otherwise return null
2091
+ * (externally-populated namespaces). Returns null for negative hits; a resolver that throws
2092
+ * (transient, e.g. RPC) is NOT cached so it retries next time.
2093
+ */
2094
+ export function cacheGet(storage: CacheStorage, namespace: string, key: string): Promise<unknown | null>;
2095
+ /**
2096
+ * Write an enrichment value out-of-band (for externally-populated namespaces like token-price
2097
+ * / wallet-label, or to pre-seed a row). TTL comes from the namespace policy unless overridden.
2098
+ */
2099
+ export function cacheSet(storage: CacheStorage, namespace: string, key: string, value: unknown, ttlSecondsOverride?: number | null): Promise<void>;
2100
+ export const TON_JETTON_NAMESPACE = "ton-jetton-wallet";
2101
+ /**
2102
+ * Resolve a jetton wallet to its { owner, master }. Returns null if the account isn't a jetton
2103
+ * wallet (definitive miss → negative-cached). Throws on transient RPC failure so the cache layer
2104
+ * does NOT cache it (retries next time).
2105
+ */
2106
+ export function resolveJettonWalletData(wallet: string): Promise<JettonWalletData | null>;
2107
+ /** Enrich a TON jetton wallet (any address form) → { owner, master } via the cache. */
2108
+ export function lookupJettonWallet(storage: CacheStorage, wallet: string): Promise<JettonWalletData | null>;
2109
+ type PgPool = {
2110
+ query: (text: string, values?: unknown[]) => Promise<{
2111
+ rows: Record<string, unknown>[];
2112
+ }>;
2113
+ };
2114
+ type PostgresCacheStorageOptions = {
2115
+ connectionUri: string;
2116
+ table?: string;
2117
+ /** Provide your own pool/client (must have `.query(text, values)`) instead of a URI. */
2118
+ pool?: PgPool;
2119
+ };
2120
+ export function createPostgresCacheStorage(opts: PostgresCacheStorageOptions): CacheStorage;
2068
2121
  export const utils: {
2069
2122
  blockToBeat(block: Record<string, unknown>): number;
2070
2123
  blockToTransactionHashes(block: Record<string, unknown>): string[];