Skip to content

Commit 56596f7

Browse files
authored
Update roamAlphaAPI types (#45)
* chore(types): update roamAlphaAPI * chore(types): refine type definitions and improve consistency * . * chore(types): simplify SidebarAction types and update SidebarWindowInput structure * 0.85.4
1 parent f2d507c commit 56596f7

File tree

4 files changed

+127
-12
lines changed

4 files changed

+127
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "roamjs-components",
33
"description": "Expansive toolset, utilities, & components for developing RoamJS extensions.",
4-
"version": "0.85.3",
4+
"version": "0.85.4",
55
"main": "index.js",
66
"types": "index.d.ts",
77
"scripts": {

src/types/index.ts

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,31 @@ declare global {
107107
update: WriteAction;
108108
move: WriteAction;
109109
delete: WriteAction;
110+
reorderBlocks: (args: {
111+
location: { "parent-uid": string };
112+
blocks: string[];
113+
}) => Promise<void>;
110114
};
111115
fast: {
112116
q: (query: string, ...params: unknown[]) => unknown[][];
113117
};
118+
async: {
119+
q: (query: string, ...params: unknown[]) => Promise<unknown[][]>;
120+
pull: (
121+
selector: string,
122+
id: number | string | [string, string]
123+
) => Promise<PullBlock>;
124+
pull_many: (
125+
pattern: string,
126+
eids: string[][]
127+
) => Promise<PullBlock[]>;
128+
fast: {
129+
q: (query: string, ...params: unknown[]) => Promise<unknown[][]>;
130+
};
131+
};
132+
backend: {
133+
q: (query: string, ...params: unknown[]) => unknown[][];
134+
};
114135
page: {
115136
create: WriteAction;
116137
update: WriteAction;
@@ -120,7 +141,7 @@ declare global {
120141
selector: string,
121142
id: number | string | [string, string]
122143
) => PullBlock;
123-
pull_many: (pattern: string, eid: string[][]) => PullBlock[];
144+
pull_many: (pattern: string, eids: string[][]) => PullBlock[];
124145
q: (query: string, ...params: unknown[]) => unknown[][];
125146
removePullWatch: (
126147
pullPattern: string,
@@ -143,11 +164,12 @@ declare global {
143164
close: () => Promise<void>;
144165
getWindows: () => SidebarWindow[];
145166
addWindow: SidebarAction;
146-
setWindowOrder: (action: {
147-
window: SidebarWindowInput & { order: number };
148-
}) => Promise<void>;
167+
setWindowOrder: SidebarAction;
149168
collapseWindow: SidebarAction;
150-
pinWindow: SidebarAction;
169+
pinWindow: (action: {
170+
window: SidebarWindowInput;
171+
"pin-to-top?"?: boolean;
172+
}) => Promise<void>;
151173
expandWindow: SidebarAction;
152174
removeWindow: SidebarAction;
153175
unpinWindow: SidebarAction;
@@ -156,6 +178,8 @@ declare global {
156178
addCommand: (action: {
157179
label: string;
158180
callback: () => void;
181+
"disable-hotkey"?: boolean;
182+
"default-hotkey"?: string | string[];
159183
}) => Promise<void>;
160184
removeCommand: (action: { label: string }) => Promise<void>;
161185
};
@@ -173,6 +197,56 @@ declare global {
173197
}) => void;
174198
removeCommand: (action: { label: string }) => void;
175199
};
200+
individualMultiselect: {
201+
getSelectedUids: () => string[];
202+
};
203+
msContextMenu: {
204+
addCommand: (action: {
205+
label: string;
206+
callback: () => void;
207+
"display-conditional"?: () => boolean;
208+
}) => void;
209+
removeCommand: (action: { label: string }) => void;
210+
};
211+
filters: {
212+
addGlobalFilter: (args: {
213+
title: string;
214+
type: "includes" | "removes";
215+
}) => Promise<void>;
216+
removeGlobalFilter: (args: {
217+
title: string;
218+
type: "includes" | "removes";
219+
}) => Promise<void>;
220+
getGlobalFilters: () => { includes: string[]; removes: string[] };
221+
getPageFilters: (args: {
222+
page: { uid?: string; title?: string };
223+
}) => {
224+
includes: string[];
225+
removes: string[];
226+
};
227+
getPageLinkedRefsFilters: (args: {
228+
page: { uid?: string; title?: string };
229+
}) => {
230+
includes: string[];
231+
removes: string[];
232+
};
233+
getSidebarWindowFilters: (args: { window: SidebarWindowInput }) => {
234+
includes: string[];
235+
removes: string[];
236+
};
237+
setPageFilters: (args: {
238+
page: { uid?: string; title?: string };
239+
filters: { includes?: string[]; removes?: string[] };
240+
}) => Promise<void>;
241+
setPageLinkedRefsFilters: (args: {
242+
page: { uid?: string; title?: string };
243+
filters: { includes?: string[]; removes?: string[] };
244+
}) => Promise<void>;
245+
setSidebarWindowFilters: (args: {
246+
window: SidebarWindowInput;
247+
filters: { includes?: string[]; removes?: string[] };
248+
}) => Promise<void>;
249+
};
176250
getFocusedBlock: () => null | {
177251
"window-id": string;
178252
"block-uid": string;
@@ -181,15 +255,36 @@ declare global {
181255
renderBlock: (args: {
182256
uid: string;
183257
el: HTMLElement;
184-
zoomPath?: boolean;
258+
"zoom-path?"?: boolean;
259+
// "open?"?: boolean; Not available yet in the API
185260
}) => null;
186261
renderPage: (args: {
187262
uid: string;
188263
el: HTMLElement;
189-
hideMentions?: boolean;
264+
"hide-mentions?"?: boolean;
190265
}) => null;
266+
renderSearch: (args: {
267+
"search-query-str": string;
268+
el: HTMLElement;
269+
"closed?"?: boolean;
270+
"group-by-page?"?: boolean;
271+
"hide-paths?"?: boolean;
272+
"config-changed-callback"?: (config: unknown) => void;
273+
}) => null;
274+
// renderString: (args: { string: string; el: HTMLElement }) => null; Not available yet in the API
275+
unmountNode: (args: { el: HTMLElement }) => void;
191276
};
192277
graphView: {
278+
addCallback: (props: {
279+
label: string;
280+
callback: (context: {
281+
cytoscape: unknown;
282+
elements: unknown[];
283+
type: "page" | "all-pages";
284+
}) => void;
285+
type?: "page" | "all-pages";
286+
}) => Promise<void>;
287+
removeCallback: (props: { label: string }) => Promise<void>;
193288
wholeGraph: {
194289
addCallback: (props: {
195290
label: string;
@@ -228,6 +323,20 @@ declare global {
228323
type: "hosted" | "offline";
229324
isEncrypted: boolean;
230325
};
326+
file: {
327+
upload: (args: {
328+
file: File;
329+
toast?: { hide: boolean };
330+
}) => Promise<string>;
331+
get: (args: { url: string }) => Promise<File>;
332+
delete: (args: { url: string }) => Promise<void>;
333+
};
334+
user: {
335+
uid: () => string | null;
336+
};
337+
constants: {
338+
corsAnywhereProxyUrl: string;
339+
};
231340
};
232341

233342
// roamjs namespace should only be used for methods that must be accessed across extension scripts

src/types/native.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,12 @@ type SidebarWindowType =
371371
| SidebarBlockWindow
372372
| SidebarMentionsWindow
373373
| SidebarGraphWindow
374-
| SidebarOutlineWindow;
374+
| SidebarOutlineWindow
375+
| SidebarSearchQueryWindow;
375376

376377
export type SidebarWindowInput = {
377-
"block-uid": string;
378378
type: SidebarWindowType["type"];
379+
order?: number;
379380
};
380381

381382
type SidebarBlockWindow = {
@@ -399,6 +400,11 @@ type SidebarGraphWindow = {
399400
"block-uid": string;
400401
};
401402

403+
type SidebarSearchQueryWindow = {
404+
type: "search-query";
405+
"search-query-uid": string;
406+
};
407+
402408
export type SidebarAction = (action: {
403409
window: SidebarWindowInput;
404410
}) => Promise<void>;

0 commit comments

Comments
 (0)