import { Koncorde } from "../shared/KoncordeWrapper"; import { JSONObject } from "kuzzle-sdk"; import { KuzzleRequest, RequestContext, RequestInput } from "../../../index"; import { Mutex } from "../../util/mutex"; import { BackendCluster } from "../backend"; import { EmbeddedSDK } from "../shared/sdk/embeddedSdk"; import { KuzzleLogger } from "kuzzle-logger/dist"; export interface Repository { create(document: JSONObject, options: any): Promise; createOrReplace(document: JSONObject, options: any): Promise; delete(documentId: string, options: any): Promise; get(documentId: string): Promise; mGet(ids: string[]): Promise; replace(document: JSONObject, options: any): Promise; search(query: JSONObject, options: any): Promise; update(document: JSONObject, options: any): Promise; } export declare class PluginContext { accessors: { /** * Embedded SDK */ sdk: EmbeddedSDK; /** * Trigger a custom plugin event */ trigger: (eventName: string, payload: any) => Promise; /** * Add or remove strategies dynamically */ strategies: { /** * Adds a new authentication strategy */ add: (name: string, properties: any) => Promise; /** * Removes an authentication strategy, preventing new authentications from using it. */ remove: (name: string) => Promise; }; /** * Accessor to the Data Validation API */ validation: { addType: any; validate: any; }; /** * Execute an API action. * * @deprecated use "accessors.sdk" instead (unless you need the original context) */ execute: (request: KuzzleRequest, callback?: any) => Promise; /** * Adds or removes realtime subscriptions from the backend. */ subscription: { /** * Registers a new realtime subscription on behalf of a client. */ register: (connectionId: string, index: string, collection: string, filters: JSONObject) => Promise<{ roomId: string; }>; /** * Removes a realtime subscription on an existing `roomId` and `connectionId` */ unregister: (connectionId: string, roomId: string, notify: boolean) => Promise; }; /** * Initializes the plugin's private data storage. */ storage: { /** * Initializes the plugin storage */ bootstrap: (collections: any) => Promise; /** * Creates a collection in the plugin storage */ createCollection: (collection: string, mappings: any) => Promise; }; /** * Cluster accessor * @type {BackendCluster} */ cluster: BackendCluster; /** * Current Kuzzle node unique identifier */ nodeId: string; }; config: JSONObject; constructors: { /** * @todo need documentation */ BaseValidationType: any; /** * @deprecated import directly: `import { Koncorde } from 'kuzzle'` */ Koncorde: Koncorde; /** * Mutex class */ Mutex: typeof Mutex; /** * Plugin private storage space */ Repository: new (collection: string, objectConstructor: any) => Repository; /** * Instantiate a new Request from the original one. */ Request: KuzzleRequest; /** * @deprecated import directly: `import { RequestContext } from 'kuzzle'` */ RequestContext: RequestContext; /** * @deprecated import directly: `import { RequestInput } from 'kuzzle'` */ RequestInput: RequestInput; /** * Constructor for Elasticsearch SDK Client */ ESClient: new () => any; }; /** * @deprecated import directly: `import { BadRequestError, ... } from 'kuzzle'` */ errors: any; /** * Errors manager */ kerror: any; /** * @deprecated use `PluginContext.kerror` instead */ errorsManager: any; /** * Decrypted secrets from Kuzzle Vault */ secrets: JSONObject; /** * Logger instance */ logger: KuzzleLogger; /** * Internal Logger */ log: { debug: (message: any) => void; error: (message: any) => void; info: (message: any) => void; silly: (message: any) => void; verbose: (message: any) => void; warn: (message: any) => void; }; constructor(pluginName: any); }