@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
53 lines (52 loc) • 2.51 kB
JavaScript
// GENERATED from packages/api-contract/src/one/v1/shared.ts by scripts/vendor-api-contract.mjs — do not edit
import { z } from 'zod';
import { CursorParams, pageSchema } from '../../core/pagination.js';
/**
* Shared pieces of One's v1 operations (phase 2 of the api.vigilbase.com
* rollout; ops/research/2026-11-02-api-contract-design.md).
*
* Every v1 operation accepts the same three credentials, never a cookie:
* - an Identity access token for `https://api.vigilbase.com/one` (or, during
* migration, `https://one.vigilbase.com`) with `one:api`;
* - a `vb_one_` organisation API key (read or write);
* - an MCP token with `one:read` / `one:write`.
*
* The declarations can only narrow what the implementation enforces: One's
* permission checks, tenant scoping and step-up guards still run inside each
* implementation (declared-versus-enforced tests in apps/one).
*/
export const ONE_READ_AUTH = [
{ kind: 'identityBearer', resource: 'one', scopes: ['one:api'] },
{ kind: 'orgApiKey', access: 'read' },
{ kind: 'mcpToken', scope: 'one:read' },
];
export const ONE_WRITE_AUTH = [
{ kind: 'identityBearer', resource: 'one', scopes: ['one:api'] },
{ kind: 'orgApiKey', access: 'write' },
{ kind: 'mcpToken', scope: 'one:write' },
];
/** A read that keys may not make: it acts for the signed-in person. */
export const ONE_PERSON_READ_AUTH = [
{ kind: 'identityBearer', resource: 'one', scopes: ['one:api'] },
{ kind: 'mcpToken', scope: 'one:read' },
];
/** A write that keys may not make: it is attributed to the signed-in person (e.g. their support contact). */
export const ONE_PERSON_WRITE_AUTH = [
{ kind: 'identityBearer', resource: 'one', scopes: ['one:api'] },
{ kind: 'mcpToken', scope: 'one:write' },
];
export const READ_ERRORS = ['unauthorized', 'forbidden', 'not_found', 'validation_failed', 'rate_limit_exceeded', 'service_unavailable'];
export const LIST_ERRORS = READ_ERRORS;
export const WRITE_ERRORS = [...READ_ERRORS, 'read_only_key', 'conflict', 'unprocessable_entity'];
/** IDs are UUIDs throughout One. */
export const Id = z.guid();
export const CustomerParams = z.object({ customerId: Id });
/** An ISO 8601 date-time as One stores it. */
export const Timestamp = z.string().meta({ format: 'date-time' });
/** Cursor query for every v1 list. */
export const ListQuery = CursorParams;
export { pageSchema };
/** `{ items, nextCursor? }` for a named item schema. */
export function page(item) {
return pageSchema(item);
}