@mirage-cli/dataforseo-cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/api/ai.d.ts +32 -0
- package/dist/api/backlinks.d.ts +20 -0
- package/dist/api/keywords.d.ts +27 -0
- package/dist/api/labs.d.ts +40 -0
- package/dist/api/meta.d.ts +4 -0
- package/dist/api/serp.d.ts +14 -0
- package/dist/api/trends.d.ts +18 -0
- package/dist/commands/ai.d.ts +8 -0
- package/dist/commands/backlinks.d.ts +8 -0
- package/dist/commands/endpoints.d.ts +5 -0
- package/dist/commands/keywords.d.ts +6 -0
- package/dist/commands/labs.d.ts +11 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/meta.d.ts +4 -0
- package/dist/commands/raw.d.ts +2 -0
- package/dist/commands/serp.d.ts +7 -0
- package/dist/commands/trends.d.ts +5 -0
- package/dist/dfs.d.ts +7 -0
- package/dist/dfs.js +687 -0
- package/dist/framework/index.d.ts +2 -0
- package/dist/framework/output.d.ts +25 -0
- package/dist/framework/runtime.d.ts +74 -0
- package/dist/framework/types.d.ts +89 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +686 -0
- package/dist/lib/auth.d.ts +8 -0
- package/dist/lib/client.d.ts +33 -0
- package/dist/lib/output.d.ts +11 -0
- package/dist/lib/spec.d.ts +15 -0
- package/package.json +61 -0
- package/src/spec/index.json +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type Credentials = {
|
|
2
|
+
login: string;
|
|
3
|
+
password: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function configPath(): string;
|
|
6
|
+
export declare function loadCredentials(): Credentials;
|
|
7
|
+
export declare function saveCredentials(creds: Credentials): string;
|
|
8
|
+
export declare function basicAuthHeader({ login, password }: Credentials): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type DfsResponse = {
|
|
2
|
+
status_code?: number;
|
|
3
|
+
status_message?: string;
|
|
4
|
+
cost?: number;
|
|
5
|
+
tasks?: Array<{
|
|
6
|
+
status_code?: number;
|
|
7
|
+
status_message?: string;
|
|
8
|
+
result?: unknown;
|
|
9
|
+
[k: string]: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type CallOptions = {
|
|
14
|
+
/** Wrap a single task object as `[task]` for endpoints that take an array body. Default: true. */
|
|
15
|
+
wrapAsTaskArray?: boolean;
|
|
16
|
+
/** Override base URL (rare). */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
/** Request timeout in ms (default 120_000). */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Call any DataForSEO endpoint. Path may be absolute (`/v3/serp/...`)
|
|
23
|
+
* or relative (`serp/...`); leading `v3/` is added if missing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function call(path: string, body: unknown, opts?: CallOptions): Promise<DfsResponse>;
|
|
26
|
+
/** GET helper for the few `GET` endpoints (locations, languages, user, errors). */
|
|
27
|
+
export declare function get(path: string, opts?: CallOptions): Promise<DfsResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Extract result rows from a DataForSEO response.
|
|
30
|
+
* DataForSEO nests results as `tasks[*].result[*]` — most useful data is the
|
|
31
|
+
* first task's result array, which itself often contains an `items` field.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractItems(resp: DfsResponse): unknown[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DfsResponse } from "./client.ts";
|
|
2
|
+
export type OutputFormat = "json" | "ndjson" | "table" | "csv" | "raw";
|
|
3
|
+
export type RenderOptions = {
|
|
4
|
+
format: OutputFormat;
|
|
5
|
+
/** When true, emit the full untouched response. Otherwise emit `extractItems(resp)`. */
|
|
6
|
+
full?: boolean;
|
|
7
|
+
/** Columns for table/csv. If omitted, derived from the first row. */
|
|
8
|
+
columns?: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare function render(resp: DfsResponse, opts: RenderOptions): string;
|
|
11
|
+
export declare function emitCost(resp: DfsResponse): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type EndpointMethod = "get" | "post";
|
|
2
|
+
export type EndpointInfo = {
|
|
3
|
+
path: string;
|
|
4
|
+
method: EndpointMethod;
|
|
5
|
+
operationId?: string;
|
|
6
|
+
tag?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/** First example body the spec ships with, useful for `dfs raw --example`. */
|
|
9
|
+
example?: unknown;
|
|
10
|
+
/** Doc URL extracted from the description, when present. */
|
|
11
|
+
docUrl?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function loadEndpoints(): EndpointInfo[];
|
|
14
|
+
export declare function findEndpoint(path: string): EndpointInfo | undefined;
|
|
15
|
+
export declare function searchEndpoints(query: string, tag?: string): EndpointInfo[];
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mirage-cli/dataforseo-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ergonomic CLI wrapper around the DataForSEO API (curated commands + raw escape hatch).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/alexbruf/mirage-cli.git",
|
|
9
|
+
"directory": "packages/dataforseo-cli"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/alexbruf/mirage-cli/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/alexbruf/mirage-cli/tree/main/packages/dataforseo-cli#readme",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"bun": "./src/index.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./cli": {
|
|
26
|
+
"types": "./dist/dfs.d.ts",
|
|
27
|
+
"bun": "./src/dfs.ts",
|
|
28
|
+
"import": "./dist/dfs.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist/",
|
|
34
|
+
"src/spec/index.json",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"bin": {
|
|
38
|
+
"dfs": "./dist/dfs.js",
|
|
39
|
+
"dataforseo": "./dist/dfs.js"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"dev": "bun run src/dfs.ts",
|
|
43
|
+
"spec:build": "bun run scripts/build-spec-index.ts",
|
|
44
|
+
"spec:refresh": "bun run scripts/refresh-spec.ts && bun run scripts/build-spec-index.ts",
|
|
45
|
+
"prebuild": "bun run scripts/build-spec-index.ts",
|
|
46
|
+
"build": "bun build src/dfs.ts src/index.ts --target=node --outdir=dist --minify && bun run scripts/postbuild.ts && bun run scripts/build-types.ts",
|
|
47
|
+
"compile": "bun build src/dfs.ts --compile --outfile=bin/dfs",
|
|
48
|
+
"test": "bun test --reporter=dots",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"commander": "^12.1.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@struktoai/mirage-core": "^0.0.1",
|
|
56
|
+
"yaml": "^2.6.0"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
}
|
|
61
|
+
}
|