@gscdump/devframe 0.0.0-stage → 5.7.1
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 +104 -2
- package/dist/account.mjs +77 -0
- package/dist/client/assets/browser-agent-rpc-BXhoSh1z-UuY7Hinl.js +1 -0
- package/dist/client/assets/index-BdO8MoYt.css +1 -0
- package/dist/client/assets/index-DA7Lgn7_.js +4 -0
- package/dist/client/index.html +13 -0
- package/dist/client-script/index.mjs +1518 -0
- package/dist/credential.mjs +59 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +53 -0
- package/dist/package.mjs +5 -0
- package/dist/page-stats.mjs +114 -0
- package/dist/reader.mjs +215 -0
- package/dist/rpc.mjs +31 -0
- package/dist/shared/protocol.d.mts +106 -0
- package/dist/shared/protocol.mjs +19 -0
- package/dist/source.d.mts +1 -0
- package/dist/source.mjs +7 -0
- package/dist/sources/hosted.d.mts +7 -0
- package/dist/sources/hosted.mjs +118 -0
- package/dist/vite.d.mts +17 -0
- package/dist/vite.mjs +6 -0
- package/package.json +81 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { bearerOf, dashboardOrigin, resolveCredential } from "../credential.mjs";
|
|
2
|
+
import { readAccount } from "../account.mjs";
|
|
3
|
+
import { parseRecordReadRefusal } from "@gscdump/contracts";
|
|
4
|
+
import { createGscdumpV1Client, isGscdumpV1Error } from "@gscdump/sdk/v1";
|
|
5
|
+
function rowsBody(dimension, path, window, rowLimit) {
|
|
6
|
+
return {
|
|
7
|
+
dimensions: [dimension],
|
|
8
|
+
filter: { _filters: [{
|
|
9
|
+
dimension: "date",
|
|
10
|
+
operator: "between",
|
|
11
|
+
expression: window.start,
|
|
12
|
+
expression2: window.end
|
|
13
|
+
}, {
|
|
14
|
+
dimension: "page",
|
|
15
|
+
operator: "equals",
|
|
16
|
+
expression: path
|
|
17
|
+
}] },
|
|
18
|
+
orderBy: dimension === "date" ? {
|
|
19
|
+
column: "date",
|
|
20
|
+
dir: "asc"
|
|
21
|
+
} : {
|
|
22
|
+
column: "clicks",
|
|
23
|
+
dir: "desc"
|
|
24
|
+
},
|
|
25
|
+
rowLimit
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createHostedSource(options, deps) {
|
|
29
|
+
const apiRoot = (options.apiRoot ?? deps.env.GSCDUMP_API_ROOT ?? "https://gscdump.com/api").replace(/\/+$/, "");
|
|
30
|
+
let ready = null;
|
|
31
|
+
async function sites() {
|
|
32
|
+
const read = await readSites();
|
|
33
|
+
if (read._tag === "Blocked") ready = null;
|
|
34
|
+
return read;
|
|
35
|
+
}
|
|
36
|
+
async function readSites() {
|
|
37
|
+
const credential = await resolveCredential({
|
|
38
|
+
apiKey: options.apiKey,
|
|
39
|
+
apiRoot: options.apiRoot,
|
|
40
|
+
env: deps.env,
|
|
41
|
+
readCliAuthentication: deps.readCliAuthentication
|
|
42
|
+
});
|
|
43
|
+
if (!credential) return {
|
|
44
|
+
_tag: "Blocked",
|
|
45
|
+
context: { _tag: "CredentialMissing" }
|
|
46
|
+
};
|
|
47
|
+
const account = await readAccount(credential, deps.fetch);
|
|
48
|
+
if (account._tag === "Rejected") return {
|
|
49
|
+
_tag: "Blocked",
|
|
50
|
+
context: {
|
|
51
|
+
_tag: "CredentialRejected",
|
|
52
|
+
source: credential.source
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (account._tag === "Unavailable") return {
|
|
56
|
+
_tag: "Blocked",
|
|
57
|
+
context: {
|
|
58
|
+
_tag: "Unavailable",
|
|
59
|
+
message: account.message
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
ready = {
|
|
63
|
+
credential,
|
|
64
|
+
client: createGscdumpV1Client({
|
|
65
|
+
apiRoot: credential.apiRoot,
|
|
66
|
+
credential: bearerOf(credential),
|
|
67
|
+
fetch: deps.fetch
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
_tag: "Ok",
|
|
72
|
+
sites: account.sites
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function readRows(siteId, body) {
|
|
76
|
+
if (!ready) return {
|
|
77
|
+
_tag: "Unauthorized",
|
|
78
|
+
context: { _tag: "CredentialMissing" }
|
|
79
|
+
};
|
|
80
|
+
const { client, credential } = ready;
|
|
81
|
+
return client.queryAnalyticsRows({
|
|
82
|
+
params: { siteId },
|
|
83
|
+
body
|
|
84
|
+
}).then((response) => ({
|
|
85
|
+
_tag: "Ok",
|
|
86
|
+
rows: response.data.rows
|
|
87
|
+
}), (error) => {
|
|
88
|
+
if (!isGscdumpV1Error(error)) throw error;
|
|
89
|
+
const refusal = parseRecordReadRefusal(error.details);
|
|
90
|
+
if (refusal) return {
|
|
91
|
+
_tag: "Refused",
|
|
92
|
+
refusal
|
|
93
|
+
};
|
|
94
|
+
if (error.code === "rate_limited") return { _tag: "RateLimited" };
|
|
95
|
+
if (error.status === 401 || error.status === 403) return {
|
|
96
|
+
_tag: "Unauthorized",
|
|
97
|
+
context: {
|
|
98
|
+
_tag: "CredentialRejected",
|
|
99
|
+
source: credential.source
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
_tag: "Failed",
|
|
104
|
+
message: error.message,
|
|
105
|
+
requestId: error.requestId ?? null
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
sites,
|
|
111
|
+
dailyRows: (siteId, path, window) => readRows(siteId, rowsBody("date", path, window, 400)),
|
|
112
|
+
queryRows: (siteId, path, window, limit) => readRows(siteId, rowsBody("query", path, window, limit)),
|
|
113
|
+
get dashboardOrigin() {
|
|
114
|
+
return dashboardOrigin(ready?.credential.apiRoot ?? apiRoot);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export { createHostedSource };
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GscdumpDevframeOptions } from "./index.mjs";
|
|
2
|
+
import { createPluginFromDevframe } from "@vitejs/devtools-kit/node";
|
|
3
|
+
/**
|
|
4
|
+
* The gscdump devframe as a Vite plugin. Vite DevTools mounts it as a dock.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // vite.config.ts
|
|
8
|
+
* import { gscdump } from '@gscdump/devframe/vite'
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* devtools: true,
|
|
12
|
+
* plugins: [gscdump({ site: 'example.com' })],
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function gscdump(options?: GscdumpDevframeOptions): ReturnType<typeof createPluginFromDevframe>;
|
|
17
|
+
export { gscdump as default };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createGscdumpDevframe } from "./index.mjs";
|
|
2
|
+
import { createPluginFromDevframe } from "@vitejs/devtools-kit/node";
|
|
3
|
+
function gscdump(options = {}) {
|
|
4
|
+
return createPluginFromDevframe(createGscdumpDevframe(options));
|
|
5
|
+
}
|
|
6
|
+
export { gscdump as default, gscdump };
|
package/package.json
CHANGED
|
@@ -1,6 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/devframe",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.7.1",
|
|
5
|
+
"description": "Search Console clicks, impressions, and queries for the page you are developing, in Vite DevTools and any devframe hub.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Harlan Wilton",
|
|
8
|
+
"email": "harlan@harlanzw.com",
|
|
9
|
+
"url": "https://harlanzw.com/"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": "https://github.com/sponsors/harlan-zw",
|
|
13
|
+
"homepage": "https://github.com/harlan-zw/gscdump/tree/main/packages/devframe#readme",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/harlan-zw/gscdump.git",
|
|
17
|
+
"directory": "packages/devframe"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/harlan-zw/gscdump/issues"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"devframe",
|
|
24
|
+
"devframe-plugin",
|
|
25
|
+
"devtools",
|
|
26
|
+
"vite-devtools",
|
|
27
|
+
"google-search-console",
|
|
28
|
+
"seo"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"import": "./dist/index.mjs",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./vite": {
|
|
38
|
+
"types": "./dist/vite.d.mts",
|
|
39
|
+
"import": "./dist/vite.mjs",
|
|
40
|
+
"default": "./dist/vite.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"types": "./dist/index.d.mts",
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22.13.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@vitejs/devtools-kit": ">=0.7.6"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@vitejs/devtools-kit": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@gscdump/contracts": "^5.7.1",
|
|
61
|
+
"@gscdump/sdk": "^5.7.1",
|
|
62
|
+
"devframe": "^1.2.0",
|
|
63
|
+
"zod": "^4.6.5"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/chrome": "^0.3.4",
|
|
67
|
+
"@types/ws": "^8.18.2",
|
|
68
|
+
"@vitejs/devtools": "^0.7.6",
|
|
69
|
+
"@vitejs/devtools-kit": "^0.7.6",
|
|
70
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
71
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
72
|
+
"vite": "^8.3.2",
|
|
73
|
+
"vitest": "^5.0.1",
|
|
74
|
+
"vue": "^3.5.43",
|
|
75
|
+
"ws": "^8.22.0"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "obuild && vite build --config app/vite.config.ts && vite build --config src/client-script/vite.config.ts",
|
|
79
|
+
"dev": "vite --config playground/vite.config.ts",
|
|
80
|
+
"typecheck": "tsc --noEmit",
|
|
81
|
+
"test": "vitest",
|
|
82
|
+
"build:extension": "vite build --config extension/vite.config.ts"
|
|
83
|
+
}
|
|
6
84
|
}
|