UNPKG

bknd

Version:

Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.

22 lines (21 loc) 1.13 kB
import { s } from "bknd/utils"; import * as query from "../../core/object/query/object-query"; export declare const policySchema: s.ObjectSchema<{ readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly condition: s.Schema<{}, query.ObjectQuery | undefined>; readonly effect: s.Schema<s.ISchemaOptions, "filter" | "allow" | "deny" | undefined, "filter" | "allow" | "deny" | undefined>; readonly filter: s.Schema<{}, query.ObjectQuery | undefined>; }, s.Merge<s.IObjectOptions & { additionalProperties: false; }>>; export type PolicySchema = s.Static<typeof policySchema>; export declare class Policy<Schema extends PolicySchema = PolicySchema> { content: Schema; constructor(content?: Schema); replace(context: object, vars?: Record<string, any>, fallback?: any): any; getReplacedFilter(context: object, fallback?: any): any; meetsCondition(context: object, vars?: Record<string, any>): boolean; meetsFilter(subject: object, vars?: Record<string, any>): boolean; getFiltered<Given extends any[]>(given: Given): Given; toJSON(): Schema; }