@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,326 @@
|
|
|
1
|
+
import { z as schema } from 'zod';
|
|
2
|
+
import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1ErrorEnvelope, publicV1StandardRatePolicy, } from './core.js';
|
|
3
|
+
export const contentBriefStatusSchema = schema.enum([
|
|
4
|
+
'queued',
|
|
5
|
+
'researching',
|
|
6
|
+
'ready',
|
|
7
|
+
'written',
|
|
8
|
+
'published',
|
|
9
|
+
'stale',
|
|
10
|
+
'failed',
|
|
11
|
+
'archived',
|
|
12
|
+
]);
|
|
13
|
+
export const contentBriefSiteParamsSchema = schema.strictObject({
|
|
14
|
+
siteId: schema.string().min(1),
|
|
15
|
+
});
|
|
16
|
+
export const contentBriefParamsSchema = schema.strictObject({
|
|
17
|
+
siteId: schema.string().min(1),
|
|
18
|
+
briefId: schema.string().min(1),
|
|
19
|
+
});
|
|
20
|
+
export const contentBriefListQuerySchema = schema.strictObject({
|
|
21
|
+
status: contentBriefStatusSchema.optional(),
|
|
22
|
+
limit: schema.coerce.number().int().min(1).max(100).default(25),
|
|
23
|
+
offset: schema.coerce.number().int().nonnegative().default(0),
|
|
24
|
+
});
|
|
25
|
+
export const contentBriefCreateBodySchema = schema.strictObject({
|
|
26
|
+
keyword: schema.string().min(1).max(200).transform(keyword => keyword.trim()),
|
|
27
|
+
targetPage: schema.url().optional(),
|
|
28
|
+
currentRank: schema.number().optional(),
|
|
29
|
+
currentImpressions: schema.number().int().optional(),
|
|
30
|
+
currentClicks: schema.number().int().optional(),
|
|
31
|
+
});
|
|
32
|
+
const contentBriefSerpResultShape = {
|
|
33
|
+
position: schema.number(),
|
|
34
|
+
url: schema.url(),
|
|
35
|
+
title: schema.string(),
|
|
36
|
+
domain: schema.string(),
|
|
37
|
+
snippet: schema.string().optional(),
|
|
38
|
+
wordCount: schema.number().int().nonnegative().optional(),
|
|
39
|
+
};
|
|
40
|
+
export const contentBriefSerpResultSchema = defineResponseObject(contentBriefSerpResultShape);
|
|
41
|
+
const contentBriefPaaItemShape = {
|
|
42
|
+
question: schema.string(),
|
|
43
|
+
answer: schema.string().optional(),
|
|
44
|
+
};
|
|
45
|
+
export const contentBriefPaaItemSchema = defineResponseObject(contentBriefPaaItemShape);
|
|
46
|
+
const contentBriefSerpSnapshotShape = {
|
|
47
|
+
fetchedAt: schema.iso.datetime(),
|
|
48
|
+
topResults: schema.array(contentBriefSerpResultSchema.producer),
|
|
49
|
+
paa: schema.array(contentBriefPaaItemSchema.producer).optional(),
|
|
50
|
+
aiOverviewPresent: schema.boolean().optional(),
|
|
51
|
+
serpFeatures: schema.array(schema.string()).optional(),
|
|
52
|
+
medianWordCount: schema.number().int().nonnegative().optional(),
|
|
53
|
+
};
|
|
54
|
+
export const contentBriefSerpSnapshotSchema = defineResponseObject(contentBriefSerpSnapshotShape, {
|
|
55
|
+
...contentBriefSerpSnapshotShape,
|
|
56
|
+
topResults: schema.array(contentBriefSerpResultSchema.client),
|
|
57
|
+
paa: schema.array(contentBriefPaaItemSchema.client).optional(),
|
|
58
|
+
});
|
|
59
|
+
const contentBriefOutlineItemShape = {
|
|
60
|
+
level: schema.enum(['h1', 'h2', 'h3']),
|
|
61
|
+
heading: schema.string(),
|
|
62
|
+
tag: schema.enum(['intent-match', 'your-strength', 'gap', 'from-paa', 'from-aio']).optional(),
|
|
63
|
+
annotation: schema.string().optional(),
|
|
64
|
+
wordCountTarget: schema.number().int().nonnegative().optional(),
|
|
65
|
+
sourceResultUrls: schema.array(schema.url()).optional(),
|
|
66
|
+
existingCoverageExcerpt: schema.string().optional(),
|
|
67
|
+
existingCoverageUrl: schema.url().optional(),
|
|
68
|
+
};
|
|
69
|
+
export const contentBriefOutlineItemSchema = defineResponseObject(contentBriefOutlineItemShape);
|
|
70
|
+
const contentBriefInternalLinkShape = {
|
|
71
|
+
url: schema.url(),
|
|
72
|
+
impressions: schema.number().int().optional(),
|
|
73
|
+
position: schema.number().optional(),
|
|
74
|
+
reasoning: schema.string(),
|
|
75
|
+
anchorSuggestion: schema.string().optional(),
|
|
76
|
+
excerpt: schema.string().optional(),
|
|
77
|
+
};
|
|
78
|
+
export const contentBriefInternalLinkSchema = defineResponseObject(contentBriefInternalLinkShape);
|
|
79
|
+
const contentBriefPayloadProducerShape = {
|
|
80
|
+
targetPage: schema.url().optional(),
|
|
81
|
+
currentRank: schema.number().optional(),
|
|
82
|
+
currentImpressions: schema.number().int().optional(),
|
|
83
|
+
currentClicks: schema.number().int().optional(),
|
|
84
|
+
serp: contentBriefSerpSnapshotSchema.producer.optional(),
|
|
85
|
+
outline: schema.array(contentBriefOutlineItemSchema.producer).optional(),
|
|
86
|
+
internalLinks: schema.array(contentBriefInternalLinkSchema.producer).optional(),
|
|
87
|
+
summary: schema.string().optional(),
|
|
88
|
+
notes: schema.array(schema.string()).optional(),
|
|
89
|
+
};
|
|
90
|
+
export const contentBriefPayloadSchema = defineResponseObject(contentBriefPayloadProducerShape, {
|
|
91
|
+
...contentBriefPayloadProducerShape,
|
|
92
|
+
serp: contentBriefSerpSnapshotSchema.client.optional(),
|
|
93
|
+
outline: schema.array(contentBriefOutlineItemSchema.client).optional(),
|
|
94
|
+
internalLinks: schema.array(contentBriefInternalLinkSchema.client).optional(),
|
|
95
|
+
});
|
|
96
|
+
const contentBriefSummaryProducerShape = {
|
|
97
|
+
id: schema.string().min(1),
|
|
98
|
+
siteId: schema.string().min(1),
|
|
99
|
+
keyword: schema.string().min(1),
|
|
100
|
+
status: contentBriefStatusSchema,
|
|
101
|
+
error: schema.string().nullable(),
|
|
102
|
+
generatedAt: schema.iso.datetime().nullable(),
|
|
103
|
+
markedPublishedAt: schema.iso.datetime().nullable(),
|
|
104
|
+
updatedAt: schema.iso.datetime().nullable(),
|
|
105
|
+
};
|
|
106
|
+
export const contentBriefSummarySchema = defineResponseObject(contentBriefSummaryProducerShape);
|
|
107
|
+
export const contentBriefResourceSchema = defineResponseObject({
|
|
108
|
+
...contentBriefSummaryProducerShape,
|
|
109
|
+
payload: contentBriefPayloadSchema.producer.nullable(),
|
|
110
|
+
createdAt: schema.iso.datetime().nullable(),
|
|
111
|
+
markedWrittenAt: schema.iso.datetime().nullable(),
|
|
112
|
+
}, {
|
|
113
|
+
...contentBriefSummaryProducerShape,
|
|
114
|
+
payload: contentBriefPayloadSchema.client.nullable(),
|
|
115
|
+
createdAt: schema.iso.datetime().nullable(),
|
|
116
|
+
markedWrittenAt: schema.iso.datetime().nullable(),
|
|
117
|
+
});
|
|
118
|
+
const contentBriefPageShape = {
|
|
119
|
+
total: schema.number().int().nonnegative(),
|
|
120
|
+
limit: schema.number().int().positive(),
|
|
121
|
+
offset: schema.number().int().nonnegative(),
|
|
122
|
+
hasMore: schema.boolean(),
|
|
123
|
+
};
|
|
124
|
+
const contentBriefPageSchema = defineResponseObject(contentBriefPageShape);
|
|
125
|
+
export const contentBriefListDataSchema = defineResponseObject({
|
|
126
|
+
briefs: schema.array(contentBriefSummarySchema.producer),
|
|
127
|
+
page: contentBriefPageSchema.producer,
|
|
128
|
+
}, {
|
|
129
|
+
briefs: schema.array(contentBriefSummarySchema.client),
|
|
130
|
+
page: contentBriefPageSchema.client,
|
|
131
|
+
});
|
|
132
|
+
export const contentBriefCreateDataSchema = defineResponseObject({
|
|
133
|
+
brief: contentBriefResourceSchema.producer,
|
|
134
|
+
created: schema.boolean(),
|
|
135
|
+
}, {
|
|
136
|
+
brief: contentBriefResourceSchema.client,
|
|
137
|
+
created: schema.boolean(),
|
|
138
|
+
});
|
|
139
|
+
export const contentBriefListResponseSchema = defineSuccessEnvelope(contentBriefListDataSchema);
|
|
140
|
+
export const contentBriefShowResponseSchema = defineSuccessEnvelope(contentBriefResourceSchema);
|
|
141
|
+
export const contentBriefCreateResponseSchema = defineSuccessEnvelope(contentBriefCreateDataSchema);
|
|
142
|
+
const readErrors = [
|
|
143
|
+
'invalid_request',
|
|
144
|
+
'unauthorized',
|
|
145
|
+
'auth_expired',
|
|
146
|
+
'forbidden',
|
|
147
|
+
'not_found',
|
|
148
|
+
'rate_limited',
|
|
149
|
+
'contract_violation',
|
|
150
|
+
'internal_error',
|
|
151
|
+
];
|
|
152
|
+
export const contentBriefListOperation = defineOperation({
|
|
153
|
+
id: 'content.briefs.list',
|
|
154
|
+
method: 'GET',
|
|
155
|
+
path: '/api/v1/sites/{siteId}/content/briefs',
|
|
156
|
+
visibility: 'public',
|
|
157
|
+
semantics: {
|
|
158
|
+
kind: 'query',
|
|
159
|
+
sideEffects: 'none',
|
|
160
|
+
retry: 'idempotent',
|
|
161
|
+
readConsistency: 'primary',
|
|
162
|
+
},
|
|
163
|
+
auth: {
|
|
164
|
+
credentials: ['session', 'api_token'],
|
|
165
|
+
scopes: ['content:read'],
|
|
166
|
+
minimumRole: 'viewer',
|
|
167
|
+
ownership: 'site',
|
|
168
|
+
},
|
|
169
|
+
request: {
|
|
170
|
+
params: contentBriefSiteParamsSchema,
|
|
171
|
+
query: contentBriefListQuerySchema,
|
|
172
|
+
headers: null,
|
|
173
|
+
body: null,
|
|
174
|
+
},
|
|
175
|
+
responses: { 200: contentBriefListResponseSchema },
|
|
176
|
+
errors: readErrors,
|
|
177
|
+
errorResponse: publicV1ErrorEnvelope,
|
|
178
|
+
resources: { reads: [{ type: 'site.content', idFrom: 'params.siteId' }], changes: [] },
|
|
179
|
+
policy: { rate: publicV1StandardRatePolicy, idempotency: { _tag: 'none' }, entitlement: null, meter: null },
|
|
180
|
+
lifecycle: { introduced: '1.0.0' },
|
|
181
|
+
docs: {
|
|
182
|
+
summary: 'List Content Briefs',
|
|
183
|
+
description: 'Lists one page of Content Brief summaries owned by a NuxtSEO Site.',
|
|
184
|
+
tags: ['Content'],
|
|
185
|
+
examples: [{
|
|
186
|
+
request: { params: { siteId: 'site_01JXYZ' }, query: { limit: 25, offset: 0 } },
|
|
187
|
+
response: {
|
|
188
|
+
status: 200,
|
|
189
|
+
body: {
|
|
190
|
+
data: {
|
|
191
|
+
briefs: [{
|
|
192
|
+
id: 'brief_01JXYZ',
|
|
193
|
+
siteId: 'site_01JXYZ',
|
|
194
|
+
keyword: 'nuxt seo',
|
|
195
|
+
status: 'ready',
|
|
196
|
+
error: null,
|
|
197
|
+
generatedAt: '2026-08-10T00:00:00.000Z',
|
|
198
|
+
markedPublishedAt: null,
|
|
199
|
+
updatedAt: '2026-08-10T00:00:00.000Z',
|
|
200
|
+
}],
|
|
201
|
+
page: { total: 1, limit: 25, offset: 0, hasMore: false },
|
|
202
|
+
},
|
|
203
|
+
meta: { requestId: 'req_01JXYZ', version: '1.0' },
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
}],
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const exampleBrief = {
|
|
210
|
+
id: 'brief_01JXYZ',
|
|
211
|
+
siteId: 'site_01JXYZ',
|
|
212
|
+
keyword: 'nuxt seo',
|
|
213
|
+
status: 'ready',
|
|
214
|
+
error: null,
|
|
215
|
+
generatedAt: '2026-08-10T00:00:00.000Z',
|
|
216
|
+
markedPublishedAt: null,
|
|
217
|
+
updatedAt: '2026-08-10T00:00:00.000Z',
|
|
218
|
+
createdAt: '2026-08-10T00:00:00.000Z',
|
|
219
|
+
markedWrittenAt: null,
|
|
220
|
+
payload: {
|
|
221
|
+
targetPage: 'https://example.com/guide',
|
|
222
|
+
outline: [{ level: 'h1', heading: 'Nuxt SEO' }],
|
|
223
|
+
internalLinks: [],
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
export const contentBriefShowOperation = defineOperation({
|
|
227
|
+
id: 'content.briefs.show',
|
|
228
|
+
method: 'GET',
|
|
229
|
+
path: '/api/v1/sites/{siteId}/content/briefs/{briefId}',
|
|
230
|
+
visibility: 'public',
|
|
231
|
+
semantics: {
|
|
232
|
+
kind: 'query',
|
|
233
|
+
sideEffects: 'none',
|
|
234
|
+
retry: 'idempotent',
|
|
235
|
+
readConsistency: 'primary',
|
|
236
|
+
},
|
|
237
|
+
auth: {
|
|
238
|
+
credentials: ['session', 'api_token'],
|
|
239
|
+
scopes: ['content:read'],
|
|
240
|
+
minimumRole: 'viewer',
|
|
241
|
+
ownership: 'site',
|
|
242
|
+
},
|
|
243
|
+
request: { params: contentBriefParamsSchema, query: null, headers: null, body: null },
|
|
244
|
+
responses: { 200: contentBriefShowResponseSchema },
|
|
245
|
+
errors: readErrors,
|
|
246
|
+
errorResponse: publicV1ErrorEnvelope,
|
|
247
|
+
resources: { reads: [{ type: 'site.content', idFrom: 'params.siteId' }], changes: [] },
|
|
248
|
+
policy: { rate: publicV1StandardRatePolicy, idempotency: { _tag: 'none' }, entitlement: null, meter: null },
|
|
249
|
+
lifecycle: { introduced: '1.0.0' },
|
|
250
|
+
docs: {
|
|
251
|
+
summary: 'Show a Content Brief',
|
|
252
|
+
description: 'Returns one Content Brief with its grounded SERP, outline, and internal-link evidence.',
|
|
253
|
+
tags: ['Content'],
|
|
254
|
+
examples: [{
|
|
255
|
+
request: { params: { siteId: 'site_01JXYZ', briefId: 'brief_01JXYZ' } },
|
|
256
|
+
response: {
|
|
257
|
+
status: 200,
|
|
258
|
+
body: { data: exampleBrief, meta: { requestId: 'req_01JXYZ', version: '1.0' } },
|
|
259
|
+
},
|
|
260
|
+
}],
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
export const contentBriefCreateOperation = defineOperation({
|
|
264
|
+
id: 'content.briefs.create',
|
|
265
|
+
method: 'POST',
|
|
266
|
+
path: '/api/v1/sites/{siteId}/content/briefs',
|
|
267
|
+
visibility: 'public',
|
|
268
|
+
semantics: {
|
|
269
|
+
kind: 'mutation',
|
|
270
|
+
sideEffects: 'state',
|
|
271
|
+
retry: 'never',
|
|
272
|
+
readConsistency: null,
|
|
273
|
+
},
|
|
274
|
+
auth: {
|
|
275
|
+
credentials: ['session', 'api_token'],
|
|
276
|
+
scopes: ['content:write'],
|
|
277
|
+
minimumRole: 'member',
|
|
278
|
+
ownership: 'site',
|
|
279
|
+
},
|
|
280
|
+
request: {
|
|
281
|
+
params: contentBriefSiteParamsSchema,
|
|
282
|
+
query: null,
|
|
283
|
+
headers: null,
|
|
284
|
+
body: contentBriefCreateBodySchema,
|
|
285
|
+
},
|
|
286
|
+
responses: { 200: contentBriefCreateResponseSchema },
|
|
287
|
+
errors: [
|
|
288
|
+
...readErrors,
|
|
289
|
+
'entitlement_required',
|
|
290
|
+
'conflict',
|
|
291
|
+
'quota_exhausted',
|
|
292
|
+
],
|
|
293
|
+
errorResponse: publicV1ErrorEnvelope,
|
|
294
|
+
resources: {
|
|
295
|
+
reads: [{ type: 'site.content', idFrom: 'params.siteId' }],
|
|
296
|
+
changes: [{ type: 'site.content', idFrom: 'params.siteId' }],
|
|
297
|
+
},
|
|
298
|
+
policy: { rate: publicV1StandardRatePolicy, idempotency: { _tag: 'none' }, entitlement: 'pro', meter: null },
|
|
299
|
+
lifecycle: { introduced: '1.0.0' },
|
|
300
|
+
docs: {
|
|
301
|
+
summary: 'Create a Content Brief',
|
|
302
|
+
description: 'Creates or returns the existing Site-owned Content Brief for a canonical target keyword.',
|
|
303
|
+
tags: ['Content'],
|
|
304
|
+
examples: [{
|
|
305
|
+
request: {
|
|
306
|
+
params: { siteId: 'site_01JXYZ' },
|
|
307
|
+
body: { keyword: 'nuxt seo', targetPage: 'https://example.com/guide' },
|
|
308
|
+
},
|
|
309
|
+
response: {
|
|
310
|
+
status: 200,
|
|
311
|
+
body: {
|
|
312
|
+
data: { brief: exampleBrief, created: true },
|
|
313
|
+
meta: { requestId: 'req_01JXYZ', version: '1.0' },
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
}],
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
export const contentV1Registry = defineRegistry({
|
|
320
|
+
feature: 'content',
|
|
321
|
+
operations: {
|
|
322
|
+
listBriefs: contentBriefListOperation,
|
|
323
|
+
showBrief: contentBriefShowOperation,
|
|
324
|
+
createBrief: contentBriefCreateOperation,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { ZodRawShape, ZodTypeAny } from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const PUBLIC_V1_VERSION: '1.0';
|
|
4
|
+
export declare const PUBLIC_V1_PATH_PREFIX: '/api/v1';
|
|
5
|
+
export declare const PUBLIC_V1_RESPONSE_HEADERS: {
|
|
6
|
+
readonly requestId: 'X-Request-Id';
|
|
7
|
+
readonly version: 'X-NuxtSEO-Version';
|
|
8
|
+
readonly operation: 'X-NuxtSEO-Operation';
|
|
9
|
+
readonly rateLimitPolicy: 'RateLimit-Policy';
|
|
10
|
+
readonly rateLimit: 'RateLimit';
|
|
11
|
+
readonly retryAfter: 'Retry-After';
|
|
12
|
+
readonly deprecation: 'Deprecation';
|
|
13
|
+
readonly sunset: 'Sunset';
|
|
14
|
+
};
|
|
15
|
+
export declare const publicV1StandardRatePolicy: {
|
|
16
|
+
readonly name: 'public-v1-fixed-window';
|
|
17
|
+
readonly limit: 50;
|
|
18
|
+
readonly windowSeconds: 60;
|
|
19
|
+
};
|
|
20
|
+
export declare const PUBLIC_V1_FEATURES: readonly ['account', 'actions', 'analytics', 'audit', 'backlinks', 'content', 'mentions', 'page', 'research', 'sites'];
|
|
21
|
+
export declare const PUBLIC_V1_METHODS: readonly ['DELETE', 'GET', 'PATCH', 'POST'];
|
|
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', 'page:read', 'page:write', 'research:read', 'research:write', 'sites:read', 'sites:write'];
|
|
24
|
+
export declare const PUBLIC_V1_ROLES: readonly ['viewer', 'member', 'admin', 'owner'];
|
|
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
|
+
export declare const PUBLIC_V1_ERROR_STATUS: {
|
|
27
|
+
readonly invalid_request: 400;
|
|
28
|
+
readonly unauthorized: 401;
|
|
29
|
+
readonly auth_expired: 401;
|
|
30
|
+
readonly forbidden: 403;
|
|
31
|
+
readonly entitlement_required: 403;
|
|
32
|
+
readonly not_found: 404;
|
|
33
|
+
readonly site_ambiguous: 409;
|
|
34
|
+
readonly stale_evidence: 409;
|
|
35
|
+
readonly conflict: 409;
|
|
36
|
+
readonly quota_exhausted: 429;
|
|
37
|
+
readonly rate_limited: 429;
|
|
38
|
+
readonly contract_violation: 500;
|
|
39
|
+
readonly internal_error: 500;
|
|
40
|
+
readonly provider_unavailable: 503;
|
|
41
|
+
};
|
|
42
|
+
export type PublicV1Feature = typeof PUBLIC_V1_FEATURES[number];
|
|
43
|
+
export type PublicV1Method = typeof PUBLIC_V1_METHODS[number];
|
|
44
|
+
export type PublicV1Credential = typeof PUBLIC_V1_CREDENTIALS[number];
|
|
45
|
+
export type PublicV1Scope = typeof PUBLIC_V1_SCOPES[number];
|
|
46
|
+
export type PublicV1Role = typeof PUBLIC_V1_ROLES[number];
|
|
47
|
+
export type PublicV1ErrorCode = typeof PUBLIC_V1_ERROR_CODES[number];
|
|
48
|
+
export type PublicV1Visibility = 'internal' | 'public';
|
|
49
|
+
export type PublicV1OwnershipRule = 'principal' | 'site' | 'team';
|
|
50
|
+
export type PublicV1ResourceType = 'account.usage' | 'site.actions' | 'site.analytics' | 'site.audit' | 'site.collection' | 'site.content' | 'site.identity' | 'site.page' | 'site.research' | 'site.sitemaps';
|
|
51
|
+
export interface PublicV1ExpectedFailure {
|
|
52
|
+
_tag: 'ApiFailure';
|
|
53
|
+
code: PublicV1ErrorCode;
|
|
54
|
+
message: string;
|
|
55
|
+
retryable: boolean;
|
|
56
|
+
details: Readonly<Record<string, unknown>>;
|
|
57
|
+
}
|
|
58
|
+
export interface CompatibleResponseSchema<TProducer extends ZodTypeAny = ZodTypeAny, TClient extends ZodTypeAny = ZodTypeAny> {
|
|
59
|
+
producer: TProducer;
|
|
60
|
+
client: TClient;
|
|
61
|
+
}
|
|
62
|
+
export interface PublicV1RequestSchemas {
|
|
63
|
+
params: ZodTypeAny | null;
|
|
64
|
+
query: ZodTypeAny | null;
|
|
65
|
+
headers: ZodTypeAny | null;
|
|
66
|
+
body: ZodTypeAny | null;
|
|
67
|
+
}
|
|
68
|
+
export interface PublicV1Semantics {
|
|
69
|
+
kind: 'mutation' | 'query';
|
|
70
|
+
sideEffects: 'none' | 'state';
|
|
71
|
+
retry: 'idempotent' | 'never';
|
|
72
|
+
readConsistency: 'primary' | 'replica-ok' | null;
|
|
73
|
+
}
|
|
74
|
+
export type PublicV1IdempotencyPolicy = {
|
|
75
|
+
_tag: 'none';
|
|
76
|
+
} | {
|
|
77
|
+
_tag: 'required';
|
|
78
|
+
header: 'Idempotency-Key';
|
|
79
|
+
retentionSeconds: number;
|
|
80
|
+
};
|
|
81
|
+
export interface PublicV1RatePolicy {
|
|
82
|
+
name: string;
|
|
83
|
+
limit: number;
|
|
84
|
+
windowSeconds: number;
|
|
85
|
+
}
|
|
86
|
+
export interface PublicV1ResourceReference {
|
|
87
|
+
type: PublicV1ResourceType;
|
|
88
|
+
idFrom: `params.${string}` | 'principal.id' | 'team.id';
|
|
89
|
+
}
|
|
90
|
+
export interface PublicV1OperationExample {
|
|
91
|
+
request: {
|
|
92
|
+
params?: unknown;
|
|
93
|
+
query?: unknown;
|
|
94
|
+
headers?: unknown;
|
|
95
|
+
body?: unknown;
|
|
96
|
+
};
|
|
97
|
+
response: {
|
|
98
|
+
status: number;
|
|
99
|
+
body: unknown;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface PublicV1OperationDefinition {
|
|
103
|
+
id: `${PublicV1Feature}.${string}`;
|
|
104
|
+
method: PublicV1Method;
|
|
105
|
+
path: `/api/v1/${string}`;
|
|
106
|
+
visibility: PublicV1Visibility;
|
|
107
|
+
semantics: PublicV1Semantics;
|
|
108
|
+
auth: {
|
|
109
|
+
credentials: readonly PublicV1Credential[];
|
|
110
|
+
scopes: readonly PublicV1Scope[];
|
|
111
|
+
minimumRole: PublicV1Role;
|
|
112
|
+
ownership: PublicV1OwnershipRule;
|
|
113
|
+
};
|
|
114
|
+
request: PublicV1RequestSchemas;
|
|
115
|
+
responses: Readonly<Record<number, CompatibleResponseSchema>>;
|
|
116
|
+
errors: readonly PublicV1ErrorCode[];
|
|
117
|
+
errorResponse: CompatibleResponseSchema;
|
|
118
|
+
resources: {
|
|
119
|
+
reads: readonly PublicV1ResourceReference[];
|
|
120
|
+
changes: readonly PublicV1ResourceReference[];
|
|
121
|
+
};
|
|
122
|
+
policy: {
|
|
123
|
+
rate: PublicV1RatePolicy;
|
|
124
|
+
idempotency: PublicV1IdempotencyPolicy;
|
|
125
|
+
entitlement: string | null;
|
|
126
|
+
meter: {
|
|
127
|
+
key: string;
|
|
128
|
+
units: number;
|
|
129
|
+
charge: 'always' | 'live-only';
|
|
130
|
+
} | null;
|
|
131
|
+
};
|
|
132
|
+
lifecycle: {
|
|
133
|
+
introduced: `${number}.${number}.${number}`;
|
|
134
|
+
deprecated?: {
|
|
135
|
+
version: `${number}.${number}.${number}`;
|
|
136
|
+
at: string;
|
|
137
|
+
};
|
|
138
|
+
sunset?: string;
|
|
139
|
+
};
|
|
140
|
+
docs: {
|
|
141
|
+
summary: string;
|
|
142
|
+
description: string;
|
|
143
|
+
tags: readonly string[];
|
|
144
|
+
examples: readonly PublicV1OperationExample[];
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export interface PublicV1Registry<TOperations extends Readonly<Record<string, PublicV1OperationDefinition>> = Readonly<Record<string, PublicV1OperationDefinition>>> {
|
|
148
|
+
feature: PublicV1Feature;
|
|
149
|
+
operations: TOperations;
|
|
150
|
+
}
|
|
151
|
+
export interface PublicV1ProtocolLike {
|
|
152
|
+
version: typeof PUBLIC_V1_VERSION;
|
|
153
|
+
registries: Readonly<Record<string, PublicV1Registry>>;
|
|
154
|
+
schemas: {
|
|
155
|
+
errorEnvelope: CompatibleResponseSchema;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
type PublicV1ProtocolRegistry<TProtocol extends PublicV1ProtocolLike> = TProtocol['registries'][keyof TProtocol['registries']];
|
|
159
|
+
type PublicV1RegistryOperation<TRegistry> = TRegistry extends PublicV1Registry<infer TOperations> ? TOperations[keyof TOperations] : never;
|
|
160
|
+
export type PublicV1ProtocolOperation<TProtocol extends PublicV1ProtocolLike> = PublicV1RegistryOperation<PublicV1ProtocolRegistry<TProtocol>>;
|
|
161
|
+
export type PublicV1OperationEntry<TProtocol extends PublicV1ProtocolLike = PublicV1ProtocolLike> = PublicV1ProtocolRegistry<TProtocol> extends infer TRegistry ? TRegistry extends PublicV1Registry ? {
|
|
162
|
+
registry: TRegistry;
|
|
163
|
+
operation: PublicV1RegistryOperation<TRegistry>;
|
|
164
|
+
} : never : never;
|
|
165
|
+
export declare function defineOperation<const TOperation extends PublicV1OperationDefinition>(operation: TOperation): TOperation;
|
|
166
|
+
export declare function defineRegistry<const TOperations extends Readonly<Record<string, PublicV1OperationDefinition>>>(registry: PublicV1Registry<TOperations>): PublicV1Registry<TOperations>;
|
|
167
|
+
export declare function defineProtocol<const TRegistries extends Readonly<Record<string, PublicV1Registry>>>(protocol: Omit<PublicV1ProtocolLike, 'registries'> & {
|
|
168
|
+
registries: TRegistries;
|
|
169
|
+
}): Omit<PublicV1ProtocolLike, 'registries'> & {
|
|
170
|
+
registries: TRegistries;
|
|
171
|
+
};
|
|
172
|
+
export declare function listOperations<const TProtocol extends PublicV1ProtocolLike>(protocol: TProtocol): PublicV1OperationEntry<TProtocol>[];
|
|
173
|
+
export declare function defineResponseObject<const TProducerShape extends ZodRawShape, const TClientShape extends ZodRawShape = TProducerShape>(producerShape: TProducerShape, clientShape?: TClientShape): CompatibleResponseSchema<z.ZodObject<TProducerShape>, z.ZodObject<TClientShape>>;
|
|
174
|
+
export declare function buildOperationPath(operation: PublicV1OperationDefinition, params?: unknown): string;
|
|
175
|
+
export declare const publicV1ErrorDetailsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
176
|
+
export declare const publicV1ErrorProducerSchema: z.ZodObject<{
|
|
177
|
+
code: z.ZodEnum<{
|
|
178
|
+
auth_expired: "auth_expired";
|
|
179
|
+
conflict: "conflict";
|
|
180
|
+
contract_violation: "contract_violation";
|
|
181
|
+
entitlement_required: "entitlement_required";
|
|
182
|
+
forbidden: "forbidden";
|
|
183
|
+
internal_error: "internal_error";
|
|
184
|
+
invalid_request: "invalid_request";
|
|
185
|
+
not_found: "not_found";
|
|
186
|
+
provider_unavailable: "provider_unavailable";
|
|
187
|
+
quota_exhausted: "quota_exhausted";
|
|
188
|
+
rate_limited: "rate_limited";
|
|
189
|
+
site_ambiguous: "site_ambiguous";
|
|
190
|
+
stale_evidence: "stale_evidence";
|
|
191
|
+
unauthorized: "unauthorized";
|
|
192
|
+
}>;
|
|
193
|
+
message: z.ZodString;
|
|
194
|
+
requestId: z.ZodString;
|
|
195
|
+
retryable: z.ZodBoolean;
|
|
196
|
+
details: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
197
|
+
}, z.core.$strict>;
|
|
198
|
+
export declare const publicV1ErrorClientSchema: z.ZodObject<{
|
|
199
|
+
code: z.ZodEnum<{
|
|
200
|
+
auth_expired: "auth_expired";
|
|
201
|
+
conflict: "conflict";
|
|
202
|
+
contract_violation: "contract_violation";
|
|
203
|
+
entitlement_required: "entitlement_required";
|
|
204
|
+
forbidden: "forbidden";
|
|
205
|
+
internal_error: "internal_error";
|
|
206
|
+
invalid_request: "invalid_request";
|
|
207
|
+
not_found: "not_found";
|
|
208
|
+
provider_unavailable: "provider_unavailable";
|
|
209
|
+
quota_exhausted: "quota_exhausted";
|
|
210
|
+
rate_limited: "rate_limited";
|
|
211
|
+
site_ambiguous: "site_ambiguous";
|
|
212
|
+
stale_evidence: "stale_evidence";
|
|
213
|
+
unauthorized: "unauthorized";
|
|
214
|
+
}>;
|
|
215
|
+
message: z.ZodString;
|
|
216
|
+
requestId: z.ZodString;
|
|
217
|
+
retryable: z.ZodBoolean;
|
|
218
|
+
details: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
219
|
+
}, z.core.$loose>;
|
|
220
|
+
export declare const publicV1ErrorEnvelope: CompatibleResponseSchema<z.ZodObject<{
|
|
221
|
+
readonly error: z.ZodObject<{
|
|
222
|
+
code: z.ZodEnum<{
|
|
223
|
+
auth_expired: "auth_expired";
|
|
224
|
+
conflict: "conflict";
|
|
225
|
+
contract_violation: "contract_violation";
|
|
226
|
+
entitlement_required: "entitlement_required";
|
|
227
|
+
forbidden: "forbidden";
|
|
228
|
+
internal_error: "internal_error";
|
|
229
|
+
invalid_request: "invalid_request";
|
|
230
|
+
not_found: "not_found";
|
|
231
|
+
provider_unavailable: "provider_unavailable";
|
|
232
|
+
quota_exhausted: "quota_exhausted";
|
|
233
|
+
rate_limited: "rate_limited";
|
|
234
|
+
site_ambiguous: "site_ambiguous";
|
|
235
|
+
stale_evidence: "stale_evidence";
|
|
236
|
+
unauthorized: "unauthorized";
|
|
237
|
+
}>;
|
|
238
|
+
message: z.ZodString;
|
|
239
|
+
requestId: z.ZodString;
|
|
240
|
+
retryable: z.ZodBoolean;
|
|
241
|
+
details: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
242
|
+
}, z.core.$strict>;
|
|
243
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
244
|
+
readonly error: z.ZodObject<{
|
|
245
|
+
code: z.ZodEnum<{
|
|
246
|
+
auth_expired: "auth_expired";
|
|
247
|
+
conflict: "conflict";
|
|
248
|
+
contract_violation: "contract_violation";
|
|
249
|
+
entitlement_required: "entitlement_required";
|
|
250
|
+
forbidden: "forbidden";
|
|
251
|
+
internal_error: "internal_error";
|
|
252
|
+
invalid_request: "invalid_request";
|
|
253
|
+
not_found: "not_found";
|
|
254
|
+
provider_unavailable: "provider_unavailable";
|
|
255
|
+
quota_exhausted: "quota_exhausted";
|
|
256
|
+
rate_limited: "rate_limited";
|
|
257
|
+
site_ambiguous: "site_ambiguous";
|
|
258
|
+
stale_evidence: "stale_evidence";
|
|
259
|
+
unauthorized: "unauthorized";
|
|
260
|
+
}>;
|
|
261
|
+
message: z.ZodString;
|
|
262
|
+
requestId: z.ZodString;
|
|
263
|
+
retryable: z.ZodBoolean;
|
|
264
|
+
details: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
265
|
+
}, z.core.$loose>;
|
|
266
|
+
}, z.core.$strip>>;
|
|
267
|
+
export declare const publicV1MetaProducerSchema: z.ZodObject<{
|
|
268
|
+
requestId: z.ZodString;
|
|
269
|
+
version: z.ZodLiteral<"1.0">;
|
|
270
|
+
}, z.core.$strict>;
|
|
271
|
+
export declare const publicV1MetaClientSchema: z.ZodObject<{
|
|
272
|
+
requestId: z.ZodString;
|
|
273
|
+
version: z.ZodLiteral<"1.0">;
|
|
274
|
+
}, z.core.$loose>;
|
|
275
|
+
export declare function defineSuccessEnvelope<const TProducer extends ZodTypeAny, const TClient extends ZodTypeAny, const TMetaProducer extends ZodTypeAny = typeof publicV1MetaProducerSchema, const TMetaClient extends ZodTypeAny = typeof publicV1MetaClientSchema>(data: CompatibleResponseSchema<TProducer, TClient>, meta?: CompatibleResponseSchema<TMetaProducer, TMetaClient>): CompatibleResponseSchema<z.ZodObject<{
|
|
276
|
+
data: TProducer;
|
|
277
|
+
meta: TMetaProducer;
|
|
278
|
+
}>, z.ZodObject<{
|
|
279
|
+
data: TClient;
|
|
280
|
+
meta: TMetaClient;
|
|
281
|
+
}>>;
|
|
282
|
+
export type OperationInput<TOperation extends PublicV1OperationDefinition> = (TOperation['request']['params'] extends ZodTypeAny ? {
|
|
283
|
+
params: z.input<TOperation['request']['params']>;
|
|
284
|
+
} : {
|
|
285
|
+
params?: never;
|
|
286
|
+
}) & (TOperation['request']['query'] extends ZodTypeAny ? {
|
|
287
|
+
query: z.input<TOperation['request']['query']>;
|
|
288
|
+
} : {
|
|
289
|
+
query?: never;
|
|
290
|
+
}) & (TOperation['request']['headers'] extends ZodTypeAny ? {
|
|
291
|
+
headers: z.input<TOperation['request']['headers']>;
|
|
292
|
+
} : {
|
|
293
|
+
headers?: never;
|
|
294
|
+
}) & (TOperation['request']['body'] extends ZodTypeAny ? {
|
|
295
|
+
body: z.input<TOperation['request']['body']>;
|
|
296
|
+
} : {
|
|
297
|
+
body?: never;
|
|
298
|
+
});
|
|
299
|
+
type OperationResponseSchema<TOperation extends PublicV1OperationDefinition> = TOperation['responses'][keyof TOperation['responses']] extends CompatibleResponseSchema<ZodTypeAny, infer TClient> ? TClient : never;
|
|
300
|
+
export type OperationOutput<TOperation extends PublicV1OperationDefinition> = z.output<OperationResponseSchema<TOperation>>;
|
|
301
|
+
export {};
|