@nuxtseo/protocol 0.2.1 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  import { z as schema } from 'zod';
2
- import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1BooleanFlag, publicV1ErrorEnvelope, publicV1StandardRatePolicy, } from './core.js';
2
+ import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1BooleanFlag, publicV1ErrorEnvelope, publicV1PageSchema, publicV1StandardRatePolicy, } from './core.js';
3
3
  export const backlinksSiteParamsSchema = schema.strictObject({
4
4
  siteId: schema.string().min(1),
5
5
  });
@@ -38,12 +38,19 @@ export const recoverableBacklinkSchema = defineResponseObject({
38
38
  lastSeenAt: schema.string().datetime().nullable(),
39
39
  });
40
40
  export const recoverableBacklinksDataSchema = defineResponseObject({
41
+ /**
42
+ * Deprecated alias of `rows`. Kept for one minor version, then removed.
43
+ */
41
44
  items: schema.array(recoverableBacklinkSchema.producer),
45
+ rows: schema.array(recoverableBacklinkSchema.producer),
46
+ page: publicV1PageSchema.producer,
42
47
  total: schema.number().int().nonnegative(),
43
48
  limit: schema.number().int().positive(),
44
49
  offset: schema.number().int().nonnegative(),
45
50
  }, {
46
51
  items: schema.array(recoverableBacklinkSchema.client),
52
+ rows: schema.array(recoverableBacklinkSchema.client).optional(),
53
+ page: publicV1PageSchema.client.optional(),
47
54
  total: schema.number().int().nonnegative(),
48
55
  limit: schema.number().int().positive(),
49
56
  offset: schema.number().int().nonnegative(),
@@ -69,6 +76,7 @@ export const recoverableBacklinksOperation = defineOperation({
69
76
  'auth_expired',
70
77
  'forbidden',
71
78
  'not_found',
79
+ 'conflict',
72
80
  'rate_limited',
73
81
  'contract_violation',
74
82
  'internal_error',
@@ -108,6 +116,20 @@ export const recoverableBacklinksOperation = defineOperation({
108
116
  firstSeenAt: '2026-02-09T20:43:50.000Z',
109
117
  lastSeenAt: '2026-07-17T04:40:07.000Z',
110
118
  }],
119
+ rows: [{
120
+ id: 'bl_01JXYZ',
121
+ destinationUrl: 'https://example.com/docs/utils',
122
+ referringUrl: 'https://news.example/posts/seo',
123
+ referringDomain: 'news.example',
124
+ anchor: 'Read the full documentation',
125
+ destinationStatus: 404,
126
+ domainRank: 529,
127
+ pageRank: 55,
128
+ dofollow: true,
129
+ firstSeenAt: '2026-02-09T20:43:50.000Z',
130
+ lastSeenAt: '2026-07-17T04:40:07.000Z',
131
+ }],
132
+ page: { total: 1, limit: 100, offset: 0, hasMore: false },
111
133
  total: 1,
112
134
  limit: 100,
113
135
  offset: 0,
@@ -150,10 +172,23 @@ export const mentionSchema = defineResponseObject({
150
172
  publishedAt: schema.string().datetime().nullable(),
151
173
  });
152
174
  export const mentionsDataSchema = defineResponseObject({
175
+ /**
176
+ * Deprecated alias of `rows`. Kept for one minor version, then removed.
177
+ */
153
178
  items: schema.array(mentionSchema.producer),
179
+ rows: schema.array(mentionSchema.producer),
180
+ page: publicV1PageSchema.producer,
181
+ /**
182
+ * The whole result set, not this page. The response carried no total and no
183
+ * `hasMore`, so a caller could not tell a full page from the last page.
184
+ */
185
+ total: schema.number().int().nonnegative(),
154
186
  limit: schema.number().int().positive(),
155
187
  }, {
156
188
  items: schema.array(mentionSchema.client),
189
+ rows: schema.array(mentionSchema.client).optional(),
190
+ page: publicV1PageSchema.client.optional(),
191
+ total: schema.number().int().nonnegative().optional(),
157
192
  limit: schema.number().int().positive(),
158
193
  });
159
194
  export const mentionsResponseSchema = defineSuccessEnvelope(mentionsDataSchema);
@@ -177,6 +212,7 @@ export const mentionsListOperation = defineOperation({
177
212
  'auth_expired',
178
213
  'forbidden',
179
214
  'not_found',
215
+ 'conflict',
180
216
  'rate_limited',
181
217
  'contract_violation',
182
218
  'internal_error',
@@ -217,6 +253,22 @@ export const mentionsListOperation = defineOperation({
217
253
  domainRank: 812,
218
254
  publishedAt: '2026-08-01T09:12:00.000Z',
219
255
  }],
256
+ rows: [{
257
+ id: 'mn_01JXYZ',
258
+ source: 'hackernews',
259
+ url: 'https://news.ycombinator.com/item?id=1',
260
+ domain: 'news.ycombinator.com',
261
+ title: 'Show HN: a sitemap module',
262
+ snippet: 'We moved to example.com last week',
263
+ author: 'Ada Lovelace',
264
+ authorHandle: 'ada',
265
+ engagement: 142,
266
+ sentiment: 'positive',
267
+ domainRank: 812,
268
+ publishedAt: '2026-08-01T09:12:00.000Z',
269
+ }],
270
+ page: { total: 1, limit: 100, offset: 0, hasMore: false },
271
+ total: 1,
220
272
  limit: 100,
221
273
  },
222
274
  meta: { requestId: 'req_01JXYZ', version: '1.0' },
package/dist/v1/core.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare const publicV1StandardRatePolicy: {
20
20
  export declare const PUBLIC_V1_FEATURES: readonly ['account', 'actions', 'analytics', 'audit', 'backlinks', 'content', 'mentions', 'page', 'research', 'sites', 'timeline'];
21
21
  export declare const PUBLIC_V1_METHODS: readonly ['DELETE', 'GET', 'PATCH', 'POST'];
22
22
  export declare const PUBLIC_V1_CREDENTIALS: readonly ['api_token', 'session'];
23
- export declare const PUBLIC_V1_SCOPES: readonly ['account:read', 'actions:read', 'actions:write', 'analytics:read', 'audit:read', 'content:read', 'content:write', 'feedback:write', 'page:read', 'page:write', 'research:read', 'research:write', 'sites:read', 'sites:write', 'timeline:read', 'timeline:write'];
23
+ export declare const PUBLIC_V1_SCOPES: readonly ['account:read', 'actions:read', 'actions:write', 'analytics:read', 'audit:read', 'feedback:write', 'page:read', 'page:write', 'research:read', 'research:write', 'sites:read', 'sites:write', 'timeline:read', 'timeline:write'];
24
24
  export declare const PUBLIC_V1_ROLES: readonly ['viewer', 'member', 'admin', 'owner'];
25
25
  export declare const PUBLIC_V1_ERROR_CODES: readonly ['invalid_request', 'unauthorized', 'forbidden', 'not_found', 'site_ambiguous', 'auth_expired', 'entitlement_required', 'quota_exhausted', 'provider_unavailable', 'stale_evidence', 'conflict', 'rate_limited', 'contract_violation', 'internal_error'];
26
26
  export declare const PUBLIC_V1_ERROR_STATUS: {
@@ -234,6 +234,55 @@ export declare const publicV1ErrorClientSchema: z.ZodObject<{
234
234
  retryable: z.ZodBoolean;
235
235
  details: z.ZodRecord<z.ZodString, z.ZodUnknown>;
236
236
  }, z.core.$loose>;
237
+ /**
238
+ * One page of a list response.
239
+ *
240
+ * Every list operation answers `data.rows` plus `data.page`. One envelope means
241
+ * a caller reads any list the same way, instead of guessing between `rows`,
242
+ * `items`, `sites`, `actions` and `clusters`.
243
+ *
244
+ * `total` counts the whole result set, not this page. `limit` is the page size
245
+ * the operation applied, and is 0 when the operation returned no page at all.
246
+ * `offset` is the index of the first row in `rows`. `hasMore` states whether a
247
+ * further request returns more rows.
248
+ *
249
+ * A producer must emit `rows` and `page`. A client treats both as optional, so
250
+ * a client newer than the deployed server still parses its answers. Read the
251
+ * domain key when `rows` is absent.
252
+ */
253
+ export declare const publicV1PageSchema: CompatibleResponseSchema<z.ZodObject<{
254
+ readonly total: z.ZodNumber;
255
+ readonly limit: z.ZodNumber;
256
+ readonly offset: z.ZodNumber;
257
+ readonly hasMore: z.ZodBoolean;
258
+ }, z.core.$strip>, z.ZodObject<{
259
+ readonly total: z.ZodNumber;
260
+ readonly limit: z.ZodNumber;
261
+ readonly offset: z.ZodNumber;
262
+ readonly hasMore: z.ZodBoolean;
263
+ }, z.core.$strip>>;
264
+ /**
265
+ * Builds the `page` object of a list response, so every operation derives
266
+ * `hasMore` the same way.
267
+ *
268
+ * `total` counts the whole result set. `rowCount` is the number of rows in this
269
+ * answer. Pass `limit` when a further request can return more rows. If the
270
+ * operation answers one response only, leave `limit` out: `limit` then reports
271
+ * the rows returned and `hasMore` is false, even when a display cap holds fewer
272
+ * rows than `total`. A `hasMore` that no request can act on sends a caller into
273
+ * a paging loop that never ends.
274
+ */
275
+ export declare function publicV1Page(input: {
276
+ total: number;
277
+ rowCount: number;
278
+ limit?: number;
279
+ offset?: number;
280
+ }): {
281
+ total: number;
282
+ limit: number;
283
+ offset: number;
284
+ hasMore: boolean;
285
+ };
237
286
  export declare const publicV1ErrorEnvelope: CompatibleResponseSchema<z.ZodObject<{
238
287
  readonly error: z.ZodObject<{
239
288
  code: z.ZodEnum<{
package/dist/v1/core.js CHANGED
@@ -40,8 +40,6 @@ export const PUBLIC_V1_SCOPES = [
40
40
  'actions:write',
41
41
  'analytics:read',
42
42
  'audit:read',
43
- 'content:read',
44
- 'content:write',
45
43
  'feedback:write',
46
44
  'page:read',
47
45
  'page:write',
@@ -347,6 +345,45 @@ export const publicV1ErrorClientSchema = z.looseObject({
347
345
  retryable: z.boolean(),
348
346
  details: publicV1ErrorDetailsSchema,
349
347
  });
348
+ /**
349
+ * One page of a list response.
350
+ *
351
+ * Every list operation answers `data.rows` plus `data.page`. One envelope means
352
+ * a caller reads any list the same way, instead of guessing between `rows`,
353
+ * `items`, `sites`, `actions` and `clusters`.
354
+ *
355
+ * `total` counts the whole result set, not this page. `limit` is the page size
356
+ * the operation applied, and is 0 when the operation returned no page at all.
357
+ * `offset` is the index of the first row in `rows`. `hasMore` states whether a
358
+ * further request returns more rows.
359
+ *
360
+ * A producer must emit `rows` and `page`. A client treats both as optional, so
361
+ * a client newer than the deployed server still parses its answers. Read the
362
+ * domain key when `rows` is absent.
363
+ */
364
+ export const publicV1PageSchema = defineResponseObject({
365
+ total: z.number().int().nonnegative(),
366
+ limit: z.number().int().nonnegative(),
367
+ offset: z.number().int().nonnegative(),
368
+ hasMore: z.boolean(),
369
+ });
370
+ /**
371
+ * Builds the `page` object of a list response, so every operation derives
372
+ * `hasMore` the same way.
373
+ *
374
+ * `total` counts the whole result set. `rowCount` is the number of rows in this
375
+ * answer. Pass `limit` when a further request can return more rows. If the
376
+ * operation answers one response only, leave `limit` out: `limit` then reports
377
+ * the rows returned and `hasMore` is false, even when a display cap holds fewer
378
+ * rows than `total`. A `hasMore` that no request can act on sends a caller into
379
+ * a paging loop that never ends.
380
+ */
381
+ export function publicV1Page(input) {
382
+ const offset = input.offset ?? 0;
383
+ const limit = input.limit ?? input.rowCount;
384
+ const pages = input.limit !== undefined;
385
+ return { total: input.total, limit, offset, hasMore: pages && offset + input.rowCount < input.total };
386
+ }
350
387
  export const publicV1ErrorEnvelope = defineResponseObject({ error: publicV1ErrorProducerSchema }, { error: publicV1ErrorClientSchema });
351
388
  export const publicV1MetaProducerSchema = z.strictObject({
352
389
  requestId: z.string().min(1),