@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,76 @@
|
|
|
1
|
+
const COUNTS = ['sessions', 'users', 'pageviews'];
|
|
2
|
+
const ALL_DIMENSIONS = ['page', 'hostname', 'source', 'medium', 'campaign', 'country', 'region', 'city', 'deviceCategory', 'browser', 'operatingSystem'];
|
|
3
|
+
// Dimensions every provider EXCEPT Cloudflare can break down (CF RUM has only a
|
|
4
|
+
// referrer host + country, no UTM tuple, no region/city).
|
|
5
|
+
const NON_CF_DIMENSIONS = ALL_DIMENSIONS;
|
|
6
|
+
export const ANALYTICS_CAPABILITIES = {
|
|
7
|
+
ga4: {
|
|
8
|
+
aggregateMetrics: ['sessions', 'users', 'pageviews', 'conversions', 'keyEvents', 'engagementRate', 'bounceRate', 'avgSessionDuration'],
|
|
9
|
+
seriesMetrics: COUNTS,
|
|
10
|
+
breakdownDimensions: ALL_DIMENSIONS,
|
|
11
|
+
breakdownMetrics: COUNTS,
|
|
12
|
+
quality: 'engagementRate',
|
|
13
|
+
webVitals: false,
|
|
14
|
+
keyEvents: true,
|
|
15
|
+
},
|
|
16
|
+
cloudflare: {
|
|
17
|
+
// CF Web Analytics serves only pageviews + visits; `users` mirrors sessions.
|
|
18
|
+
aggregateMetrics: ['sessions', 'users', 'pageviews'],
|
|
19
|
+
seriesMetrics: ['sessions', 'pageviews'],
|
|
20
|
+
breakdownDimensions: ['page', 'hostname', 'source', 'country', 'deviceCategory', 'browser', 'operatingSystem'],
|
|
21
|
+
breakdownMetrics: COUNTS,
|
|
22
|
+
quality: null,
|
|
23
|
+
webVitals: true,
|
|
24
|
+
keyEvents: false,
|
|
25
|
+
},
|
|
26
|
+
posthog: {
|
|
27
|
+
aggregateMetrics: ['sessions', 'users', 'pageviews'],
|
|
28
|
+
seriesMetrics: COUNTS,
|
|
29
|
+
breakdownDimensions: NON_CF_DIMENSIONS,
|
|
30
|
+
breakdownMetrics: COUNTS,
|
|
31
|
+
quality: null,
|
|
32
|
+
webVitals: true,
|
|
33
|
+
keyEvents: false,
|
|
34
|
+
},
|
|
35
|
+
umami: {
|
|
36
|
+
// `keyEvents` = custom-event occurrences (umami.track), fetched separately.
|
|
37
|
+
aggregateMetrics: ['sessions', 'users', 'pageviews', 'bounceRate', 'avgSessionDuration', 'keyEvents'],
|
|
38
|
+
// `/pageviews` emits only pageviews + sessions series (no per-day visitors).
|
|
39
|
+
seriesMetrics: ['sessions', 'pageviews'],
|
|
40
|
+
// No UTM medium/campaign breakdown on the Cloud API.
|
|
41
|
+
breakdownDimensions: ['page', 'hostname', 'source', 'country', 'region', 'city', 'deviceCategory', 'browser', 'operatingSystem'],
|
|
42
|
+
// `/metrics` returns a visitor count only — pageviews/sessions per row N/A.
|
|
43
|
+
breakdownMetrics: ['users'],
|
|
44
|
+
quality: 'bounceRate',
|
|
45
|
+
webVitals: false,
|
|
46
|
+
keyEvents: true,
|
|
47
|
+
},
|
|
48
|
+
plausible: {
|
|
49
|
+
// `keyEvents` = goal conversions (the `events` metric on `event:goal`).
|
|
50
|
+
aggregateMetrics: ['sessions', 'users', 'pageviews', 'keyEvents', 'bounceRate', 'avgSessionDuration'],
|
|
51
|
+
seriesMetrics: COUNTS,
|
|
52
|
+
breakdownDimensions: NON_CF_DIMENSIONS,
|
|
53
|
+
breakdownMetrics: COUNTS,
|
|
54
|
+
quality: 'bounceRate',
|
|
55
|
+
webVitals: false,
|
|
56
|
+
keyEvents: true,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export function getAnalyticsCapabilities(provider) {
|
|
60
|
+
return provider && provider in ANALYTICS_CAPABILITIES
|
|
61
|
+
? ANALYTICS_CAPABILITIES[provider]
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The metric to rank/show a breakdown by. Returns `preferred` when the provider
|
|
66
|
+
* populates it per row (the common case: pages by pageviews, else sessions),
|
|
67
|
+
* otherwise the provider's single available breakdown metric — Umami serves a
|
|
68
|
+
* visitor count only, so every breakdown there ranks by `users`. An unknown
|
|
69
|
+
* provider keeps `preferred`.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveBreakdownMetric(provider, preferred) {
|
|
72
|
+
const cap = getAnalyticsCapabilities(provider);
|
|
73
|
+
if (!cap || cap.breakdownMetrics.includes(preferred))
|
|
74
|
+
return preferred;
|
|
75
|
+
return cap.breakdownMetrics[0] ?? preferred;
|
|
76
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export declare const CLI_PAIRING_START_PATH: '/api/cli/pair/start';
|
|
3
|
+
export declare const CLI_PAIRING_POLL_PATH: '/api/cli/pair/poll';
|
|
4
|
+
/** How long a pairing request stays approvable. */
|
|
5
|
+
export declare const CLI_PAIRING_TTL_MS = 600000;
|
|
6
|
+
/** Cadence the CLI must respect. The server rejects a faster caller. */
|
|
7
|
+
export declare const CLI_PAIRING_POLL_INTERVAL_MS = 2000;
|
|
8
|
+
/** Backstop against a hostile client hammering one pairing ID. */
|
|
9
|
+
export declare const CLI_PAIRING_MAX_POLLS = 400;
|
|
10
|
+
export declare const cliPairingStartRequestSchema: z.ZodObject<{
|
|
11
|
+
clientName: z.ZodString;
|
|
12
|
+
clientVersion: z.ZodOptional<z.ZodString>;
|
|
13
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export declare const cliPairingStartResponseSchema: z.ZodObject<{
|
|
16
|
+
pairingId: z.ZodString;
|
|
17
|
+
pairingCode: z.ZodString;
|
|
18
|
+
pollSecret: z.ZodString;
|
|
19
|
+
verificationUrl: z.ZodString;
|
|
20
|
+
expiresAt: z.ZodString;
|
|
21
|
+
pollIntervalMs: z.ZodNumber;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export declare const cliPairingPollRequestSchema: z.ZodObject<{
|
|
24
|
+
pairingId: z.ZodString;
|
|
25
|
+
pollSecret: z.ZodString;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export declare const cliPairingApprovedSchema: z.ZodObject<{
|
|
28
|
+
status: z.ZodLiteral<"approved">;
|
|
29
|
+
token: z.ZodString;
|
|
30
|
+
teamId: z.ZodString;
|
|
31
|
+
teamName: z.ZodNullable<z.ZodString>;
|
|
32
|
+
role: z.ZodEnum<{
|
|
33
|
+
admin: "admin";
|
|
34
|
+
editor: "editor";
|
|
35
|
+
viewer: "viewer";
|
|
36
|
+
}>;
|
|
37
|
+
last4: z.ZodString;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export declare const cliPairingPollResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
40
|
+
status: z.ZodLiteral<"pending">;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
status: z.ZodLiteral<"denied">;
|
|
43
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
44
|
+
status: z.ZodLiteral<"expired">;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
status: z.ZodLiteral<"claimed">;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
status: z.ZodLiteral<"slow_down">;
|
|
49
|
+
retryAfterMs: z.ZodNumber;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
status: z.ZodLiteral<"approved">;
|
|
52
|
+
token: z.ZodString;
|
|
53
|
+
teamId: z.ZodString;
|
|
54
|
+
teamName: z.ZodNullable<z.ZodString>;
|
|
55
|
+
role: z.ZodEnum<{
|
|
56
|
+
admin: "admin";
|
|
57
|
+
editor: "editor";
|
|
58
|
+
viewer: "viewer";
|
|
59
|
+
}>;
|
|
60
|
+
last4: z.ZodString;
|
|
61
|
+
}, z.core.$strict>], "status">;
|
|
62
|
+
export type CliPairingStartRequest = z.infer<typeof cliPairingStartRequestSchema>;
|
|
63
|
+
export type CliPairingStartResponse = z.infer<typeof cliPairingStartResponseSchema>;
|
|
64
|
+
export type CliPairingPollRequest = z.infer<typeof cliPairingPollRequestSchema>;
|
|
65
|
+
export type CliPairingPollResponse = z.infer<typeof cliPairingPollResponseSchema>;
|
|
66
|
+
export type CliPairingApproved = z.infer<typeof cliPairingApprovedSchema>;
|
|
67
|
+
export type CliPairingStatus = CliPairingPollResponse['status'];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// CLI browser pairing wire format.
|
|
2
|
+
//
|
|
3
|
+
// This is deliberately NOT a public v1 operation. A v1 operation must declare at
|
|
4
|
+
// least one credential (`assertOperation` in ./v1/core.ts), and every /api/v1
|
|
5
|
+
// route is asserted to answer 401 without one. Pairing runs before the CLI holds
|
|
6
|
+
// any credential, so it lives on its own unauthenticated routes and carries its
|
|
7
|
+
// own schemas. Both the server routes and the CLI validate against these, so the
|
|
8
|
+
// format still has a single owner.
|
|
9
|
+
import { z as schema } from 'zod';
|
|
10
|
+
export const CLI_PAIRING_START_PATH = '/api/cli/pair/start';
|
|
11
|
+
export const CLI_PAIRING_POLL_PATH = '/api/cli/pair/poll';
|
|
12
|
+
/** How long a pairing request stays approvable. */
|
|
13
|
+
export const CLI_PAIRING_TTL_MS = 600_000;
|
|
14
|
+
/** Cadence the CLI must respect. The server rejects a faster caller. */
|
|
15
|
+
export const CLI_PAIRING_POLL_INTERVAL_MS = 2_000;
|
|
16
|
+
/** Backstop against a hostile client hammering one pairing ID. */
|
|
17
|
+
export const CLI_PAIRING_MAX_POLLS = 400;
|
|
18
|
+
export const cliPairingStartRequestSchema = schema.strictObject({
|
|
19
|
+
clientName: schema.string().min(1).max(60),
|
|
20
|
+
clientVersion: schema.string().min(1).max(40).optional(),
|
|
21
|
+
hostname: schema.string().min(1).max(120).optional(),
|
|
22
|
+
});
|
|
23
|
+
export const cliPairingStartResponseSchema = schema.strictObject({
|
|
24
|
+
pairingId: schema.string().min(1),
|
|
25
|
+
/** Shown by the CLI and again on the approval page so the user can compare. */
|
|
26
|
+
pairingCode: schema.string().min(1),
|
|
27
|
+
/** Held only by the CLI. The server stores a hash. */
|
|
28
|
+
pollSecret: schema.string().min(1),
|
|
29
|
+
verificationUrl: schema.string().min(1),
|
|
30
|
+
expiresAt: schema.string().min(1),
|
|
31
|
+
pollIntervalMs: schema.number().int().positive(),
|
|
32
|
+
});
|
|
33
|
+
export const cliPairingPollRequestSchema = schema.strictObject({
|
|
34
|
+
pairingId: schema.string().min(1),
|
|
35
|
+
pollSecret: schema.string().min(1),
|
|
36
|
+
});
|
|
37
|
+
export const cliPairingApprovedSchema = schema.strictObject({
|
|
38
|
+
status: schema.literal('approved'),
|
|
39
|
+
token: schema.string().min(1),
|
|
40
|
+
teamId: schema.string().min(1),
|
|
41
|
+
teamName: schema.string().min(1).nullable(),
|
|
42
|
+
role: schema.enum(['admin', 'editor', 'viewer']),
|
|
43
|
+
last4: schema.string().min(1),
|
|
44
|
+
});
|
|
45
|
+
export const cliPairingPollResponseSchema = schema.discriminatedUnion('status', [
|
|
46
|
+
schema.strictObject({ status: schema.literal('pending') }),
|
|
47
|
+
schema.strictObject({ status: schema.literal('denied') }),
|
|
48
|
+
schema.strictObject({ status: schema.literal('expired') }),
|
|
49
|
+
schema.strictObject({ status: schema.literal('claimed') }),
|
|
50
|
+
schema.strictObject({ status: schema.literal('slow_down'), retryAfterMs: schema.number().int().positive() }),
|
|
51
|
+
cliPairingApprovedSchema,
|
|
52
|
+
]);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v1/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v1/index.js';
|