@quickscores/chat 0.3.0 → 0.4.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/dist/types/api.d.ts +31 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -1
- package/dist/types/message.d.ts +37 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js +20 -2
- package/package.json +1 -1
package/dist/types/api.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface SendMessageBody {
|
|
|
35
35
|
body?: string | null;
|
|
36
36
|
payload?: Record<string, unknown>;
|
|
37
37
|
client_nonce?: string | null;
|
|
38
|
+
/** When set, this message is a reply to the given message (must be in the same thread). */
|
|
39
|
+
reply_to_message_id?: string | null;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* POST /chat-mark-read
|
|
@@ -50,10 +52,27 @@ export interface ThreadResponse {
|
|
|
50
52
|
thread: Thread;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* Message enrichment (sender_name, sender_user_role, reply_to) – included in GET /chat-messages and POST /chat-send-message responses and Realtime new_message payload.
|
|
56
|
+
*/
|
|
57
|
+
export interface ReplyToPayload {
|
|
58
|
+
message_id: string;
|
|
59
|
+
body: string | null;
|
|
60
|
+
sender_name: string | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Message shape returned by GET /chat-messages, POST /chat-send-message, and
|
|
64
|
+
* Realtime broadcast event `new_message`. Use MessageWithEnrichment from "./message" for Zod parsing.
|
|
65
|
+
*/
|
|
66
|
+
export type ApiMessage = Message & {
|
|
67
|
+
sender_name: string | null;
|
|
68
|
+
sender_user_role: "player" | "parent" | "coach" | null;
|
|
69
|
+
reply_to: ReplyToPayload | null;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Response: send message (chat-send-message). Message includes sender_name, sender_user_role, reply_to.
|
|
54
73
|
*/
|
|
55
74
|
export interface MessageResponse {
|
|
56
|
-
message:
|
|
75
|
+
message: ApiMessage;
|
|
57
76
|
}
|
|
58
77
|
/**
|
|
59
78
|
* Query params for GET /chat-messages
|
|
@@ -64,10 +83,11 @@ export interface GetMessagesParams {
|
|
|
64
83
|
before?: string | null;
|
|
65
84
|
}
|
|
66
85
|
/**
|
|
67
|
-
* Response: GET /chat-messages (paginated list, newest first)
|
|
86
|
+
* Response: GET /chat-messages (paginated list, newest first).
|
|
87
|
+
* Each message includes sender_name, sender_user_role, reply_to.
|
|
68
88
|
*/
|
|
69
89
|
export interface MessagesResponse {
|
|
70
|
-
messages:
|
|
90
|
+
messages: ApiMessage[];
|
|
71
91
|
}
|
|
72
92
|
/**
|
|
73
93
|
* Response: mark read (chat-mark-read)
|
|
@@ -75,4 +95,11 @@ export interface MessagesResponse {
|
|
|
75
95
|
export interface MarkReadResponse {
|
|
76
96
|
ok: true;
|
|
77
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Realtime broadcast event `new_message`. Use for typing the callback:
|
|
100
|
+
* `channel.on('broadcast', { event: 'new_message' }, (event) => { const message: ApiMessage = event.payload; })`
|
|
101
|
+
*/
|
|
102
|
+
export interface RealtimeNewMessageEvent {
|
|
103
|
+
payload: ApiMessage;
|
|
104
|
+
}
|
|
78
105
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/types/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eA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and docs/api-chat.md.
|
|
4
4
|
*/
|
|
5
5
|
export { threadKindSchema, threadSchema, threadListRowSchema, type Thread, type ThreadKind, type ThreadListRow, } from "./thread";
|
|
6
|
-
export { messageSchema, type Message } from "./message";
|
|
7
|
-
export type { ErrorResponse, CreateThreadBody, LeagueRoomBody, TeamRoomBody, SendMessageBody, MarkReadBody, GetMessagesParams, ThreadResponse, MessageResponse, MessagesResponse, MarkReadResponse, } from "./api";
|
|
6
|
+
export { messageSchema, replyToSchema, messageWithEnrichmentSchema, type Message, type ReplyTo, type MessageWithEnrichment, } from "./message";
|
|
7
|
+
export type { ErrorResponse, CreateThreadBody, LeagueRoomBody, TeamRoomBody, SendMessageBody, MarkReadBody, GetMessagesParams, ApiMessage, ReplyToPayload, ThreadResponse, MessageResponse, MessagesResponse, MarkReadResponse, RealtimeNewMessageEvent, } from "./api";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,OAAO,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* Kept in sync with Supabase migrations and docs/api-chat.md.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.messageSchema = exports.threadListRowSchema = exports.threadSchema = exports.threadKindSchema = void 0;
|
|
7
|
+
exports.messageWithEnrichmentSchema = exports.replyToSchema = exports.messageSchema = exports.threadListRowSchema = exports.threadSchema = exports.threadKindSchema = void 0;
|
|
8
8
|
var thread_1 = require("./thread");
|
|
9
9
|
Object.defineProperty(exports, "threadKindSchema", { enumerable: true, get: function () { return thread_1.threadKindSchema; } });
|
|
10
10
|
Object.defineProperty(exports, "threadSchema", { enumerable: true, get: function () { return thread_1.threadSchema; } });
|
|
11
11
|
Object.defineProperty(exports, "threadListRowSchema", { enumerable: true, get: function () { return thread_1.threadListRowSchema; } });
|
|
12
12
|
var message_1 = require("./message");
|
|
13
13
|
Object.defineProperty(exports, "messageSchema", { enumerable: true, get: function () { return message_1.messageSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "replyToSchema", { enumerable: true, get: function () { return message_1.replyToSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "messageWithEnrichmentSchema", { enumerable: true, get: function () { return message_1.messageWithEnrichmentSchema; } });
|
package/dist/types/message.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Reply-to payload – included when the message is a reply to another message.
|
|
4
|
+
*/
|
|
5
|
+
export declare const replyToSchema: z.ZodObject<{
|
|
6
|
+
message_id: z.ZodString;
|
|
7
|
+
body: z.ZodNullable<z.ZodString>;
|
|
8
|
+
sender_name: z.ZodNullable<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type ReplyTo = z.infer<typeof replyToSchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Message – base shape (chat_messages table).
|
|
4
13
|
*/
|
|
5
14
|
export declare const messageSchema: z.ZodObject<{
|
|
6
15
|
id: z.ZodString;
|
|
@@ -13,4 +22,31 @@ export declare const messageSchema: z.ZodObject<{
|
|
|
13
22
|
created_at: z.ZodString;
|
|
14
23
|
}, z.core.$strip>;
|
|
15
24
|
export type Message = z.infer<typeof messageSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Message as returned by API (GET /chat-messages, POST /chat-send-message) and
|
|
27
|
+
* Realtime broadcast event `new_message`. Same shape everywhere.
|
|
28
|
+
* Includes sender_name, sender_user_role, and reply_to (no reply_to_message_id in response).
|
|
29
|
+
*/
|
|
30
|
+
export declare const messageWithEnrichmentSchema: z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
thread_id: z.ZodString;
|
|
33
|
+
sender_id: z.ZodNumber;
|
|
34
|
+
type: z.ZodString;
|
|
35
|
+
body: z.ZodNullable<z.ZodString>;
|
|
36
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
37
|
+
client_nonce: z.ZodNullable<z.ZodString>;
|
|
38
|
+
created_at: z.ZodString;
|
|
39
|
+
sender_name: z.ZodNullable<z.ZodString>;
|
|
40
|
+
sender_user_role: z.ZodNullable<z.ZodEnum<{
|
|
41
|
+
player: "player";
|
|
42
|
+
parent: "parent";
|
|
43
|
+
coach: "coach";
|
|
44
|
+
}>>;
|
|
45
|
+
reply_to: z.ZodNullable<z.ZodObject<{
|
|
46
|
+
message_id: z.ZodString;
|
|
47
|
+
body: z.ZodNullable<z.ZodString>;
|
|
48
|
+
sender_name: z.ZodNullable<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type MessageWithEnrichment = z.infer<typeof messageWithEnrichmentSchema>;
|
|
16
52
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;iBASxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa;;;;iBAIxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;iBASxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;iBAItC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
package/dist/types/message.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messageSchema = void 0;
|
|
3
|
+
exports.messageWithEnrichmentSchema = exports.messageSchema = exports.replyToSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Reply-to payload – included when the message is a reply to another message.
|
|
7
|
+
*/
|
|
8
|
+
exports.replyToSchema = zod_1.z.object({
|
|
9
|
+
message_id: zod_1.z.string().uuid(),
|
|
10
|
+
body: zod_1.z.string().nullable(),
|
|
11
|
+
sender_name: zod_1.z.string().nullable(),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Message – base shape (chat_messages table).
|
|
7
15
|
*/
|
|
8
16
|
exports.messageSchema = zod_1.z.object({
|
|
9
17
|
id: zod_1.z.string().uuid(),
|
|
@@ -15,3 +23,13 @@ exports.messageSchema = zod_1.z.object({
|
|
|
15
23
|
client_nonce: zod_1.z.string().nullable(),
|
|
16
24
|
created_at: zod_1.z.string(),
|
|
17
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Message as returned by API (GET /chat-messages, POST /chat-send-message) and
|
|
28
|
+
* Realtime broadcast event `new_message`. Same shape everywhere.
|
|
29
|
+
* Includes sender_name, sender_user_role, and reply_to (no reply_to_message_id in response).
|
|
30
|
+
*/
|
|
31
|
+
exports.messageWithEnrichmentSchema = exports.messageSchema.extend({
|
|
32
|
+
sender_name: zod_1.z.string().nullable(),
|
|
33
|
+
sender_user_role: zod_1.z.enum(["player", "parent", "coach"]).nullable(),
|
|
34
|
+
reply_to: exports.replyToSchema.nullable(),
|
|
35
|
+
});
|