xyne-apps 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 +243 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +61 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/chat/index.d.ts +23 -0
- package/dist/modules/chat/index.d.ts.map +1 -0
- package/dist/modules/chat/index.js +76 -0
- package/dist/modules/chat/index.js.map +1 -0
- package/dist/modules/chat/schema.d.ts +124 -0
- package/dist/modules/chat/schema.d.ts.map +1 -0
- package/dist/modules/chat/schema.js +53 -0
- package/dist/modules/chat/schema.js.map +1 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.d.ts.map +1 -0
- package/dist/modules/files/index.js +31 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/files/schema.d.ts +43 -0
- package/dist/modules/files/schema.d.ts.map +1 -0
- package/dist/modules/files/schema.js +14 -0
- package/dist/modules/files/schema.js.map +1 -0
- package/dist/modules/tickets/index.d.ts +8 -0
- package/dist/modules/tickets/index.d.ts.map +1 -0
- package/dist/modules/tickets/index.js +16 -0
- package/dist/modules/tickets/index.js.map +1 -0
- package/dist/modules/tickets/schema.d.ts +49 -0
- package/dist/modules/tickets/schema.d.ts.map +1 -0
- package/dist/modules/tickets/schema.js +20 -0
- package/dist/modules/tickets/schema.js.map +1 -0
- package/dist/modules/user/index.d.ts +8 -0
- package/dist/modules/user/index.d.ts.map +1 -0
- package/dist/modules/user/index.js +22 -0
- package/dist/modules/user/index.js.map +1 -0
- package/dist/modules/user/schema.d.ts +33 -0
- package/dist/modules/user/schema.d.ts.map +1 -0
- package/dist/modules/user/schema.js +16 -0
- package/dist/modules/user/schema.js.map +1 -0
- package/package.json +18 -0
- package/src/client.ts +87 -0
- package/src/index.ts +38 -0
- package/src/modules/chat/index.ts +106 -0
- package/src/modules/chat/schema.ts +119 -0
- package/src/modules/files/index.ts +37 -0
- package/src/modules/files/schema.ts +37 -0
- package/src/modules/tickets/index.ts +23 -0
- package/src/modules/tickets/schema.ts +31 -0
- package/src/modules/user/index.ts +28 -0
- package/src/modules/user/schema.ts +29 -0
- package/tsconfig.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# xyne-apps
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with the **Xyne Apps API**. It provides typed modules for Chat, Tickets, Users, and File uploads.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install xyne-apps
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Requirements:** Node.js 18+ (uses the native `fetch` and `FormData` globals).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { createClient } from "xyne-apps";
|
|
21
|
+
|
|
22
|
+
const client = createClient({ authToken: "YOUR_AUTH_TOKEN" });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> All requests are sent to the Xyne Spaces API at:
|
|
26
|
+
> `https://spaces.xyne.juspay.net/api/apps`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Modules
|
|
31
|
+
|
|
32
|
+
### `client.chat` — Chat Module
|
|
33
|
+
|
|
34
|
+
#### `postMessage(params)`
|
|
35
|
+
|
|
36
|
+
Sends a message to a channel or a conversation. Either `channelId` or `conversationId` is required.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const response = await client.chat.postMessage({
|
|
40
|
+
text: "Hello, world!",
|
|
41
|
+
channelId: "channel-123",
|
|
42
|
+
// or: conversationId: "conv-456",
|
|
43
|
+
});
|
|
44
|
+
// response: { eventType, conversationId, messageId }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Required |
|
|
48
|
+
| ---------------- | -------- | -------- |
|
|
49
|
+
| `text` | `string` | ✅ |
|
|
50
|
+
| `channelId` | `string` | ✅ (one of) |
|
|
51
|
+
| `conversationId` | `string` | ✅ (one of) |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
#### `updateMessage(params)`
|
|
56
|
+
|
|
57
|
+
Updates the text of an existing message. Either `channelId` or `conversationId` is required.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const response = await client.chat.updateMessage({
|
|
61
|
+
messageId: "msg-789",
|
|
62
|
+
text: "Updated message text",
|
|
63
|
+
channelId: "channel-123",
|
|
64
|
+
});
|
|
65
|
+
// response: { eventType, conversationId, messageId }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Parameter | Type | Required |
|
|
69
|
+
| ---------------- | -------- | -------- |
|
|
70
|
+
| `messageId` | `string` | ✅ |
|
|
71
|
+
| `text` | `string` | ✅ |
|
|
72
|
+
| `channelId` | `string` | ✅ (one of) |
|
|
73
|
+
| `conversationId` | `string` | ✅ (one of) |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
#### `channelHistory(params)`
|
|
78
|
+
|
|
79
|
+
Fetches paginated message history for a channel.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const history = await client.chat.channelHistory({
|
|
83
|
+
channelId: "channel-123",
|
|
84
|
+
limit: "50", // optional, defaults to 1000
|
|
85
|
+
cursor: "...", // optional, for pagination
|
|
86
|
+
});
|
|
87
|
+
// history: { items, nextCursor, hasMore }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Parameter | Type | Required |
|
|
91
|
+
| ----------- | -------- | -------- |
|
|
92
|
+
| `channelId` | `string` | ✅ |
|
|
93
|
+
| `limit` | `string` | ❌ (default: 1000) |
|
|
94
|
+
| `cursor` | `string` | ❌ |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
#### `conversationReplies(params)`
|
|
99
|
+
|
|
100
|
+
Fetches paginated replies for a conversation.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const replies = await client.chat.conversationReplies({
|
|
104
|
+
conversationId: "conv-456",
|
|
105
|
+
channelId: "channel-123", // optional
|
|
106
|
+
limit: "25",
|
|
107
|
+
cursor: "...",
|
|
108
|
+
});
|
|
109
|
+
// replies: { items, nextCursor, hasMore }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Parameter | Type | Required |
|
|
113
|
+
| ---------------- | -------- | -------- |
|
|
114
|
+
| `conversationId` | `string` | ✅ |
|
|
115
|
+
| `channelId` | `string` | ❌ |
|
|
116
|
+
| `limit` | `string` | ❌ (default: 1000) |
|
|
117
|
+
| `cursor` | `string` | ❌ |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### `client.tickets` — Tickets Module
|
|
122
|
+
|
|
123
|
+
#### `createTicket(params)`
|
|
124
|
+
|
|
125
|
+
Creates a new ticket.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { TicketPriority } from "xyne-apps";
|
|
129
|
+
|
|
130
|
+
const ticket = await client.tickets.createTicket({
|
|
131
|
+
title: "Bug: login broken",
|
|
132
|
+
description: "Users cannot log in with SSO.",
|
|
133
|
+
projectId: "proj-001",
|
|
134
|
+
boardId: "board-001",
|
|
135
|
+
channelId: "channel-123",
|
|
136
|
+
userId: "user-42",
|
|
137
|
+
priority: TicketPriority.HIGH, // optional: LOW | MEDIUM | HIGH
|
|
138
|
+
assignedToEmail: "engineer@example.com", // optional
|
|
139
|
+
assignedUserGroupAlias: "backend-team", // optional
|
|
140
|
+
text: "Additional context…", // optional
|
|
141
|
+
});
|
|
142
|
+
// ticket: { eventType, ticketId, xyneId, conversationId, messageId }
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Parameter | Type | Required |
|
|
146
|
+
| ------------------------ | ---------------- | -------- |
|
|
147
|
+
| `title` | `string` | ✅ |
|
|
148
|
+
| `description` | `string` | ✅ |
|
|
149
|
+
| `projectId` | `string` | ✅ |
|
|
150
|
+
| `boardId` | `string` | ✅ |
|
|
151
|
+
| `channelId` | `string` | ✅ |
|
|
152
|
+
| `userId` | `string` | ✅ |
|
|
153
|
+
| `priority` | `TicketPriority` | ❌ |
|
|
154
|
+
| `assignedToEmail` | `string` | ❌ |
|
|
155
|
+
| `assignedUserGroupAlias` | `string` | ❌ |
|
|
156
|
+
| `text` | `string` | ❌ |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `client.user` — User Module
|
|
161
|
+
|
|
162
|
+
#### `info(params)`
|
|
163
|
+
|
|
164
|
+
Fetches profile information for a user. Either `channelId` or `conversationId` is required.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const user = await client.user.info({
|
|
168
|
+
user: "user-42",
|
|
169
|
+
channelId: "channel-123",
|
|
170
|
+
// or: conversationId: "conv-456",
|
|
171
|
+
});
|
|
172
|
+
// user: { userId, name, email, picture, userType, status, joined }
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| Parameter | Type | Required |
|
|
176
|
+
| ---------------- | -------- | -------- |
|
|
177
|
+
| `user` | `string` | ✅ |
|
|
178
|
+
| `channelId` | `string` | ✅ (one of) |
|
|
179
|
+
| `conversationId` | `string` | ✅ (one of) |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### `client.files` — Files Module
|
|
184
|
+
|
|
185
|
+
#### `filesUpload(params)`
|
|
186
|
+
|
|
187
|
+
Uploads one or more files to a channel or conversation. Either `channelId` or `conversationId` is required.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { readFileSync } from "fs";
|
|
191
|
+
|
|
192
|
+
const blob = new Blob([readFileSync("report.pdf")], { type: "application/pdf" });
|
|
193
|
+
|
|
194
|
+
const result = await client.files.filesUpload({
|
|
195
|
+
files: [blob],
|
|
196
|
+
channelId: "channel-123",
|
|
197
|
+
// or: conversationId: "conv-456",
|
|
198
|
+
text: "Here is the report", // optional caption
|
|
199
|
+
});
|
|
200
|
+
// result: { eventType, conversationId, messageId, attachments }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Parameter | Type | Required |
|
|
204
|
+
| ---------------- | ---------- | -------- |
|
|
205
|
+
| `files` | `Blob[]` | ✅ (min 1) |
|
|
206
|
+
| `channelId` | `string` | ✅ (one of) |
|
|
207
|
+
| `conversationId` | `string` | ✅ (one of) |
|
|
208
|
+
| `text` | `string` | ❌ |
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Error Handling
|
|
213
|
+
|
|
214
|
+
All methods throw a `XyneApiError` when the server returns a non-2xx response.
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { XyneApiError } from "xyne-apps";
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
await client.chat.postMessage({ text: "Hi", channelId: "channel-123" });
|
|
221
|
+
} catch (err) {
|
|
222
|
+
if (err instanceof XyneApiError) {
|
|
223
|
+
console.error(err.status); // HTTP status code
|
|
224
|
+
console.error(err.bodyText); // Raw response body
|
|
225
|
+
console.error(err.message); // Human-readable error message
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Building from Source
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npm install
|
|
236
|
+
npm run build # runs tsc, output goes to dist/
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
ISC
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ChatModule } from "./modules/chat/index.js";
|
|
2
|
+
import { TicketsModule } from "./modules/tickets/index.js";
|
|
3
|
+
import { UserModule } from "./modules/user/index.js";
|
|
4
|
+
import { FilesModule } from "./modules/files/index.js";
|
|
5
|
+
export type HttpMethod = "GET" | "POST";
|
|
6
|
+
export interface XyneClientOptions {
|
|
7
|
+
authToken: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class XyneApiError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly bodyText: string;
|
|
12
|
+
constructor(message: string, status: number, bodyText: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class XyneClient {
|
|
15
|
+
readonly chat: ChatModule;
|
|
16
|
+
readonly tickets: TicketsModule;
|
|
17
|
+
readonly files: FilesModule;
|
|
18
|
+
readonly user: UserModule;
|
|
19
|
+
private readonly authToken;
|
|
20
|
+
constructor(options: XyneClientOptions);
|
|
21
|
+
request<TResponse = unknown>(args: {
|
|
22
|
+
method: HttpMethod;
|
|
23
|
+
path: string;
|
|
24
|
+
body?: unknown;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}): Promise<TResponse>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createClient(options: XyneClientOptions): XyneClient;
|
|
29
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAM9D;AAED,qBAAa,UAAU;IACrB,SAAgB,IAAI,EAAE,UAAU,CAAC;IACjC,SAAgB,OAAO,EAAE,aAAa,CAAC;IACvC,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,IAAI,EAAE,UAAU,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,iBAAiB;IAQzB,OAAO,CAAC,SAAS,GAAG,OAAO,EAAE,IAAI,EAAE;QAC9C,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,SAAS,CAAC;CAoCvB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAEnE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ChatModule } from "./modules/chat/index.js";
|
|
2
|
+
import { TicketsModule } from "./modules/tickets/index.js";
|
|
3
|
+
import { UserModule } from "./modules/user/index.js";
|
|
4
|
+
import { FilesModule } from "./modules/files/index.js";
|
|
5
|
+
const BASE_URL = "https://spaces.xyne.juspay.net/api/apps";
|
|
6
|
+
export class XyneApiError extends Error {
|
|
7
|
+
status;
|
|
8
|
+
bodyText;
|
|
9
|
+
constructor(message, status, bodyText) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "XyneApiError";
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.bodyText = bodyText;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class XyneClient {
|
|
17
|
+
chat;
|
|
18
|
+
tickets;
|
|
19
|
+
files;
|
|
20
|
+
user;
|
|
21
|
+
authToken;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.authToken = options.authToken;
|
|
24
|
+
this.chat = new ChatModule(this);
|
|
25
|
+
this.tickets = new TicketsModule(this);
|
|
26
|
+
this.files = new FilesModule(this);
|
|
27
|
+
this.user = new UserModule(this);
|
|
28
|
+
}
|
|
29
|
+
async request(args) {
|
|
30
|
+
const url = `${BASE_URL}${args.path}`;
|
|
31
|
+
const headers = {
|
|
32
|
+
...(args.headers ?? {}),
|
|
33
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
34
|
+
};
|
|
35
|
+
const init = { method: args.method, headers };
|
|
36
|
+
if (args.body !== undefined) {
|
|
37
|
+
const formDataCtor = globalThis["FormData"];
|
|
38
|
+
const isFormData = !!formDataCtor && args.body instanceof formDataCtor;
|
|
39
|
+
if (isFormData) {
|
|
40
|
+
// Let the runtime set the correct `Content-Type` boundary for multipart.
|
|
41
|
+
init.body = args.body;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
headers["Content-Type"] = "application/json";
|
|
45
|
+
init.body = JSON.stringify(args.body);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const res = await globalThis.fetch(url, init);
|
|
49
|
+
const bodyText = await res.text();
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw new XyneApiError(`Request failed with status ${res.status} for ${args.method} ${url}`, res.status, bodyText);
|
|
52
|
+
}
|
|
53
|
+
if (!bodyText)
|
|
54
|
+
return undefined;
|
|
55
|
+
return JSON.parse(bodyText);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function createClient(options) {
|
|
59
|
+
return new XyneClient(options);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EA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,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QAE3D,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,YAAY,GAAI,UAAsC,CAAC,UAAU,CAAC,CAAC;YACzE,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,YAAa,YAAgC,CAAC;YAC5F,IAAI,UAAU,EAAE,CAAC;gBACf,yEAAyE;gBACzE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAgB,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;gBAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAElC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,YAAY,CACpB,8BAA8B,GAAG,CAAC,MAAM,QAAQ,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,EACpE,GAAG,CAAC,MAAM,EACV,QAAQ,CACT,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAsB,CAAC;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAc,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,OAA0B;IACrD,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createClient, XyneApiError, XyneClient } from "./client.js";
|
|
2
|
+
export type { XyneClientOptions } from "./client.js";
|
|
3
|
+
export { ChatModule } from "./modules/chat/index.js";
|
|
4
|
+
export { TicketsModule } from "./modules/tickets/index.js";
|
|
5
|
+
export { UserModule } from "./modules/user/index.js";
|
|
6
|
+
export { FilesModule } from "./modules/files/index.js";
|
|
7
|
+
export type { ChatPostMessageParams, ChatPostMessageResponse, ChatUpdateMessageParams, ChatUpdateMessageResponse, AppEventAttachment, ChannelHistoryQueryParams, ChannelHistoryItem, ConversationRepliesQueryParams, ConversationRepliesItem, ChatPaginatedResponse, } from "./modules/chat/schema.js";
|
|
8
|
+
export { CreateTicketBodySchema, type CreateTicketBodyParams, type TicketActionResponse, TicketPriority, } from "./modules/tickets/schema.js";
|
|
9
|
+
export { UserInfoQuerySchema, type UserInfoQueryParams, type UserResponse, } from "./modules/user/schema.js";
|
|
10
|
+
export { UploadFilesInputSchema, type UploadFilesInput, type FileUploadResponse, } from "./modules/files/schema.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,8BAA8B,EAC9B,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createClient, XyneApiError, XyneClient } from "./client.js";
|
|
2
|
+
export { ChatModule } from "./modules/chat/index.js";
|
|
3
|
+
export { TicketsModule } from "./modules/tickets/index.js";
|
|
4
|
+
export { UserModule } from "./modules/user/index.js";
|
|
5
|
+
export { FilesModule } from "./modules/files/index.js";
|
|
6
|
+
export { CreateTicketBodySchema, TicketPriority, } from "./modules/tickets/schema.js";
|
|
7
|
+
export { UserInfoQuerySchema, } from "./modules/user/schema.js";
|
|
8
|
+
export { UploadFilesInputSchema, } from "./modules/files/schema.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAcvD,OAAO,EACL,sBAAsB,EAGtB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,mBAAmB,GAGpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,sBAAsB,GAGvB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { XyneClient } from "../../client.js";
|
|
2
|
+
import { type ChatPostMessageParams, type ChatPostMessageResponse, type ChatUpdateMessageParams, type ChatUpdateMessageResponse, type ChannelHistoryQueryParams, type ConversationRepliesQueryParams, type ChatPaginatedResponse } from "./schema.js";
|
|
3
|
+
export declare class ChatModule {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: XyneClient);
|
|
6
|
+
/**
|
|
7
|
+
* Sends a message to either a channel or a conversation.
|
|
8
|
+
*/
|
|
9
|
+
postMessage(params: ChatPostMessageParams): Promise<ChatPostMessageResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Updates an existing message.
|
|
12
|
+
*/
|
|
13
|
+
updateMessage(params: ChatUpdateMessageParams): Promise<ChatUpdateMessageResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetches channel/conversation message history with pagination.
|
|
16
|
+
*/
|
|
17
|
+
channelHistory(params: ChannelHistoryQueryParams): Promise<ChatPaginatedResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetches replies for a given conversation with pagination.
|
|
20
|
+
*/
|
|
21
|
+
conversationReplies(params: ConversationRepliesQueryParams): Promise<ChatPaginatedResponse>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAKL,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAErB,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;OAEG;IACU,WAAW,CACtB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,uBAAuB,CAAC;IAgBnC;;OAEG;IACU,aAAa,CACxB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;OAEG;IACU,cAAc,CACzB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,qBAAqB,CAAC;IAgBjC;;OAEG;IACU,mBAAmB,CAC9B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,qBAAqB,CAAC;CAgBlC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ChatPostMessageSchema, ChatUpdateMessageSchema, ChannelHistoryQuerySchema, ConversationRepliesQuerySchema, } from "./schema.js";
|
|
2
|
+
export class ChatModule {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sends a message to either a channel or a conversation.
|
|
9
|
+
*/
|
|
10
|
+
async postMessage(params) {
|
|
11
|
+
const parsed = ChatPostMessageSchema.parse(params);
|
|
12
|
+
const body = {
|
|
13
|
+
text: parsed.text,
|
|
14
|
+
...(parsed.channelId && { channelId: parsed.channelId }),
|
|
15
|
+
...(parsed.conversationId && { conversationId: parsed.conversationId }),
|
|
16
|
+
};
|
|
17
|
+
return this.client.request({
|
|
18
|
+
method: "POST",
|
|
19
|
+
path: "/chat/postMessage",
|
|
20
|
+
body,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Updates an existing message.
|
|
25
|
+
*/
|
|
26
|
+
async updateMessage(params) {
|
|
27
|
+
const parsed = ChatUpdateMessageSchema.parse(params);
|
|
28
|
+
const body = {
|
|
29
|
+
messageId: parsed.messageId,
|
|
30
|
+
text: parsed.text,
|
|
31
|
+
...(parsed.channelId
|
|
32
|
+
? { channelId: parsed.channelId }
|
|
33
|
+
: { conversationId: parsed.conversationId }),
|
|
34
|
+
};
|
|
35
|
+
return this.client.request({
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: "/chat/updateMessage",
|
|
38
|
+
body,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetches channel/conversation message history with pagination.
|
|
43
|
+
*/
|
|
44
|
+
async channelHistory(params) {
|
|
45
|
+
const parsed = ChannelHistoryQuerySchema.parse(params);
|
|
46
|
+
const queryParams = new URLSearchParams();
|
|
47
|
+
queryParams.set("channelId", parsed.channelId);
|
|
48
|
+
queryParams.set("limit", String(parsed.limit));
|
|
49
|
+
if (parsed.cursor)
|
|
50
|
+
queryParams.set("cursor", parsed.cursor);
|
|
51
|
+
const result = await this.client.request({
|
|
52
|
+
method: "GET",
|
|
53
|
+
path: `/chat/channelHistory?${queryParams.toString()}`,
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Fetches replies for a given conversation with pagination.
|
|
59
|
+
*/
|
|
60
|
+
async conversationReplies(params) {
|
|
61
|
+
const parsed = ConversationRepliesQuerySchema.parse(params);
|
|
62
|
+
const queryParams = new URLSearchParams();
|
|
63
|
+
queryParams.set("conversationId", parsed.conversationId);
|
|
64
|
+
if (parsed.channelId)
|
|
65
|
+
queryParams.set("channelId", parsed.channelId);
|
|
66
|
+
queryParams.set("limit", String(parsed.limit));
|
|
67
|
+
if (parsed.cursor)
|
|
68
|
+
queryParams.set("cursor", parsed.cursor);
|
|
69
|
+
const result = await this.client.request({
|
|
70
|
+
method: "GET",
|
|
71
|
+
path: `/chat/conversationReplies?${queryParams.toString()}`,
|
|
72
|
+
});
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/chat/index.ts"],"names":[],"mappings":"AACA,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C,OAAO,CAAU;YAChD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,6BAA6B,WAAW,CAAC,QAAQ,EAAE,EAAE;SAC5D,CAAC,CAAC;QAEH,OAAO,MAA+B,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ChatPostMessageSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
text: z.ZodString;
|
|
4
|
+
} & {
|
|
5
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
text: string;
|
|
9
|
+
channelId?: string | undefined;
|
|
10
|
+
conversationId?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
text: string;
|
|
13
|
+
channelId?: string | undefined;
|
|
14
|
+
conversationId?: string | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
text: string;
|
|
17
|
+
channelId?: string | undefined;
|
|
18
|
+
conversationId?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
text: string;
|
|
21
|
+
channelId?: string | undefined;
|
|
22
|
+
conversationId?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export type ChatPostMessageParams = z.infer<typeof ChatPostMessageSchema>;
|
|
25
|
+
export interface ChatPostMessageResponse {
|
|
26
|
+
eventType: string;
|
|
27
|
+
conversationId: string;
|
|
28
|
+
messageId: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const ChatUpdateMessageSchema: z.ZodEffects<z.ZodObject<{
|
|
31
|
+
messageId: z.ZodString;
|
|
32
|
+
text: z.ZodString;
|
|
33
|
+
} & {
|
|
34
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
text: string;
|
|
38
|
+
messageId: string;
|
|
39
|
+
channelId?: string | undefined;
|
|
40
|
+
conversationId?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
text: string;
|
|
43
|
+
messageId: string;
|
|
44
|
+
channelId?: string | undefined;
|
|
45
|
+
conversationId?: string | undefined;
|
|
46
|
+
}>, {
|
|
47
|
+
text: string;
|
|
48
|
+
messageId: string;
|
|
49
|
+
channelId?: string | undefined;
|
|
50
|
+
conversationId?: string | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
text: string;
|
|
53
|
+
messageId: string;
|
|
54
|
+
channelId?: string | undefined;
|
|
55
|
+
conversationId?: string | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
export type ChatUpdateMessageParams = z.infer<typeof ChatUpdateMessageSchema>;
|
|
58
|
+
export interface ChatUpdateMessageResponse {
|
|
59
|
+
eventType: string;
|
|
60
|
+
conversationId: string;
|
|
61
|
+
messageId: string;
|
|
62
|
+
}
|
|
63
|
+
export declare const ChannelHistoryQuerySchema: z.ZodObject<{
|
|
64
|
+
channelId: z.ZodString;
|
|
65
|
+
limit: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>;
|
|
66
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
channelId: string;
|
|
69
|
+
limit: number;
|
|
70
|
+
cursor?: string | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
channelId: string;
|
|
73
|
+
limit?: string | undefined;
|
|
74
|
+
cursor?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
export type ChannelHistoryQueryParams = z.input<typeof ChannelHistoryQuerySchema>;
|
|
77
|
+
export declare const ConversationRepliesQuerySchema: z.ZodObject<{
|
|
78
|
+
conversationId: z.ZodString;
|
|
79
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
80
|
+
limit: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>;
|
|
81
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
conversationId: string;
|
|
84
|
+
limit: number;
|
|
85
|
+
channelId?: string | undefined;
|
|
86
|
+
cursor?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
conversationId: string;
|
|
89
|
+
channelId?: string | undefined;
|
|
90
|
+
limit?: string | undefined;
|
|
91
|
+
cursor?: string | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
export type ConversationRepliesQueryParams = z.input<typeof ConversationRepliesQuerySchema>;
|
|
94
|
+
export interface AppEventAttachment {
|
|
95
|
+
attachmentId: string;
|
|
96
|
+
fileName: string;
|
|
97
|
+
fileSize: number;
|
|
98
|
+
mimeType: string;
|
|
99
|
+
fileUrl: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ChannelHistoryItem {
|
|
102
|
+
initialMessageId: string;
|
|
103
|
+
conversationId: string;
|
|
104
|
+
content: string;
|
|
105
|
+
cleanContent: string;
|
|
106
|
+
userId: string;
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
attachments?: AppEventAttachment[];
|
|
109
|
+
}
|
|
110
|
+
export interface ConversationRepliesItem {
|
|
111
|
+
messageId: string;
|
|
112
|
+
conversationId: string;
|
|
113
|
+
content: string;
|
|
114
|
+
cleanContent: string;
|
|
115
|
+
userId: string;
|
|
116
|
+
createdAt: Date;
|
|
117
|
+
attachments?: AppEventAttachment[];
|
|
118
|
+
}
|
|
119
|
+
export interface ChatPaginatedResponse {
|
|
120
|
+
items: ChannelHistoryItem[] | ConversationRepliesItem[];
|
|
121
|
+
nextCursor?: string;
|
|
122
|
+
hasMore: boolean;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/chat/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;E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,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,kBAAkB,EAAE,GAAG,uBAAuB,EAAE,CAAC;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ChatPostMessageSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
text: z.string().min(1, "text is required").trim(),
|
|
5
|
+
})
|
|
6
|
+
.extend({
|
|
7
|
+
channelId: z.string().min(1, "Channel ID is required").trim().optional(),
|
|
8
|
+
conversationId: z.string().trim().optional(),
|
|
9
|
+
})
|
|
10
|
+
.refine((data) => !!data.channelId || !!data.conversationId, {
|
|
11
|
+
message: "Either channelId or conversationId is required",
|
|
12
|
+
path: ["channelId"],
|
|
13
|
+
});
|
|
14
|
+
export const ChatUpdateMessageSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
messageId: z.string().min(1, "messageId is required").trim(),
|
|
17
|
+
text: z.string().min(1, "text is required").trim(),
|
|
18
|
+
})
|
|
19
|
+
.extend({
|
|
20
|
+
channelId: z.string().min(1, "channelId is required").trim().optional(),
|
|
21
|
+
conversationId: z
|
|
22
|
+
.string()
|
|
23
|
+
.min(1, "conversationId is required")
|
|
24
|
+
.trim()
|
|
25
|
+
.optional(),
|
|
26
|
+
})
|
|
27
|
+
.refine((data) => !!data.channelId || !!data.conversationId, {
|
|
28
|
+
message: "At least one of channelId or conversationId is required",
|
|
29
|
+
path: ["channelId"],
|
|
30
|
+
});
|
|
31
|
+
export const ChannelHistoryQuerySchema = z
|
|
32
|
+
.object({
|
|
33
|
+
channelId: z.string().min(1, "Channel ID is required").trim(),
|
|
34
|
+
limit: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.transform((val) => (val ? parseInt(val, 10) : 1000)),
|
|
38
|
+
cursor: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
export const ConversationRepliesQuerySchema = z
|
|
41
|
+
.object({
|
|
42
|
+
conversationId: z
|
|
43
|
+
.string()
|
|
44
|
+
.min(1, "Conversation ID is required")
|
|
45
|
+
.trim(),
|
|
46
|
+
channelId: z.string().min(1, "Channel ID is required").trim().optional(),
|
|
47
|
+
limit: z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.transform((val) => (val ? parseInt(val, 10) : 1000)),
|
|
51
|
+
cursor: z.string().optional(),
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=schema.js.map
|