ultra-igdl 1.0.0

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,180 @@
1
+ /** Auto-generated by scripts/sync-version.mjs — do not edit */
2
+ declare const PACKAGE_VERSION = "1.0.0";
3
+
4
+ type MediaType = "video" | "image";
5
+ interface Media {
6
+ type: MediaType;
7
+ url: string;
8
+ thumbnail?: string;
9
+ width?: number;
10
+ height?: number;
11
+ duration?: number;
12
+ }
13
+ interface ResponseMeta {
14
+ extractor: string;
15
+ version: string;
16
+ }
17
+ interface Engagement {
18
+ likes?: number;
19
+ comments?: number;
20
+ views?: number;
21
+ shares?: number;
22
+ /** Creator disabled public like/view counts (not the same as zero likes). */
23
+ likesHidden?: boolean;
24
+ /** Creator disabled comments or comment counts. */
25
+ commentsHidden?: boolean;
26
+ /** Raw stats line from Instagram (likes/comments prefix) when present */
27
+ raw?: string;
28
+ }
29
+ /** Visibility / extraction hints for clients (e.g. owner hid like counts). */
30
+ type EngagementTag = "likes_hidden" | "comments_hidden" | "engagement_hidden";
31
+ /** Post shape hints (carousel detection, session needs). */
32
+ type PostContentTag = "carousel" | "partial_carousel" | "session_recommended";
33
+ type ResultTag = EngagementTag | PostContentTag;
34
+ interface DownloadResponse {
35
+ code: number;
36
+ meta: ResponseMeta;
37
+ media: Media[];
38
+ /** Original post caption only (no likes/comments/shares text) */
39
+ caption: string;
40
+ username: string;
41
+ /** Likes, comments, views, shares — separate from caption */
42
+ engagement?: Engagement;
43
+ /** e.g. likes_hidden, carousel, partial_carousel */
44
+ tags?: ResultTag[];
45
+ message?: string;
46
+ }
47
+ interface ErrorResponse {
48
+ code: number;
49
+ message: string;
50
+ meta?: ResponseMeta;
51
+ /** Hint for clients when a background fetch is still running. */
52
+ retryAfterMs?: number;
53
+ }
54
+ type ApiResponse = DownloadResponse | ErrorResponse;
55
+ interface UltraIgdlOptions {
56
+ cache?: boolean;
57
+ cacheTtlMs?: number;
58
+ /** How long stale cache may be served while revalidating (default 24h). */
59
+ staleCacheTtlMs?: number;
60
+ cacheMaxSize?: number;
61
+ redis?: RedisAdapter;
62
+ maxConcurrency?: number;
63
+ timeoutMs?: number;
64
+ retries?: number;
65
+ userAgentRotation?: boolean;
66
+ verbose?: boolean;
67
+ /**
68
+ * Target max time for `download()` to return. Uses instant cache/stale hits;
69
+ * on cold URLs returns 503 + `retryAfterMs` while fetch continues in background.
70
+ * Set `fastMode: true` for 500ms budget.
71
+ */
72
+ responseBudgetMs?: number;
73
+ /** Shorthand: `responseBudgetMs: 500`, `retries: 0`, aggressive cache. */
74
+ fastMode?: boolean;
75
+ /**
76
+ * Instagram `sessionid` cookie value (from a logged-in browser).
77
+ * Required for story downloads — Instagram does not embed story media in public HTML.
78
+ */
79
+ sessionId?: string;
80
+ /** Full Cookie header override (includes sessionid, csrftoken, etc.). */
81
+ cookies?: string;
82
+ }
83
+ interface RedisAdapter {
84
+ get(key: string): Promise<string | null>;
85
+ set(key: string, value: string, ttlMs?: number): Promise<void>;
86
+ del?(key: string): Promise<void>;
87
+ }
88
+ interface ParsedUrl {
89
+ type: "reel" | "post" | "story" | "highlight" | "tv" | "unknown";
90
+ shortcode?: string;
91
+ username?: string;
92
+ storyId?: string;
93
+ highlightId?: string;
94
+ storyMediaId?: string;
95
+ normalized: string;
96
+ }
97
+ interface HealthStatus {
98
+ status: "ok" | "degraded" | "error";
99
+ version: string;
100
+ uptime: number;
101
+ cache: {
102
+ size: number;
103
+ maxSize: number;
104
+ hitRate?: number;
105
+ };
106
+ pool: {
107
+ connections: number;
108
+ pending: number;
109
+ };
110
+ }
111
+ interface BatchResult {
112
+ url: string;
113
+ result: ApiResponse;
114
+ durationMs: number;
115
+ }
116
+
117
+ declare const EXTRACTOR_NAME = "ultra-igdl";
118
+
119
+ declare class DownloaderCore {
120
+ private client;
121
+ private cache;
122
+ private options;
123
+ private startTime;
124
+ private semaphore;
125
+ constructor(options?: UltraIgdlOptions);
126
+ private acquire;
127
+ private release;
128
+ private meta;
129
+ private success;
130
+ private error;
131
+ private startDownloadTask;
132
+ /** API-only attempt for story/highlight (fits ~500ms budget). */
133
+ private fetchFastExtract;
134
+ /** Warm cache in background (full extraction, no response budget). */
135
+ prefetch(url: string): Promise<ApiResponse>;
136
+ download(url: string): Promise<ApiResponse>;
137
+ private ensureBackgroundFetch;
138
+ private fetchAndExtract;
139
+ info(url: string): Promise<ApiResponse>;
140
+ validate(url: string): Promise<{
141
+ valid: boolean;
142
+ type?: string;
143
+ normalized?: string;
144
+ }>;
145
+ media(url: string): Promise<Media[] | ErrorResponse>;
146
+ batch(urls: string[]): Promise<BatchResult[]>;
147
+ health(): Promise<HealthStatus>;
148
+ clearCache(): void;
149
+ }
150
+
151
+ interface ValidationResult {
152
+ valid: boolean;
153
+ type?: string;
154
+ normalized?: string;
155
+ error?: string;
156
+ }
157
+ declare function validateUrl(input: string): ValidationResult;
158
+
159
+ declare function parseInstagramUrl(input: string): ParsedUrl;
160
+ declare function isInstagramUrl(input: string): boolean;
161
+
162
+ declare class ultraigdl {
163
+ private core;
164
+ constructor(options?: UltraIgdlOptions);
165
+ download(url: string): Promise<ApiResponse>;
166
+ info(url: string): Promise<ApiResponse>;
167
+ validate(url: string): Promise<{
168
+ valid: boolean;
169
+ type?: string;
170
+ normalized?: string;
171
+ }>;
172
+ media(url: string): Promise<Media[] | ErrorResponse>;
173
+ batch(urls: string[]): Promise<BatchResult[]>;
174
+ health(): Promise<HealthStatus>;
175
+ clearCache(): void;
176
+ /** Start extraction now so the next `download()` can return within `responseBudgetMs`. */
177
+ prefetch(url: string): Promise<ApiResponse>;
178
+ }
179
+
180
+ export { type ApiResponse, type BatchResult, type DownloadResponse, DownloaderCore, EXTRACTOR_NAME, type Engagement, type EngagementTag, type ErrorResponse, type HealthStatus, type Media, PACKAGE_VERSION, type PostContentTag, type RedisAdapter, type ResultTag, type UltraIgdlOptions, type ValidationResult, ultraigdl as default, isInstagramUrl, parseInstagramUrl, ultraigdl, validateUrl };
@@ -0,0 +1,180 @@
1
+ /** Auto-generated by scripts/sync-version.mjs — do not edit */
2
+ declare const PACKAGE_VERSION = "1.0.0";
3
+
4
+ type MediaType = "video" | "image";
5
+ interface Media {
6
+ type: MediaType;
7
+ url: string;
8
+ thumbnail?: string;
9
+ width?: number;
10
+ height?: number;
11
+ duration?: number;
12
+ }
13
+ interface ResponseMeta {
14
+ extractor: string;
15
+ version: string;
16
+ }
17
+ interface Engagement {
18
+ likes?: number;
19
+ comments?: number;
20
+ views?: number;
21
+ shares?: number;
22
+ /** Creator disabled public like/view counts (not the same as zero likes). */
23
+ likesHidden?: boolean;
24
+ /** Creator disabled comments or comment counts. */
25
+ commentsHidden?: boolean;
26
+ /** Raw stats line from Instagram (likes/comments prefix) when present */
27
+ raw?: string;
28
+ }
29
+ /** Visibility / extraction hints for clients (e.g. owner hid like counts). */
30
+ type EngagementTag = "likes_hidden" | "comments_hidden" | "engagement_hidden";
31
+ /** Post shape hints (carousel detection, session needs). */
32
+ type PostContentTag = "carousel" | "partial_carousel" | "session_recommended";
33
+ type ResultTag = EngagementTag | PostContentTag;
34
+ interface DownloadResponse {
35
+ code: number;
36
+ meta: ResponseMeta;
37
+ media: Media[];
38
+ /** Original post caption only (no likes/comments/shares text) */
39
+ caption: string;
40
+ username: string;
41
+ /** Likes, comments, views, shares — separate from caption */
42
+ engagement?: Engagement;
43
+ /** e.g. likes_hidden, carousel, partial_carousel */
44
+ tags?: ResultTag[];
45
+ message?: string;
46
+ }
47
+ interface ErrorResponse {
48
+ code: number;
49
+ message: string;
50
+ meta?: ResponseMeta;
51
+ /** Hint for clients when a background fetch is still running. */
52
+ retryAfterMs?: number;
53
+ }
54
+ type ApiResponse = DownloadResponse | ErrorResponse;
55
+ interface UltraIgdlOptions {
56
+ cache?: boolean;
57
+ cacheTtlMs?: number;
58
+ /** How long stale cache may be served while revalidating (default 24h). */
59
+ staleCacheTtlMs?: number;
60
+ cacheMaxSize?: number;
61
+ redis?: RedisAdapter;
62
+ maxConcurrency?: number;
63
+ timeoutMs?: number;
64
+ retries?: number;
65
+ userAgentRotation?: boolean;
66
+ verbose?: boolean;
67
+ /**
68
+ * Target max time for `download()` to return. Uses instant cache/stale hits;
69
+ * on cold URLs returns 503 + `retryAfterMs` while fetch continues in background.
70
+ * Set `fastMode: true` for 500ms budget.
71
+ */
72
+ responseBudgetMs?: number;
73
+ /** Shorthand: `responseBudgetMs: 500`, `retries: 0`, aggressive cache. */
74
+ fastMode?: boolean;
75
+ /**
76
+ * Instagram `sessionid` cookie value (from a logged-in browser).
77
+ * Required for story downloads — Instagram does not embed story media in public HTML.
78
+ */
79
+ sessionId?: string;
80
+ /** Full Cookie header override (includes sessionid, csrftoken, etc.). */
81
+ cookies?: string;
82
+ }
83
+ interface RedisAdapter {
84
+ get(key: string): Promise<string | null>;
85
+ set(key: string, value: string, ttlMs?: number): Promise<void>;
86
+ del?(key: string): Promise<void>;
87
+ }
88
+ interface ParsedUrl {
89
+ type: "reel" | "post" | "story" | "highlight" | "tv" | "unknown";
90
+ shortcode?: string;
91
+ username?: string;
92
+ storyId?: string;
93
+ highlightId?: string;
94
+ storyMediaId?: string;
95
+ normalized: string;
96
+ }
97
+ interface HealthStatus {
98
+ status: "ok" | "degraded" | "error";
99
+ version: string;
100
+ uptime: number;
101
+ cache: {
102
+ size: number;
103
+ maxSize: number;
104
+ hitRate?: number;
105
+ };
106
+ pool: {
107
+ connections: number;
108
+ pending: number;
109
+ };
110
+ }
111
+ interface BatchResult {
112
+ url: string;
113
+ result: ApiResponse;
114
+ durationMs: number;
115
+ }
116
+
117
+ declare const EXTRACTOR_NAME = "ultra-igdl";
118
+
119
+ declare class DownloaderCore {
120
+ private client;
121
+ private cache;
122
+ private options;
123
+ private startTime;
124
+ private semaphore;
125
+ constructor(options?: UltraIgdlOptions);
126
+ private acquire;
127
+ private release;
128
+ private meta;
129
+ private success;
130
+ private error;
131
+ private startDownloadTask;
132
+ /** API-only attempt for story/highlight (fits ~500ms budget). */
133
+ private fetchFastExtract;
134
+ /** Warm cache in background (full extraction, no response budget). */
135
+ prefetch(url: string): Promise<ApiResponse>;
136
+ download(url: string): Promise<ApiResponse>;
137
+ private ensureBackgroundFetch;
138
+ private fetchAndExtract;
139
+ info(url: string): Promise<ApiResponse>;
140
+ validate(url: string): Promise<{
141
+ valid: boolean;
142
+ type?: string;
143
+ normalized?: string;
144
+ }>;
145
+ media(url: string): Promise<Media[] | ErrorResponse>;
146
+ batch(urls: string[]): Promise<BatchResult[]>;
147
+ health(): Promise<HealthStatus>;
148
+ clearCache(): void;
149
+ }
150
+
151
+ interface ValidationResult {
152
+ valid: boolean;
153
+ type?: string;
154
+ normalized?: string;
155
+ error?: string;
156
+ }
157
+ declare function validateUrl(input: string): ValidationResult;
158
+
159
+ declare function parseInstagramUrl(input: string): ParsedUrl;
160
+ declare function isInstagramUrl(input: string): boolean;
161
+
162
+ declare class ultraigdl {
163
+ private core;
164
+ constructor(options?: UltraIgdlOptions);
165
+ download(url: string): Promise<ApiResponse>;
166
+ info(url: string): Promise<ApiResponse>;
167
+ validate(url: string): Promise<{
168
+ valid: boolean;
169
+ type?: string;
170
+ normalized?: string;
171
+ }>;
172
+ media(url: string): Promise<Media[] | ErrorResponse>;
173
+ batch(urls: string[]): Promise<BatchResult[]>;
174
+ health(): Promise<HealthStatus>;
175
+ clearCache(): void;
176
+ /** Start extraction now so the next `download()` can return within `responseBudgetMs`. */
177
+ prefetch(url: string): Promise<ApiResponse>;
178
+ }
179
+
180
+ export { type ApiResponse, type BatchResult, type DownloadResponse, DownloaderCore, EXTRACTOR_NAME, type Engagement, type EngagementTag, type ErrorResponse, type HealthStatus, type Media, PACKAGE_VERSION, type PostContentTag, type RedisAdapter, type ResultTag, type UltraIgdlOptions, type ValidationResult, ultraigdl as default, isInstagramUrl, parseInstagramUrl, ultraigdl, validateUrl };