@graview/core 0.2.16 → 0.2.18
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 +9 -0
- package/dist/app-places.d.ts.map +1 -1
- package/dist/app-places.js +3 -1
- package/dist/app-places.js.map +1 -1
- package/dist/app.d.ts +13 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -1
- package/dist/app.js.map +1 -1
- package/dist/beginning.d.ts.map +1 -1
- package/dist/beginning.js +6 -2
- package/dist/beginning.js.map +1 -1
- package/dist/catalog.d.ts +52 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +145 -0
- package/dist/catalog.js.map +1 -1
- package/dist/city.d.ts.map +1 -1
- package/dist/city.js +3 -1
- package/dist/city.js.map +1 -1
- package/dist/cli/check/index.d.ts +1 -0
- package/dist/cli/check/index.d.ts.map +1 -1
- package/dist/cli/check/index.js +1 -0
- package/dist/cli/check/index.js.map +1 -1
- package/dist/cli/check/policy.d.ts.map +1 -1
- package/dist/cli/check/policy.js +3 -1
- package/dist/cli/check/policy.js.map +1 -1
- package/dist/cli/check/rooms.d.ts +10 -0
- package/dist/cli/check/rooms.d.ts.map +1 -0
- package/dist/cli/check/rooms.js +23 -0
- package/dist/cli/check/rooms.js.map +1 -0
- package/dist/cli/check.d.ts +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +18 -2
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/describe.d.ts +1 -1
- package/dist/cli/describe.d.ts.map +1 -1
- package/dist/cli/describe.js +38 -4
- package/dist/cli/describe.js.map +1 -1
- package/dist/cli/document-schema.d.ts.map +1 -1
- package/dist/cli/document-schema.js +21 -0
- package/dist/cli/document-schema.js.map +1 -1
- package/dist/compose-home.js +1 -1
- package/dist/compose-home.js.map +1 -1
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +3 -1
- package/dist/conformance/index.js.map +1 -1
- package/dist/document/compile-checked.d.ts.map +1 -1
- package/dist/document/compile-checked.js +3 -2
- package/dist/document/compile-checked.js.map +1 -1
- package/dist/document/compiled.d.ts.map +1 -1
- package/dist/document/compiled.js +9 -1
- package/dist/document/compiled.js.map +1 -1
- package/dist/document/graview-template.d.ts +3 -3
- package/dist/document/purpose-spec.d.ts +2 -2
- package/dist/document/schema.d.ts +22 -21
- package/dist/document/schema.d.ts.map +1 -1
- package/dist/document/schema.js +6 -0
- package/dist/document/schema.js.map +1 -1
- package/dist/document/to-document.d.ts +1 -1
- package/dist/document/to-document.d.ts.map +1 -1
- package/dist/document/to-document.js +6 -2
- package/dist/document/to-document.js.map +1 -1
- package/dist/document/workflow-spec.d.ts +2 -2
- package/dist/document.schema.json +53 -2
- package/dist/field-sight.d.ts.map +1 -1
- package/dist/field-sight.js +6 -1
- package/dist/field-sight.js.map +1 -1
- package/dist/friction-record.d.ts +8 -0
- package/dist/friction-record.d.ts.map +1 -1
- package/dist/friction-record.js +25 -0
- package/dist/friction-record.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/installation.d.ts +2 -2
- package/dist/installation.d.ts.map +1 -1
- package/dist/installation.js +2 -0
- package/dist/installation.js.map +1 -1
- package/dist/mutations/define-mutation.d.ts +3 -0
- package/dist/mutations/define-mutation.d.ts.map +1 -1
- package/dist/mutations/define-mutation.js +2 -0
- package/dist/mutations/define-mutation.js.map +1 -1
- package/dist/mutations/derive-edits.d.ts.map +1 -1
- package/dist/mutations/derive-edits.js +7 -0
- package/dist/mutations/derive-edits.js.map +1 -1
- package/dist/mutations/derive-relations.d.ts.map +1 -1
- package/dist/mutations/derive-relations.js +4 -0
- package/dist/mutations/derive-relations.js.map +1 -1
- package/dist/mutations/derive-repeats.d.ts.map +1 -1
- package/dist/mutations/derive-repeats.js +4 -0
- package/dist/mutations/derive-repeats.js.map +1 -1
- package/dist/mutations/types.d.ts +24 -0
- package/dist/mutations/types.d.ts.map +1 -1
- package/dist/mutations/visitor-form.js +1 -1
- package/dist/mutations/visitor-form.js.map +1 -1
- package/dist/ops/digest.d.ts +2 -1
- package/dist/ops/digest.d.ts.map +1 -1
- package/dist/ops/digest.js +7 -1
- package/dist/ops/digest.js.map +1 -1
- package/dist/permissions/policy.d.ts +16 -0
- package/dist/permissions/policy.d.ts.map +1 -1
- package/dist/permissions/policy.js +16 -0
- package/dist/permissions/policy.js.map +1 -1
- package/dist/permissions/sight.d.ts +9 -0
- package/dist/permissions/sight.d.ts.map +1 -1
- package/dist/permissions/sight.js +18 -0
- package/dist/permissions/sight.js.map +1 -1
- package/dist/permissions/types.d.ts +24 -0
- package/dist/permissions/types.d.ts.map +1 -1
- package/dist/permissions/types.js.map +1 -1
- package/dist/rooms/findings.d.ts +53 -0
- package/dist/rooms/findings.d.ts.map +1 -0
- package/dist/rooms/findings.js +109 -0
- package/dist/rooms/findings.js.map +1 -0
- package/dist/rooms/kind.d.ts +86 -0
- package/dist/rooms/kind.d.ts.map +1 -0
- package/dist/rooms/kind.js +530 -0
- package/dist/rooms/kind.js.map +1 -0
- package/dist/rooms/read.d.ts +164 -0
- package/dist/rooms/read.d.ts.map +1 -0
- package/dist/rooms/read.js +246 -0
- package/dist/rooms/read.js.map +1 -0
- package/dist/rooms/shape.d.ts +133 -0
- package/dist/rooms/shape.d.ts.map +1 -0
- package/dist/rooms/shape.js +71 -0
- package/dist/rooms/shape.js.map +1 -0
- package/dist/rooms/support-open.d.ts +7 -0
- package/dist/rooms/support-open.d.ts.map +1 -0
- package/dist/rooms/support-open.js +25 -0
- package/dist/rooms/support-open.js.map +1 -0
- package/dist/rooms/support.d.ts +95 -0
- package/dist/rooms/support.d.ts.map +1 -0
- package/dist/rooms/support.js +62 -0
- package/dist/rooms/support.js.map +1 -0
- package/dist/rooms.d.ts +12 -0
- package/dist/rooms.d.ts.map +1 -0
- package/dist/rooms.js +25 -0
- package/dist/rooms.js.map +1 -0
- package/dist/scaffold/domain.js +1 -1
- package/dist/scaffold/from-template.js +3 -3
- package/dist/scaffold/from-template.js.map +1 -1
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +2 -3
- package/dist/scaffold/index.js.map +1 -1
- package/dist/scaffold/names.d.ts +0 -1
- package/dist/scaffold/names.d.ts.map +1 -1
- package/dist/scaffold/names.js.map +1 -1
- package/dist/scaffold/project.d.ts.map +1 -1
- package/dist/scaffold/project.js +18 -13
- package/dist/scaffold/project.js.map +1 -1
- package/dist/scaffold/ui.d.ts +1 -1
- package/dist/scaffold/ui.d.ts.map +1 -1
- package/dist/scaffold/ui.js +115 -164
- package/dist/scaffold/ui.js.map +1 -1
- package/dist/seen.d.ts.map +1 -1
- package/dist/seen.js +84 -12
- package/dist/seen.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -2
- package/dist/store.js.map +1 -1
- package/dist/subscription-shape.d.ts +4 -0
- package/dist/subscription-shape.d.ts.map +1 -1
- package/dist/subscription-shape.js.map +1 -1
- package/dist/subscriptions.d.ts +8 -0
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/subscriptions.js +48 -2
- package/dist/subscriptions.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { GraviewApp } from "../app.js";
|
|
2
|
+
import type { AnySchema } from "../schema/schema.js";
|
|
3
|
+
import { type AppRooms, type MessageRecord, type RoomDeclaration } from "./shape.js";
|
|
4
|
+
/** A room with what it leaves unsaid said: its address word, and whether it reads mentions. */
|
|
5
|
+
export interface ResolvedRoom extends RoomDeclaration {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly mentions: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Every room an app declares, in the order it declares them. */
|
|
10
|
+
export declare function roomsOf(app: Pick<GraviewApp<AnySchema>, "rooms">): readonly ResolvedRoom[];
|
|
11
|
+
/** The app-wide rooms: about no one record, each a place of its own. */
|
|
12
|
+
export declare const appRooms: (app: Pick<GraviewApp<AnySchema>, "rooms">) => readonly ResolvedRoom[];
|
|
13
|
+
/** The threads a record has: each room declared `about` its kind. */
|
|
14
|
+
export declare function threadsOf(app: Pick<GraviewApp<AnySchema>, "rooms">, record: {
|
|
15
|
+
readonly kind: string;
|
|
16
|
+
} | undefined): readonly ResolvedRoom[];
|
|
17
|
+
/** The thread a record has — the first room declared `about` its kind — or none. */
|
|
18
|
+
export declare const threadOf: (app: Pick<GraviewApp<AnySchema>, "rooms">, record: {
|
|
19
|
+
readonly kind: string;
|
|
20
|
+
} | undefined) => ResolvedRoom | undefined;
|
|
21
|
+
/** Whether a seat holding these roles may read a room, by what the room says (its sight says it again, on the store). */
|
|
22
|
+
export declare const mayReadRoom: (room: RoomDeclaration, roles: readonly string[] | undefined) => boolean;
|
|
23
|
+
/** Whether a seat holding these roles may post in a room: its `post`, else its `read`, else anybody. */
|
|
24
|
+
export declare function mayPostIn(room: RoomDeclaration, roles: readonly string[] | undefined): boolean;
|
|
25
|
+
/** Whether a seat may remove a message: its own, or anybody's for a role the room lets moderate. */
|
|
26
|
+
export declare function mayRemove(room: RoomDeclaration | undefined, message: MessageRecord, seat: {
|
|
27
|
+
readonly id?: string | undefined;
|
|
28
|
+
readonly roles?: readonly string[] | undefined;
|
|
29
|
+
}): boolean;
|
|
30
|
+
/** Whether a seat may edit a message: its own, and not removed. */
|
|
31
|
+
export declare const mayEdit: (message: MessageRecord, seat: {
|
|
32
|
+
readonly id?: string | undefined;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
/** Every message a graph holds, in the order they were said. */
|
|
35
|
+
export declare function allMessages(graph: {
|
|
36
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
37
|
+
}): readonly MessageRecord[];
|
|
38
|
+
/** What was said in a room — or, with `about`, in the thread on that record — in the order it was said. */
|
|
39
|
+
export declare function messagesIn(graph: {
|
|
40
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
41
|
+
}, room: string, about?: string): readonly MessageRecord[];
|
|
42
|
+
/** A person of the app, as a mention names them. */
|
|
43
|
+
export interface Mentionable {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
}
|
|
47
|
+
/** The people a mention may name: every record of a kind that stands for the people, by its name. */
|
|
48
|
+
export declare function mentionablesOf(graph: {
|
|
49
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
50
|
+
}, schema: AnySchema): readonly Mentionable[];
|
|
51
|
+
/**
|
|
52
|
+
* WHOM A MESSAGE MENTIONS: each person named after an `@` — their whole
|
|
53
|
+
* name, or the first word of it where only one person's name begins so —
|
|
54
|
+
* case aside, each once, in the order they are first named. A word that
|
|
55
|
+
* names nobody, or two people at once, mentions nobody.
|
|
56
|
+
*/
|
|
57
|
+
export declare function mentionsIn(body: string, people: readonly Mentionable[]): readonly string[];
|
|
58
|
+
/** Where a person has read up to, by room (`roomKey`): the instant of the last message they have seen there. */
|
|
59
|
+
export type ReadUpTo = Readonly<Record<string, string>>;
|
|
60
|
+
/** What a person has not read: in all, by room or thread, by the thread of replies under one message, and how many of those name them. */
|
|
61
|
+
export interface Unread {
|
|
62
|
+
readonly total: number;
|
|
63
|
+
readonly mentions: number;
|
|
64
|
+
/** By room or record thread (`roomKey`): every unread message there, replies included — what the bell counts. */
|
|
65
|
+
readonly byRoom: Readonly<Record<string, number>>;
|
|
66
|
+
/** By room or record thread (`roomKey`): the unread messages there that name the person. */
|
|
67
|
+
readonly mentionsByRoom: Readonly<Record<string, number>>;
|
|
68
|
+
/** By the replies under one message (`threadKey`): the unread replies in each. */
|
|
69
|
+
readonly byThread: Readonly<Record<string, number>>;
|
|
70
|
+
/** By the replies under one message (`threadKey`): the unread replies in each that name the person. */
|
|
71
|
+
readonly mentionsByThread: Readonly<Record<string, number>>;
|
|
72
|
+
}
|
|
73
|
+
/** Where the replies under one message are read up to: its room's key (`roomKey`) and the message they hang from. */
|
|
74
|
+
export declare const threadKey: (room: string, about: string | undefined, root: string) => string;
|
|
75
|
+
/** The message a message's thread begins with: itself, or the first message the chain of answers it is part of goes back to, in its own room or thread. */
|
|
76
|
+
export declare function threadRootOf(message: MessageRecord, byId: ReadonlyMap<string, MessageRecord>): string;
|
|
77
|
+
/** One message and the replies filed under it, in the order they were said. */
|
|
78
|
+
export interface MessageThread {
|
|
79
|
+
readonly root: MessageRecord;
|
|
80
|
+
readonly replies: readonly MessageRecord[];
|
|
81
|
+
/** When the thread was last added to: its last reply, or the message itself. */
|
|
82
|
+
readonly lastAt: string;
|
|
83
|
+
}
|
|
84
|
+
/** Messages folded into threads: each message that answers none (or one not here) with the replies under it, in the order the threads began. */
|
|
85
|
+
export declare function threadsIn(messages: readonly MessageRecord[]): readonly MessageThread[];
|
|
86
|
+
/**
|
|
87
|
+
* WHAT A PERSON HAS NOT READ: every message in a room or thread after
|
|
88
|
+
* where they read up to there, said by somebody else and not removed —
|
|
89
|
+
* counted in all, by room (`roomKey`), and those that mention them.
|
|
90
|
+
* Handed the graph as they are served it, it counts only what they may
|
|
91
|
+
* read. A room they never opened counts from its first message. A reply
|
|
92
|
+
* is read once its own thread is (`threadKey`), never by the room read
|
|
93
|
+
* past it, and is counted by thread as well (`byThread`).
|
|
94
|
+
*/
|
|
95
|
+
export declare function unreadFor(person: string | undefined, graph: {
|
|
96
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
97
|
+
}, readUpTo: ReadUpTo, people?: readonly Mentionable[]): Unread;
|
|
98
|
+
/** A room's address word, said as words, for a room the app does not declare (one of the framework's own): "inline-ai" is "Inline AI". */
|
|
99
|
+
export declare function roomWords(room: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* ONE CONVERSATION: a room for the whole app, or the thread on one record
|
|
102
|
+
* — what a person sees in the list of every conversation they may read.
|
|
103
|
+
*/
|
|
104
|
+
export interface Conversation {
|
|
105
|
+
/** Where its messages are (`roomKey`). */
|
|
106
|
+
readonly key: string;
|
|
107
|
+
readonly room: string;
|
|
108
|
+
/** The record it is about; none for a room for the whole app. */
|
|
109
|
+
readonly about?: string;
|
|
110
|
+
/** The room's title: as the app declares it, else as the framework names its own room, else its address word in words. */
|
|
111
|
+
readonly title: string;
|
|
112
|
+
/** Whether the app declares the room (else it is one of the framework's own). */
|
|
113
|
+
readonly declared: boolean;
|
|
114
|
+
/** What is said there and not removed. */
|
|
115
|
+
readonly messages: number;
|
|
116
|
+
/** How many threads of replies it holds. */
|
|
117
|
+
readonly threads: number;
|
|
118
|
+
/** The last message said there, not removed. */
|
|
119
|
+
readonly last: MessageRecord;
|
|
120
|
+
readonly lastAt: string;
|
|
121
|
+
/** What the person has not read there, and how many of those name them. */
|
|
122
|
+
readonly unread: number;
|
|
123
|
+
readonly mentions: number;
|
|
124
|
+
}
|
|
125
|
+
export interface ConversationsOptions {
|
|
126
|
+
/** The rooms the app declares, as `roomsOf` resolves them: a room a seat may not read by its roles is left out. */
|
|
127
|
+
readonly rooms?: readonly ResolvedRoom[];
|
|
128
|
+
/** Who is reading, by id and roles: their own messages are never unread. */
|
|
129
|
+
readonly person?: string;
|
|
130
|
+
readonly roles?: readonly string[];
|
|
131
|
+
readonly readUpTo?: ReadUpTo;
|
|
132
|
+
readonly people?: readonly Mentionable[];
|
|
133
|
+
/** The title of a room the app does not declare — one of the framework's own. Unsaid, or saying nothing, its address word in words (`roomWords`). */
|
|
134
|
+
readonly titleOf?: (room: string) => string | undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* EVERY CONVERSATION IN THE GRAPH AS HANDED, newest activity first: each
|
|
138
|
+
* room and each record's thread with something said and not removed in
|
|
139
|
+
* it — whatever room it is, declared by the app or kept by the framework —
|
|
140
|
+
* with what the reader has not read there. Handed the graph a seat is
|
|
141
|
+
* served, it lists only what that seat may read.
|
|
142
|
+
*/
|
|
143
|
+
export declare function conversationsOf(graph: {
|
|
144
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
145
|
+
}, options?: ConversationsOptions): readonly Conversation[];
|
|
146
|
+
/**
|
|
147
|
+
* WHETHER A READER IS SHOWN A MESSAGE OF A CONVERSATION WITH THE AI: its
|
|
148
|
+
* asker, or anybody once it is shared. A host serves a seat only what its
|
|
149
|
+
* sight lets it see; this holds the same on a page handed the whole graph.
|
|
150
|
+
* A message of a room the app declares is always shown here.
|
|
151
|
+
*/
|
|
152
|
+
export declare const mayReadAiTurn: (message: Pick<MessageRecord, "room" | "asker" | "shared">, person: string | undefined) => boolean;
|
|
153
|
+
/** How much is said about each record, in every room and thread: its messages not removed, by the record's id — what a talk badge on the record counts; a conversation with the AI only for its asker, or once shared. */
|
|
154
|
+
export declare function talkAbout(graph: {
|
|
155
|
+
nodesOfKind(kind: string): readonly unknown[];
|
|
156
|
+
}, options?: {
|
|
157
|
+
readonly person?: string;
|
|
158
|
+
}): ReadonlyMap<string, number>;
|
|
159
|
+
/** The read-up-to markers a host kept for a person (`ViewerState.read(ROOMS_READ_STATE)`), only the ones that read as instants. */
|
|
160
|
+
export declare function readUpToOf(kept: Readonly<Record<string, string>> | undefined): ReadUpTo;
|
|
161
|
+
/** Whether rooms are declared at all: the one question a page asks before it fetches any of this. */
|
|
162
|
+
export declare const hasRooms: (app: Pick<GraviewApp<AnySchema>, "rooms">) => boolean;
|
|
163
|
+
export type { AppRooms };
|
|
164
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/rooms/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAA0C,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAU7H,+F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,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACzD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAAA;CAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,SAAS,YAAY,EAAE,CAkCrJ;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,QAAQ,MAAM,GAAG,SAAS,KAAG,OACA,CAAC;AAEvH,0NAA0N;AAC1N,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAAA;CAAE,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAO3J;AAED,mIAAmI;AACnI,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ,CAEvF;AAED,qGAAqG;AACrG,eAAO,MAAM,QAAQ,GAAI,KAAK,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,KAAG,OAA+D,CAAC;AAErI,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { labelOf } from "../schema/define-node.js";
|
|
2
|
+
import { unfoldedApp } from "./kind.js";
|
|
3
|
+
import { isFrameworkRoom, MESSAGE_KIND, roomKey } from "./shape.js";
|
|
4
|
+
/** Every room an app declares, in the order it declares them. */
|
|
5
|
+
export function roomsOf(app) {
|
|
6
|
+
return Object.entries(unfoldedApp(app).rooms ?? {}).map(([id, room]) => ({ ...room, id, mentions: room.mentions !== false }));
|
|
7
|
+
}
|
|
8
|
+
/** The app-wide rooms: about no one record, each a place of its own. */
|
|
9
|
+
export const appRooms = (app) => roomsOf(app).filter((room) => !room.about);
|
|
10
|
+
/** The threads a record has: each room declared `about` its kind. */
|
|
11
|
+
export function threadsOf(app, record) {
|
|
12
|
+
return record ? roomsOf(app).filter((room) => room.about === record.kind) : [];
|
|
13
|
+
}
|
|
14
|
+
/** The thread a record has — the first room declared `about` its kind — or none. */
|
|
15
|
+
export const threadOf = (app, record) => threadsOf(app, record)[0];
|
|
16
|
+
/** Whether a seat holding these roles may read a room, by what the room says (its sight says it again, on the store). */
|
|
17
|
+
export const mayReadRoom = (room, roles) => room.read === undefined || (roles ?? []).some((role) => room.read.includes(role));
|
|
18
|
+
/** Whether a seat holding these roles may post in a room: its `post`, else its `read`, else anybody. */
|
|
19
|
+
export function mayPostIn(room, roles) {
|
|
20
|
+
const allowed = room.post ?? room.read;
|
|
21
|
+
return allowed === undefined || (roles ?? []).some((role) => allowed.includes(role));
|
|
22
|
+
}
|
|
23
|
+
/** Whether a seat may remove a message: its own, or anybody's for a role the room lets moderate. */
|
|
24
|
+
export function mayRemove(room, message, seat) {
|
|
25
|
+
if (message.removed)
|
|
26
|
+
return false;
|
|
27
|
+
if (seat.id !== undefined && message.author === seat.id)
|
|
28
|
+
return true;
|
|
29
|
+
return room?.moderate !== undefined && (seat.roles ?? []).some((role) => room.moderate.includes(role));
|
|
30
|
+
}
|
|
31
|
+
/** Whether a seat may edit a message: its own, and not removed. */
|
|
32
|
+
export const mayEdit = (message, seat) => !message.removed && seat.id !== undefined && message.author === seat.id;
|
|
33
|
+
/** The order messages are read in: when they were said, and by id where two were said at once. */
|
|
34
|
+
const inOrder = (a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
35
|
+
/** Every message a graph holds, in the order they were said. */
|
|
36
|
+
export function allMessages(graph) {
|
|
37
|
+
return graph.nodesOfKind(MESSAGE_KIND).slice().sort(inOrder);
|
|
38
|
+
}
|
|
39
|
+
/** What was said in a room — or, with `about`, in the thread on that record — in the order it was said. */
|
|
40
|
+
export function messagesIn(graph, room, about) {
|
|
41
|
+
return allMessages(graph).filter((message) => message.room === room && (message.about ?? undefined) === (about ?? undefined));
|
|
42
|
+
}
|
|
43
|
+
/** The people a mention may name: every record of a kind that stands for the people, by its name. */
|
|
44
|
+
export function mentionablesOf(graph, schema) {
|
|
45
|
+
return schema.definitions.flatMap((definition) => definition.people
|
|
46
|
+
? graph.nodesOfKind(definition.kind).flatMap((node) => {
|
|
47
|
+
const name = labelOf(definition, node).trim();
|
|
48
|
+
return name && node["status"] !== "removed" ? [{ id: node.id, name }] : [];
|
|
49
|
+
})
|
|
50
|
+
: []);
|
|
51
|
+
}
|
|
52
|
+
const WORD = /[\p{L}\p{N}_'-]/u;
|
|
53
|
+
/**
|
|
54
|
+
* WHOM A MESSAGE MENTIONS: each person named after an `@` — their whole
|
|
55
|
+
* name, or the first word of it where only one person's name begins so —
|
|
56
|
+
* case aside, each once, in the order they are first named. A word that
|
|
57
|
+
* names nobody, or two people at once, mentions nobody.
|
|
58
|
+
*/
|
|
59
|
+
export function mentionsIn(body, people) {
|
|
60
|
+
const found = [];
|
|
61
|
+
const lower = body.toLowerCase();
|
|
62
|
+
const firsts = new Map();
|
|
63
|
+
for (const person of people) {
|
|
64
|
+
const first = person.name.split(/\s+/)[0].toLowerCase();
|
|
65
|
+
firsts.set(first, [...(firsts.get(first) ?? []), person.id]);
|
|
66
|
+
}
|
|
67
|
+
for (let at = lower.indexOf("@"); at >= 0; at = lower.indexOf("@", at + 1)) {
|
|
68
|
+
if (at > 0 && WORD.test(lower[at - 1]))
|
|
69
|
+
continue;
|
|
70
|
+
const rest = lower.slice(at + 1);
|
|
71
|
+
// The longest whole name first, so "@Sam Rivera" is Sam Rivera before it is anybody called Sam.
|
|
72
|
+
const whole = people
|
|
73
|
+
.filter((person) => rest.startsWith(person.name.toLowerCase()) && !WORD.test(rest[person.name.length] ?? " "))
|
|
74
|
+
.sort((a, b) => b.name.length - a.name.length)[0];
|
|
75
|
+
const word = /^[\p{L}\p{N}_'-]+/u.exec(rest)?.[0];
|
|
76
|
+
const id = whole?.id ?? (word && firsts.get(word)?.length === 1 ? firsts.get(word)[0] : undefined);
|
|
77
|
+
if (id !== undefined && !found.includes(id))
|
|
78
|
+
found.push(id);
|
|
79
|
+
}
|
|
80
|
+
return found;
|
|
81
|
+
}
|
|
82
|
+
/*
|
|
83
|
+
* REPLIES (Graview HQ feature:f-chat-threads-and-plain-words). A message
|
|
84
|
+
* that answers another (`replyTo`) is filed under the message that began
|
|
85
|
+
* its thread: one level deep, as a reply to a reply is filed under the
|
|
86
|
+
* first message, never under the reply. A reply whose message is not
|
|
87
|
+
* there — not served to this reader, or in another room — stands on its
|
|
88
|
+
* own.
|
|
89
|
+
*/
|
|
90
|
+
/** Where the replies under one message are read up to: its room's key (`roomKey`) and the message they hang from. */
|
|
91
|
+
export const threadKey = (room, about, root) => `${roomKey(room, about)}#${root}`;
|
|
92
|
+
/** The message a message's thread begins with: itself, or the first message the chain of answers it is part of goes back to, in its own room or thread. */
|
|
93
|
+
export function threadRootOf(message, byId) {
|
|
94
|
+
let at = message;
|
|
95
|
+
const seen = new Set([at.id]);
|
|
96
|
+
while (at.replyTo !== undefined) {
|
|
97
|
+
const answered = byId.get(at.replyTo);
|
|
98
|
+
if (!answered || answered.room !== at.room || (answered.about ?? undefined) !== (at.about ?? undefined) || seen.has(answered.id))
|
|
99
|
+
break;
|
|
100
|
+
seen.add(answered.id);
|
|
101
|
+
at = answered;
|
|
102
|
+
}
|
|
103
|
+
return at.id;
|
|
104
|
+
}
|
|
105
|
+
/** Messages folded into threads: each message that answers none (or one not here) with the replies under it, in the order the threads began. */
|
|
106
|
+
export function threadsIn(messages) {
|
|
107
|
+
const byId = new Map(messages.map((message) => [message.id, message]));
|
|
108
|
+
const replies = new Map();
|
|
109
|
+
const roots = [];
|
|
110
|
+
for (const message of [...messages].sort(inOrder)) {
|
|
111
|
+
const root = threadRootOf(message, byId);
|
|
112
|
+
if (root === message.id)
|
|
113
|
+
roots.push(message);
|
|
114
|
+
else {
|
|
115
|
+
const under = replies.get(root);
|
|
116
|
+
if (under)
|
|
117
|
+
under.push(message);
|
|
118
|
+
else
|
|
119
|
+
replies.set(root, [message]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return roots.map((root) => {
|
|
123
|
+
const under = replies.get(root.id) ?? [];
|
|
124
|
+
return { root, replies: under, lastAt: under.at(-1)?.at ?? root.at };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* WHAT A PERSON HAS NOT READ: every message in a room or thread after
|
|
129
|
+
* where they read up to there, said by somebody else and not removed —
|
|
130
|
+
* counted in all, by room (`roomKey`), and those that mention them.
|
|
131
|
+
* Handed the graph as they are served it, it counts only what they may
|
|
132
|
+
* read. A room they never opened counts from its first message. A reply
|
|
133
|
+
* is read once its own thread is (`threadKey`), never by the room read
|
|
134
|
+
* past it, and is counted by thread as well (`byThread`).
|
|
135
|
+
*/
|
|
136
|
+
export function unreadFor(person, graph, readUpTo, people = []) {
|
|
137
|
+
const byRoom = {};
|
|
138
|
+
const byThread = {};
|
|
139
|
+
const mentionsByRoom = {};
|
|
140
|
+
const mentionsByThread = {};
|
|
141
|
+
let total = 0;
|
|
142
|
+
let mentions = 0;
|
|
143
|
+
const every = allMessages(graph);
|
|
144
|
+
const byId = new Map(every.map((message) => [message.id, message]));
|
|
145
|
+
for (const message of every) {
|
|
146
|
+
if (message.removed || (person !== undefined && message.author === person))
|
|
147
|
+
continue;
|
|
148
|
+
const key = roomKey(message.room, message.about);
|
|
149
|
+
const root = threadRootOf(message, byId);
|
|
150
|
+
const thread = root === message.id ? undefined : threadKey(message.room, message.about, root);
|
|
151
|
+
const read = readUpTo[thread ?? key];
|
|
152
|
+
if (read !== undefined && message.at <= read)
|
|
153
|
+
continue;
|
|
154
|
+
byRoom[key] = (byRoom[key] ?? 0) + 1;
|
|
155
|
+
total++;
|
|
156
|
+
const named = person !== undefined && mentionsIn(message.body, people).includes(person);
|
|
157
|
+
if (named) {
|
|
158
|
+
mentions++;
|
|
159
|
+
mentionsByRoom[key] = (mentionsByRoom[key] ?? 0) + 1;
|
|
160
|
+
}
|
|
161
|
+
if (thread !== undefined) {
|
|
162
|
+
byThread[thread] = (byThread[thread] ?? 0) + 1;
|
|
163
|
+
if (named)
|
|
164
|
+
mentionsByThread[thread] = (mentionsByThread[thread] ?? 0) + 1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { total, mentions, byRoom, mentionsByRoom, byThread, mentionsByThread };
|
|
168
|
+
}
|
|
169
|
+
/** A room's address word, said as words, for a room the app does not declare (one of the framework's own): "inline-ai" is "Inline AI". */
|
|
170
|
+
export function roomWords(room) {
|
|
171
|
+
const said = room.replace(/^(graview:|~)/, "").replace(/[-_:.]+/g, " ").trim();
|
|
172
|
+
if (said === "")
|
|
173
|
+
return "Conversation";
|
|
174
|
+
return said.charAt(0).toUpperCase() + said.slice(1).replace(/\b(ai|ui)\b/gi, (word) => word.toUpperCase());
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* EVERY CONVERSATION IN THE GRAPH AS HANDED, newest activity first: each
|
|
178
|
+
* room and each record's thread with something said and not removed in
|
|
179
|
+
* it — whatever room it is, declared by the app or kept by the framework —
|
|
180
|
+
* with what the reader has not read there. Handed the graph a seat is
|
|
181
|
+
* served, it lists only what that seat may read.
|
|
182
|
+
*/
|
|
183
|
+
export function conversationsOf(graph, options = {}) {
|
|
184
|
+
const declared = new Map((options.rooms ?? []).map((room) => [room.id, room]));
|
|
185
|
+
const unread = unreadFor(options.person, graph, options.readUpTo ?? {}, options.people ?? []);
|
|
186
|
+
const groups = new Map();
|
|
187
|
+
for (const message of allMessages(graph)) {
|
|
188
|
+
const room = declared.get(message.room);
|
|
189
|
+
if (room && !mayReadRoom(room, options.roles))
|
|
190
|
+
continue;
|
|
191
|
+
if (!mayReadAiTurn(message, options.person))
|
|
192
|
+
continue;
|
|
193
|
+
const key = roomKey(message.room, message.about);
|
|
194
|
+
const group = groups.get(key);
|
|
195
|
+
if (group)
|
|
196
|
+
group.push(message);
|
|
197
|
+
else
|
|
198
|
+
groups.set(key, [message]);
|
|
199
|
+
}
|
|
200
|
+
const out = [];
|
|
201
|
+
for (const [key, messages] of groups) {
|
|
202
|
+
const kept = messages.filter((one) => !one.removed);
|
|
203
|
+
const last = kept.at(-1);
|
|
204
|
+
if (!last)
|
|
205
|
+
continue;
|
|
206
|
+
const room = declared.get(last.room);
|
|
207
|
+
out.push({
|
|
208
|
+
key,
|
|
209
|
+
room: last.room,
|
|
210
|
+
...(last.about !== undefined ? { about: last.about } : {}),
|
|
211
|
+
title: room?.title ?? options.titleOf?.(last.room) ?? roomWords(last.room),
|
|
212
|
+
declared: room !== undefined,
|
|
213
|
+
messages: kept.length,
|
|
214
|
+
threads: threadsIn(messages).filter((thread) => thread.replies.some((one) => !one.removed)).length,
|
|
215
|
+
last,
|
|
216
|
+
lastAt: last.at,
|
|
217
|
+
unread: unread.byRoom[key] ?? 0,
|
|
218
|
+
mentions: unread.mentionsByRoom[key] ?? 0,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return out.sort((a, b) => (a.lastAt < b.lastAt ? 1 : a.lastAt > b.lastAt ? -1 : a.key < b.key ? -1 : 1));
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* WHETHER A READER IS SHOWN A MESSAGE OF A CONVERSATION WITH THE AI: its
|
|
225
|
+
* asker, or anybody once it is shared. A host serves a seat only what its
|
|
226
|
+
* sight lets it see; this holds the same on a page handed the whole graph.
|
|
227
|
+
* A message of a room the app declares is always shown here.
|
|
228
|
+
*/
|
|
229
|
+
export const mayReadAiTurn = (message, person) => !isFrameworkRoom(message.room) || message.shared !== undefined || (person !== undefined && message.asker === person);
|
|
230
|
+
/** How much is said about each record, in every room and thread: its messages not removed, by the record's id — what a talk badge on the record counts; a conversation with the AI only for its asker, or once shared. */
|
|
231
|
+
export function talkAbout(graph, options = {}) {
|
|
232
|
+
const counts = new Map();
|
|
233
|
+
for (const message of graph.nodesOfKind(MESSAGE_KIND)) {
|
|
234
|
+
if (message.removed || message.about === undefined || !mayReadAiTurn(message, options.person))
|
|
235
|
+
continue;
|
|
236
|
+
counts.set(message.about, (counts.get(message.about) ?? 0) + 1);
|
|
237
|
+
}
|
|
238
|
+
return counts;
|
|
239
|
+
}
|
|
240
|
+
/** The read-up-to markers a host kept for a person (`ViewerState.read(ROOMS_READ_STATE)`), only the ones that read as instants. */
|
|
241
|
+
export function readUpToOf(kept) {
|
|
242
|
+
return Object.fromEntries(Object.entries(kept ?? {}).filter(([, at]) => typeof at === "string" && !Number.isNaN(Date.parse(at))));
|
|
243
|
+
}
|
|
244
|
+
/** Whether rooms are declared at all: the one question a page asks before it fetches any of this. */
|
|
245
|
+
export const hasRooms = (app) => Object.keys(unfoldedApp(app).rooms ?? {}).length > 0;
|
|
246
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/rooms/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAA2D,MAAM,YAAY,CAAC;AAgB7H,iEAAiE;AACjE,MAAM,UAAU,OAAO,CAAC,GAAyC;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EA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,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACpI,CAAC;AAED,qGAAqG;AACrG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAyC,EAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ROOMS: WHERE THE PEOPLE IN AN APP TALK TO EACH OTHER (Graview HQ
|
|
3
|
+
* feature:f-chat-rooms).
|
|
4
|
+
*
|
|
5
|
+
* rooms: {
|
|
6
|
+
* household: { title: "Household" },
|
|
7
|
+
* "task-talk": { title: "Comments", about: "task", mentions: true },
|
|
8
|
+
* }
|
|
9
|
+
*
|
|
10
|
+
* A room is declared, as a workflow is: by its address word, with a title.
|
|
11
|
+
* Without `about` it is one room for the whole app; with `about: "<kind>"`
|
|
12
|
+
* it is a thread on each record of that kind, drawn beside the record's
|
|
13
|
+
* page. `read` and `post` name the roles that may read it and post in it,
|
|
14
|
+
* and default to whoever may see the app (or the record, for a thread);
|
|
15
|
+
* `moderate` names the roles that may remove anybody's message, where
|
|
16
|
+
* everybody else removes only their own. `mentions` (on unless false)
|
|
17
|
+
* reads `@Name` in a message as a person of the app, who is told.
|
|
18
|
+
*
|
|
19
|
+
* What is said in a room is a record of the framework's own kind,
|
|
20
|
+
* `message` (`MESSAGE_KIND`), made, changed and removed by three acts the
|
|
21
|
+
* framework adds to an app that declares a room (`post-message`,
|
|
22
|
+
* `edit-message`, `remove-message`) — so sight, roles, history and undo
|
|
23
|
+
* hold of a message as of any record, and an agent's seat has the acts as
|
|
24
|
+
* tools. The same shape in a document (`rooms`) and in
|
|
25
|
+
* `defineApp({ rooms })`; `graview check` holds each to the declaration
|
|
26
|
+
* (`room-*`); `@graview/core/rooms` reads them (`roomsOf`, `threadOf`,
|
|
27
|
+
* `messagesIn`, `unreadFor`, `mentionsIn`).
|
|
28
|
+
*/
|
|
29
|
+
/** One room, by its address word in `rooms`. */
|
|
30
|
+
export interface RoomDeclaration {
|
|
31
|
+
/** What the room is called, on its page and in the bar: "Household", "Comments". */
|
|
32
|
+
readonly title: string;
|
|
33
|
+
/** A sentence under the title: what the room is for. */
|
|
34
|
+
readonly description?: string;
|
|
35
|
+
/** A thread on each record of this kind, rather than one room for the whole app. */
|
|
36
|
+
readonly about?: string;
|
|
37
|
+
/** The roles that may read it. Unsaid, whoever may see the app (or the record, for a thread). */
|
|
38
|
+
readonly read?: readonly string[];
|
|
39
|
+
/** The roles that may post in it. Unsaid, whoever may read it. */
|
|
40
|
+
readonly post?: readonly string[];
|
|
41
|
+
/** The roles that may remove anybody's message in it. Everybody else removes only their own. */
|
|
42
|
+
readonly moderate?: readonly string[];
|
|
43
|
+
/** Whether `@Name` in a message tells that person. On unless false. */
|
|
44
|
+
readonly mentions?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** An app's rooms, by address word. */
|
|
47
|
+
export type AppRooms = Readonly<Record<string, RoomDeclaration>>;
|
|
48
|
+
/** The framework's own kind every room's messages are records of. An app that declares rooms may not declare one of its own by this name (`room-kind-taken`). */
|
|
49
|
+
export declare const MESSAGE_KIND = "message";
|
|
50
|
+
/** The three acts an app with rooms is given. */
|
|
51
|
+
export declare const POST_MESSAGE = "post-message";
|
|
52
|
+
export declare const EDIT_MESSAGE = "edit-message";
|
|
53
|
+
export declare const REMOVE_MESSAGE = "remove-message";
|
|
54
|
+
export declare const ROOM_ACTS: readonly ["post-message", "edit-message", "remove-message"];
|
|
55
|
+
/**
|
|
56
|
+
* THE FRAMEWORK'S OWN ROOMS (Graview HQ feature:f-conversations-in-the-graph):
|
|
57
|
+
* where every app keeps what its people said to its AI and what the AI said
|
|
58
|
+
* back, whether or not it declares rooms of its own. `~asks` holds the
|
|
59
|
+
* inline AI's questions (the menu's "Ask") and the seat's conversation;
|
|
60
|
+
* `~design` holds the "Better UI" conversations that change how the app
|
|
61
|
+
* looks. An app need not declare them, and may not declare a room of its
|
|
62
|
+
* own whose id starts with `~` (`room-id-reserved`). A conversation in one
|
|
63
|
+
* is seen only by whoever asked it, until they share it.
|
|
64
|
+
*/
|
|
65
|
+
export declare const ASKS_ROOM = "~asks";
|
|
66
|
+
export declare const DESIGN_ROOM = "~design";
|
|
67
|
+
export declare const FRAMEWORK_ROOMS: readonly ["~asks", "~design"];
|
|
68
|
+
export type FrameworkRoom = (typeof FRAMEWORK_ROOMS)[number];
|
|
69
|
+
/** Whether a room is one the framework keeps, not one an app declared. */
|
|
70
|
+
export declare const isFrameworkRoom: (room: unknown) => room is FrameworkRoom;
|
|
71
|
+
/** A framework room's title, in plain words ("Questions to the AI", "Design changes"); undefined for a room the app declared. */
|
|
72
|
+
export declare const frameworkRoomTitle: (room: string) => string | undefined;
|
|
73
|
+
/** The acts every app is given for its conversations with the AI: keep a finished turn, settle what became of it, share the conversation. */
|
|
74
|
+
export declare const KEEP_AI_TURN = "keep-ai-turn";
|
|
75
|
+
export declare const SETTLE_AI_TURN = "settle-ai-turn";
|
|
76
|
+
export declare const SHARE_CONVERSATION = "share-conversation";
|
|
77
|
+
export declare const AI_ROOM_ACTS: readonly ["keep-ai-turn", "settle-ai-turn", "share-conversation"];
|
|
78
|
+
/** Whether an act is one of those: kept by the page's AI desk and the conversation's own controls, never offered among an app's acts or an agent's tools. */
|
|
79
|
+
export declare const isAiRoomAct: (name: string | undefined) => boolean;
|
|
80
|
+
/** Which door a conversation with the AI came through: the inline AI's menu, the seat, or "Better UI". */
|
|
81
|
+
export type AiDoor = "menu" | "seat" | "better";
|
|
82
|
+
/** Whom a conversation with the AI is shared with, beyond whoever asked it: the roles that may change everything in the app, or everybody. */
|
|
83
|
+
export type ConversationShare = "editors" | "everyone";
|
|
84
|
+
/** The module a room's kind and acts are in, so a host may turn rooms off for an installation (`enabledModules`) as it turns off any module. */
|
|
85
|
+
export declare const ROOMS_MODULE = "rooms";
|
|
86
|
+
/** The most an app declares, and the longest a message is: a message is talk, not a document. */
|
|
87
|
+
export declare const MOST_ROOMS = 24;
|
|
88
|
+
export declare const LONGEST_MESSAGE = 4000;
|
|
89
|
+
export declare const LONGEST_ROOM_TITLE = 60;
|
|
90
|
+
/** The view name a person's "read up to" markers are kept under (`ViewerState`), one key a room or thread. */
|
|
91
|
+
export declare const ROOMS_READ_STATE = "graview:rooms";
|
|
92
|
+
/** A message's fields, as a record of the framework's kind holds them. */
|
|
93
|
+
export interface MessageRecord {
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly kind: typeof MESSAGE_KIND;
|
|
96
|
+
/** The room's address word. */
|
|
97
|
+
readonly room: string;
|
|
98
|
+
/** The record a thread is on; none in an app-wide room. */
|
|
99
|
+
readonly about?: string;
|
|
100
|
+
/** What was said, in markdown-lite: paragraphs, `*emphasis*`, `**strong**`, `code`, links. Empty once removed. */
|
|
101
|
+
readonly body: string;
|
|
102
|
+
/** Who said it: the acting seat's id (a person, or an agent posting as itself). */
|
|
103
|
+
readonly author: string;
|
|
104
|
+
/** The author's name as it was when they posted, for a reader who cannot look them up. */
|
|
105
|
+
readonly authorName?: string;
|
|
106
|
+
/** `human`, `agent`, `system`: who the author was. */
|
|
107
|
+
readonly authorKind?: string;
|
|
108
|
+
/** When it was said, an ISO instant. */
|
|
109
|
+
readonly at: string;
|
|
110
|
+
/** The message it answers, in the same room or thread. */
|
|
111
|
+
readonly replyTo?: string;
|
|
112
|
+
/** When it was last changed, if it was. */
|
|
113
|
+
readonly editedAt?: string;
|
|
114
|
+
/** Taken out: the body is gone and the message says so where it stood. */
|
|
115
|
+
readonly removed?: boolean;
|
|
116
|
+
/** In a framework room: whose conversation it is — the person who asked, on the AI's answers too. */
|
|
117
|
+
readonly asker?: string;
|
|
118
|
+
/** In a framework room: the door the conversation came through. */
|
|
119
|
+
readonly door?: AiDoor;
|
|
120
|
+
/** On the AI's answer: the interaction it was (`AiInteraction.id`, `@graview/core/catalog`), whose batches carry lineage `interaction: <id>`. */
|
|
121
|
+
readonly interaction?: string;
|
|
122
|
+
/** On the AI's answer: what became of what it offered (`AiInteraction.outcome`). */
|
|
123
|
+
readonly outcome?: string;
|
|
124
|
+
/** On the AI's answer: the batches it made, in order. */
|
|
125
|
+
readonly batches?: readonly string[];
|
|
126
|
+
/** On the AI's answer: the whole interaction as Activity reads it, as JSON (`interactionsOf`, `@graview/core/catalog`). */
|
|
127
|
+
readonly entry?: string;
|
|
128
|
+
/** Whom the conversation is shared with beyond its asker; unsaid, nobody else. */
|
|
129
|
+
readonly shared?: ConversationShare;
|
|
130
|
+
}
|
|
131
|
+
/** Where a room's messages are, said as one key: the room alone, or the room and the record a thread is on. */
|
|
132
|
+
export declare const roomKey: (room: string, about?: string) => string;
|
|
133
|
+
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/rooms/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iGAAiG;IACjG,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,CAA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