@pedi/chika-types 1.0.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 +41 -0
- package/dist/index.d.mts +257 -0
- package/dist/index.d.ts +257 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @pedi/chika-types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript types and Zod validation schemas for the Pedi Chika chat system.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
Provides the single source of truth for all data structures in the chat system. Every message, participant, channel event, and API request/response is defined here and shared across both the server and the SDK.
|
|
8
|
+
|
|
9
|
+
## Problems It Solves
|
|
10
|
+
|
|
11
|
+
- **Type drift between client and server** — A single package defines the contract, so the SDK and server can never disagree on the shape of a message or participant
|
|
12
|
+
- **Runtime validation** — Zod schemas validate incoming data at API boundaries while TypeScript generics enforce correctness at compile time
|
|
13
|
+
- **Domain flexibility** — The generic `ChatDomain` system lets you reuse the entire type system for different chat contexts (ride-hailing, customer support, etc.) with full type safety
|
|
14
|
+
|
|
15
|
+
## Key Features
|
|
16
|
+
|
|
17
|
+
- Generic `ChatDomain` interface for defining strongly-typed chat domains
|
|
18
|
+
- Pre-built `PediChat` domain for ride-hailing (driver/rider roles, booking events, vehicle metadata)
|
|
19
|
+
- Zod schemas for all API request validation (participants, messages, history queries)
|
|
20
|
+
- Full TypeScript generics — `Message<PediChat>`, `Participant<PediChat>`, etc.
|
|
21
|
+
- Zero dependencies beyond Zod
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import type { Message, Participant, PediChat } from '@pedi/chika-types';
|
|
27
|
+
import { sendMessageRequestSchema } from '@pedi/chika-types';
|
|
28
|
+
|
|
29
|
+
// Strongly typed for ride-hailing
|
|
30
|
+
const msg: Message<PediChat> = { /* autocomplete guides you */ };
|
|
31
|
+
|
|
32
|
+
// Runtime validation at API boundaries
|
|
33
|
+
const parsed = sendMessageRequestSchema.parse(requestBody);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
See the [docs](./docs/) for detailed documentation:
|
|
39
|
+
|
|
40
|
+
- [Type Reference](./docs/type-reference.md) — All types, interfaces, and schemas
|
|
41
|
+
- [Chat Domain Guide](./docs/chat-domain-guide.md) — How the generic domain system works, with examples
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface ChatDomain {
|
|
4
|
+
role: string;
|
|
5
|
+
metadata: Record<string, unknown>;
|
|
6
|
+
messageType: string;
|
|
7
|
+
attributes: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
interface DefaultDomain extends ChatDomain {
|
|
10
|
+
role: string;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
messageType: string;
|
|
13
|
+
attributes: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const participantSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
role: z.ZodString;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
profile_image: z.ZodOptional<z.ZodString>;
|
|
21
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
id: string;
|
|
24
|
+
role: string;
|
|
25
|
+
name: string;
|
|
26
|
+
profile_image?: string | undefined;
|
|
27
|
+
metadata?: Record<string, unknown> | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
id: string;
|
|
30
|
+
role: string;
|
|
31
|
+
name: string;
|
|
32
|
+
profile_image?: string | undefined;
|
|
33
|
+
metadata?: Record<string, unknown> | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
interface Participant<D extends ChatDomain = DefaultDomain> {
|
|
36
|
+
id: string;
|
|
37
|
+
role: D['role'];
|
|
38
|
+
name: string;
|
|
39
|
+
profile_image?: string;
|
|
40
|
+
metadata?: D['metadata'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare const messageAttributesSchema: z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>;
|
|
44
|
+
type MessageAttributes<D extends ChatDomain = DefaultDomain> = D['attributes'];
|
|
45
|
+
interface Message<D extends ChatDomain = DefaultDomain> {
|
|
46
|
+
id: string;
|
|
47
|
+
channel_id: string;
|
|
48
|
+
sender_id: string | null;
|
|
49
|
+
sender_role: D['role'] | 'system';
|
|
50
|
+
type: D['messageType'];
|
|
51
|
+
body: string;
|
|
52
|
+
attributes: MessageAttributes<D>;
|
|
53
|
+
created_at: string;
|
|
54
|
+
}
|
|
55
|
+
declare const sendMessageRequestSchema: z.ZodObject<{
|
|
56
|
+
sender_id: z.ZodString;
|
|
57
|
+
type: z.ZodString;
|
|
58
|
+
body: z.ZodString;
|
|
59
|
+
attributes: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
type: string;
|
|
62
|
+
sender_id: string;
|
|
63
|
+
body: string;
|
|
64
|
+
attributes?: z.objectOutputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
type: string;
|
|
67
|
+
sender_id: string;
|
|
68
|
+
body: string;
|
|
69
|
+
attributes?: z.objectInputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
interface SendMessageRequest<D extends ChatDomain = DefaultDomain> {
|
|
72
|
+
sender_id: string;
|
|
73
|
+
type: D['messageType'];
|
|
74
|
+
body: string;
|
|
75
|
+
attributes?: MessageAttributes<D>;
|
|
76
|
+
}
|
|
77
|
+
interface SendMessageResponse {
|
|
78
|
+
id: string;
|
|
79
|
+
created_at: string;
|
|
80
|
+
}
|
|
81
|
+
declare const systemMessageRequestSchema: z.ZodObject<{
|
|
82
|
+
type: z.ZodString;
|
|
83
|
+
body: z.ZodString;
|
|
84
|
+
attributes: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
type: string;
|
|
87
|
+
body: string;
|
|
88
|
+
attributes?: z.objectOutputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
type: string;
|
|
91
|
+
body: string;
|
|
92
|
+
attributes?: z.objectInputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
interface SystemMessageRequest<D extends ChatDomain = DefaultDomain> {
|
|
95
|
+
type: D['messageType'];
|
|
96
|
+
body: string;
|
|
97
|
+
attributes?: MessageAttributes<D>;
|
|
98
|
+
}
|
|
99
|
+
declare const messageHistoryQuerySchema: z.ZodObject<{
|
|
100
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
101
|
+
before: z.ZodOptional<z.ZodString>;
|
|
102
|
+
after: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
limit: number;
|
|
105
|
+
before?: string | undefined;
|
|
106
|
+
after?: string | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
limit?: number | undefined;
|
|
109
|
+
before?: string | undefined;
|
|
110
|
+
after?: string | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
interface MessageHistoryQuery {
|
|
113
|
+
limit?: number;
|
|
114
|
+
before?: string;
|
|
115
|
+
after?: string;
|
|
116
|
+
}
|
|
117
|
+
interface MessageHistoryResponse<D extends ChatDomain = DefaultDomain> {
|
|
118
|
+
channel_id: string;
|
|
119
|
+
participants: Participant<D>[];
|
|
120
|
+
messages: Message<D>[];
|
|
121
|
+
has_more: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare const joinRequestSchema: z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
role: z.ZodString;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
profile_image: z.ZodOptional<z.ZodString>;
|
|
129
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
id: string;
|
|
132
|
+
role: string;
|
|
133
|
+
name: string;
|
|
134
|
+
profile_image?: string | undefined;
|
|
135
|
+
metadata?: Record<string, unknown> | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
id: string;
|
|
138
|
+
role: string;
|
|
139
|
+
name: string;
|
|
140
|
+
profile_image?: string | undefined;
|
|
141
|
+
metadata?: Record<string, unknown> | undefined;
|
|
142
|
+
}>;
|
|
143
|
+
type JoinRequest = z.infer<typeof joinRequestSchema>;
|
|
144
|
+
interface JoinResponse<D extends ChatDomain = DefaultDomain> {
|
|
145
|
+
channel_id: string;
|
|
146
|
+
status: 'active' | 'closed';
|
|
147
|
+
participants: Participant<D>[];
|
|
148
|
+
messages: Message<D>[];
|
|
149
|
+
joined_at: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface SSEMessageEvent<D extends ChatDomain = DefaultDomain> {
|
|
153
|
+
id: string;
|
|
154
|
+
event: 'message';
|
|
155
|
+
data: Message<D>;
|
|
156
|
+
}
|
|
157
|
+
interface SSEResyncEvent {
|
|
158
|
+
event: 'resync';
|
|
159
|
+
data: {
|
|
160
|
+
reason: string;
|
|
161
|
+
missed_count: number;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
type SSEEvent<D extends ChatDomain = DefaultDomain> = SSEMessageEvent<D> | SSEResyncEvent;
|
|
165
|
+
|
|
166
|
+
interface ChatBucket {
|
|
167
|
+
group: string;
|
|
168
|
+
range: [number, number];
|
|
169
|
+
server_url: string;
|
|
170
|
+
}
|
|
171
|
+
interface ChatManifest {
|
|
172
|
+
buckets: ChatBucket[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Configurable auth validator types.
|
|
177
|
+
*
|
|
178
|
+
* Implementors create an `auth.config.ts` file (gitignored) that exports
|
|
179
|
+
* an {@link AuthConfig} object. The server dynamically imports it at
|
|
180
|
+
* startup; if the file is absent, auth is disabled.
|
|
181
|
+
*/
|
|
182
|
+
/** The context passed to every validator invocation. */
|
|
183
|
+
interface AuthValidatorContext {
|
|
184
|
+
/** All request headers (lowercased keys). */
|
|
185
|
+
headers: Record<string, string>;
|
|
186
|
+
/** The channel being accessed. */
|
|
187
|
+
channelId: string;
|
|
188
|
+
}
|
|
189
|
+
/** What the validator must return. */
|
|
190
|
+
interface AuthValidatorResult {
|
|
191
|
+
/** Whether the request is allowed. */
|
|
192
|
+
valid: boolean;
|
|
193
|
+
/** Optional user identifier — stored for audit / logging. */
|
|
194
|
+
userId?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A function that decides whether an incoming request is authorised.
|
|
198
|
+
*
|
|
199
|
+
* Return `{ valid: true }` to allow, `{ valid: false }` to reject (401).
|
|
200
|
+
*/
|
|
201
|
+
type AuthValidator = (ctx: AuthValidatorContext) => Promise<AuthValidatorResult> | AuthValidatorResult;
|
|
202
|
+
/** The shape of the default export in `auth.config.ts`. */
|
|
203
|
+
interface AuthConfig {
|
|
204
|
+
/** The validation function. */
|
|
205
|
+
validate: AuthValidator;
|
|
206
|
+
/**
|
|
207
|
+
* How long (ms) a **valid** result is cached per cache-key.
|
|
208
|
+
* Set to `0` to disable caching. Defaults to `300_000` (5 min).
|
|
209
|
+
*/
|
|
210
|
+
cacheTtl?: number;
|
|
211
|
+
/**
|
|
212
|
+
* How long (ms) an **invalid** result is cached per cache-key.
|
|
213
|
+
* Defaults to `2_000` (2 s).
|
|
214
|
+
*/
|
|
215
|
+
invalidCacheTtl?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Derive a cache key from the request context.
|
|
218
|
+
* Defaults to the full `Authorization` header value.
|
|
219
|
+
* Return `null` to skip caching for a request.
|
|
220
|
+
*/
|
|
221
|
+
cacheKey?: (ctx: AuthValidatorContext) => string | null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface PediVehicle {
|
|
225
|
+
plate_number: string;
|
|
226
|
+
body_number: string;
|
|
227
|
+
color: string;
|
|
228
|
+
brand: string;
|
|
229
|
+
}
|
|
230
|
+
interface PediLocation {
|
|
231
|
+
latitude: number;
|
|
232
|
+
longitude: number;
|
|
233
|
+
}
|
|
234
|
+
type PediRole = 'driver' | 'rider';
|
|
235
|
+
type PediMessageType = 'chat' | 'driver_arrived' | 'booking_started' | 'booking_completed' | 'booking_cancelled' | 'system_notice';
|
|
236
|
+
interface PediParticipantMeta {
|
|
237
|
+
vehicle?: PediVehicle;
|
|
238
|
+
rating?: number;
|
|
239
|
+
current_location?: PediLocation | null;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
interface PediMessageAttributes {
|
|
243
|
+
location?: PediLocation;
|
|
244
|
+
device?: 'android' | 'ios';
|
|
245
|
+
app_version?: string;
|
|
246
|
+
booking_id?: string;
|
|
247
|
+
booking_status?: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
}
|
|
250
|
+
interface PediChat extends ChatDomain {
|
|
251
|
+
role: PediRole;
|
|
252
|
+
metadata: PediParticipantMeta;
|
|
253
|
+
messageType: PediMessageType;
|
|
254
|
+
attributes: PediMessageAttributes;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { type AuthConfig, type AuthValidator, type AuthValidatorContext, type AuthValidatorResult, type ChatBucket, type ChatDomain, type ChatManifest, type DefaultDomain, type JoinRequest, type JoinResponse, type Message, type MessageAttributes, type MessageHistoryQuery, type MessageHistoryResponse, type Participant, type PediChat, type PediLocation, type PediMessageAttributes, type PediMessageType, type PediParticipantMeta, type PediRole, type PediVehicle, type SSEEvent, type SSEMessageEvent, type SSEResyncEvent, type SendMessageRequest, type SendMessageResponse, type SystemMessageRequest, joinRequestSchema, messageAttributesSchema, messageHistoryQuerySchema, participantSchema, sendMessageRequestSchema, systemMessageRequestSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface ChatDomain {
|
|
4
|
+
role: string;
|
|
5
|
+
metadata: Record<string, unknown>;
|
|
6
|
+
messageType: string;
|
|
7
|
+
attributes: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
interface DefaultDomain extends ChatDomain {
|
|
10
|
+
role: string;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
messageType: string;
|
|
13
|
+
attributes: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const participantSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
role: z.ZodString;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
profile_image: z.ZodOptional<z.ZodString>;
|
|
21
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
id: string;
|
|
24
|
+
role: string;
|
|
25
|
+
name: string;
|
|
26
|
+
profile_image?: string | undefined;
|
|
27
|
+
metadata?: Record<string, unknown> | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
id: string;
|
|
30
|
+
role: string;
|
|
31
|
+
name: string;
|
|
32
|
+
profile_image?: string | undefined;
|
|
33
|
+
metadata?: Record<string, unknown> | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
interface Participant<D extends ChatDomain = DefaultDomain> {
|
|
36
|
+
id: string;
|
|
37
|
+
role: D['role'];
|
|
38
|
+
name: string;
|
|
39
|
+
profile_image?: string;
|
|
40
|
+
metadata?: D['metadata'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare const messageAttributesSchema: z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>;
|
|
44
|
+
type MessageAttributes<D extends ChatDomain = DefaultDomain> = D['attributes'];
|
|
45
|
+
interface Message<D extends ChatDomain = DefaultDomain> {
|
|
46
|
+
id: string;
|
|
47
|
+
channel_id: string;
|
|
48
|
+
sender_id: string | null;
|
|
49
|
+
sender_role: D['role'] | 'system';
|
|
50
|
+
type: D['messageType'];
|
|
51
|
+
body: string;
|
|
52
|
+
attributes: MessageAttributes<D>;
|
|
53
|
+
created_at: string;
|
|
54
|
+
}
|
|
55
|
+
declare const sendMessageRequestSchema: z.ZodObject<{
|
|
56
|
+
sender_id: z.ZodString;
|
|
57
|
+
type: z.ZodString;
|
|
58
|
+
body: z.ZodString;
|
|
59
|
+
attributes: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
type: string;
|
|
62
|
+
sender_id: string;
|
|
63
|
+
body: string;
|
|
64
|
+
attributes?: z.objectOutputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
type: string;
|
|
67
|
+
sender_id: string;
|
|
68
|
+
body: string;
|
|
69
|
+
attributes?: z.objectInputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
interface SendMessageRequest<D extends ChatDomain = DefaultDomain> {
|
|
72
|
+
sender_id: string;
|
|
73
|
+
type: D['messageType'];
|
|
74
|
+
body: string;
|
|
75
|
+
attributes?: MessageAttributes<D>;
|
|
76
|
+
}
|
|
77
|
+
interface SendMessageResponse {
|
|
78
|
+
id: string;
|
|
79
|
+
created_at: string;
|
|
80
|
+
}
|
|
81
|
+
declare const systemMessageRequestSchema: z.ZodObject<{
|
|
82
|
+
type: z.ZodString;
|
|
83
|
+
body: z.ZodString;
|
|
84
|
+
attributes: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodUnknown, z.objectOutputType<{}, z.ZodUnknown, "strip">, z.objectInputType<{}, z.ZodUnknown, "strip">>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
type: string;
|
|
87
|
+
body: string;
|
|
88
|
+
attributes?: z.objectOutputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
type: string;
|
|
91
|
+
body: string;
|
|
92
|
+
attributes?: z.objectInputType<{}, z.ZodUnknown, "strip"> | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
interface SystemMessageRequest<D extends ChatDomain = DefaultDomain> {
|
|
95
|
+
type: D['messageType'];
|
|
96
|
+
body: string;
|
|
97
|
+
attributes?: MessageAttributes<D>;
|
|
98
|
+
}
|
|
99
|
+
declare const messageHistoryQuerySchema: z.ZodObject<{
|
|
100
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
101
|
+
before: z.ZodOptional<z.ZodString>;
|
|
102
|
+
after: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
limit: number;
|
|
105
|
+
before?: string | undefined;
|
|
106
|
+
after?: string | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
limit?: number | undefined;
|
|
109
|
+
before?: string | undefined;
|
|
110
|
+
after?: string | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
interface MessageHistoryQuery {
|
|
113
|
+
limit?: number;
|
|
114
|
+
before?: string;
|
|
115
|
+
after?: string;
|
|
116
|
+
}
|
|
117
|
+
interface MessageHistoryResponse<D extends ChatDomain = DefaultDomain> {
|
|
118
|
+
channel_id: string;
|
|
119
|
+
participants: Participant<D>[];
|
|
120
|
+
messages: Message<D>[];
|
|
121
|
+
has_more: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare const joinRequestSchema: z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
role: z.ZodString;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
profile_image: z.ZodOptional<z.ZodString>;
|
|
129
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
id: string;
|
|
132
|
+
role: string;
|
|
133
|
+
name: string;
|
|
134
|
+
profile_image?: string | undefined;
|
|
135
|
+
metadata?: Record<string, unknown> | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
id: string;
|
|
138
|
+
role: string;
|
|
139
|
+
name: string;
|
|
140
|
+
profile_image?: string | undefined;
|
|
141
|
+
metadata?: Record<string, unknown> | undefined;
|
|
142
|
+
}>;
|
|
143
|
+
type JoinRequest = z.infer<typeof joinRequestSchema>;
|
|
144
|
+
interface JoinResponse<D extends ChatDomain = DefaultDomain> {
|
|
145
|
+
channel_id: string;
|
|
146
|
+
status: 'active' | 'closed';
|
|
147
|
+
participants: Participant<D>[];
|
|
148
|
+
messages: Message<D>[];
|
|
149
|
+
joined_at: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface SSEMessageEvent<D extends ChatDomain = DefaultDomain> {
|
|
153
|
+
id: string;
|
|
154
|
+
event: 'message';
|
|
155
|
+
data: Message<D>;
|
|
156
|
+
}
|
|
157
|
+
interface SSEResyncEvent {
|
|
158
|
+
event: 'resync';
|
|
159
|
+
data: {
|
|
160
|
+
reason: string;
|
|
161
|
+
missed_count: number;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
type SSEEvent<D extends ChatDomain = DefaultDomain> = SSEMessageEvent<D> | SSEResyncEvent;
|
|
165
|
+
|
|
166
|
+
interface ChatBucket {
|
|
167
|
+
group: string;
|
|
168
|
+
range: [number, number];
|
|
169
|
+
server_url: string;
|
|
170
|
+
}
|
|
171
|
+
interface ChatManifest {
|
|
172
|
+
buckets: ChatBucket[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Configurable auth validator types.
|
|
177
|
+
*
|
|
178
|
+
* Implementors create an `auth.config.ts` file (gitignored) that exports
|
|
179
|
+
* an {@link AuthConfig} object. The server dynamically imports it at
|
|
180
|
+
* startup; if the file is absent, auth is disabled.
|
|
181
|
+
*/
|
|
182
|
+
/** The context passed to every validator invocation. */
|
|
183
|
+
interface AuthValidatorContext {
|
|
184
|
+
/** All request headers (lowercased keys). */
|
|
185
|
+
headers: Record<string, string>;
|
|
186
|
+
/** The channel being accessed. */
|
|
187
|
+
channelId: string;
|
|
188
|
+
}
|
|
189
|
+
/** What the validator must return. */
|
|
190
|
+
interface AuthValidatorResult {
|
|
191
|
+
/** Whether the request is allowed. */
|
|
192
|
+
valid: boolean;
|
|
193
|
+
/** Optional user identifier — stored for audit / logging. */
|
|
194
|
+
userId?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A function that decides whether an incoming request is authorised.
|
|
198
|
+
*
|
|
199
|
+
* Return `{ valid: true }` to allow, `{ valid: false }` to reject (401).
|
|
200
|
+
*/
|
|
201
|
+
type AuthValidator = (ctx: AuthValidatorContext) => Promise<AuthValidatorResult> | AuthValidatorResult;
|
|
202
|
+
/** The shape of the default export in `auth.config.ts`. */
|
|
203
|
+
interface AuthConfig {
|
|
204
|
+
/** The validation function. */
|
|
205
|
+
validate: AuthValidator;
|
|
206
|
+
/**
|
|
207
|
+
* How long (ms) a **valid** result is cached per cache-key.
|
|
208
|
+
* Set to `0` to disable caching. Defaults to `300_000` (5 min).
|
|
209
|
+
*/
|
|
210
|
+
cacheTtl?: number;
|
|
211
|
+
/**
|
|
212
|
+
* How long (ms) an **invalid** result is cached per cache-key.
|
|
213
|
+
* Defaults to `2_000` (2 s).
|
|
214
|
+
*/
|
|
215
|
+
invalidCacheTtl?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Derive a cache key from the request context.
|
|
218
|
+
* Defaults to the full `Authorization` header value.
|
|
219
|
+
* Return `null` to skip caching for a request.
|
|
220
|
+
*/
|
|
221
|
+
cacheKey?: (ctx: AuthValidatorContext) => string | null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface PediVehicle {
|
|
225
|
+
plate_number: string;
|
|
226
|
+
body_number: string;
|
|
227
|
+
color: string;
|
|
228
|
+
brand: string;
|
|
229
|
+
}
|
|
230
|
+
interface PediLocation {
|
|
231
|
+
latitude: number;
|
|
232
|
+
longitude: number;
|
|
233
|
+
}
|
|
234
|
+
type PediRole = 'driver' | 'rider';
|
|
235
|
+
type PediMessageType = 'chat' | 'driver_arrived' | 'booking_started' | 'booking_completed' | 'booking_cancelled' | 'system_notice';
|
|
236
|
+
interface PediParticipantMeta {
|
|
237
|
+
vehicle?: PediVehicle;
|
|
238
|
+
rating?: number;
|
|
239
|
+
current_location?: PediLocation | null;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
interface PediMessageAttributes {
|
|
243
|
+
location?: PediLocation;
|
|
244
|
+
device?: 'android' | 'ios';
|
|
245
|
+
app_version?: string;
|
|
246
|
+
booking_id?: string;
|
|
247
|
+
booking_status?: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
}
|
|
250
|
+
interface PediChat extends ChatDomain {
|
|
251
|
+
role: PediRole;
|
|
252
|
+
metadata: PediParticipantMeta;
|
|
253
|
+
messageType: PediMessageType;
|
|
254
|
+
attributes: PediMessageAttributes;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { type AuthConfig, type AuthValidator, type AuthValidatorContext, type AuthValidatorResult, type ChatBucket, type ChatDomain, type ChatManifest, type DefaultDomain, type JoinRequest, type JoinResponse, type Message, type MessageAttributes, type MessageHistoryQuery, type MessageHistoryResponse, type Participant, type PediChat, type PediLocation, type PediMessageAttributes, type PediMessageType, type PediParticipantMeta, type PediRole, type PediVehicle, type SSEEvent, type SSEMessageEvent, type SSEResyncEvent, type SendMessageRequest, type SendMessageResponse, type SystemMessageRequest, joinRequestSchema, messageAttributesSchema, messageHistoryQuerySchema, participantSchema, sendMessageRequestSchema, systemMessageRequestSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
joinRequestSchema: () => joinRequestSchema,
|
|
24
|
+
messageAttributesSchema: () => messageAttributesSchema,
|
|
25
|
+
messageHistoryQuerySchema: () => messageHistoryQuerySchema,
|
|
26
|
+
participantSchema: () => participantSchema,
|
|
27
|
+
sendMessageRequestSchema: () => sendMessageRequestSchema,
|
|
28
|
+
systemMessageRequestSchema: () => systemMessageRequestSchema
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
|
|
32
|
+
// src/participant.ts
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
var participantSchema = import_zod.z.object({
|
|
35
|
+
id: import_zod.z.string().min(1),
|
|
36
|
+
role: import_zod.z.string().min(1),
|
|
37
|
+
name: import_zod.z.string().min(1),
|
|
38
|
+
profile_image: import_zod.z.string().url().optional(),
|
|
39
|
+
metadata: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/channel.ts
|
|
43
|
+
var joinRequestSchema = participantSchema;
|
|
44
|
+
|
|
45
|
+
// src/message.ts
|
|
46
|
+
var import_zod2 = require("zod");
|
|
47
|
+
var messageAttributesSchema = import_zod2.z.object({}).catchall(import_zod2.z.unknown());
|
|
48
|
+
var sendMessageRequestSchema = import_zod2.z.object({
|
|
49
|
+
sender_id: import_zod2.z.string().min(1),
|
|
50
|
+
type: import_zod2.z.string().min(1),
|
|
51
|
+
body: import_zod2.z.string().min(1).max(1e4),
|
|
52
|
+
attributes: messageAttributesSchema.optional()
|
|
53
|
+
});
|
|
54
|
+
var systemMessageRequestSchema = import_zod2.z.object({
|
|
55
|
+
type: import_zod2.z.string().min(1),
|
|
56
|
+
body: import_zod2.z.string().min(1).max(1e4),
|
|
57
|
+
attributes: messageAttributesSchema.optional()
|
|
58
|
+
});
|
|
59
|
+
var messageHistoryQuerySchema = import_zod2.z.object({
|
|
60
|
+
limit: import_zod2.z.coerce.number().int().positive().max(200).default(50),
|
|
61
|
+
before: import_zod2.z.string().datetime().optional(),
|
|
62
|
+
after: import_zod2.z.string().datetime().optional()
|
|
63
|
+
});
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
joinRequestSchema,
|
|
67
|
+
messageAttributesSchema,
|
|
68
|
+
messageHistoryQuerySchema,
|
|
69
|
+
participantSchema,
|
|
70
|
+
sendMessageRequestSchema,
|
|
71
|
+
systemMessageRequestSchema
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/participant.ts","../src/channel.ts","../src/message.ts"],"sourcesContent":["export type { ChatDomain, DefaultDomain } from './domain';\nexport type { Participant } from './participant';\nexport type {\n MessageAttributes,\n Message,\n SendMessageRequest,\n SendMessageResponse,\n SystemMessageRequest,\n MessageHistoryQuery,\n MessageHistoryResponse,\n} from './message';\nexport type { JoinRequest, JoinResponse } from './channel';\nexport type { SSEMessageEvent, SSEResyncEvent, SSEEvent } from './sse';\nexport type { ChatBucket, ChatManifest } from './manifest';\nexport type {\n AuthValidatorContext,\n AuthValidatorResult,\n AuthValidator,\n AuthConfig,\n} from './auth';\n\nexport type {\n PediChat,\n PediRole,\n PediVehicle,\n PediLocation,\n PediParticipantMeta,\n PediMessageType,\n PediMessageAttributes,\n} from './domains';\n\nexport { participantSchema } from './participant';\nexport { joinRequestSchema } from './channel';\nexport {\n messageAttributesSchema,\n sendMessageRequestSchema,\n systemMessageRequestSchema,\n messageHistoryQuerySchema,\n} from './message';\n","import { z } from 'zod';\nimport type { ChatDomain, DefaultDomain } from './domain';\n\nexport const participantSchema = z.object({\n id: z.string().min(1),\n role: z.string().min(1),\n name: z.string().min(1),\n profile_image: z.string().url().optional(),\n metadata: z.record(z.unknown()).optional(),\n});\n\nexport interface Participant<D extends ChatDomain = DefaultDomain> {\n id: string;\n role: D['role'];\n name: string;\n profile_image?: string;\n metadata?: D['metadata'];\n}\n","import { z } from 'zod';\nimport { participantSchema, type Participant } from './participant';\nimport type { Message } from './message';\nimport type { ChatDomain, DefaultDomain } from './domain';\n\nexport const joinRequestSchema = participantSchema;\n\nexport type JoinRequest = z.infer<typeof joinRequestSchema>;\n\nexport interface JoinResponse<D extends ChatDomain = DefaultDomain> {\n channel_id: string;\n status: 'active' | 'closed';\n participants: Participant<D>[];\n messages: Message<D>[];\n joined_at: string;\n}\n","import { z } from 'zod';\nimport type { ChatDomain, DefaultDomain } from './domain';\nimport type { Participant } from './participant';\n\nexport const messageAttributesSchema = z\n .object({})\n .catchall(z.unknown());\n\nexport type MessageAttributes<D extends ChatDomain = DefaultDomain> = D['attributes'];\n\nexport interface Message<D extends ChatDomain = DefaultDomain> {\n id: string;\n channel_id: string;\n sender_id: string | null;\n sender_role: D['role'] | 'system';\n type: D['messageType'];\n body: string;\n attributes: MessageAttributes<D>;\n created_at: string;\n}\n\nexport const sendMessageRequestSchema = z.object({\n sender_id: z.string().min(1),\n type: z.string().min(1),\n body: z.string().min(1).max(10_000),\n attributes: messageAttributesSchema.optional(),\n});\n\nexport interface SendMessageRequest<D extends ChatDomain = DefaultDomain> {\n sender_id: string;\n type: D['messageType'];\n body: string;\n attributes?: MessageAttributes<D>;\n}\n\nexport interface SendMessageResponse {\n id: string;\n created_at: string;\n}\n\nexport const systemMessageRequestSchema = z.object({\n type: z.string().min(1),\n body: z.string().min(1).max(10_000),\n attributes: messageAttributesSchema.optional(),\n});\n\nexport interface SystemMessageRequest<D extends ChatDomain = DefaultDomain> {\n type: D['messageType'];\n body: string;\n attributes?: MessageAttributes<D>;\n}\n\nexport const messageHistoryQuerySchema = z.object({\n limit: z.coerce.number().int().positive().max(200).default(50),\n before: z.string().datetime().optional(),\n after: z.string().datetime().optional(),\n});\n\nexport interface MessageHistoryQuery {\n limit?: number;\n before?: string;\n after?: string;\n}\n\nexport interface MessageHistoryResponse<D extends ChatDomain = DefaultDomain> {\n channel_id: string;\n participants: Participant<D>[];\n messages: Message<D>[];\n has_more: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAGX,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,IAAI,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,MAAM,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAM,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,eAAe,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACzC,UAAU,aAAE,OAAO,aAAE,QAAQ,CAAC,EAAE,SAAS;AAC3C,CAAC;;;ACJM,IAAM,oBAAoB;;;ACLjC,IAAAA,cAAkB;AAIX,IAAM,0BAA0B,cACpC,OAAO,CAAC,CAAC,EACT,SAAS,cAAE,QAAQ,CAAC;AAehB,IAAM,2BAA2B,cAAE,OAAO;AAAA,EAC/C,WAAW,cAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,MAAM,cAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAM,cAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAM;AAAA,EAClC,YAAY,wBAAwB,SAAS;AAC/C,CAAC;AAcM,IAAM,6BAA6B,cAAE,OAAO;AAAA,EACjD,MAAM,cAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAM,cAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAM;AAAA,EAClC,YAAY,wBAAwB,SAAS;AAC/C,CAAC;AAQM,IAAM,4BAA4B,cAAE,OAAO;AAAA,EAChD,OAAO,cAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AAAA,EAC7D,QAAQ,cAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACvC,OAAO,cAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AACxC,CAAC;","names":["import_zod"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/participant.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var participantSchema = z.object({
|
|
4
|
+
id: z.string().min(1),
|
|
5
|
+
role: z.string().min(1),
|
|
6
|
+
name: z.string().min(1),
|
|
7
|
+
profile_image: z.string().url().optional(),
|
|
8
|
+
metadata: z.record(z.unknown()).optional()
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// src/channel.ts
|
|
12
|
+
var joinRequestSchema = participantSchema;
|
|
13
|
+
|
|
14
|
+
// src/message.ts
|
|
15
|
+
import { z as z2 } from "zod";
|
|
16
|
+
var messageAttributesSchema = z2.object({}).catchall(z2.unknown());
|
|
17
|
+
var sendMessageRequestSchema = z2.object({
|
|
18
|
+
sender_id: z2.string().min(1),
|
|
19
|
+
type: z2.string().min(1),
|
|
20
|
+
body: z2.string().min(1).max(1e4),
|
|
21
|
+
attributes: messageAttributesSchema.optional()
|
|
22
|
+
});
|
|
23
|
+
var systemMessageRequestSchema = z2.object({
|
|
24
|
+
type: z2.string().min(1),
|
|
25
|
+
body: z2.string().min(1).max(1e4),
|
|
26
|
+
attributes: messageAttributesSchema.optional()
|
|
27
|
+
});
|
|
28
|
+
var messageHistoryQuerySchema = z2.object({
|
|
29
|
+
limit: z2.coerce.number().int().positive().max(200).default(50),
|
|
30
|
+
before: z2.string().datetime().optional(),
|
|
31
|
+
after: z2.string().datetime().optional()
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
joinRequestSchema,
|
|
35
|
+
messageAttributesSchema,
|
|
36
|
+
messageHistoryQuerySchema,
|
|
37
|
+
participantSchema,
|
|
38
|
+
sendMessageRequestSchema,
|
|
39
|
+
systemMessageRequestSchema
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/participant.ts","../src/channel.ts","../src/message.ts"],"sourcesContent":["import { z } from 'zod';\nimport type { ChatDomain, DefaultDomain } from './domain';\n\nexport const participantSchema = z.object({\n id: z.string().min(1),\n role: z.string().min(1),\n name: z.string().min(1),\n profile_image: z.string().url().optional(),\n metadata: z.record(z.unknown()).optional(),\n});\n\nexport interface Participant<D extends ChatDomain = DefaultDomain> {\n id: string;\n role: D['role'];\n name: string;\n profile_image?: string;\n metadata?: D['metadata'];\n}\n","import { z } from 'zod';\nimport { participantSchema, type Participant } from './participant';\nimport type { Message } from './message';\nimport type { ChatDomain, DefaultDomain } from './domain';\n\nexport const joinRequestSchema = participantSchema;\n\nexport type JoinRequest = z.infer<typeof joinRequestSchema>;\n\nexport interface JoinResponse<D extends ChatDomain = DefaultDomain> {\n channel_id: string;\n status: 'active' | 'closed';\n participants: Participant<D>[];\n messages: Message<D>[];\n joined_at: string;\n}\n","import { z } from 'zod';\nimport type { ChatDomain, DefaultDomain } from './domain';\nimport type { Participant } from './participant';\n\nexport const messageAttributesSchema = z\n .object({})\n .catchall(z.unknown());\n\nexport type MessageAttributes<D extends ChatDomain = DefaultDomain> = D['attributes'];\n\nexport interface Message<D extends ChatDomain = DefaultDomain> {\n id: string;\n channel_id: string;\n sender_id: string | null;\n sender_role: D['role'] | 'system';\n type: D['messageType'];\n body: string;\n attributes: MessageAttributes<D>;\n created_at: string;\n}\n\nexport const sendMessageRequestSchema = z.object({\n sender_id: z.string().min(1),\n type: z.string().min(1),\n body: z.string().min(1).max(10_000),\n attributes: messageAttributesSchema.optional(),\n});\n\nexport interface SendMessageRequest<D extends ChatDomain = DefaultDomain> {\n sender_id: string;\n type: D['messageType'];\n body: string;\n attributes?: MessageAttributes<D>;\n}\n\nexport interface SendMessageResponse {\n id: string;\n created_at: string;\n}\n\nexport const systemMessageRequestSchema = z.object({\n type: z.string().min(1),\n body: z.string().min(1).max(10_000),\n attributes: messageAttributesSchema.optional(),\n});\n\nexport interface SystemMessageRequest<D extends ChatDomain = DefaultDomain> {\n type: D['messageType'];\n body: string;\n attributes?: MessageAttributes<D>;\n}\n\nexport const messageHistoryQuerySchema = z.object({\n limit: z.coerce.number().int().positive().max(200).default(50),\n before: z.string().datetime().optional(),\n after: z.string().datetime().optional(),\n});\n\nexport interface MessageHistoryQuery {\n limit?: number;\n before?: string;\n after?: string;\n}\n\nexport interface MessageHistoryResponse<D extends ChatDomain = DefaultDomain> {\n channel_id: string;\n participants: Participant<D>[];\n messages: Message<D>[];\n has_more: boolean;\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAGX,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACzC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC3C,CAAC;;;ACJM,IAAM,oBAAoB;;;ACLjC,SAAS,KAAAA,UAAS;AAIX,IAAM,0BAA0BA,GACpC,OAAO,CAAC,CAAC,EACT,SAASA,GAAE,QAAQ,CAAC;AAehB,IAAM,2BAA2BA,GAAE,OAAO;AAAA,EAC/C,WAAWA,GAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,MAAMA,GAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAMA,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAM;AAAA,EAClC,YAAY,wBAAwB,SAAS;AAC/C,CAAC;AAcM,IAAM,6BAA6BA,GAAE,OAAO;AAAA,EACjD,MAAMA,GAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,MAAMA,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAM;AAAA,EAClC,YAAY,wBAAwB,SAAS;AAC/C,CAAC;AAQM,IAAM,4BAA4BA,GAAE,OAAO;AAAA,EAChD,OAAOA,GAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AAAA,EAC7D,QAAQA,GAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACvC,OAAOA,GAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AACxC,CAAC;","names":["z"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pedi/chika-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared TypeScript types and Zod schemas for Pedi Chika chat service",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "^3.24.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"tsup": "^8.4.0",
|
|
35
|
+
"typescript": "^5.7.0"
|
|
36
|
+
}
|
|
37
|
+
}
|