orgnote-api 0.41.6 → 0.41.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { COMMAND_GROUPS } from "../constants/index.js";
3
3
  import { DefaultCommands } from './default-commands.js';
4
4
  import { OrgNoteApi } from "../api.js";
5
5
  import { VueComponent } from './vue-component.js';
6
+ import type { ExecuteCommandOptions } from './commands-store.js';
6
7
  export type CommandGroup = (typeof COMMAND_GROUPS)[number] | (string & Record<never, never>);
7
8
  export type CommandName = DefaultCommands | (string & {});
8
9
  export type CommandIcon = string | VueComponent;
@@ -33,4 +34,4 @@ export interface CommandMeta<T = any> extends Partial<CommandPreview> {
33
34
  export interface Command<T = any, R = unknown> extends CommandMeta<T> {
34
35
  handler: (api: OrgNoteApi, params: CommandHandlerParams<T>) => R | Promise<R>;
35
36
  }
36
- export type CommandCallback = <T = any>(meta: Command, data: T) => void;
37
+ export type CommandCallback = <T = any>(meta: Command, data: T, options?: ExecuteCommandOptions) => void;
@@ -2,12 +2,15 @@ import { Ref } from 'vue';
2
2
  import { Command, CommandCallback } from './command.js';
3
3
  import { StoreDefinition } from './store.js';
4
4
  export type CommandUnsubscribFn = () => void;
5
+ export interface ExecuteCommandOptions {
6
+ interactive?: boolean;
7
+ }
5
8
  export interface CommandsStore {
6
9
  add: (...newCommands: Command[]) => void;
7
10
  remove: (...commandsToUnregister: Command[]) => void;
8
11
  get: (name: string) => Command | undefined;
9
12
  commands: Ref<Command[]>;
10
- execute: (name: string, data?: unknown) => Promise<void>;
13
+ execute: (name: string, data?: unknown, options?: ExecuteCommandOptions) => Promise<void>;
11
14
  afterExecute: (commandNames: string | string[], callback: CommandCallback) => CommandUnsubscribFn;
12
15
  }
13
16
  export type CommandsStoreDefinition = StoreDefinition<CommandsStore>;
@@ -1,5 +1,5 @@
1
1
  import { ComputedRef } from 'vue';
2
- import { Completion, CompletionConfig } from './completion.js';
2
+ import { Completion, CompletionConfig, CompletionInterceptor } from './completion.js';
3
3
  import { StoreDefinition } from './store.js';
4
4
  export interface CompletionStore {
5
5
  restore: () => void;
@@ -10,5 +10,6 @@ export interface CompletionStore {
10
10
  nextCandidate: () => void;
11
11
  previousCandidate: () => void;
12
12
  search: (limit?: number, offset?: number) => void;
13
+ registerInterceptor: <T = unknown>(interceptor: CompletionInterceptor<T>) => () => void;
13
14
  }
14
15
  export type CompletionStoreDefinition = StoreDefinition<CompletionStore>;
@@ -14,6 +14,7 @@ export interface CompletionSearchResult<T = unknown> {
14
14
  }
15
15
  export type CandidateGetterFn<T = unknown> = (filter: string, limit?: number, offset?: number) => CompletionSearchResult<T> | Promise<CompletionSearchResult<T>>;
16
16
  export interface CompletionConfig<T = unknown> {
17
+ name?: string;
17
18
  searchAutocompletions?: string[];
18
19
  itemsGetter: CandidateGetterFn<T>;
19
20
  type?: 'input' | 'choice' | 'input-choice';
@@ -30,3 +31,14 @@ export interface Completion<T = any, TResult = any> extends CompletionConfig<T>
30
31
  searchQuery: string;
31
32
  result: Promise<TResult>;
32
33
  }
34
+ export interface CompletionInterceptorContext {
35
+ completionName: string;
36
+ searchQuery: string;
37
+ }
38
+ export type CompletionInterceptorTarget = string | string[] | '*';
39
+ export interface CompletionInterceptor<T = unknown> {
40
+ name: string;
41
+ target: CompletionInterceptorTarget;
42
+ priority?: number;
43
+ handler: (candidates: CompletionCandidate<T>[], context: CompletionInterceptorContext) => CompletionCandidate<T>[] | Promise<CompletionCandidate<T>[]>;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.41.6",
3
+ "version": "0.41.7",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.js",