@nuxtseo/protocol 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/dist/analytics-codecs/analytics-row.d.ts +265 -0
- package/dist/analytics-codecs/analytics-row.js +175 -0
- package/dist/analytics-codecs/analytics-web-vitals.d.ts +57 -0
- package/dist/analytics-codecs/analytics-web-vitals.js +76 -0
- package/dist/analytics-codecs/capabilities.d.ts +35 -0
- package/dist/analytics-codecs/capabilities.js +76 -0
- package/dist/analytics-codecs/index.d.ts +3 -0
- package/dist/analytics-codecs/index.js +3 -0
- package/dist/cli-pairing.d.ts +67 -0
- package/dist/cli-pairing.js +52 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/v1/account.d.ts +715 -0
- package/dist/v1/account.js +123 -0
- package/dist/v1/actions.d.ts +2591 -0
- package/dist/v1/actions.js +460 -0
- package/dist/v1/analytics.d.ts +6145 -0
- package/dist/v1/analytics.js +296 -0
- package/dist/v1/audit.d.ts +4053 -0
- package/dist/v1/audit.js +609 -0
- package/dist/v1/backlinks.d.ts +1002 -0
- package/dist/v1/backlinks.js +239 -0
- package/dist/v1/content.d.ts +2745 -0
- package/dist/v1/content.js +326 -0
- package/dist/v1/core.d.ts +301 -0
- package/dist/v1/core.js +333 -0
- package/dist/v1/documents.d.ts +4 -0
- package/dist/v1/documents.js +216 -0
- package/dist/v1/gsc.d.ts +5172 -0
- package/dist/v1/gsc.js +583 -0
- package/dist/v1/index.d.ts +49 -0
- package/dist/v1/index.js +52 -0
- package/dist/v1/pages.d.ts +1404 -0
- package/dist/v1/pages.js +287 -0
- package/dist/v1/performance.d.ts +1379 -0
- package/dist/v1/performance.js +198 -0
- package/dist/v1/research.d.ts +1173 -0
- package/dist/v1/research.js +174 -0
- package/dist/v1/sitemaps.d.ts +1506 -0
- package/dist/v1/sitemaps.js +199 -0
- package/dist/v1/sites.d.ts +591 -0
- package/dist/v1/sites.js +101 -0
- package/generated/openapi.v1.json +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { z as schema } from 'zod';
|
|
2
|
+
import { analyticsDimensionSchema, analyticsFilterSchema, analyticsProviderSchema } from '../analytics-codecs/index.js';
|
|
3
|
+
import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1ErrorEnvelope, publicV1StandardRatePolicy, } from './core.js';
|
|
4
|
+
export const analyticsViewSchema = schema.enum([
|
|
5
|
+
'performance',
|
|
6
|
+
'top-pages',
|
|
7
|
+
'source-medium',
|
|
8
|
+
'key-events',
|
|
9
|
+
'countries',
|
|
10
|
+
'devices',
|
|
11
|
+
'dimension',
|
|
12
|
+
]);
|
|
13
|
+
export const analyticsSiteParamsSchema = schema.strictObject({
|
|
14
|
+
siteId: schema.string().min(1),
|
|
15
|
+
view: analyticsViewSchema,
|
|
16
|
+
});
|
|
17
|
+
function booleanQuerySchema(fallback) {
|
|
18
|
+
return schema
|
|
19
|
+
.union([schema.boolean(), schema.enum(['true', 'false'])])
|
|
20
|
+
.default(fallback)
|
|
21
|
+
.transform(value => value === true || value === 'true');
|
|
22
|
+
}
|
|
23
|
+
export const analyticsFiltersQuerySchema = schema.string().optional().transform((raw, context) => {
|
|
24
|
+
if (!raw)
|
|
25
|
+
return [];
|
|
26
|
+
let value;
|
|
27
|
+
try {
|
|
28
|
+
value = JSON.parse(raw);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
context.addIssue({ code: 'custom', message: 'filters must be a JSON array' });
|
|
32
|
+
return schema.NEVER;
|
|
33
|
+
}
|
|
34
|
+
const parsed = schema.array(analyticsFilterSchema).safeParse(value);
|
|
35
|
+
if (!parsed.success) {
|
|
36
|
+
for (const issue of parsed.error.issues)
|
|
37
|
+
context.addIssue({ ...issue, path: ['filters', ...issue.path] });
|
|
38
|
+
return schema.NEVER;
|
|
39
|
+
}
|
|
40
|
+
return parsed.data;
|
|
41
|
+
});
|
|
42
|
+
export const analyticsReadQuerySchema = schema.strictObject({
|
|
43
|
+
period: schema.string().min(1).default('28d'),
|
|
44
|
+
compare: schema.enum(['previous', 'year', 'none']).default('previous'),
|
|
45
|
+
stableData: booleanQuerySchema(true),
|
|
46
|
+
filters: analyticsFiltersQuerySchema,
|
|
47
|
+
hostScope: booleanQuerySchema(true),
|
|
48
|
+
dimension: analyticsDimensionSchema.optional(),
|
|
49
|
+
performancePhase: schema.enum(['current', 'prior', 'full']).default('full'),
|
|
50
|
+
comparePrior: booleanQuerySchema(true),
|
|
51
|
+
fresh: booleanQuerySchema(false),
|
|
52
|
+
});
|
|
53
|
+
export const webAnalyticsDeltaSchema = defineResponseObject({
|
|
54
|
+
current: schema.number(),
|
|
55
|
+
prior: schema.number(),
|
|
56
|
+
absolute: schema.number(),
|
|
57
|
+
relative: schema.number(),
|
|
58
|
+
}, {
|
|
59
|
+
current: schema.number(),
|
|
60
|
+
prior: schema.number(),
|
|
61
|
+
absolute: schema.number(),
|
|
62
|
+
relative: schema.number(),
|
|
63
|
+
});
|
|
64
|
+
export const webAnalyticsDailyRowSchema = defineResponseObject({
|
|
65
|
+
date: schema.string(),
|
|
66
|
+
sessions: schema.number(),
|
|
67
|
+
users: schema.number(),
|
|
68
|
+
pageviews: schema.number(),
|
|
69
|
+
}, {
|
|
70
|
+
date: schema.string(),
|
|
71
|
+
sessions: schema.number(),
|
|
72
|
+
users: schema.number(),
|
|
73
|
+
pageviews: schema.number(),
|
|
74
|
+
});
|
|
75
|
+
export const webAnalyticsPerformanceDataSchema = defineResponseObject({
|
|
76
|
+
phase: schema.enum(['current', 'prior', 'full']),
|
|
77
|
+
sessions: webAnalyticsDeltaSchema.producer,
|
|
78
|
+
users: webAnalyticsDeltaSchema.producer,
|
|
79
|
+
pageviews: webAnalyticsDeltaSchema.producer,
|
|
80
|
+
engagementRate: webAnalyticsDeltaSchema.producer,
|
|
81
|
+
bounceRate: webAnalyticsDeltaSchema.producer,
|
|
82
|
+
keyEvents: webAnalyticsDeltaSchema.producer,
|
|
83
|
+
daily: schema.array(webAnalyticsDailyRowSchema.producer),
|
|
84
|
+
priorDaily: schema.array(webAnalyticsDailyRowSchema.producer),
|
|
85
|
+
dataFrom: schema.string().optional(),
|
|
86
|
+
provider: analyticsProviderSchema,
|
|
87
|
+
}, {
|
|
88
|
+
phase: schema.enum(['current', 'prior', 'full']),
|
|
89
|
+
sessions: webAnalyticsDeltaSchema.client,
|
|
90
|
+
users: webAnalyticsDeltaSchema.client,
|
|
91
|
+
pageviews: webAnalyticsDeltaSchema.client,
|
|
92
|
+
engagementRate: webAnalyticsDeltaSchema.client,
|
|
93
|
+
bounceRate: webAnalyticsDeltaSchema.client,
|
|
94
|
+
keyEvents: webAnalyticsDeltaSchema.client,
|
|
95
|
+
daily: schema.array(webAnalyticsDailyRowSchema.client),
|
|
96
|
+
priorDaily: schema.array(webAnalyticsDailyRowSchema.client),
|
|
97
|
+
dataFrom: schema.string().optional(),
|
|
98
|
+
provider: analyticsProviderSchema,
|
|
99
|
+
});
|
|
100
|
+
const topPageRowSchema = defineResponseObject({
|
|
101
|
+
page: schema.string(),
|
|
102
|
+
pageviews: schema.number(),
|
|
103
|
+
sessions: schema.number(),
|
|
104
|
+
pageviewsDelta: webAnalyticsDeltaSchema.producer,
|
|
105
|
+
}, {
|
|
106
|
+
page: schema.string(),
|
|
107
|
+
pageviews: schema.number(),
|
|
108
|
+
sessions: schema.number(),
|
|
109
|
+
pageviewsDelta: webAnalyticsDeltaSchema.client,
|
|
110
|
+
});
|
|
111
|
+
export const webAnalyticsTopPagesDataSchema = defineResponseObject({ provider: analyticsProviderSchema, rows: schema.array(topPageRowSchema.producer) }, { provider: analyticsProviderSchema, rows: schema.array(topPageRowSchema.client) });
|
|
112
|
+
const sourceMediumRowSchema = defineResponseObject({
|
|
113
|
+
sessions: schema.number(),
|
|
114
|
+
sessionsDelta: webAnalyticsDeltaSchema.producer,
|
|
115
|
+
source: schema.string(),
|
|
116
|
+
users: schema.number(),
|
|
117
|
+
}, {
|
|
118
|
+
sessions: schema.number(),
|
|
119
|
+
sessionsDelta: webAnalyticsDeltaSchema.client,
|
|
120
|
+
source: schema.string(),
|
|
121
|
+
users: schema.number(),
|
|
122
|
+
});
|
|
123
|
+
export const webAnalyticsSourceMediumDataSchema = defineResponseObject({ provider: analyticsProviderSchema, rows: schema.array(sourceMediumRowSchema.producer) }, { provider: analyticsProviderSchema, rows: schema.array(sourceMediumRowSchema.client) });
|
|
124
|
+
const keyEventDailyRowSchema = defineResponseObject({ date: schema.string(), keyEvents: schema.number() }, { date: schema.string(), keyEvents: schema.number() });
|
|
125
|
+
export const webAnalyticsKeyEventsDataSchema = defineResponseObject({
|
|
126
|
+
daily: schema.array(keyEventDailyRowSchema.producer).optional(),
|
|
127
|
+
provider: analyticsProviderSchema,
|
|
128
|
+
total: webAnalyticsDeltaSchema.producer,
|
|
129
|
+
}, {
|
|
130
|
+
daily: schema.array(keyEventDailyRowSchema.client).optional(),
|
|
131
|
+
provider: analyticsProviderSchema,
|
|
132
|
+
total: webAnalyticsDeltaSchema.client,
|
|
133
|
+
});
|
|
134
|
+
const countryRowSchema = defineResponseObject({
|
|
135
|
+
country: schema.string(),
|
|
136
|
+
sessions: schema.number(),
|
|
137
|
+
users: schema.number(),
|
|
138
|
+
pageviews: schema.number(),
|
|
139
|
+
sessionsDelta: webAnalyticsDeltaSchema.producer,
|
|
140
|
+
}, {
|
|
141
|
+
country: schema.string(),
|
|
142
|
+
sessions: schema.number(),
|
|
143
|
+
users: schema.number(),
|
|
144
|
+
pageviews: schema.number(),
|
|
145
|
+
sessionsDelta: webAnalyticsDeltaSchema.client,
|
|
146
|
+
});
|
|
147
|
+
export const webAnalyticsCountriesDataSchema = defineResponseObject({ provider: analyticsProviderSchema, rows: schema.array(countryRowSchema.producer) }, { provider: analyticsProviderSchema, rows: schema.array(countryRowSchema.client) });
|
|
148
|
+
const deviceRowSchema = defineResponseObject({
|
|
149
|
+
device: schema.string(),
|
|
150
|
+
sessions: schema.number(),
|
|
151
|
+
users: schema.number(),
|
|
152
|
+
pageviews: schema.number(),
|
|
153
|
+
sessionsDelta: webAnalyticsDeltaSchema.producer,
|
|
154
|
+
share: schema.number(),
|
|
155
|
+
}, {
|
|
156
|
+
device: schema.string(),
|
|
157
|
+
sessions: schema.number(),
|
|
158
|
+
users: schema.number(),
|
|
159
|
+
pageviews: schema.number(),
|
|
160
|
+
sessionsDelta: webAnalyticsDeltaSchema.client,
|
|
161
|
+
share: schema.number(),
|
|
162
|
+
});
|
|
163
|
+
export const webAnalyticsDevicesDataSchema = defineResponseObject({ provider: analyticsProviderSchema, rows: schema.array(deviceRowSchema.producer) }, { provider: analyticsProviderSchema, rows: schema.array(deviceRowSchema.client) });
|
|
164
|
+
export const webAnalyticsByDimensionRowSchema = defineResponseObject({
|
|
165
|
+
label: schema.string(),
|
|
166
|
+
sessions: schema.number(),
|
|
167
|
+
users: schema.number(),
|
|
168
|
+
pageviews: schema.number(),
|
|
169
|
+
share: schema.number(),
|
|
170
|
+
delta: webAnalyticsDeltaSchema.producer,
|
|
171
|
+
}, {
|
|
172
|
+
label: schema.string(),
|
|
173
|
+
sessions: schema.number(),
|
|
174
|
+
users: schema.number(),
|
|
175
|
+
pageviews: schema.number(),
|
|
176
|
+
share: schema.number(),
|
|
177
|
+
delta: webAnalyticsDeltaSchema.client,
|
|
178
|
+
});
|
|
179
|
+
export const webAnalyticsDimensionDataSchema = defineResponseObject({
|
|
180
|
+
provider: analyticsProviderSchema,
|
|
181
|
+
dimension: analyticsDimensionSchema,
|
|
182
|
+
rows: schema.array(webAnalyticsByDimensionRowSchema.producer),
|
|
183
|
+
}, {
|
|
184
|
+
provider: analyticsProviderSchema,
|
|
185
|
+
dimension: analyticsDimensionSchema,
|
|
186
|
+
rows: schema.array(webAnalyticsByDimensionRowSchema.client),
|
|
187
|
+
});
|
|
188
|
+
export const analyticsSiteViewDataSchemas = {
|
|
189
|
+
'performance': webAnalyticsPerformanceDataSchema,
|
|
190
|
+
'top-pages': webAnalyticsTopPagesDataSchema,
|
|
191
|
+
'source-medium': webAnalyticsSourceMediumDataSchema,
|
|
192
|
+
'key-events': webAnalyticsKeyEventsDataSchema,
|
|
193
|
+
'countries': webAnalyticsCountriesDataSchema,
|
|
194
|
+
'devices': webAnalyticsDevicesDataSchema,
|
|
195
|
+
'dimension': webAnalyticsDimensionDataSchema,
|
|
196
|
+
};
|
|
197
|
+
export const analyticsSiteViewResponseSchemas = {
|
|
198
|
+
'performance': defineSuccessEnvelope(webAnalyticsPerformanceDataSchema),
|
|
199
|
+
'top-pages': defineSuccessEnvelope(webAnalyticsTopPagesDataSchema),
|
|
200
|
+
'source-medium': defineSuccessEnvelope(webAnalyticsSourceMediumDataSchema),
|
|
201
|
+
'key-events': defineSuccessEnvelope(webAnalyticsKeyEventsDataSchema),
|
|
202
|
+
'countries': defineSuccessEnvelope(webAnalyticsCountriesDataSchema),
|
|
203
|
+
'devices': defineSuccessEnvelope(webAnalyticsDevicesDataSchema),
|
|
204
|
+
'dimension': defineSuccessEnvelope(webAnalyticsDimensionDataSchema),
|
|
205
|
+
};
|
|
206
|
+
const responseSchemas = Object.values(analyticsSiteViewResponseSchemas);
|
|
207
|
+
export const analyticsQueryResponseSchema = {
|
|
208
|
+
producer: schema.union(responseSchemas.map(response => response.producer)),
|
|
209
|
+
client: schema.union(responseSchemas.map(response => response.client)),
|
|
210
|
+
};
|
|
211
|
+
export const analyticsQueryOperation = defineOperation({
|
|
212
|
+
id: 'analytics.query',
|
|
213
|
+
method: 'GET',
|
|
214
|
+
path: '/api/v1/sites/{siteId}/analytics/{view}',
|
|
215
|
+
visibility: 'public',
|
|
216
|
+
semantics: {
|
|
217
|
+
kind: 'query',
|
|
218
|
+
sideEffects: 'none',
|
|
219
|
+
retry: 'idempotent',
|
|
220
|
+
readConsistency: 'replica-ok',
|
|
221
|
+
},
|
|
222
|
+
auth: {
|
|
223
|
+
credentials: ['session', 'api_token'],
|
|
224
|
+
scopes: ['analytics:read'],
|
|
225
|
+
minimumRole: 'viewer',
|
|
226
|
+
ownership: 'site',
|
|
227
|
+
},
|
|
228
|
+
request: {
|
|
229
|
+
params: analyticsSiteParamsSchema,
|
|
230
|
+
query: analyticsReadQuerySchema,
|
|
231
|
+
headers: null,
|
|
232
|
+
body: null,
|
|
233
|
+
},
|
|
234
|
+
responses: { 200: analyticsQueryResponseSchema },
|
|
235
|
+
errors: [
|
|
236
|
+
'invalid_request',
|
|
237
|
+
'unauthorized',
|
|
238
|
+
'auth_expired',
|
|
239
|
+
'forbidden',
|
|
240
|
+
'not_found',
|
|
241
|
+
'entitlement_required',
|
|
242
|
+
'conflict',
|
|
243
|
+
'rate_limited',
|
|
244
|
+
'provider_unavailable',
|
|
245
|
+
'contract_violation',
|
|
246
|
+
'internal_error',
|
|
247
|
+
],
|
|
248
|
+
errorResponse: publicV1ErrorEnvelope,
|
|
249
|
+
resources: {
|
|
250
|
+
reads: [{ type: 'site.analytics', idFrom: 'params.siteId' }],
|
|
251
|
+
changes: [],
|
|
252
|
+
},
|
|
253
|
+
policy: {
|
|
254
|
+
rate: publicV1StandardRatePolicy,
|
|
255
|
+
idempotency: { _tag: 'none' },
|
|
256
|
+
entitlement: 'growth',
|
|
257
|
+
meter: null,
|
|
258
|
+
},
|
|
259
|
+
lifecycle: { introduced: '1.0.0' },
|
|
260
|
+
docs: {
|
|
261
|
+
summary: 'Query Web Analytics',
|
|
262
|
+
description: 'Reads one provider-normalized Web Analytics Site Signal for an owned Site.',
|
|
263
|
+
tags: ['Web Analytics'],
|
|
264
|
+
examples: [{
|
|
265
|
+
request: {
|
|
266
|
+
params: { siteId: 'site_01JXYZ', view: 'performance' },
|
|
267
|
+
query: { period: '28d' },
|
|
268
|
+
},
|
|
269
|
+
response: {
|
|
270
|
+
status: 200,
|
|
271
|
+
body: {
|
|
272
|
+
data: {
|
|
273
|
+
phase: 'full',
|
|
274
|
+
sessions: { current: 120, prior: 100, absolute: 20, relative: 0.2 },
|
|
275
|
+
users: { current: 90, prior: 80, absolute: 10, relative: 0.125 },
|
|
276
|
+
pageviews: { current: 180, prior: 150, absolute: 30, relative: 0.2 },
|
|
277
|
+
engagementRate: { current: 0.62, prior: 0.58, absolute: 0.04, relative: 0.0689655172 },
|
|
278
|
+
bounceRate: { current: 0.38, prior: 0.42, absolute: -0.04, relative: -0.0952380952 },
|
|
279
|
+
keyEvents: { current: 8, prior: 5, absolute: 3, relative: 0.6 },
|
|
280
|
+
daily: [{ date: '2026-08-09', sessions: 12, users: 9, pageviews: 18 }],
|
|
281
|
+
priorDaily: [{ date: '2026-07-12', sessions: 10, users: 8, pageviews: 15 }],
|
|
282
|
+
dataFrom: '2026-08-09',
|
|
283
|
+
provider: 'ga4',
|
|
284
|
+
},
|
|
285
|
+
meta: { requestId: 'req_01JXYZ', version: '1.0' },
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
}],
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
export const analyticsV1Registry = defineRegistry({
|
|
292
|
+
feature: 'analytics',
|
|
293
|
+
operations: {
|
|
294
|
+
query: analyticsQueryOperation,
|
|
295
|
+
},
|
|
296
|
+
});
|