@nuxtseo/protocol 0.1.4 → 0.1.5

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, publicV1ErrorEnvelope, publicV1MetaClientSchema, publicV1MetaProducerSchema, publicV1StandardRatePolicy, } from './core.js';
2
+ import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, PUBLIC_V1_ROLES, PUBLIC_V1_SCOPES, publicV1ErrorEnvelope, publicV1MetaClientSchema, publicV1MetaProducerSchema, publicV1StandardRatePolicy, } from './core.js';
3
3
  export const usageMeterGroupSchema = schema.enum(['integrations', 'compute', 'capacity']);
4
4
  export const usageUpgradeTierSchema = schema.enum(['free', 'pro', 'lifetime']);
5
5
  export const usagePlanSchema = usageUpgradeTierSchema;
@@ -115,9 +115,128 @@ export const accountUsageOperation = defineOperation({
115
115
  }],
116
116
  },
117
117
  });
118
+ export const accountTokenCredentialSchema = schema.enum(['api_token', 'session']);
119
+ const accountTokenTeamProducerSchema = schema.strictObject({
120
+ id: schema.string().min(1),
121
+ name: schema.string().nullable(),
122
+ plan: usagePlanSchema,
123
+ });
124
+ const accountTokenTeamClientSchema = schema.looseObject({
125
+ id: schema.string().min(1),
126
+ name: schema.string().nullable(),
127
+ plan: usagePlanSchema,
128
+ });
129
+ const accountTokenDetailProducerSchema = schema.strictObject({
130
+ id: schema.string().min(1),
131
+ label: schema.string().nullable(),
132
+ client: schema.string().nullable(),
133
+ createdAt: schema.iso.datetime().nullable(),
134
+ lastUsedAt: schema.iso.datetime().nullable(),
135
+ expiresAt: schema.iso.datetime().nullable(),
136
+ });
137
+ const accountTokenDetailClientSchema = schema.looseObject({
138
+ id: schema.string().min(1),
139
+ label: schema.string().nullable(),
140
+ client: schema.string().nullable(),
141
+ createdAt: schema.iso.datetime().nullable(),
142
+ lastUsedAt: schema.iso.datetime().nullable(),
143
+ expiresAt: schema.iso.datetime().nullable(),
144
+ });
145
+ const accountTokenUserProducerSchema = schema.strictObject({
146
+ id: schema.string().min(1),
147
+ email: schema.string().nullable(),
148
+ });
149
+ const accountTokenUserClientSchema = schema.looseObject({
150
+ id: schema.string().min(1),
151
+ email: schema.string().nullable(),
152
+ });
153
+ export const accountTokenDataSchema = defineResponseObject({
154
+ credential: accountTokenCredentialSchema,
155
+ role: schema.enum(PUBLIC_V1_ROLES),
156
+ scopes: schema.array(schema.enum(PUBLIC_V1_SCOPES)),
157
+ team: accountTokenTeamProducerSchema,
158
+ token: accountTokenDetailProducerSchema.nullable(),
159
+ user: accountTokenUserProducerSchema,
160
+ }, {
161
+ credential: accountTokenCredentialSchema,
162
+ role: schema.enum(PUBLIC_V1_ROLES),
163
+ scopes: schema.array(schema.enum(PUBLIC_V1_SCOPES)),
164
+ team: accountTokenTeamClientSchema,
165
+ token: accountTokenDetailClientSchema.nullable(),
166
+ user: accountTokenUserClientSchema,
167
+ });
168
+ export const accountTokenResponseSchema = defineSuccessEnvelope(accountTokenDataSchema);
169
+ export const accountTokenOperation = defineOperation({
170
+ id: 'account.token',
171
+ method: 'GET',
172
+ path: '/api/v1/account/token',
173
+ visibility: 'public',
174
+ semantics: {
175
+ kind: 'query',
176
+ sideEffects: 'none',
177
+ retry: 'idempotent',
178
+ readConsistency: 'primary',
179
+ },
180
+ auth: {
181
+ credentials: ['session', 'api_token'],
182
+ scopes: ['account:read'],
183
+ minimumRole: 'viewer',
184
+ ownership: 'team',
185
+ },
186
+ request: {
187
+ params: null,
188
+ query: null,
189
+ headers: null,
190
+ body: null,
191
+ },
192
+ responses: { 200: accountTokenResponseSchema },
193
+ errors: ['unauthorized', 'auth_expired', 'forbidden', 'rate_limited', 'contract_violation', 'internal_error'],
194
+ errorResponse: publicV1ErrorEnvelope,
195
+ resources: {
196
+ reads: [{ type: 'account.usage', idFrom: 'team.id' }],
197
+ changes: [],
198
+ },
199
+ policy: {
200
+ rate: publicV1StandardRatePolicy,
201
+ idempotency: { _tag: 'none' },
202
+ entitlement: null,
203
+ meter: null,
204
+ },
205
+ lifecycle: { introduced: '1.0.0' },
206
+ docs: {
207
+ summary: 'Describe the presented credential',
208
+ description: 'Returns the Team, role, granted scopes, and expiry of the credential on this request. It spends no quota and reads no Site.',
209
+ tags: ['Account'],
210
+ examples: [{
211
+ request: {},
212
+ response: {
213
+ status: 200,
214
+ body: {
215
+ data: {
216
+ credential: 'api_token',
217
+ role: 'admin',
218
+ scopes: ['account:read', 'sites:read'],
219
+ team: { id: 'team_01JXYZ', name: 'Example', plan: 'pro' },
220
+ token: {
221
+ id: 'token_01JXYZ',
222
+ label: 'CLI on laptop',
223
+ client: null,
224
+ createdAt: '2026-08-01T00:00:00.000Z',
225
+ lastUsedAt: '2026-08-20T00:00:00.000Z',
226
+ expiresAt: null,
227
+ },
228
+ user: { id: 'user_01JXYZ', email: 'agent@example.com' },
229
+ },
230
+ meta: { requestId: 'req_01JXYZ', version: '1.0' },
231
+ },
232
+ },
233
+ }],
234
+ },
235
+ });
118
236
  export const accountV1Registry = defineRegistry({
119
237
  feature: 'account',
120
238
  operations: {
121
239
  usage: accountUsageOperation,
240
+ token: accountTokenOperation,
122
241
  },
123
242
  });
@@ -505,10 +505,12 @@ export declare const backlinksV1Registry: import("./core.js").PublicV1Registry<{
505
505
  }>;
506
506
  export declare const mentionsQuerySchema: z.ZodObject<{
507
507
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
508
- includeFiltered: z.ZodDefault<z.ZodEnum<{
508
+ includeFiltered: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
509
509
  0: "0";
510
510
  1: "1";
511
- }>>;
511
+ false: "false";
512
+ true: "true";
513
+ }>>, z.ZodTransform<boolean, "0" | "1" | "false" | "true">>;
512
514
  }, z.core.$strict>;
513
515
  export declare const mentionSchema: import("./core.js").CompatibleResponseSchema<z.ZodObject<{
514
516
  readonly id: z.ZodString;
@@ -639,10 +641,12 @@ export declare const mentionsListOperation: {
639
641
  }, z.core.$strict>;
640
642
  readonly query: z.ZodObject<{
641
643
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
642
- includeFiltered: z.ZodDefault<z.ZodEnum<{
644
+ includeFiltered: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
643
645
  0: "0";
644
646
  1: "1";
645
- }>>;
647
+ false: "false";
648
+ true: "true";
649
+ }>>, z.ZodTransform<boolean, "0" | "1" | "false" | "true">>;
646
650
  }, z.core.$strict>;
647
651
  readonly headers: null;
648
652
  readonly body: null;
@@ -831,10 +835,12 @@ export declare const mentionsV1Registry: import("./core.js").PublicV1Registry<{
831
835
  }, z.core.$strict>;
832
836
  readonly query: z.ZodObject<{
833
837
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
834
- includeFiltered: z.ZodDefault<z.ZodEnum<{
838
+ includeFiltered: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
835
839
  0: "0";
836
840
  1: "1";
837
- }>>;
841
+ false: "false";
842
+ true: "true";
843
+ }>>, z.ZodTransform<boolean, "0" | "1" | "false" | "true">>;
838
844
  }, z.core.$strict>;
839
845
  readonly headers: null;
840
846
  readonly body: null;
@@ -1,5 +1,5 @@
1
1
  import { z as schema } from 'zod';
2
- import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1ErrorEnvelope, publicV1StandardRatePolicy, } from './core.js';
2
+ import { defineOperation, defineRegistry, defineResponseObject, defineSuccessEnvelope, publicV1BooleanFlag, publicV1ErrorEnvelope, publicV1StandardRatePolicy, } from './core.js';
3
3
  export const backlinksSiteParamsSchema = schema.strictObject({
4
4
  siteId: schema.string().min(1),
5
5
  });
@@ -126,7 +126,7 @@ export const backlinksV1Registry = defineRegistry({
126
126
  });
127
127
  export const mentionsQuerySchema = schema.strictObject({
128
128
  limit: schema.coerce.number().int().min(1).max(200).default(100),
129
- includeFiltered: schema.enum(['0', '1']).default('0'),
129
+ includeFiltered: publicV1BooleanFlag(false),
130
130
  });
131
131
  export const mentionSchema = defineResponseObject({
132
132
  id: schema.string().min(1),
package/dist/v1/core.d.ts CHANGED
@@ -172,6 +172,23 @@ export declare function defineProtocol<const TRegistries extends Readonly<Record
172
172
  export declare function listOperations<const TProtocol extends PublicV1ProtocolLike>(protocol: TProtocol): PublicV1OperationEntry<TProtocol>[];
173
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
174
  export declare function buildOperationPath(operation: PublicV1OperationDefinition, params?: unknown): string;
175
+ /**
176
+ * One boolean query flag, parsed once at the public wire boundary.
177
+ *
178
+ * A query string carries text, so the flag arrives as text. Both spellings a
179
+ * caller is likely to send are accepted, and the schema hands the handler a
180
+ * boolean. Handlers never compare the raw string again: `includeFiltered` used
181
+ * to be declared as `'0' | '1'` and re-tested as `=== '1'` inside its route,
182
+ * which is the same value parsed twice under two types.
183
+ */
184
+ export declare function publicV1BooleanFlag(defaultValue: boolean): z.ZodPipe<z.ZodDefault<z.ZodEnum<{
185
+ 0: "0";
186
+ 1: "1";
187
+ false: "false";
188
+ true: "true";
189
+ }>>, z.ZodTransform<boolean, "0" | "1" | "false" | "true">>;
190
+ /** The canonical wire spelling a client sends for {@link publicV1BooleanFlag}. */
191
+ export declare function publicV1BooleanFlagValue(value: boolean): '0' | '1';
175
192
  export declare const publicV1ErrorDetailsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
176
193
  export declare const publicV1ErrorProducerSchema: z.ZodObject<{
177
194
  code: z.ZodEnum<{
package/dist/v1/core.js CHANGED
@@ -303,6 +303,24 @@ export function buildOperationPath(operation, params) {
303
303
  return encodeURIComponent(serialized);
304
304
  });
305
305
  }
306
+ /**
307
+ * One boolean query flag, parsed once at the public wire boundary.
308
+ *
309
+ * A query string carries text, so the flag arrives as text. Both spellings a
310
+ * caller is likely to send are accepted, and the schema hands the handler a
311
+ * boolean. Handlers never compare the raw string again: `includeFiltered` used
312
+ * to be declared as `'0' | '1'` and re-tested as `=== '1'` inside its route,
313
+ * which is the same value parsed twice under two types.
314
+ */
315
+ export function publicV1BooleanFlag(defaultValue) {
316
+ return z.enum(['0', '1', 'true', 'false'])
317
+ .default(defaultValue ? '1' : '0')
318
+ .transform(value => value === '1' || value === 'true');
319
+ }
320
+ /** The canonical wire spelling a client sends for {@link publicV1BooleanFlag}. */
321
+ export function publicV1BooleanFlagValue(value) {
322
+ return value ? '1' : '0';
323
+ }
306
324
  export const publicV1ErrorDetailsSchema = z.record(z.string(), z.unknown());
307
325
  export const publicV1ErrorProducerSchema = z.strictObject({
308
326
  code: z.enum(PUBLIC_V1_ERROR_CODES),