@coworkee/airworks 0.0.1026 → 0.0.1028
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.
- package/dist/coworkee.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/search.d.ts +28 -0
- package/dist/search.js +30 -0
- package/package.json +2 -2
package/dist/coworkee.js
CHANGED
|
@@ -2,6 +2,7 @@ import { apiRequest, applyTheme, createCoworkeeClient, createRealtime, realtimeE
|
|
|
2
2
|
import { bffAuthProvider } from "./auth.js";
|
|
3
3
|
import { toast } from "./dom.js";
|
|
4
4
|
import { defaultMudExFrameUrl, defaultMudExUrl } from "./mudex.js";
|
|
5
|
+
import { globalSearchProvider } from "./search.js";
|
|
5
6
|
/** English of the MudBlazor keys the apps borrow; the API serves them only for other languages. */
|
|
6
7
|
const mudTexts = {
|
|
7
8
|
MudDataGridPager_InfoFormat: '{0}-{1} of {2}', MudTablePager_PreviousPage: 'Previous page', MudTablePager_NextPage: 'Next page', MudDataGrid_Loading: 'Loading...',
|
|
@@ -109,5 +110,8 @@ export async function useCoworkee(airWorks, options) {
|
|
|
109
110
|
});
|
|
110
111
|
if (user.isAuthenticated && user.userId)
|
|
111
112
|
follow(coworkee, user.userId);
|
|
113
|
+
// the server's global search (users, files, reports, chats, the app's sets) in the search of the desktop
|
|
114
|
+
if (user.isAuthenticated)
|
|
115
|
+
airWorks.registerSearchProvider(globalSearchProvider(coworkee));
|
|
112
116
|
return coworkee;
|
|
113
117
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { reportDesignerApp, setPath } from './apps/report-designer.ts';
|
|
|
20
20
|
export { createWidget, place, presets, resolveRange, widgetFilter } from './apps/report-model.ts';
|
|
21
21
|
export { type LookupItem, type LookupSource } from './lookup.ts';
|
|
22
22
|
export { aiSettingsApp, assistantApp } from './apps/assistant.ts';
|
|
23
|
+
export { defaultSearchTarget, globalSearchProvider, toResults, type GlobalSearchHit, type SearchTarget } from './search.ts';
|
|
23
24
|
export * from './apps/admin/index.ts';
|
|
24
25
|
/** The apps of the library for every user: profile, settings, files with preview, data, chat, reports with their designer, assistant, notifications and the API documentation. */
|
|
25
26
|
export declare const defaultApps: AppFactory[];
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { reportDesignerApp, setPath } from "./apps/report-designer.js";
|
|
|
29
29
|
export { createWidget, place, presets, resolveRange, widgetFilter } from "./apps/report-model.js";
|
|
30
30
|
export {} from "./lookup.js";
|
|
31
31
|
export { aiSettingsApp, assistantApp } from "./apps/assistant.js";
|
|
32
|
+
export { defaultSearchTarget, globalSearchProvider, toResults } from "./search.js";
|
|
32
33
|
export * from "./apps/admin/index.js";
|
|
33
34
|
/** The apps of the library for every user: profile, settings, files with preview, data, chat, reports with their designer, assistant, notifications and the API documentation. */
|
|
34
35
|
export const defaultApps = [profileApp, settingsApp, filesApp, filePreviewApp, dataApp, chatApp, reportsApp, reportApp, reportDesignerApp, assistantApp, notificationsApp, apiDocsApp];
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Intent, SearchProvider, SearchResult } from '@fgilde/airworks';
|
|
2
|
+
import type { Coworkee } from './coworkee.ts';
|
|
3
|
+
/** A hit of GET /api/v1/search (GlobalSearchHit). */
|
|
4
|
+
export type GlobalSearchHit = {
|
|
5
|
+
provider: string;
|
|
6
|
+
group: string;
|
|
7
|
+
title: string;
|
|
8
|
+
subtitle?: string | null;
|
|
9
|
+
url?: string | null;
|
|
10
|
+
entitySet?: string | null;
|
|
11
|
+
id?: string | null;
|
|
12
|
+
score: number;
|
|
13
|
+
thumbnail?: string | null;
|
|
14
|
+
icon?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** Which app opens a hit, with which intent; undefined leaves the hit out. */
|
|
17
|
+
export type SearchTarget = (hit: GlobalSearchHit) => {
|
|
18
|
+
appId: string;
|
|
19
|
+
intent?: Intent;
|
|
20
|
+
} | undefined;
|
|
21
|
+
/** Reports, chats and files open their own app, records of OData sets the data app on their set. */
|
|
22
|
+
export declare function defaultSearchTarget(hit: GlobalSearchHit): {
|
|
23
|
+
appId: string;
|
|
24
|
+
intent?: Intent;
|
|
25
|
+
} | undefined;
|
|
26
|
+
/** The server's global search in the AirWorks search, best hits first; register it with airWorks.registerSearchProvider. */
|
|
27
|
+
export declare function globalSearchProvider(coworkee: Coworkee, target?: SearchTarget, limit?: number): SearchProvider;
|
|
28
|
+
export declare const toResults: (hits: GlobalSearchHit[], target?: SearchTarget) => SearchResult[];
|
package/dist/search.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { filePreviewAppId } from "./apps/file-preview.js";
|
|
2
|
+
import { reportAppId } from "./apps/reports.js";
|
|
3
|
+
/** Reports, chats and files open their own app, records of OData sets the data app on their set. */
|
|
4
|
+
export function defaultSearchTarget(hit) {
|
|
5
|
+
if (hit.provider === 'reports' && hit.id)
|
|
6
|
+
return { appId: reportAppId, intent: { id: hit.id } };
|
|
7
|
+
if (hit.provider === 'chats' && hit.id)
|
|
8
|
+
return { appId: 'coworkee.chat', intent: { user: hit.id } };
|
|
9
|
+
if (hit.provider === 'files' && hit.id)
|
|
10
|
+
return { appId: filePreviewAppId, intent: { id: hit.id, name: hit.title, contentType: hit.subtitle ?? '' } };
|
|
11
|
+
if (hit.entitySet)
|
|
12
|
+
return { appId: 'coworkee.data', intent: { set: hit.entitySet } };
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
/** The server's global search in the AirWorks search, best hits first; register it with airWorks.registerSearchProvider. */
|
|
16
|
+
export function globalSearchProvider(coworkee, target = defaultSearchTarget, limit = 5) {
|
|
17
|
+
return {
|
|
18
|
+
id: 'coworkee.global-search',
|
|
19
|
+
search: async (query, { signal }) => {
|
|
20
|
+
if (query.trim().length < 2)
|
|
21
|
+
return [];
|
|
22
|
+
const result = await coworkee.request(`/api/v1/search?${new URLSearchParams({ q: query, limit: String(limit) })}`, { signal });
|
|
23
|
+
return toResults(result.hits, target);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const toResults = (hits, target = defaultSearchTarget) => hits.flatMap((hit) => {
|
|
28
|
+
const opens = target(hit);
|
|
29
|
+
return opens ? [{ title: hit.title, description: hit.subtitle ?? hit.group, appId: opens.appId, intent: opens.intent }] : [];
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coworkee/airworks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1028",
|
|
4
4
|
"description": "AirWorks web desktop for Coworkee apps: sign-in through the app's BFF, theme, texts, realtime and apps for settings, files, data, chat, reports, the assistant and the administration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://fgilde.github.io/CoworkeeLib/web/airworks/",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "node --test \"test/**/*.test.ts\""
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@coworkee/client": "0.0.
|
|
42
|
+
"@coworkee/client": "0.0.1028"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@fgilde/airworks": ">=0.4.0"
|