@koishijs/core
Advanced tools
Comparing version 4.14.3 to 4.14.4
@@ -220,2 +220,42 @@ /// <reference types="node" /> | ||
} | ||
declare module '@satorijs/core' { | ||
interface Context { | ||
permissions: Permissions; | ||
} | ||
interface Events { | ||
'internal/permission'(): void; | ||
} | ||
} | ||
export interface PermissionConfig { | ||
authority?: number; | ||
permissions?: string[]; | ||
dependencies?: string[]; | ||
} | ||
declare class DAG { | ||
store: Map<string, Map<string, Computed<boolean>[]>>; | ||
define(name: string): void; | ||
delete(name: string): void; | ||
link(source: string, target: string, condition: Computed<boolean>): void; | ||
unlink(source: string, target: string, condition: Computed<boolean>): void; | ||
subgraph(parents: Iterable<string>, session: Partial<Session>, result?: Set<string>): Set<string>; | ||
} | ||
export namespace Permissions { | ||
type ProvideCallback = (name: string, session: Partial<Session>) => Awaitable<boolean>; | ||
} | ||
export class Permissions { | ||
ctx: Context; | ||
_inherits: DAG; | ||
_depends: DAG; | ||
_providers: Dict<Permissions.ProvideCallback>; | ||
constructor(ctx: Context); | ||
private get caller(); | ||
provide(name: string, callback: Permissions.ProvideCallback): () => void; | ||
check(name: string, session: Partial<Session>): Promise<boolean>; | ||
config(name: string, config?: PermissionConfig, defaultAuthority?: number): () => void; | ||
define(name: string, inherits: string[]): () => void; | ||
inherit(child: string, parent: string, condition?: Computed<boolean>): () => void; | ||
depend(dependent: string, dependency: string, condition?: Computed<boolean>): () => void; | ||
list(): string[]; | ||
test(names: Iterable<string>, session?: Partial<Session>, cache?: Map<string, Promise<boolean>>): Promise<boolean>; | ||
} | ||
export interface Token { | ||
@@ -286,3 +326,3 @@ rest?: string; | ||
export type OptionType<S extends string> = ExtractFirst<Replace<S, '>', ']'>, any>; | ||
export type Type = DomainType | RegExp | readonly string[] | Transform<any>; | ||
export type Type = DomainType | RegExp | readonly string[] | Transform<any> | DomainConfig<any>; | ||
export interface Declaration { | ||
@@ -299,6 +339,7 @@ name?: string; | ||
greedy?: boolean; | ||
numeric?: boolean; | ||
} | ||
export function createDomain<K extends keyof Domain>(name: K, transform: Transform<Domain[K]>, options?: DomainConfig<Domain[K]>): void; | ||
export function parseValue(source: string, quoted: boolean, kind: string, argv: Argv, decl?: Declaration): any; | ||
export interface OptionConfig<T extends Type = Type> { | ||
export function parseValue(source: string, kind: string, argv: Argv, decl?: Declaration): any; | ||
export interface OptionConfig<T extends Type = Type> extends PermissionConfig { | ||
aliases?: string[]; | ||
@@ -309,3 +350,2 @@ symbols?: string[]; | ||
type?: T; | ||
authority?: number; | ||
descPath?: string; | ||
@@ -432,2 +472,3 @@ } | ||
namespace Session { | ||
const shadow: unique symbol; | ||
interface Private extends Session { | ||
@@ -440,5 +481,2 @@ [Context.filter](ctx: Context): boolean; | ||
} | ||
interface Payload { | ||
locales?: string[]; | ||
} | ||
} | ||
@@ -452,2 +490,3 @@ } | ||
expect: readonly string[]; | ||
filter?: (name: string) => Awaitable<boolean>; | ||
prefix?: string; | ||
@@ -540,5 +579,3 @@ suffix: string; | ||
export namespace Command { | ||
interface Config { | ||
/** min authority */ | ||
authority?: number; | ||
interface Config extends PermissionConfig { | ||
/** disallow unknown options */ | ||
@@ -721,27 +758,2 @@ checkUnknown?: boolean; | ||
} | ||
declare module '@satorijs/core' { | ||
interface Context { | ||
permissions: Permissions; | ||
} | ||
interface Events { | ||
'internal/permission'(): void; | ||
} | ||
} | ||
export namespace Permissions { | ||
type ProvideCallback = (name: string, session: Partial<Session>) => Awaitable<boolean>; | ||
} | ||
export class Permissions { | ||
#private; | ||
ctx: Context; | ||
constructor(ctx: Context); | ||
private get caller(); | ||
provide(name: string, callback: Permissions.ProvideCallback): () => void; | ||
check(name: string, session: Partial<Session>): Promise<boolean>; | ||
authority(value: number, name: string): void; | ||
define(name: string, inherits: string[]): () => void; | ||
inherit(child: string, parent: string, condition?: Computed<boolean>): () => void; | ||
depend(dependent: string, dependency: string, condition?: Computed<boolean>): () => void; | ||
list(): string[]; | ||
test(y: Iterable<string>, session?: Partial<Session>): Promise<boolean>; | ||
} | ||
export * from '@koishijs/utils'; | ||
@@ -748,0 +760,0 @@ export * from '@minatojs/core'; |
{ | ||
"name": "@koishijs/core", | ||
"description": "Core Features for Koishi", | ||
"version": "4.14.3", | ||
"version": "4.14.4", | ||
"main": "lib/index.cjs", | ||
@@ -36,4 +36,4 @@ "module": "lib/index.mjs", | ||
"@minatojs/core": "^2.4.0", | ||
"@satorijs/core": "^2.6.3", | ||
"cordis": "^2.8.7", | ||
"@satorijs/core": "^2.7.1", | ||
"cordis": "^2.8.8", | ||
"cosmokit": "^1.4.5", | ||
@@ -40,0 +40,0 @@ "fastest-levenshtein": "^1.0.16" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
591784
5786
Updated@satorijs/core@^2.7.1
Updatedcordis@^2.8.8