palbase 0.18.5 → 0.19.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 +14 -0
- package/dist/ai/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +3 -3
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{DSRFESUP.js → 26R7KNH7.js} +2 -2
- package/dist/chunks/{EJCZSU6N.js → 2XM3DQXS.js} +2 -2
- package/dist/chunks/{GEKPVLFJ.js → 424IEUQX.js} +2 -2
- package/dist/chunks/{2CZIJUEA.js → 43RXGTTL.js} +1 -1
- package/dist/chunks/{TKFOVBGN.js → B6OLQP6W.js} +2 -2
- package/dist/chunks/{T4R24MAP.js → EDIQ4SAO.js} +2 -2
- package/dist/chunks/{JXS4PFKE.js → F5CWCOSS.js} +1 -1
- package/dist/chunks/{ICDIBK5M.js → HM7G4WGJ.js} +2 -2
- package/dist/chunks/{IB2CXDQX.js → KE4DEYSH.js} +1 -1
- package/dist/chunks/{WBFCNBXY.js → LCBMI6UP.js} +1 -1
- package/dist/chunks/{LVWFOKBJ.js → LRWWDIJZ.js} +2 -2
- package/dist/chunks/{J3MZRKKM.js → MI3PAKT3.js} +2 -2
- package/dist/chunks/{3JSH2MUE.js → PRIISRPI.js} +2 -2
- package/dist/chunks/{VTEQCSQV.js → QOUBSZM4.js} +1 -1
- package/dist/chunks/{UILOHBBQ.js → RIQJUVZK.js} +1 -1
- package/dist/chunks/{ITJURBMS.js → SGASB5G4.js} +2 -2
- package/dist/chunks/{7YDYPPAK.js → TOPRHPT6.js} +1 -1
- package/dist/chunks/{P7K2DF3E.js → V2GWROU3.js} +2 -2
- package/dist/chunks/{5W3LOKAA.js → V6TFL4HC.js} +2 -2
- package/dist/chunks/{JHK7EIQJ.js → WHKAPZX7.js} +3 -3
- package/dist/chunks/{YYDJXLXP.js → Y4THIE6E.js} +2 -2
- package/dist/chunks/Z4YKS2EK.js +2 -0
- package/dist/chunks/{RYK2ZLYB.js → ZW57VOIW.js} +2 -2
- package/dist/cli.js +53 -53
- package/dist/cloud/index.js +2 -0
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/cloud.js +2 -0
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/message.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/push-sw.js +1 -1
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +18 -4
- package/types/cloud/src/cloud.d.ts +23 -0
- package/types/cloud/src/generated/project.d.ts +19 -0
- package/types/cloud/src/generated/studio.d.ts +1765 -0
- package/types/cloud/src/index.d.ts +7 -0
- package/types/cloud/src/token.d.ts +6 -0
- package/types/internal/src/messaging/engine.d.ts +6 -2
- package/types/internal/src/messaging/store.d.ts +21 -2
- package/types/internal/src/modules/messaging.d.ts +39 -6
- package/types/internal/src/transport.d.ts +10 -1
- package/types/web/src/index.d.ts +1 -1
- package/types/web/src/messaging.d.ts +24 -2
- package/dist/chunks/5FJ5HY4N.js +0 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PalbaseCloud, DEFAULT_DOMAIN, type CloudOptions } from './cloud.js';
|
|
2
|
+
export { tokenIsWellFormed } from './token.js';
|
|
3
|
+
export type { Project } from './generated/project.js';
|
|
4
|
+
export type { Client as Studio } from './generated/studio.js';
|
|
5
|
+
export { PalbaseError } from '../../internal/src/transport.js';
|
|
6
|
+
export type { RetryPolicy } from '../../internal/src/retry.js';
|
|
7
|
+
export type * as types from '../../internal/src/modules/index.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** What is wrong with `token` as an access token, or undefined when it is well formed. The token itself is never in it. */
|
|
2
|
+
export declare function tokenProblem(token: unknown): string | undefined;
|
|
3
|
+
/** Whether `token` is an access token as Palbase makes one: its prefix, its length and its checksum. Nothing is sent. */
|
|
4
|
+
export declare function tokenIsWellFormed(token: unknown): token is string;
|
|
5
|
+
/** Throws a TypeError naming what is wrong with `token` (never the token). */
|
|
6
|
+
export declare function checkToken(token: unknown): asserts token is string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as api from '../modules/messaging.js';
|
|
2
2
|
import type { Kept } from './local.js';
|
|
3
3
|
import { Outbox, type OutboxItem, type SendOutcome } from './outbox.js';
|
|
4
|
-
import { Store, type Changes, type Message, type Touched } from './store.js';
|
|
4
|
+
import { Store, type Changes, type DeletedGroup, type Message, type Touched } from './store.js';
|
|
5
5
|
export type Entry = {
|
|
6
6
|
kind: 'message';
|
|
7
7
|
message: Message;
|
|
@@ -13,7 +13,9 @@ export declare class Engine {
|
|
|
13
13
|
readonly store: Store;
|
|
14
14
|
readonly outbox: Outbox;
|
|
15
15
|
readonly me: string;
|
|
16
|
-
|
|
16
|
+
/** Its clock (ms): what says a deleted group may no longer be reported. */
|
|
17
|
+
readonly now: () => number;
|
|
18
|
+
constructor(me: string, now?: () => number);
|
|
17
19
|
apply(ch: Changes): Touched;
|
|
18
20
|
reset(ch: Changes): Touched;
|
|
19
21
|
private settled;
|
|
@@ -34,6 +36,8 @@ export declare class Engine {
|
|
|
34
36
|
/** A thread's answers, then what is on its way to it. */
|
|
35
37
|
answers(conversationId: string, rootId: string): Entry[];
|
|
36
38
|
private entries;
|
|
39
|
+
/** The groups a person deleted that may still be reported, the latest to stop first. */
|
|
40
|
+
deletedGroups(): DeletedGroup[];
|
|
37
41
|
kept(): Kept;
|
|
38
42
|
load(k: Kept): void;
|
|
39
43
|
}
|
|
@@ -4,6 +4,19 @@ export type Member = api.Member;
|
|
|
4
4
|
export type Message = api.Message;
|
|
5
5
|
export type ThreadState = api.ThreadState;
|
|
6
6
|
export type ScheduledMessage = api.ScheduledMessage;
|
|
7
|
+
/** A group a person deleted, as the device keeps it while those who were in it may still report it. */
|
|
8
|
+
export interface DeletedGroup {
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Its title as the device had it: null when the device no longer had the group as the word came — one it never had,
|
|
12
|
+
* or, on the deleter's own device, one its app took from the list before the server's word with its days arrived.
|
|
13
|
+
*/
|
|
14
|
+
title: string | null;
|
|
15
|
+
/** Who deleted it: null when no one is known any more. */
|
|
16
|
+
deletedBy: string | null;
|
|
17
|
+
/** Until when it may be reported (POST /messaging/reports naming it, no message), ISO 8601. */
|
|
18
|
+
reportableUntil: string;
|
|
19
|
+
}
|
|
7
20
|
/** What changed for the reader: a sync page's, or a live `changes` event's. */
|
|
8
21
|
export interface Changes {
|
|
9
22
|
conversations?: Conversation[];
|
|
@@ -22,10 +35,11 @@ export interface Snapshot {
|
|
|
22
35
|
messages: Message[];
|
|
23
36
|
threads: ThreadState[];
|
|
24
37
|
scheduled: ScheduledMessage[];
|
|
38
|
+
deleted: DeletedGroup[];
|
|
25
39
|
}
|
|
26
40
|
/** What changed in the store by one apply: what its views read again. */
|
|
27
41
|
export interface Touched {
|
|
28
|
-
/** The list of conversations (an order, an unread count, a last message). */
|
|
42
|
+
/** The list of conversations (an order, an unread count, a last message), and the groups deleted from it. */
|
|
29
43
|
list: boolean;
|
|
30
44
|
/** Conversations whose messages, members or details changed. */
|
|
31
45
|
conversations: Set<string>;
|
|
@@ -45,11 +59,14 @@ export declare class Store {
|
|
|
45
59
|
/** By the thread's root. */
|
|
46
60
|
readonly threads: Map<string, api.ThreadState>;
|
|
47
61
|
readonly scheduled: Map<string, api.ScheduledMessage>;
|
|
62
|
+
/** Groups a person deleted, by id: kept while they may be reported. */
|
|
63
|
+
readonly deleted: Map<string, DeletedGroup>;
|
|
48
64
|
constructor(reader: string);
|
|
49
65
|
/** Applies what changed; answers what of the store it touched. */
|
|
50
66
|
apply(ch: Changes): Touched;
|
|
51
|
-
/** A sync that starts again (reset): what the store kept goes, then the page is applied. */
|
|
67
|
+
/** A sync that starts again (reset): what the store kept goes — but the groups deleted, which no page carries again — then the page is applied. */
|
|
52
68
|
reset(ch: Changes): Touched;
|
|
69
|
+
private removed;
|
|
53
70
|
private drop;
|
|
54
71
|
private putConversation;
|
|
55
72
|
private putMember;
|
|
@@ -74,6 +91,8 @@ export declare class Store {
|
|
|
74
91
|
timeline(conversationId: string): Message[];
|
|
75
92
|
/** A thread's answers, the oldest first. */
|
|
76
93
|
answers(conversationId: string, rootId: string): Message[];
|
|
94
|
+
/** The groups a person deleted that may still be reported at now (ms), the latest to stop first, then by id: those past it go. */
|
|
95
|
+
deletedGroups(now: number): DeletedGroup[];
|
|
77
96
|
membersOf(conversationId: string): Member[];
|
|
78
97
|
snapshot(): Snapshot;
|
|
79
98
|
load(s: Snapshot): void;
|
|
@@ -391,6 +391,19 @@ export type DirectRequest = {
|
|
|
391
391
|
*/
|
|
392
392
|
user_id: string;
|
|
393
393
|
};
|
|
394
|
+
/**
|
|
395
|
+
* What an edited message said before a change.
|
|
396
|
+
*/
|
|
397
|
+
export type EarlierVersion = {
|
|
398
|
+
/**
|
|
399
|
+
* When it was changed.
|
|
400
|
+
*/
|
|
401
|
+
replaced_at: string;
|
|
402
|
+
/**
|
|
403
|
+
* What it said.
|
|
404
|
+
*/
|
|
405
|
+
text: string;
|
|
406
|
+
};
|
|
394
407
|
/**
|
|
395
408
|
* A message's new words.
|
|
396
409
|
*/
|
|
@@ -964,15 +977,31 @@ export type RemovedConversation = {
|
|
|
964
977
|
* The conversation.
|
|
965
978
|
*/
|
|
966
979
|
conversation_id: string;
|
|
980
|
+
/**
|
|
981
|
+
* The person who deleted the group (absent: the project's server, or no one known any more).
|
|
982
|
+
*/
|
|
983
|
+
deleted_by?: string | null;
|
|
967
984
|
/**
|
|
968
985
|
* Why: deleted.
|
|
969
986
|
*/
|
|
970
987
|
reason: string;
|
|
988
|
+
/**
|
|
989
|
+
* For a group a person deleted: until when those who were in it still report it (POST /messaging/reports, naming the conversation), 14 days after it was deleted. Absent once that is past, or when the project's server deleted it.
|
|
990
|
+
*/
|
|
991
|
+
reportable_until?: string | null;
|
|
971
992
|
};
|
|
972
993
|
/**
|
|
973
994
|
* A report as the project's server reads it.
|
|
974
995
|
*/
|
|
975
996
|
export type Report = {
|
|
997
|
+
/**
|
|
998
|
+
* For a report of a group a person had deleted: when they deleted it.
|
|
999
|
+
*/
|
|
1000
|
+
conversation_deleted_at: string | null;
|
|
1001
|
+
/**
|
|
1002
|
+
* Who deleted it (null when not deleted, or no one known any more).
|
|
1003
|
+
*/
|
|
1004
|
+
conversation_deleted_by: string | null;
|
|
976
1005
|
/**
|
|
977
1006
|
* The conversation.
|
|
978
1007
|
*/
|
|
@@ -1087,7 +1116,7 @@ export type ReportRequest = {
|
|
|
1087
1116
|
*/
|
|
1088
1117
|
conversation_id: string;
|
|
1089
1118
|
/**
|
|
1090
|
-
* Messages the reader sees in it (at most 50).
|
|
1119
|
+
* Messages the reader sees in it (at most 50). Naming none for a group a person deleted, the last 30 messages the reader saw go with the report.
|
|
1091
1120
|
*/
|
|
1092
1121
|
message_ids?: string[];
|
|
1093
1122
|
/**
|
|
@@ -1115,6 +1144,10 @@ export type ReportedMessage = {
|
|
|
1115
1144
|
* When it was sent.
|
|
1116
1145
|
*/
|
|
1117
1146
|
created_at: string;
|
|
1147
|
+
/**
|
|
1148
|
+
* What it said before its edits, the oldest first: the versions changed while the reporter was in the conversation, kept 14 days after each change.
|
|
1149
|
+
*/
|
|
1150
|
+
earlier_versions: EarlierVersion[];
|
|
1118
1151
|
/**
|
|
1119
1152
|
* The message.
|
|
1120
1153
|
*/
|
|
@@ -1693,7 +1726,7 @@ export declare function client(t: Transport): {
|
|
|
1693
1726
|
/**
|
|
1694
1727
|
* Delete a conversation
|
|
1695
1728
|
*
|
|
1696
|
-
* The conversation goes for everyone, its messages, files and keys with it. In the access log.
|
|
1729
|
+
* The conversation goes for everyone, its messages, files and keys with it, at once — a group a person deleted, still sealed for reports, too. In the access log.
|
|
1697
1730
|
*/
|
|
1698
1731
|
adminDeleteConversation(input: {
|
|
1699
1732
|
path: {
|
|
@@ -1805,7 +1838,7 @@ export declare function client(t: Transport): {
|
|
|
1805
1838
|
/**
|
|
1806
1839
|
* One report, with what it carries
|
|
1807
1840
|
*
|
|
1808
|
-
* A report with its reporter's note and what the messages it names said when reported (their files with the keys that open them; a message already gone from its reader's screen — seen once, its time up, vanish mode, taken back — as it was kept for reports, 14 days). In the access log. An owner's or an admin's read from Studio or with a token: a member sees the conversations and the reports, not what was said. A report is kept
|
|
1841
|
+
* A report with its reporter's note and what the messages it names said when reported (their files with the keys that open them; a message already gone from its reader's screen — seen once, its time up, vanish mode, taken back — as it was kept for reports, 14 days). In the access log. An owner's or an admin's read from Studio or with a token: a member sees the conversations and the reports, not what was said. A report is kept 190 days once resolved, two years never resolved.
|
|
1809
1842
|
*/
|
|
1810
1843
|
adminGetReport(input: {
|
|
1811
1844
|
path: {
|
|
@@ -1918,7 +1951,7 @@ export declare function client(t: Transport): {
|
|
|
1918
1951
|
/**
|
|
1919
1952
|
* Delete a group for everyone
|
|
1920
1953
|
*
|
|
1921
|
-
* A group's owner or admin deletes it for everyone:
|
|
1954
|
+
* A group's owner or admin deletes it for everyone: it goes from their lists at once (`removed`, with `reportable_until`), and what it said, its files and its keys stay sealed 14 days for those who were in it to report it, then go. A direct conversation is cleared, not deleted (…/clear).
|
|
1922
1955
|
*/
|
|
1923
1956
|
deleteConversation(input: {
|
|
1924
1957
|
path: {
|
|
@@ -2069,7 +2102,7 @@ export declare function client(t: Transport): {
|
|
|
2069
2102
|
/**
|
|
2070
2103
|
* Change a message
|
|
2071
2104
|
*
|
|
2072
|
-
* Its writer changes what a message says, within 15 minutes of sending it; its files stay.
|
|
2105
|
+
* Its writer changes what a message says, within 15 minutes of sending it; its files stay. What it said before is kept 14 days, sealed, for a report alone.
|
|
2073
2106
|
*/
|
|
2074
2107
|
editMessage(input: {
|
|
2075
2108
|
path: {
|
|
@@ -2254,7 +2287,7 @@ export declare function client(t: Transport): {
|
|
|
2254
2287
|
/**
|
|
2255
2288
|
* Report a conversation, a person or messages
|
|
2256
2289
|
*
|
|
2257
|
-
* The reader reports a conversation, someone in it or messages they see in it, saying why. What the messages say is kept with the report, sealed — it outlives them — and the project's backend is told (`messaging.report.created`) to read it with its secret key.
|
|
2290
|
+
* The reader reports a conversation, someone in it or messages they see in it, saying why. What the messages say is kept with the report, sealed — it outlives them — with what they said before an edit, and the project's backend is told (`messaging.report.created`) to read it with its secret key. A group a person deleted is reported, for 14 days, by those who were in it: naming no message, its last 30 the reader saw go with the report.
|
|
2258
2291
|
*/
|
|
2259
2292
|
report(input: {
|
|
2260
2293
|
body: ReportRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Scheme = 'ApiKeyAuth' | 'SecretKeyAuth' | 'AdminAuth' | 'userJWT' | 'OAuthClient' | 'OAuthAccessToken';
|
|
1
|
+
export type Scheme = 'ApiKeyAuth' | 'SecretKeyAuth' | 'AdminAuth' | 'userJWT' | 'OAuthClient' | 'OAuthAccessToken' | 'PalbaseBearer';
|
|
2
2
|
export interface Credentials {
|
|
3
3
|
/** pb_<ref>_c…: ships in apps. */
|
|
4
4
|
publishableKey?: string;
|
|
@@ -6,6 +6,13 @@ export interface Credentials {
|
|
|
6
6
|
secretKey?: string;
|
|
7
7
|
/** The signed-in user's access token, asked for on every call that takes one. */
|
|
8
8
|
accessToken?: () => string | undefined | Promise<string | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* An access token of an organization (pbo_…) or an environment (pbe_…):
|
|
11
|
+
* servers only. It stands where a server's credential does — the secret
|
|
12
|
+
* key's AdminAuth and SecretKeyAuth, Studio's PalbaseBearer — and goes as
|
|
13
|
+
* Authorization: Bearer, with no apikey.
|
|
14
|
+
*/
|
|
15
|
+
token?: string;
|
|
9
16
|
}
|
|
10
17
|
export type AnswerKind = 'json' | 'empty' | 'raw' | 'redirect';
|
|
11
18
|
export interface CallSpec {
|
|
@@ -23,6 +30,8 @@ export interface CallSpec {
|
|
|
23
30
|
};
|
|
24
31
|
/** The contract takes an Idempotency-Key on this write. */
|
|
25
32
|
idempotent?: boolean;
|
|
33
|
+
/** The handler answers with its own Response (the contract declares no answer but its default): any 2xx is the answer, read as it is. */
|
|
34
|
+
ownResponse?: boolean;
|
|
26
35
|
signal?: AbortSignal;
|
|
27
36
|
/** The request outlives the page that sends it (fetch keepalive: 64 KiB of body at most) — what a page sends as it closes. */
|
|
28
37
|
keepalive?: boolean;
|
package/types/web/src/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { connectVoice, type StartedVoice, type VoiceConnection, type VoiceOption
|
|
|
10
10
|
export { Purchases, redemptionToken, type CheckoutSource, type CustomerInfo, type CustomerInfoListener, type GrantInfo, type MergeGrant, type OfferView, type Offerings, type Redeemed, type RedemptionLink, } from './purchases.js';
|
|
11
11
|
export { Notify, WebPush, type PushPermission, type PushSubscribeOptions } from './notify.js';
|
|
12
12
|
export { Flags, type FlagSource, type FlagsListener } from './flags.js';
|
|
13
|
-
export { ConversationList, ConversationView, indexedDBKeyValue, Messaging, ScheduledList, ThreadView, type Conversation, type ConversationViewState, type ConversationListState, type Entry, type Member, type Message, type MessagingOptions, type MyProfile, type Observed, type OpenedFile, type OutboxItem, type OutgoingFile, type Profile, type ScheduledMessage, type SendOptions, type ThreadState, type ThreadViewState, } from './messaging.js';
|
|
13
|
+
export { ConversationList, ConversationView, DeletedGroupList, indexedDBKeyValue, Messaging, ScheduledList, ThreadView, type Conversation, type ConversationViewState, type ConversationListState, type DeletedGroup, type DeletedGroupListState, type Entry, type Member, type Message, type MessagingOptions, type MyProfile, type Observed, type OpenedFile, type OutboxItem, type OutgoingFile, type Profile, type ScheduledMessage, type SendOptions, type ThreadState, type ThreadViewState, } from './messaging.js';
|
|
14
14
|
export { Inbox, type InboxItem, type InboxListOptions, type InboxPage, type InboxView, type InboxViewOptions } from './inbox.js';
|
|
15
15
|
export { InApp, SESSION_START, type InAppOptions } from './inapp.js';
|
|
16
16
|
export type { Paywall, PaywallRenderOptions } from './paywall/placement.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { messaging as api } from '../../internal/src/modules/index.js';
|
|
2
|
-
import { Engine, type Entry, type KeyValue, type OutboxItem, type Touched } from '../../internal/src/messaging/index.js';
|
|
2
|
+
import { Engine, type DeletedGroup, type Entry, type KeyValue, type OutboxItem, type Touched } from '../../internal/src/messaging/index.js';
|
|
3
3
|
import { type Fetch, type Transport } from '../../internal/src/transport.js';
|
|
4
4
|
import { type SessionManager } from './session.js';
|
|
5
5
|
import type { RealtimeSocket } from './socket.js';
|
|
@@ -10,7 +10,7 @@ export type MyProfile = api.MyProfile;
|
|
|
10
10
|
export type Profile = api.Profile;
|
|
11
11
|
export type ScheduledMessage = api.ScheduledMessage;
|
|
12
12
|
export type ThreadState = api.ThreadState;
|
|
13
|
-
export type { Entry, OutboxItem } from '../../internal/src/messaging/index.js';
|
|
13
|
+
export type { DeletedGroup, Entry, OutboxItem } from '../../internal/src/messaging/index.js';
|
|
14
14
|
export interface MessagingOptions {
|
|
15
15
|
/**
|
|
16
16
|
* What the device keeps of a person's conversations when they sign out:
|
|
@@ -74,6 +74,10 @@ export interface ConversationListState {
|
|
|
74
74
|
/** The device's copy was drawn and the sync has caught up. */
|
|
75
75
|
synced: boolean;
|
|
76
76
|
}
|
|
77
|
+
export interface DeletedGroupListState {
|
|
78
|
+
/** The groups deleted that the person may still report, the latest to stop first. */
|
|
79
|
+
items: DeletedGroup[];
|
|
80
|
+
}
|
|
77
81
|
export interface ConversationViewState {
|
|
78
82
|
conversation: Conversation | null;
|
|
79
83
|
/** Its timeline: its messages, the oldest first, then what is on its way. */
|
|
@@ -154,6 +158,8 @@ export declare class Messaging {
|
|
|
154
158
|
private after;
|
|
155
159
|
/** A message whose time is up goes from the device at once: the server says so too, a moment after. */
|
|
156
160
|
private expireAt;
|
|
161
|
+
/** A group deleted goes from deletedGroups() once it may no longer be reported: the views hear it then. */
|
|
162
|
+
private expireDeleted;
|
|
157
163
|
private deliver;
|
|
158
164
|
private save;
|
|
159
165
|
/** Sends what waits, in each conversation's order; tries again later while the network or the server is away. */
|
|
@@ -168,6 +174,13 @@ export declare class Messaging {
|
|
|
168
174
|
private tell;
|
|
169
175
|
/** The person's conversations, the latest first, kept up to date. */
|
|
170
176
|
conversations(): ConversationList;
|
|
177
|
+
/**
|
|
178
|
+
* The groups the person was in that someone deleted, kept up to date while the person may still report them
|
|
179
|
+
* (reportableUntil, 14 days after), the latest to stop first: report() names one by its id, no message needed. A
|
|
180
|
+
* group the project's server deleted is not among them. A title may be null: the device did not have the group as
|
|
181
|
+
* the word came (on the deleter's own device, now and then, the group the person deleted).
|
|
182
|
+
*/
|
|
183
|
+
deletedGroups(): DeletedGroupList;
|
|
171
184
|
/** A conversation of the person's, kept up to date: its timeline, its members, who is typing. */
|
|
172
185
|
conversation(conversationId: string): ConversationView;
|
|
173
186
|
/** The direct conversation with someone — the one there is, or a new one. */
|
|
@@ -227,6 +240,11 @@ export declare class Messaging {
|
|
|
227
240
|
profiles(userIds: string[]): Promise<Profile[]>;
|
|
228
241
|
block(userId: string): Promise<void>;
|
|
229
242
|
unblock(userId: string): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Reports a conversation, someone in it (user_id) or messages they see in it (message_ids), saying why: what the
|
|
245
|
+
* messages say is kept with the report, sealed. A group from deletedGroups() is reported by its id until its
|
|
246
|
+
* reportableUntil, naming no message: the last 30 messages the person saw in it go with the report.
|
|
247
|
+
*/
|
|
230
248
|
report(input: api.ReportRequest): Promise<api.ReportCreated>;
|
|
231
249
|
}
|
|
232
250
|
declare abstract class View<S> implements Observed<S> {
|
|
@@ -247,6 +265,10 @@ export declare class ConversationList extends View<ConversationListState> {
|
|
|
247
265
|
protected touches(t: Touched): boolean;
|
|
248
266
|
protected read(): ConversationListState;
|
|
249
267
|
}
|
|
268
|
+
export declare class DeletedGroupList extends View<DeletedGroupListState> {
|
|
269
|
+
protected touches(t: Touched): boolean;
|
|
270
|
+
protected read(): DeletedGroupListState;
|
|
271
|
+
}
|
|
250
272
|
export declare class ConversationView extends View<ConversationViewState> {
|
|
251
273
|
readonly id: string;
|
|
252
274
|
constructor(m: Messaging, id: string);
|
package/dist/chunks/5FJ5HY4N.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! palbase 0.18.5 — Palbase SDK License (see LICENSE) */
|
|
2
|
-
import{a as g,b}from"./2CZIJUEA.js";var A=Symbol.for("palbase.data"),T=globalThis,m=T[A]??=new WeakSet;function S(t){return t instanceof Date||ArrayBuffer.isView(t)||t instanceof ArrayBuffer}function k(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!(typeof n!="object"||n===null||m.has(n)||S(n))){m.add(n);for(let a of Array.isArray(n)?n:Object.values(n))e.push(a)}}return t}var l=class extends Error{status;code;requestId;retryAfter;body;op;get isNetworkError(){return this.code==="network_error"}constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause}),this.name="PalbaseError",this.op=e.op,this.status=e.status,this.code=e.code,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.body=e.body}};function C(t,e,n){let a=String(n);if(a===""||a==="."||a==="..")throw new l({op:t,status:0,code:"invalid_path_parameter",message:`${t}: ${e} cannot be ${a===""?"empty":JSON.stringify(a)}`});return encodeURIComponent(a)}var x=new Set(["apikey","authorization"]),q=64*1024;function W(t){let e=E(t.baseUrl),n=t.fetch??globalThis.fetch,a=t.solveProofOfWork??!0,u=async(r,o)=>{let d=v(e,r),s=new Headers;for(let[h,y]of Object.entries(r.headers??{}))y!=null&&!x.has(h.toLowerCase())&&s.set(h,String(y));for(let[h,y]of Object.entries(o))s.set(h,y);await j(r,t.credentials,s),s.has("accept")||s.set("accept","application/json");let f={method:r.method,headers:s,redirect:"manual",signal:r.signal,...r.keepalive?{keepalive:!0}:{}};r.body&&r.body.value!==void 0&&(s.set("content-type",r.body.contentType),f.body=L(r.body.kind,r.body.value),R(f.body)||(f.duplex="half"));let i;try{i=r.onUploadProgress&&t.xmlHttpRequest?await U(t.xmlHttpRequest,r.op,d,f,r.onUploadProgress):await n(d,f)}catch(h){throw r.signal?.aborted||h instanceof l?h:new l({op:r.op,status:0,code:"network_error",message:`${r.op}: the request did not reach ${e.origin}`,cause:h})}let c=r.answers[i.status];if(c===void 0)throw i.status>=200&&i.status<300?(await i.body?.cancel(),new l({op:r.op,status:i.status,code:"undeclared_answer",message:`${r.op}: the server answered ${i.status}, which its contract does not declare; the request may have taken effect`})):await P(r.op,i);let p;switch(c){case"json":try{p=k(await i.json())}catch(h){throw new l({op:r.op,status:i.status,code:"invalid_json",message:`${r.op}: the answer is not JSON`,cause:h})}break;case"raw":p=i;break;default:await i.body?.cancel(),p=void 0}return{status:i.status,data:p,headers:i.headers}};return{async send(r){try{return await u(r,{})}catch(o){let d=a&&o instanceof l&&o.status===403?g(o.body):null,s=r.body?.value;if(!d||r.body?.kind==="raw"&&!R(s))throw o;let f=o,i;try{i=await b(d,{signal:r.signal})}catch(c){throw r.signal?.aborted?c:new l({op:r.op,status:403,code:"pow_unsolved",message:`${r.op}: ${c instanceof Error?c.message:String(c)}`,requestId:f.requestId,body:f.body,cause:c})}return u(r,i)}}}}function U(t,e,n,a,u){return new Promise((r,o)=>{let d=a.signal;if(d?.aborted)return o(d.reason);let s=new t,f=()=>s.abort();d?.addEventListener("abort",f,{once:!0});let i=c=>{d?.removeEventListener("abort",f),c()};s.open(a.method??"GET",n.href),s.responseType="arraybuffer",new Headers(a.headers).forEach((c,p)=>s.setRequestHeader(p,c)),s.upload&&(s.upload.onprogress=c=>{c.lengthComputable&&u(c.loaded,c.total)}),s.onload=()=>i(()=>{if(s.responseURL!==""&&s.responseURL!==n.href){o(new l({op:e,status:0,code:"undeclared_redirect",message:`${e}: the server redirected; the answer is another address's, and was not read`}));return}if(s.status<200||s.status>599)return o(new TypeError(`${e}: answered ${s.status}`));let c=s.status===204||s.status===205||s.status===304;r(new Response(c?null:s.response,{status:s.status,statusText:s.statusText,headers:$(s.getAllResponseHeaders())}))}),s.onerror=()=>i(()=>o(new TypeError(`${e}: the request failed`))),s.onabort=()=>i(()=>o(d?.reason??new DOMException("The request was aborted","AbortError"))),s.send(a.body)})}function $(t){let e=new Headers;for(let n of t.split(/\r?\n/)){let a=n.indexOf(":");if(!(a<=0))try{e.append(n.slice(0,a).trim(),n.slice(a+1).trim())}catch{}}return e}function E(t){let e;try{e=new URL(t)}catch{throw new TypeError(`baseUrl ${JSON.stringify(t)} is not an absolute URL`)}let n=e.hostname==="localhost"||e.hostname.endsWith(".localhost")||e.hostname==="127.0.0.1"||e.hostname==="[::1]";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${e.origin}`);if(e.username||e.password||e.search||e.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(e.pathname!=="/"&&e.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return e}function v(t,e){if(!e.path.startsWith("/")||e.path.startsWith("//"))throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path ${JSON.stringify(e.path)} is not absolute`});let n=new URL(e.path+O(e.query),t);if(n.origin!==t.origin)throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path leaves the project's origin`});return n}async function j(t,e,n){if(t.auth.length===0)return;let a=t.auth.some(o=>o.includes("userJWT"))?await e.accessToken?.():void 0,u=o=>{switch(o){case"ApiKeyAuth":return!!(e.publishableKey??e.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!e.secretKey;case"userJWT":return!!a;default:return!1}},r=t.auth.filter(o=>o.every(u)).reduce((o,d)=>o===void 0||d.length>o.length?d:o,void 0);if(!r)throw new l({op:t.op,status:0,code:"missing_credential",message:`${t.op} needs one of: ${t.auth.map(o=>o.length===0?"nothing":o.join(" + ")).join(" | ")}`});for(let o of r)o==="ApiKeyAuth"?n.set("apikey",e.publishableKey??e.secretKey):o==="SecretKeyAuth"||o==="AdminAuth"?n.set("apikey",e.secretKey):o==="userJWT"&&n.set("authorization",`Bearer ${a}`)}function L(t,e){switch(t){case"json":return JSON.stringify(e);case"form":{let n=new URLSearchParams;for(let[a,u]of Object.entries(e))w(n,a,u);return n}case"raw":return e}}function R(t){return!!(t==null||typeof t=="string"||t instanceof URLSearchParams||t instanceof Blob||t instanceof FormData||t instanceof ArrayBuffer||ArrayBuffer.isView(t))}function O(t){if(!t)return"";let e=new URLSearchParams;for(let[a,u]of Object.entries(t))w(e,a,u);let n=e.toString();return n===""?"":`?${n}`}function w(t,e,n){if(n!=null){if(Array.isArray(n)){for(let a of n)w(t,e,a);return}if(n instanceof Date){t.append(e,n.toISOString());return}t.append(e,typeof n=="object"?JSON.stringify(n):String(n))}}async function P(t,e){let n=await _(e,q).catch(()=>""),a;try{a=n===""?void 0:JSON.parse(n)}catch{a=n}let u=B(a)?a:void 0,r=Number(e.headers.get("retry-after")),o=e.status>=300&&e.status<400;return new l({op:t,status:e.status,code:u?.error??(o?"undeclared_redirect":`http_${e.status}`),message:u?.error_description??(o?`${t}: the server redirected (${e.status}); the request was not followed, its credentials stay here`:`${t}: ${e.status} ${e.statusText}`.trim()),requestId:u?.request_id??e.headers.get("x-request-id")??void 0,retryAfter:u?.retry_after??(Number.isFinite(r)&&r>0?r:void 0),body:a})}async function _(t,e){if(!t.body)return"";let n=t.body.getReader(),a=[],u=0;for(;u<e;){let{done:d,value:s}=await n.read();if(d)break;a.push(s),u+=s.byteLength}await n.cancel().catch(()=>{});let r=new Uint8Array(Math.min(u,e)),o=0;for(let d of a){let s=Math.min(d.byteLength,r.byteLength-o);if(r.set(d.subarray(0,s),o),o+=s,o>=r.byteLength)break}return new TextDecoder().decode(r)}function B(t){return typeof t=="object"&&t!==null&&typeof t.error=="string"}export{k as a,l as b,C as c,W as d,E as e,R as f};
|