@protobase/client 0.45.20 → 0.45.22
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/client.d.ts +10 -0
- package/dist/client.js +3 -1
- package/dist/index.d.ts +2 -1
- package/dist/notification-history.d.ts +36 -0
- package/dist/notification-history.js +45 -0
- package/dist/routed-client.d.ts +1 -1
- package/dist/routed-client.js +3 -2
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClientOptions } from "./transport.js";
|
|
2
2
|
import { RegisteredDevice, WebDeviceRegistration } from "./devices.js";
|
|
3
|
+
import { InboxPage } from "./notification-history.js";
|
|
3
4
|
import { FilterInput, ListParams, MapParams } from "./query-string.js";
|
|
4
5
|
import { UploadProgress } from "./upload-request.js";
|
|
5
6
|
import { LiveHandlers } from "./live.js";
|
|
@@ -100,6 +101,15 @@ export declare const createClient: (options?: ClientOptions) => {
|
|
|
100
101
|
register: (device: WebDeviceRegistration) => Promise<RegisteredDevice>;
|
|
101
102
|
remove: (id: string) => Promise<void>;
|
|
102
103
|
};
|
|
104
|
+
notifications: {
|
|
105
|
+
list: ({ cursor, limit }?: {
|
|
106
|
+
cursor?: string;
|
|
107
|
+
limit?: number;
|
|
108
|
+
}) => Promise<InboxPage>;
|
|
109
|
+
unread: () => Promise<number>;
|
|
110
|
+
markRead: (id: string) => Promise<void>;
|
|
111
|
+
markAllRead: (upTo: string) => Promise<void>;
|
|
112
|
+
};
|
|
103
113
|
};
|
|
104
114
|
export type Client = ReturnType<typeof createClient>;
|
|
105
115
|
//#endregion
|
package/dist/client.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createTransport } from "./transport.js";
|
|
|
4
4
|
import { fetchWithProgress } from "./upload-request.js";
|
|
5
5
|
import { followLive } from "./live.js";
|
|
6
6
|
import { devicesClient } from "./devices.js";
|
|
7
|
+
import { notificationHistoryClient } from "./notification-history.js";
|
|
7
8
|
import { encodeKey } from "@protobase/schema/internal";
|
|
8
9
|
//#region src/client.ts
|
|
9
10
|
const nameOf = (resource) => typeof resource === "string" ? resource : resource.toModel().name;
|
|
@@ -440,7 +441,8 @@ const createClient = (options = {}) => {
|
|
|
440
441
|
formChallenge,
|
|
441
442
|
submitForm,
|
|
442
443
|
live,
|
|
443
|
-
devices: devicesClient(send)
|
|
444
|
+
devices: devicesClient(send),
|
|
445
|
+
notifications: notificationHistoryClient(send)
|
|
444
446
|
};
|
|
445
447
|
};
|
|
446
448
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClientOptions } from "./transport.js";
|
|
2
2
|
import { DevicesClient, RegisteredDevice, WebDeviceRegistration } from "./devices.js";
|
|
3
|
+
import { InboxNotification, InboxPage, NotificationHistoryClient } from "./notification-history.js";
|
|
3
4
|
import { FilterInput, ListParams, MapParams, filterText, listWire } from "./query-string.js";
|
|
4
5
|
import { UploadProgress } from "./upload-request.js";
|
|
5
6
|
import { LiveChange, LiveHandlers } from "./live.js";
|
|
@@ -22,4 +23,4 @@ import { AuthSession, AuthSessionOptions, createAuthSession, tokenExpiry } from
|
|
|
22
23
|
import { createStaticSession } from "./static-session.js";
|
|
23
24
|
import { AssistantClient, AssistantClientOptions, AssistantConnection, createAssistantClient } from "./assistant.js";
|
|
24
25
|
import { RuntimeClient, RuntimeClientOptions, RuntimeLastUpdate, RuntimePolicy, RuntimeStatus, RuntimeUpdateStage, createRuntimeClient } from "./runtime.js";
|
|
25
|
-
export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, type AggregateSplitTotal, ApiError, type AppUser, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type ConnectClient, type ConnectedApp, type ConnectingClient, type CurrentOrganization, type DevicesClient, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type LiveChange, type LiveHandlers, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type OrganizationsFound, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RegisteredDevice, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type SamlSignIn, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, type UserInvitation, type UserInvitationSent, type UsersClient, type UsersFound, type WebDeviceRegistration, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
|
|
26
|
+
export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, type AggregateSplitTotal, ApiError, type AppUser, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type ConnectClient, type ConnectedApp, type ConnectingClient, type CurrentOrganization, type DevicesClient, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InboxNotification, type InboxPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type LiveChange, type LiveHandlers, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type NotificationHistoryClient, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type OrganizationsFound, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RegisteredDevice, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type SamlSignIn, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, type UserInvitation, type UserInvitationSent, type UsersClient, type UsersFound, type WebDeviceRegistration, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Transport } from "./transport.js";
|
|
2
|
+
//#region src/notification-history.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* One of the signed-in user's inbox notifications, as the server answers it: `title` and `body` are plain text, `url` a
|
|
5
|
+
* path on the app or an absolute URL on one of its origins, or `null`; `readAt` is `null` while it is unread.
|
|
6
|
+
*/
|
|
7
|
+
export type InboxNotification = {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
body: string | null;
|
|
11
|
+
url: string | null;
|
|
12
|
+
data: Record<string, unknown> | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
readAt: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** A page of the history, newest first; `next` is the cursor of the page after it, `null` on the last one. */
|
|
17
|
+
export type InboxPage = {
|
|
18
|
+
items: InboxNotification[];
|
|
19
|
+
next: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The signed-in user's own notification history (`/api/notifications/history`): `list` a page of it, `unread` how many
|
|
23
|
+
* are unread (at most 100), `markRead` one of them by its id, and `markAllRead` those created up to `upTo`, the
|
|
24
|
+
* `createdAt` of the newest one the user was shown.
|
|
25
|
+
*/
|
|
26
|
+
export declare const notificationHistoryClient: (send: Transport) => {
|
|
27
|
+
list: ({ cursor, limit }?: {
|
|
28
|
+
cursor?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
}) => Promise<InboxPage>;
|
|
31
|
+
unread: () => Promise<number>;
|
|
32
|
+
markRead: (id: string) => Promise<void>;
|
|
33
|
+
markAllRead: (upTo: string) => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export type NotificationHistoryClient = ReturnType<typeof notificationHistoryClient>;
|
|
36
|
+
//#endregion
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { historyPath } from "@protobase/schema/internal";
|
|
2
|
+
//#region src/notification-history.ts
|
|
3
|
+
/**
|
|
4
|
+
* The signed-in user's own notification history (`/api/notifications/history`): `list` a page of it, `unread` how many
|
|
5
|
+
* are unread (at most 100), `markRead` one of them by its id, and `markAllRead` those created up to `upTo`, the
|
|
6
|
+
* `createdAt` of the newest one the user was shown.
|
|
7
|
+
*/
|
|
8
|
+
const notificationHistoryClient = (send) => ({
|
|
9
|
+
list: async ({ cursor, limit } = {}) => {
|
|
10
|
+
const params = new URLSearchParams({
|
|
11
|
+
...cursor !== void 0 && { cursor },
|
|
12
|
+
...limit !== void 0 && { limit: String(limit) }
|
|
13
|
+
});
|
|
14
|
+
const query = params.size > 0 ? `?${params}` : "";
|
|
15
|
+
return (await send({
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: historyPath(""),
|
|
18
|
+
query,
|
|
19
|
+
system: true
|
|
20
|
+
})).json();
|
|
21
|
+
},
|
|
22
|
+
unread: async () => (await (await send({
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: historyPath("", "unread"),
|
|
25
|
+
system: true
|
|
26
|
+
})).json()).count,
|
|
27
|
+
markRead: async (id) => {
|
|
28
|
+
await send({
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: historyPath("", { read: id }),
|
|
31
|
+
body: {},
|
|
32
|
+
system: true
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
markAllRead: async (upTo) => {
|
|
36
|
+
await send({
|
|
37
|
+
method: "POST",
|
|
38
|
+
path: historyPath("", "read"),
|
|
39
|
+
body: { upTo },
|
|
40
|
+
system: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { notificationHistoryClient };
|
package/dist/routed-client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Client } from "./client.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* One client over the app's own API and the sources it draws resources from: a call about a resource goes to the API
|
|
5
5
|
* that serves it (`sourceOf` gives a source's client, or `undefined` for the app's own), and `meta`, `invoke`, the
|
|
6
|
-
* public forms, `live` and the user's devices go to the app's own. A batch goes to the one API all its writes are for; one that writes to two cannot be atomic, so it is
|
|
6
|
+
* public forms, `live` and the user's devices and notifications go to the app's own. A batch goes to the one API all its writes are for; one that writes to two cannot be atomic, so it is
|
|
7
7
|
* refused before anything is sent.
|
|
8
8
|
*/
|
|
9
9
|
export declare const routedClient: (own: Client, sourceOf: (resource: string) => Client | undefined) => Client;
|
package/dist/routed-client.js
CHANGED
|
@@ -3,7 +3,7 @@ const nameOf = (resource) => typeof resource === "string" ? resource : resource.
|
|
|
3
3
|
/**
|
|
4
4
|
* One client over the app's own API and the sources it draws resources from: a call about a resource goes to the API
|
|
5
5
|
* that serves it (`sourceOf` gives a source's client, or `undefined` for the app's own), and `meta`, `invoke`, the
|
|
6
|
-
* public forms, `live` and the user's devices go to the app's own. A batch goes to the one API all its writes are for; one that writes to two cannot be atomic, so it is
|
|
6
|
+
* public forms, `live` and the user's devices and notifications go to the app's own. A batch goes to the one API all its writes are for; one that writes to two cannot be atomic, so it is
|
|
7
7
|
* refused before anything is sent.
|
|
8
8
|
*/
|
|
9
9
|
const routedClient = (own, sourceOf) => {
|
|
@@ -40,7 +40,8 @@ const routedClient = (own, sourceOf) => {
|
|
|
40
40
|
formChallenge: (name) => own.formChallenge(name),
|
|
41
41
|
submitForm: (name, values, proof) => own.submitForm(name, values, proof),
|
|
42
42
|
live: (handlers) => own.live(handlers),
|
|
43
|
-
devices: own.devices
|
|
43
|
+
devices: own.devices,
|
|
44
|
+
notifications: own.notifications
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
//#endregion
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/client",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.22",
|
|
4
4
|
"description": "Typed fetch client for the Protobase REST API.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@better-auth/passkey": "^1.7.12",
|
|
33
|
-
"@protobase/layout": "0.45.
|
|
34
|
-
"@protobase/schema": "0.45.
|
|
33
|
+
"@protobase/layout": "0.45.22",
|
|
34
|
+
"@protobase/schema": "0.45.22",
|
|
35
35
|
"@simplewebauthn/browser": "^13.3.0",
|
|
36
36
|
"better-auth": "^1.7.12"
|
|
37
37
|
}
|