@sovovs/bycli 2.1.58 → 2.1.59
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.
|
@@ -87,6 +87,26 @@ export async function readKnowledgeBaseFromChrome(page, query, dependencies = {}
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export async function readImaMediaUrl(page, item, dependencies = {}) {
|
|
90
|
+
if (typeof page.requestImaMedia === 'function' && typeof page.startImaAuthCapture === 'function') {
|
|
91
|
+
const authId = await acquireImaChromeAuth(page, item?.knowledgeBaseId, dependencies);
|
|
92
|
+
try {
|
|
93
|
+
const response = await page.requestImaMedia(authId, {
|
|
94
|
+
knowledgeBaseId: String(item?.knowledgeBaseId ?? ''),
|
|
95
|
+
mediaId: String(item?.mediaId ?? ''),
|
|
96
|
+
scene: dependencies.scene ?? 4,
|
|
97
|
+
...(item?.shareId ? { shareId: String(item.shareId) } : {}),
|
|
98
|
+
...(item?.sourceKnowledgeBaseId ? { sourceKnowledgeBaseId: String(item.sourceKnowledgeBaseId) } : {}),
|
|
99
|
+
});
|
|
100
|
+
const data = response && typeof response === 'object' ? response : {};
|
|
101
|
+
const url = data.jumpUrlInfo?.url ?? data.jump_url_info?.url;
|
|
102
|
+
if (Number(data.action) !== 1 || typeof url !== 'string' || !url) {
|
|
103
|
+
throw codedError('IMA_ORIGINAL_URL_UNAVAILABLE', data.toastText || data.toast_text || 'IMA did not return an exportable file URL');
|
|
104
|
+
}
|
|
105
|
+
return url;
|
|
106
|
+
} finally {
|
|
107
|
+
await releaseImaAuth(page, authId);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
90
110
|
if (!page || typeof page.fetchJson !== 'function') {
|
|
91
111
|
throw codedError('IMA_ORIGINAL_URL_UNAVAILABLE', 'IMA browser page cannot call get_media');
|
|
92
112
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { AdapterLease, AdapterLeaseRelease, AdapterLeaseRequest, AdapterResourceGrant } from '../adapter-scheduler.js';
|
|
7
7
|
export interface DaemonCommand {
|
|
8
8
|
id: string;
|
|
9
|
-
action: 'exec' | 'navigate' | 'tabs' | 'cookies' | 'screenshot' | 'close-window' | 'set-file-input' | 'insert-text' | 'bind' | 'network-capture-start' | 'network-capture-read' | 'ima-auth-start' | 'ima-auth-read' | 'ima-reader-request' | 'ima-auth-release' | 'wait-download' | 'cdp' | 'frames';
|
|
9
|
+
action: 'exec' | 'navigate' | 'tabs' | 'cookies' | 'screenshot' | 'close-window' | 'set-file-input' | 'insert-text' | 'bind' | 'network-capture-start' | 'network-capture-read' | 'ima-auth-start' | 'ima-auth-read' | 'ima-reader-request' | 'ima-media-request' | 'ima-auth-release' | 'wait-download' | 'cdp' | 'frames';
|
|
10
10
|
/** Target page identity (targetId). Cross-layer contract with the extension. */
|
|
11
11
|
page?: string;
|
|
12
12
|
code?: string;
|
|
@@ -36,6 +36,7 @@ export interface DaemonCommand {
|
|
|
36
36
|
authId?: string;
|
|
37
37
|
readerPath?: string;
|
|
38
38
|
readerBody?: Record<string, unknown>;
|
|
39
|
+
mediaBody?: Record<string, unknown>;
|
|
39
40
|
/** Download wait timeout in milliseconds */
|
|
40
41
|
timeoutMs?: number;
|
|
41
42
|
cdpMethod?: string;
|
|
@@ -64,6 +64,7 @@ export declare class Page extends BasePage {
|
|
|
64
64
|
authId: string;
|
|
65
65
|
} | null>;
|
|
66
66
|
requestImaReader(authId: string, path: string, body: Record<string, unknown>): Promise<unknown>;
|
|
67
|
+
requestImaMedia(authId: string, body: Record<string, unknown>): Promise<unknown>;
|
|
67
68
|
releaseImaAuth(authId: string): Promise<void>;
|
|
68
69
|
waitForDownload(pattern?: string, timeoutMs?: number, options?: BrowserDownloadWaitOptions): Promise<BrowserDownloadWaitResult>;
|
|
69
70
|
/**
|
package/dist/src/browser/page.js
CHANGED
|
@@ -325,6 +325,9 @@ export class Page extends BasePage {
|
|
|
325
325
|
...this._cmdOpts(),
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
|
+
async requestImaMedia(authId, body) {
|
|
329
|
+
return sendCommand('ima-media-request', { authId, mediaBody: body, ...this._cmdOpts() });
|
|
330
|
+
}
|
|
328
331
|
async releaseImaAuth(authId) {
|
|
329
332
|
await sendCommand('ima-auth-release', { authId, ...this._cmdOpts() });
|
|
330
333
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -208,6 +208,7 @@ export interface IPage {
|
|
|
208
208
|
authId: string;
|
|
209
209
|
} | null>;
|
|
210
210
|
requestImaReader?(authId: string, path: string, body: Record<string, unknown>): Promise<unknown>;
|
|
211
|
+
requestImaMedia?(authId: string, body: Record<string, unknown>): Promise<unknown>;
|
|
211
212
|
releaseImaAuth?(authId: string): Promise<void>;
|
|
212
213
|
/**
|
|
213
214
|
* Set local file paths on a file input element via CDP DOM.setFileInputFiles.
|