@seedprotocol/feed 0.4.7
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/README.md +41 -0
- package/dist/cache/CacheManager.d.ts +81 -0
- package/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/FileCache.d.ts +75 -0
- package/dist/cache/FileCache.d.ts.map +1 -0
- package/dist/cache/MemoryCache.d.ts +68 -0
- package/dist/cache/MemoryCache.d.ts.map +1 -0
- package/dist/cache/config.d.ts +13 -0
- package/dist/cache/config.d.ts.map +1 -0
- package/dist/cache/types.d.ts +59 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1163 -0
- package/dist/index.js.map +1 -0
- package/dist/services/arweaveImageService.d.ts +41 -0
- package/dist/services/arweaveImageService.d.ts.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/etag.d.ts +28 -0
- package/dist/utils/etag.d.ts.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @seedprotocol/feed
|
|
2
|
+
|
|
3
|
+
## Configuration
|
|
4
|
+
|
|
5
|
+
### Feed Item URLs (EASScan attestation links)
|
|
6
|
+
|
|
7
|
+
Item links in the feed can point to EASScan attestation pages. Set these environment variables:
|
|
8
|
+
|
|
9
|
+
- `FEED_ITEM_URL_BASE` - Base URL for attestation links. When set, item URLs use `{base}/attestation/view/{uid}`.
|
|
10
|
+
- **Testnet**: `https://optimism-sepolia.easscan.org`
|
|
11
|
+
- **Mainnet**: `https://easscan.org`
|
|
12
|
+
- `FEED_ITEM_URL_PATH` - Path segment (default: `attestation/view`). Only used when `FEED_ITEM_URL_BASE` is set.
|
|
13
|
+
|
|
14
|
+
When `FEED_ITEM_URL_BASE` is not set, item URLs fall back to `{siteUrl}/{collection}/{uid}` (e.g. `https://seedprotocol.io/posts/{uid}`).
|
|
15
|
+
|
|
16
|
+
### Example .env
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# EASScan attestation links (testnet)
|
|
20
|
+
FEED_ITEM_URL_BASE=https://optimism-sepolia.easscan.org
|
|
21
|
+
FEED_ITEM_URL_PATH=attestation/view
|
|
22
|
+
|
|
23
|
+
# When going live, switch to:
|
|
24
|
+
# FEED_ITEM_URL_BASE=https://easscan.org
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
To install dependencies:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To run:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bun run index.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { MemoryCache } from './MemoryCache';
|
|
2
|
+
import type { CachedFeedData, CachedFeedContent, CacheConfig, CacheStats } from './types';
|
|
3
|
+
import type { GraphQLItem, ImageMetadata } from '../types';
|
|
4
|
+
import type { FeedFormat } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Unified cache manager that combines in-memory and file-based caching
|
|
7
|
+
*/
|
|
8
|
+
export declare class CacheManager {
|
|
9
|
+
private memoryCache;
|
|
10
|
+
private fileCache;
|
|
11
|
+
private config;
|
|
12
|
+
private stats;
|
|
13
|
+
constructor(config: CacheConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Get cached feed data for a schema
|
|
16
|
+
* Checks memory cache first, then file cache
|
|
17
|
+
*/
|
|
18
|
+
getFeedData(schemaName: string): Promise<CachedFeedData | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Set cached feed data for a schema
|
|
21
|
+
* Updates both memory and file cache
|
|
22
|
+
*/
|
|
23
|
+
setFeedData(schemaName: string, items: GraphQLItem[]): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get cached feed content for a schema and format
|
|
26
|
+
* Checks memory cache first, then file cache
|
|
27
|
+
*/
|
|
28
|
+
getFeedContent(schemaName: string, format: FeedFormat): Promise<CachedFeedContent | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Set cached feed content for a schema and format
|
|
31
|
+
* Updates both memory and file cache
|
|
32
|
+
*/
|
|
33
|
+
setFeedContent(schemaName: string, format: FeedFormat, content: string, contentType: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Clear feed data cache for a schema
|
|
36
|
+
*/
|
|
37
|
+
clearFeedData(schemaName: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Clear all caches
|
|
40
|
+
*/
|
|
41
|
+
clearAll(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get or create a refresh lock for a schema
|
|
44
|
+
* Prevents concurrent fetches for the same schema
|
|
45
|
+
*/
|
|
46
|
+
withRefreshLock<T>(schemaName: string, fn: () => Promise<T>): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Merge new items with cached items
|
|
49
|
+
* Deduplicates by item ID and sorts by timeCreated (descending)
|
|
50
|
+
*/
|
|
51
|
+
mergeItems(cachedItems: GraphQLItem[], newItems: GraphQLItem[]): GraphQLItem[];
|
|
52
|
+
/**
|
|
53
|
+
* Filter items to only include those newer than the given timestamp
|
|
54
|
+
*/
|
|
55
|
+
filterNewItems(items: GraphQLItem[], lastProcessedTimestamp: number): GraphQLItem[];
|
|
56
|
+
/**
|
|
57
|
+
* Update configuration
|
|
58
|
+
*/
|
|
59
|
+
updateConfig(config: Partial<CacheConfig>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get cache statistics
|
|
62
|
+
*/
|
|
63
|
+
getStats(): CacheStats & {
|
|
64
|
+
memoryStats: ReturnType<MemoryCache['getStats']>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get cached image metadata for a transaction ID
|
|
68
|
+
* Checks memory cache first, then file cache
|
|
69
|
+
*/
|
|
70
|
+
getImageMetadata(transactionId: string): Promise<ImageMetadata | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Set cached image metadata for a transaction ID
|
|
73
|
+
* Updates both memory and file cache
|
|
74
|
+
*/
|
|
75
|
+
setImageMetadata(transactionId: string, metadata: ImageMetadata): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Reset statistics
|
|
78
|
+
*/
|
|
79
|
+
resetStats(): void;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=CacheManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/CacheManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,KAAK,CAKX;gBAEU,MAAM,EAAE,WAAW;IAM/B;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA+BrE;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB1E;;;OAGG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAuCpC;;;OAGG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B;;;OAGG;IACG,eAAe,CAAC,CAAC,EACrB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC;IAIb;;;OAGG;IACH,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE;IAkC9E;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,sBAAsB,EAAE,MAAM,GAAG,WAAW,EAAE;IAOnF;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAMhD;;OAEG;IACH,QAAQ,IAAI,UAAU,GAAG;QAAE,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE;IAO7E;;;OAGG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IA+B5E;;;OAGG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrF;;OAEG;IACH,UAAU,IAAI,IAAI;CAQnB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { CachedFeedData, CachedFeedContent, CacheConfig } from './types';
|
|
2
|
+
import type { ImageMetadata } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* File-based persistent cache implementation
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileCache {
|
|
7
|
+
private cacheDir;
|
|
8
|
+
private config;
|
|
9
|
+
constructor(config: CacheConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Ensure cache directory exists
|
|
12
|
+
*/
|
|
13
|
+
private ensureCacheDir;
|
|
14
|
+
/**
|
|
15
|
+
* Get file path for feed data
|
|
16
|
+
*/
|
|
17
|
+
private getFeedDataPath;
|
|
18
|
+
/**
|
|
19
|
+
* Get file path for feed content
|
|
20
|
+
*/
|
|
21
|
+
private getFeedContentPath;
|
|
22
|
+
/**
|
|
23
|
+
* Get file path for image metadata
|
|
24
|
+
*/
|
|
25
|
+
private getImageMetadataPath;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure image metadata directory exists
|
|
28
|
+
*/
|
|
29
|
+
private ensureImageMetadataDir;
|
|
30
|
+
/**
|
|
31
|
+
* Get cached feed data for a schema
|
|
32
|
+
*/
|
|
33
|
+
getFeedData(schemaName: string): Promise<CachedFeedData | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Set cached feed data for a schema
|
|
36
|
+
*/
|
|
37
|
+
setFeedData(schemaName: string, data: CachedFeedData): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Get cached feed content for a schema and format
|
|
40
|
+
*/
|
|
41
|
+
getFeedContent(schemaName: string, format: string): Promise<CachedFeedContent | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Set cached feed content for a schema and format
|
|
44
|
+
*/
|
|
45
|
+
setFeedContent(schemaName: string, format: string, content: CachedFeedContent): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Clear feed data cache for a schema
|
|
48
|
+
*/
|
|
49
|
+
clearFeedData(schemaName: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Clear content cache for a schema and format
|
|
52
|
+
*/
|
|
53
|
+
clearFeedContent(schemaName: string, format: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Clear all content cache for a schema (all formats)
|
|
56
|
+
*/
|
|
57
|
+
clearAllContentCache(schemaName: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Get cached image metadata for a transaction ID
|
|
60
|
+
*/
|
|
61
|
+
getImageMetadata(transactionId: string): Promise<ImageMetadata | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Set cached image metadata for a transaction ID
|
|
64
|
+
*/
|
|
65
|
+
setImageMetadata(transactionId: string, metadata: ImageMetadata): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Clear image metadata cache for a transaction ID
|
|
68
|
+
*/
|
|
69
|
+
clearImageMetadata(transactionId: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Clear all caches
|
|
72
|
+
*/
|
|
73
|
+
clearAll(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=FileCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCache.d.ts","sourceRoot":"","sources":["../../src/cache/FileCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AACnG,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,EAAE,WAAW;IAS/B;;OAEG;YACW,cAAc;IAW5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAK5B;;OAEG;YACW,sBAAsB;IAWpC;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA0BrE;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1E;;OAEG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IA4BpC;;OAEG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC;IAchB;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtD;;OAEG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAezE;;OAEG;IACG,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7D;;OAEG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAyB5E;;OAEG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrF;;OAEG;IACG,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9D;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAwBhC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { CachedFeedData, CachedFeedContent, CacheConfig } from './types';
|
|
2
|
+
import type { GraphQLItem, ImageMetadata } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* In-memory cache implementation with TTL support
|
|
5
|
+
*/
|
|
6
|
+
export declare class MemoryCache {
|
|
7
|
+
private feedDataCache;
|
|
8
|
+
private feedContentCache;
|
|
9
|
+
private imageMetadataCache;
|
|
10
|
+
private config;
|
|
11
|
+
private refreshLocks;
|
|
12
|
+
constructor(config: CacheConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Get cached feed data for a schema
|
|
15
|
+
*/
|
|
16
|
+
getFeedData(schemaName: string): CachedFeedData | null;
|
|
17
|
+
/**
|
|
18
|
+
* Set cached feed data for a schema
|
|
19
|
+
*/
|
|
20
|
+
setFeedData(schemaName: string, items: GraphQLItem[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get cached feed content for a schema and format
|
|
23
|
+
*/
|
|
24
|
+
getFeedContent(schemaName: string, format: string): CachedFeedContent | null;
|
|
25
|
+
/**
|
|
26
|
+
* Set cached feed content for a schema and format
|
|
27
|
+
*/
|
|
28
|
+
setFeedContent(schemaName: string, format: string, content: string, contentType: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Clear feed data cache for a schema
|
|
31
|
+
*/
|
|
32
|
+
clearFeedData(schemaName: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Clear content cache for a schema (all formats)
|
|
35
|
+
*/
|
|
36
|
+
clearContentCache(schemaName: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get cached image metadata for a transaction ID
|
|
39
|
+
*/
|
|
40
|
+
getImageMetadata(transactionId: string): ImageMetadata | null;
|
|
41
|
+
/**
|
|
42
|
+
* Set cached image metadata for a transaction ID
|
|
43
|
+
*/
|
|
44
|
+
setImageMetadata(transactionId: string, metadata: ImageMetadata): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clear all caches
|
|
47
|
+
*/
|
|
48
|
+
clearAll(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get or create a refresh lock for a schema
|
|
51
|
+
* Prevents concurrent fetches for the same schema
|
|
52
|
+
*/
|
|
53
|
+
withRefreshLock<T>(schemaName: string, fn: () => Promise<T>): Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Update configuration
|
|
56
|
+
*/
|
|
57
|
+
updateConfig(config: Partial<CacheConfig>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get cache statistics
|
|
60
|
+
*/
|
|
61
|
+
getStats(): {
|
|
62
|
+
feedDataCount: number;
|
|
63
|
+
feedContentCount: number;
|
|
64
|
+
imageMetadataCount: number;
|
|
65
|
+
activeLocks: number;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=MemoryCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryCache.d.ts","sourceRoot":"","sources":["../../src/cache/MemoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AACnG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG3D;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,gBAAgB,CAA6C;IACrE,OAAO,CAAC,kBAAkB,CAA+C;IACzE,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAyC;gBAEjD,MAAM,EAAE,WAAW;IAI/B;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAmBtD;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI;IAiC3D;;OAEG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAiB5E;;OAEG;IACH,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,IAAI;IAkBP;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAU3C;;OAEG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAgB7D;;OAEG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IActE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAMhB;;;OAGG;IACG,eAAe,CAAC,CAAC,EACrB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC;IA0Bb;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIhD;;OAEG;IACH,QAAQ,IAAI;QACV,aAAa,EAAE,MAAM,CAAC;QACtB,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;KACrB;CAQF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CacheConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Load cache configuration from environment variables
|
|
4
|
+
*
|
|
5
|
+
* Environment variables:
|
|
6
|
+
* - CACHE_ENABLED: Set to 'false' to disable caching (default: 'true')
|
|
7
|
+
* - CACHE_TTL: Cache time-to-live in seconds (default: 3600)
|
|
8
|
+
* - CACHE_DIR: Directory for cache files (default: './cache')
|
|
9
|
+
* - CACHE_BACKGROUND_REFRESH: Enable background refresh (default: 'false')
|
|
10
|
+
* - CACHE_REFRESH_INTERVAL: Background refresh interval in seconds (default: 300)
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadCacheConfig(): CacheConfig;
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cache/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AAEhE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,WAAW,CA4C7C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { GraphQLItem, ImageMetadata } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Cached feed data for a specific schema
|
|
4
|
+
*/
|
|
5
|
+
export interface CachedFeedData {
|
|
6
|
+
items: GraphQLItem[];
|
|
7
|
+
lastProcessedTimestamp: number;
|
|
8
|
+
lastProcessedItemId: string;
|
|
9
|
+
lastUpdated: number;
|
|
10
|
+
etag: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Cached image metadata for an Arweave transaction ID
|
|
14
|
+
*/
|
|
15
|
+
export interface CachedImageMetadata {
|
|
16
|
+
metadata: ImageMetadata;
|
|
17
|
+
cachedAt: number;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Cached feed content for a specific schema and format
|
|
22
|
+
*/
|
|
23
|
+
export interface CachedFeedContent {
|
|
24
|
+
content: string;
|
|
25
|
+
contentType: string;
|
|
26
|
+
etag: string;
|
|
27
|
+
lastModified: number;
|
|
28
|
+
expiresAt: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Image metadata cache configuration
|
|
32
|
+
*/
|
|
33
|
+
export interface ImageMetadataConfig {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
ttl: number;
|
|
36
|
+
gateways: string[];
|
|
37
|
+
timeout: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Cache configuration options
|
|
41
|
+
*/
|
|
42
|
+
export interface CacheConfig {
|
|
43
|
+
ttl: number;
|
|
44
|
+
cacheDir: string;
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
backgroundRefresh: boolean;
|
|
47
|
+
refreshInterval: number;
|
|
48
|
+
imageMetadata?: ImageMetadataConfig;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Cache statistics for monitoring
|
|
52
|
+
*/
|
|
53
|
+
export interface CacheStats {
|
|
54
|
+
hits: number;
|
|
55
|
+
misses: number;
|
|
56
|
+
refreshes: number;
|
|
57
|
+
errors: number;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cache/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,mBAAmB,CAAA;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load feed configuration from environment variables
|
|
3
|
+
*
|
|
4
|
+
* Environment variables:
|
|
5
|
+
* - FEED_ITEM_URL_BASE: Base URL for attestation links (e.g. https://optimism-sepolia.easscan.org or https://easscan.org).
|
|
6
|
+
* When set, item links use {base}/attestation/view/{uid}. When unset, falls back to siteUrl/{collection}/{uid}.
|
|
7
|
+
* - FEED_ITEM_URL_PATH: Path segment for attestation links (default: 'attestation/view').
|
|
8
|
+
* Only used when FEED_ITEM_URL_BASE is set.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadFeedConfig(): {
|
|
11
|
+
itemUrlBase: string | undefined;
|
|
12
|
+
itemUrlPath: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB,CAMA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FeedFormat, GraphQLItem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Reset cache manager (useful for testing)
|
|
4
|
+
*/
|
|
5
|
+
export declare function resetCacheManager(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the Seed Protocol client
|
|
8
|
+
* This should be called as soon as the app is ready
|
|
9
|
+
*/
|
|
10
|
+
export declare const initializeSeedClient: () => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the Seed Protocol client, initializing it if necessary
|
|
13
|
+
* This function can be called from any context (Electron main process or Vite dev server)
|
|
14
|
+
*/
|
|
15
|
+
export declare const getClient: () => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Teardown the Seed Protocol client
|
|
18
|
+
* This should be called when the app is quitting
|
|
19
|
+
*/
|
|
20
|
+
export declare const teardownSeedClient: () => Promise<void>;
|
|
21
|
+
export declare const GET_SEEDS: string;
|
|
22
|
+
export declare const createFeed: (items: GraphQLItem[], schemaName: string, format: FeedFormat, cacheBust?: string) => Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Main route handler for feed generation.
|
|
25
|
+
*
|
|
26
|
+
* URL Pattern: /:collection/:format
|
|
27
|
+
* Examples:
|
|
28
|
+
* - /posts/rss → RSS feed of posts
|
|
29
|
+
* - /posts/atom → Atom feed of posts
|
|
30
|
+
* - /identities/json → JSON feed of identities
|
|
31
|
+
* - /posts/rss?v=1234567890 → RSS feed with cache busting parameter
|
|
32
|
+
*/
|
|
33
|
+
export declare function handleFeedRequest(collectionSegment: string, formatSegment: string, ifNoneMatch?: string | null, cacheBust?: string): Promise<Response>;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAA+C,MAAM,SAAS,CAAC;AAuBpG;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,IAAI,CAkCzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,GAAG,CAe7C,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,IAAI,CAmBvD,CAAA;AA0BD,eAAO,MAAM,SAAS,QAkBrB,CAAA;AA4JD,eAAO,MAAM,UAAU,GACrB,OAAO,WAAW,EAAE,EACpB,YAAY,MAAM,EAClB,QAAQ,UAAU,EAClB,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,CAgUhB,CAAA;AA8BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,iBAAiB,EAAE,MAAM,EACzB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAqNnB"}
|