auth/scope_kind_schema.ts view source
(consumer_kinds: Record<string, ScopeKindMeta>): ScopeKindSchemaResult Create a scope-kind schema from a consumer-declared registry.
Open registry — no builtins. The 'GLOBAL' token used inside the
partial unique indexes on role_grant and role_grant_offer is not a
registry entry (it's an index expression only) and cannot collide
with consumer-declared kinds because the regex rejects uppercase.
Call once at server init. Pass the result into create_role_schema's
optional scope_kinds parameter so each role's
applicable_scope_kinds entries are validated against this set at
construction time. v1 keeps applicable_scope_kinds informative-only
(registry-membership validation only); v2 may add INSERT-time
(role, scope_kind) enforcement once the shape is clear from real
consumer usage.
consumer_kinds
the consumer-declared scope-kind set with optional metadata
Record<string, ScopeKindMeta>returns
ScopeKindSchemaResult {ScopeKind, scope_kinds} — Zod schema and metadata map
throws
Error- if any `consumer_kinds` key fails the `ScopeKindName` regex or appears more than once
examples
// visiones
const {ScopeKind, scope_kinds} = create_scope_kind_schema({
classroom: {description: 'A classroom — teacher and student role_grants scope here.'},
});