@quartal/messages-client 0.3.0 → 0.5.0
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/README.md +37 -37
- package/dist/mod.d.ts +24 -1
- package/dist/mod.js +24 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# @quartal/messages-client
|
|
2
|
-
|
|
3
|
-
The browser SDK of the **Quartal Messages API**. `MessagesApi` bundles every resource the UI reads
|
|
4
|
-
and writes — channels and their listed companies, threads, messages, channel agents, the model /
|
|
5
|
-
agent / skill catalog, companies and the signed-in user — plus the live event stream
|
|
6
|
-
(`POST /events`, Server-Sent Events), all over HTTP with the user's bearer token. The API's access
|
|
7
|
-
rules decide what each call sees.
|
|
8
|
-
|
|
9
|
-
A pnpm workspace package of this repo (`workspace:*`); it is not published.
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { MessagesApi } from '@quartal/messages-client';
|
|
15
|
-
|
|
16
|
-
const api = new MessagesApi('http://localhost:8002', () => currentAccessToken());
|
|
17
|
-
|
|
18
|
-
const channels = await api.channels.getOData({ $filter: { advisory } });
|
|
19
|
-
const threads = await api.threads.list('salaxy-payroll');
|
|
20
|
-
await api.messages.create(threads[0].id, [{ id: crypto.randomUUID(), type: 'text', text: 'Hei', state: 'active' }]);
|
|
21
|
-
|
|
22
|
-
const stop = api.events.subscribe((event) => {
|
|
23
|
-
if (event.type === 'message') console.log(event.message.threadId, event.message.parts);
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
The catalog and channel resources (`channels`, `models`, `agents`, `skills`) keep the
|
|
28
|
-
`ICrudApiBase` shape: `getBlank` and `validate` run locally, the API validates again on write.
|
|
29
|
-
Failed calls reject with an `ApiError` carrying the HTTP status and the API's message.
|
|
30
|
-
|
|
31
|
-
`loadClientConfig()` reads the browser settings (`VITE_MESSAGES_API_URL`, `VITE_OIDC_*`,
|
|
32
|
-
`VITE_IAM_API_URL`); `@quartal/ui-messages` uses it to create the shared client.
|
|
33
|
-
|
|
34
|
-
The CRUD shapes (`ApiCrudItem`, `ODataResult`, `ValidationResult`, …) come from
|
|
35
|
-
[`@quartal/core`](https://www.npmjs.com/package/@quartal/core) — import them from there. Only
|
|
36
|
-
`ODataQuery` is re-defined here, with its `$filter` typed as a domain-shaped object instead of an
|
|
37
|
-
OData filter string.
|
|
1
|
+
# @quartal/messages-client
|
|
2
|
+
|
|
3
|
+
The browser SDK of the **Quartal Messages API**. `MessagesApi` bundles every resource the UI reads
|
|
4
|
+
and writes — channels and their listed companies, threads, messages, channel agents, the model /
|
|
5
|
+
agent / skill catalog, companies and the signed-in user — plus the live event stream
|
|
6
|
+
(`POST /events`, Server-Sent Events), all over HTTP with the user's bearer token. The API's access
|
|
7
|
+
rules decide what each call sees.
|
|
8
|
+
|
|
9
|
+
A pnpm workspace package of this repo (`workspace:*`); it is not published.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { MessagesApi } from '@quartal/messages-client';
|
|
15
|
+
|
|
16
|
+
const api = new MessagesApi('http://localhost:8002', () => currentAccessToken());
|
|
17
|
+
|
|
18
|
+
const channels = await api.channels.getOData({ $filter: { advisory } });
|
|
19
|
+
const threads = await api.threads.list('salaxy-payroll');
|
|
20
|
+
await api.messages.create(threads[0].id, [{ id: crypto.randomUUID(), type: 'text', text: 'Hei', state: 'active' }]);
|
|
21
|
+
|
|
22
|
+
const stop = api.events.subscribe((event) => {
|
|
23
|
+
if (event.type === 'message') console.log(event.message.threadId, event.message.parts);
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The catalog and channel resources (`channels`, `models`, `agents`, `skills`) keep the
|
|
28
|
+
`ICrudApiBase` shape: `getBlank` and `validate` run locally, the API validates again on write.
|
|
29
|
+
Failed calls reject with an `ApiError` carrying the HTTP status and the API's message.
|
|
30
|
+
|
|
31
|
+
`loadClientConfig()` reads the browser settings (`VITE_MESSAGES_API_URL`, `VITE_OIDC_*`,
|
|
32
|
+
`VITE_IAM_API_URL`); `@quartal/ui-messages` uses it to create the shared client.
|
|
33
|
+
|
|
34
|
+
The CRUD shapes (`ApiCrudItem`, `ODataResult`, `ValidationResult`, …) come from
|
|
35
|
+
[`@quartal/core`](https://www.npmjs.com/package/@quartal/core) — import them from there. Only
|
|
36
|
+
`ODataQuery` is re-defined here, with its `$filter` typed as a domain-shaped object instead of an
|
|
37
|
+
OData filter string.
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiCrudItem, ApiListItem, FsContent, FsEncoding, FsEntry, FsWriteResult, ODataQueryOptions, ODataResult, QFsSource, ValidationResult } from "@quartal/core";
|
|
2
|
-
import { Agent, AgentPlugin, CatalogRepositoryInfo, Channel, ChannelAgentAssignment, ChannelAgentSchedule, ChannelAgentTrigger, ChannelCompany, ChannelDefinition, ChannelDefinitionInfo, ChannelMessageFile, ChannelSyncResult, ChannelsStats, ChatMessage, CompanyStats, CompanySummary, ExternalPlugin, HomeView, HostedPlugin, HostedPluginContent, HubConfigurationInfo, HubConfigurationPatch, HubToolSetting, LiveEvent, MessageFileContent, MessageUsage, Model, ModelCatalogRefreshResult, ModelGateway, PluginAgent, PluginCodeAttachment, PluginCodeChat, PluginCodeChatSummary, PluginHostGitCommit, PluginHostGitDiscardResult, PluginHostGitDiscardScope, PluginHostGitFileVersions, PluginHostGitResetMode, PluginHostGitResetResult, PluginHostGitStatus, PluginHostInfo, PluginHostPullResult, PluginHostPushResult, PluginInfo, PluginSyncResult, PluginTestSubject, PluginTestToken, PluginTestTool, ShownHomeView, ThreadSummary, UIFilePart, UIMessagePart, UIWidgetContextPart, UserInfo, WidgetResource, WidgetToolResult } from "@quartal/messages-types";
|
|
2
|
+
import { Agent, AgentPlugin, CatalogRepositoryInfo, Channel, ChannelAgentAssignment, ChannelAgentSchedule, ChannelAgentTrigger, ChannelCompany, ChannelDefinition, ChannelDefinitionInfo, ChannelMessageFile, ChannelSyncResult, ChannelsStats, ChatMessage, CompanyStats, CompanySummary, ExternalPlugin, HomeView, HostedPlugin, HostedPluginContent, HubConfigurationInfo, HubConfigurationPatch, HubToolSetting, LiveEvent, MessageFileContent, MessageUsage, Model, ModelCatalogRefreshResult, ModelGateway, PluginAgent, PluginCodeAttachment, PluginCodeChat, PluginCodeChatSummary, PluginHostGitCommit, PluginHostGitDiscardResult, PluginHostGitDiscardScope, PluginHostGitFileVersions, PluginHostGitResetMode, PluginHostGitResetResult, PluginHostGitStatus, PluginHostInfo, PluginHostPullResult, PluginHostPushResult, PluginInfo, PluginSyncResult, PluginTestSubject, PluginTestToken, PluginTestTool, SeedDataInfo, SeedResetResult, ShownHomeView, ThreadSummary, UIFilePart, UIMessagePart, UIWidgetContextPart, UserInfo, WidgetResource, WidgetToolResult } from "@quartal/messages-types";
|
|
3
3
|
|
|
4
4
|
//#region src/ICrudApiBase.d.ts
|
|
5
5
|
/**
|
|
@@ -431,6 +431,20 @@ declare class MessagesApi {
|
|
|
431
431
|
/** The configuration of an organization the user is a direct member of; empty without the file. */get: (companyId: string) => Promise<HubConfigurationInfo>; /** Sets the keys given (null removes one) for an organization the user is a direct admin of. */
|
|
432
432
|
update: (companyId: string, configuration: HubConfigurationPatch) => Promise<HubConfigurationInfo>;
|
|
433
433
|
};
|
|
434
|
+
/**
|
|
435
|
+
* Seed data of a test environment: resetting an organization to the starting point of its demo,
|
|
436
|
+
* a branch of its plugin repository. Offered only where the API has `HUB_SEED_REF`, to the
|
|
437
|
+
* organization's direct admins.
|
|
438
|
+
*/
|
|
439
|
+
readonly seedData: {
|
|
440
|
+
/** Whether the organization can be reset, the ref it goes to and the customers to choose from. */info: (owner: string) => Promise<SeedDataInfo>;
|
|
441
|
+
/**
|
|
442
|
+
* Resets the organization to its seed data, building the demo around the customers given (in
|
|
443
|
+
* order, at most five). Changes in the plugin repository that are not in the seed are lost, and
|
|
444
|
+
* so are the organization's channels, threads and messages.
|
|
445
|
+
*/
|
|
446
|
+
reset: (owner: string, customers: string[]) => Promise<SeedResetResult>;
|
|
447
|
+
};
|
|
434
448
|
/** The Quartal Hub plugin catalog. */
|
|
435
449
|
readonly plugins: {
|
|
436
450
|
/** Every plugin: synced ones first, then the placeholders. */list: () => Promise<PluginInfo[]>; /** One plugin by id. */
|
|
@@ -685,6 +699,15 @@ declare class MessagesApi {
|
|
|
685
699
|
callTool: (subject: PluginTestSubject, pluginId: string, name: string, args?: Record<string, unknown>, forWidget?: boolean) => Promise<WidgetToolResult>; /** The widget document of a tool. */
|
|
686
700
|
getWidget: (subject: PluginTestSubject, pluginId: string, uri: string) => Promise<WidgetResource>;
|
|
687
701
|
};
|
|
702
|
+
/**
|
|
703
|
+
* Concept pictures of channels (a channel's overview, the workflow of its statuses), drawn and
|
|
704
|
+
* read by the concepts plugin (`hub-concepts`). The plugin keeps nothing: read the pictures from the
|
|
705
|
+
* channel plugin's `docs/` and store what the person saves.
|
|
706
|
+
*/
|
|
707
|
+
readonly channelConcepts: {
|
|
708
|
+
/** The editor widget's document. */getWidget: () => Promise<WidgetResource>; /** Calls a tool of the concepts plugin (`showConcept`, `conceptFile`, …). */
|
|
709
|
+
callTool: (name: string, args?: Record<string, unknown>) => Promise<WidgetToolResult>;
|
|
710
|
+
};
|
|
688
711
|
/**
|
|
689
712
|
* The views of the Hub's front page besides the chats: the saved dashboards of the dashboards
|
|
690
713
|
* plugins the organization's channels use, each shown with its plugin's widget as the person.
|
package/dist/mod.js
CHANGED
|
@@ -564,6 +564,18 @@ var MessagesApi = class {
|
|
|
564
564
|
get: (companyId) => this.http.get(`/api/hub-configuration/${seg(companyId)}`),
|
|
565
565
|
update: (companyId, configuration) => this.http.put(`/api/hub-configuration/${seg(companyId)}`, { configuration })
|
|
566
566
|
};
|
|
567
|
+
/**
|
|
568
|
+
* Seed data of a test environment: resetting an organization to the starting point of its demo,
|
|
569
|
+
* a branch of its plugin repository. Offered only where the API has `HUB_SEED_REF`, to the
|
|
570
|
+
* organization's direct admins.
|
|
571
|
+
*/
|
|
572
|
+
seedData = {
|
|
573
|
+
info: (owner) => this.http.get("/api/seed-data/info", { query: { owner } }),
|
|
574
|
+
reset: (owner, customers) => this.http.post("/api/seed-data/reset", {
|
|
575
|
+
owner,
|
|
576
|
+
customers
|
|
577
|
+
})
|
|
578
|
+
};
|
|
567
579
|
/** The Quartal Hub plugin catalog. */
|
|
568
580
|
plugins = {
|
|
569
581
|
list: async () => (await this.http.get("/api/plugins")).plugins,
|
|
@@ -937,6 +949,18 @@ var MessagesApi = class {
|
|
|
937
949
|
} })
|
|
938
950
|
};
|
|
939
951
|
/**
|
|
952
|
+
* Concept pictures of channels (a channel's overview, the workflow of its statuses), drawn and
|
|
953
|
+
* read by the concepts plugin (`hub-concepts`). The plugin keeps nothing: read the pictures from the
|
|
954
|
+
* channel plugin's `docs/` and store what the person saves.
|
|
955
|
+
*/
|
|
956
|
+
channelConcepts = {
|
|
957
|
+
getWidget: () => this.http.get("/api/channel-concepts/widget"),
|
|
958
|
+
callTool: (name, args = {}) => this.http.post("/api/channel-concepts/call-tool", {
|
|
959
|
+
name,
|
|
960
|
+
args
|
|
961
|
+
})
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
940
964
|
* The views of the Hub's front page besides the chats: the saved dashboards of the dashboards
|
|
941
965
|
* plugins the organization's channels use, each shown with its plugin's widget as the person.
|
|
942
966
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quartal/messages-client",
|
|
3
3
|
"description": "The browser SDK of the Quartal Messages API",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Quartal Accounting Software Oy",
|
|
7
7
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@quartal/core": "^1.5.1",
|
|
29
|
-
"@quartal/messages-types": "0.
|
|
29
|
+
"@quartal/messages-types": "0.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"tsdown": "^0.21.9",
|