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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/chat/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,IAAI,EAAE;CACnD,CAAC;KACD,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACxE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EACnD;IACE,OAAO,EAAE,gDAAgD;IACzD,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CACF,CAAC;AAUJ,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC;KACrC,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,IAAI,EAAE;IAC5D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,IAAI,EAAE;CACnD,CAAC;KACD,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACvE,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;SACpC,IAAI,EAAE;SACN,QAAQ,EAAE;CACd,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE;IAC3D,OAAO,EAAE,yDAAyD;IAClE,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CAAC,CAAC;AAWL,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE;IAC7D,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CACD;AAMH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC;KAC5C,MAAM,CAAC;IACN,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;SACrC,IAAI,EAAE;IACT,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACxE,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { XyneClient } from "../../client.js";
|
|
2
|
+
import { type UploadFilesInput, type FileUploadResponse } from "./schema.js";
|
|
3
|
+
export declare class FilesModule {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: XyneClient);
|
|
6
|
+
filesUpload(params: UploadFilesInput): Promise<FileUploadResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/files/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAElC,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyBhF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UploadFilesInputSchema, } from "./schema.js";
|
|
2
|
+
export class FilesModule {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async filesUpload(params) {
|
|
8
|
+
const parsed = UploadFilesInputSchema.parse(params);
|
|
9
|
+
const { files, channelId, text, conversationId } = parsed;
|
|
10
|
+
const formData = new FormData();
|
|
11
|
+
if (channelId)
|
|
12
|
+
formData.append("channelId", channelId);
|
|
13
|
+
if (text)
|
|
14
|
+
formData.append("text", text);
|
|
15
|
+
if (conversationId)
|
|
16
|
+
formData.append("conversationId", conversationId);
|
|
17
|
+
for (const f of files) {
|
|
18
|
+
const nameFromBlob = f.name;
|
|
19
|
+
const multipartName = typeof nameFromBlob === "string" && nameFromBlob.length > 0
|
|
20
|
+
? nameFromBlob
|
|
21
|
+
: "file";
|
|
22
|
+
formData.append("files", f, multipartName);
|
|
23
|
+
}
|
|
24
|
+
return this.client.request({
|
|
25
|
+
method: "POST",
|
|
26
|
+
path: "/files/filesUpload",
|
|
27
|
+
body: formData,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/files/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE5C,KAAK,CAAC,WAAW,CAAC,MAAwB;QAC/C,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;QAE1D,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAEhC,IAAI,SAAS;YAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,IAAI;YAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxC,IAAI,cAAc;YAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAEtE,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,YAAY,GAAI,CAAS,CAAC,IAAI,CAAC;YACrC,MAAM,aAAa,GACjB,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;gBACzD,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,MAAM,CAAC;YACb,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAQ,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB;YAC7C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const UploadFilesInputSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
files: z.ZodArray<z.ZodType<Blob, z.ZodTypeDef, Blob>, "many">;
|
|
4
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
text: z.ZodOptional<z.ZodString>;
|
|
6
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
files: Blob[];
|
|
9
|
+
text?: string | undefined;
|
|
10
|
+
channelId?: string | undefined;
|
|
11
|
+
conversationId?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
files: Blob[];
|
|
14
|
+
text?: string | undefined;
|
|
15
|
+
channelId?: string | undefined;
|
|
16
|
+
conversationId?: string | undefined;
|
|
17
|
+
}>, {
|
|
18
|
+
files: Blob[];
|
|
19
|
+
text?: string | undefined;
|
|
20
|
+
channelId?: string | undefined;
|
|
21
|
+
conversationId?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
files: Blob[];
|
|
24
|
+
text?: string | undefined;
|
|
25
|
+
channelId?: string | undefined;
|
|
26
|
+
conversationId?: string | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type UploadFilesInput = z.input<typeof UploadFilesInputSchema>;
|
|
29
|
+
export interface FileAttachment {
|
|
30
|
+
fileid: string;
|
|
31
|
+
originalFilename: string;
|
|
32
|
+
url: string;
|
|
33
|
+
size: number;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
}
|
|
36
|
+
export type FileUploadEventType = string;
|
|
37
|
+
export interface FileUploadResponse {
|
|
38
|
+
eventType: FileUploadEventType;
|
|
39
|
+
conversationId: string;
|
|
40
|
+
messageId: string;
|
|
41
|
+
attachments: Array<FileAttachment>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/files/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;EAchC,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const UploadFilesInputSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
// Multipart payload expects `files` entries.
|
|
5
|
+
files: z.array(z.instanceof(Blob)).min(1, "Missing file uploads. Provide `files`."),
|
|
6
|
+
channelId: z.string().min(1, "Channel ID is required").trim().optional(),
|
|
7
|
+
text: z.string().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
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/files/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC;IACN,6CAA6C;IAC7C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;IACnF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACxE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAClC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EACnD;IACE,OAAO,EAAE,gDAAgD;IACzD,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { XyneClient } from "../../client.js";
|
|
2
|
+
import { type CreateTicketBodyParams, type TicketActionResponse } from "./schema.js";
|
|
3
|
+
export declare class TicketsModule {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: XyneClient);
|
|
6
|
+
createTicket(params: CreateTicketBodyParams): Promise<TicketActionResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/tickets/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAErB,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAElC,YAAY,CACvB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,oBAAoB,CAAC;CASjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CreateTicketBodySchema, } from "./schema.js";
|
|
2
|
+
export class TicketsModule {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async createTicket(params) {
|
|
8
|
+
const body = CreateTicketBodySchema.parse(params);
|
|
9
|
+
return this.client.request({
|
|
10
|
+
method: "POST",
|
|
11
|
+
path: "/ticket/createTicket",
|
|
12
|
+
body,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/tickets/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,GAGvB,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE5C,KAAK,CAAC,YAAY,CACvB,MAA8B;QAE9B,MAAM,IAAI,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAElD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAuB;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum TicketPriority {
|
|
3
|
+
LOW = "LOW",
|
|
4
|
+
MEDIUM = "MEDIUM",
|
|
5
|
+
HIGH = "HIGH"
|
|
6
|
+
}
|
|
7
|
+
export declare const CreateTicketBodySchema: z.ZodObject<{
|
|
8
|
+
title: z.ZodString;
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
projectId: z.ZodString;
|
|
11
|
+
boardId: z.ZodString;
|
|
12
|
+
channelId: z.ZodString;
|
|
13
|
+
text: z.ZodOptional<z.ZodString>;
|
|
14
|
+
priority: z.ZodOptional<z.ZodNativeEnum<typeof TicketPriority>>;
|
|
15
|
+
assignedToEmail: z.ZodOptional<z.ZodString>;
|
|
16
|
+
assignedUserGroupAlias: z.ZodOptional<z.ZodString>;
|
|
17
|
+
userId: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
channelId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
projectId: string;
|
|
23
|
+
boardId: string;
|
|
24
|
+
userId: string;
|
|
25
|
+
text?: string | undefined;
|
|
26
|
+
priority?: TicketPriority | undefined;
|
|
27
|
+
assignedToEmail?: string | undefined;
|
|
28
|
+
assignedUserGroupAlias?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
channelId: string;
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
projectId: string;
|
|
34
|
+
boardId: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
text?: string | undefined;
|
|
37
|
+
priority?: TicketPriority | undefined;
|
|
38
|
+
assignedToEmail?: string | undefined;
|
|
39
|
+
assignedUserGroupAlias?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type CreateTicketBodyParams = z.infer<typeof CreateTicketBodySchema>;
|
|
42
|
+
export interface TicketActionResponse {
|
|
43
|
+
eventType: string;
|
|
44
|
+
ticketId: string;
|
|
45
|
+
xyneId: string;
|
|
46
|
+
conversationId: string;
|
|
47
|
+
messageId: string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/tickets/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWjC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export var TicketPriority;
|
|
3
|
+
(function (TicketPriority) {
|
|
4
|
+
TicketPriority["LOW"] = "LOW";
|
|
5
|
+
TicketPriority["MEDIUM"] = "MEDIUM";
|
|
6
|
+
TicketPriority["HIGH"] = "HIGH";
|
|
7
|
+
})(TicketPriority || (TicketPriority = {}));
|
|
8
|
+
export const CreateTicketBodySchema = z.object({
|
|
9
|
+
title: z.string().min(1, "Title is required").trim(),
|
|
10
|
+
description: z.string().min(1, "Description is required").trim(),
|
|
11
|
+
projectId: z.string().min(1, "Project ID is required").trim(),
|
|
12
|
+
boardId: z.string().min(1, "Board ID is required").trim(),
|
|
13
|
+
channelId: z.string().min(1, "Channel ID is required").trim(),
|
|
14
|
+
text: z.string().trim().optional(),
|
|
15
|
+
priority: z.nativeEnum(TicketPriority).optional(),
|
|
16
|
+
assignedToEmail: z.string().email("Invalid email format").trim().optional(),
|
|
17
|
+
assignedUserGroupAlias: z.string().trim().optional(),
|
|
18
|
+
userId: z.string().min(1, "User ID is required").trim(),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/tickets/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IACjB,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,IAAI,EAAE;IACpD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC,IAAI,EAAE;IAChE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE;IAC7D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,IAAI,EAAE;IACzD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;IACjD,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC3E,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,IAAI,EAAE;CACxD,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { XyneClient } from "../../client.js";
|
|
2
|
+
import { type UserInfoQueryParams, type UserResponse } from "./schema.js";
|
|
3
|
+
export declare class UserModule {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: XyneClient);
|
|
6
|
+
info(params: UserInfoQueryParams): Promise<UserResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAElC,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;CAgBtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UserInfoQuerySchema, } from "./schema.js";
|
|
2
|
+
export class UserModule {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async info(params) {
|
|
8
|
+
const parsed = UserInfoQuerySchema.parse(params);
|
|
9
|
+
const queryParams = new URLSearchParams();
|
|
10
|
+
if (parsed.channelId)
|
|
11
|
+
queryParams.set("channelId", parsed.channelId);
|
|
12
|
+
if (parsed.conversationId)
|
|
13
|
+
queryParams.set("conversationId", parsed.conversationId);
|
|
14
|
+
queryParams.set("user", parsed.user);
|
|
15
|
+
const result = await this.client.request({
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: `/user/info?${queryParams.toString()}`,
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/user/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,GAGpB,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE5C,KAAK,CAAC,IAAI,CAAC,MAA2B;QAC3C,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEjD,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAC1C,IAAI,MAAM,CAAC,SAAS;YAAE,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACrE,IAAI,MAAM,CAAC,cAAc;YACvB,WAAW,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;QAC3D,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU;YAChD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc,WAAW,CAAC,QAAQ,EAAE,EAAE;SAC7C,CAAC,CAAC;QAEH,OAAO,MAAsB,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const UserInfoQuerySchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
4
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
user: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
user: string;
|
|
8
|
+
channelId?: string | undefined;
|
|
9
|
+
conversationId?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
user: string;
|
|
12
|
+
channelId?: string | undefined;
|
|
13
|
+
conversationId?: string | undefined;
|
|
14
|
+
}>, {
|
|
15
|
+
user: string;
|
|
16
|
+
channelId?: string | undefined;
|
|
17
|
+
conversationId?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
user: string;
|
|
20
|
+
channelId?: string | undefined;
|
|
21
|
+
conversationId?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export type UserInfoQueryParams = z.input<typeof UserInfoQuerySchema>;
|
|
24
|
+
export interface UserResponse {
|
|
25
|
+
userId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
email: string;
|
|
28
|
+
picture: string | null;
|
|
29
|
+
userType: string;
|
|
30
|
+
status: string;
|
|
31
|
+
joined: Date;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/user/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;EAa5B,CAAC;AAEL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;CACd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const UserInfoQuerySchema = z
|
|
3
|
+
.object({
|
|
4
|
+
channelId: z.string().min(1, "Channel ID is required").trim().optional(),
|
|
5
|
+
conversationId: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1, "Conversation ID is required")
|
|
8
|
+
.trim()
|
|
9
|
+
.optional(),
|
|
10
|
+
user: z.string().min(1, "User is required").trim(),
|
|
11
|
+
})
|
|
12
|
+
.refine((data) => !!data.channelId || !!data.conversationId, {
|
|
13
|
+
message: "Either channelId or conversationId is required",
|
|
14
|
+
path: ["channelId"],
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/user/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACxE,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;SACrC,IAAI,EAAE;SACN,QAAQ,EAAE;IACb,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,IAAI,EAAE;CACnD,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE;IAC3D,OAAO,EAAE,gDAAgD;IACzD,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xyne-apps",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"description": "",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"typescript": "^5.9.3",
|
|
16
|
+
"zod": "^3.23.8"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
|
|
6
|
+
const BASE_URL = "https://spaces.xyne.juspay.net/api/apps";
|
|
7
|
+
|
|
8
|
+
export type HttpMethod = "GET" | "POST";
|
|
9
|
+
|
|
10
|
+
export interface XyneClientOptions {
|
|
11
|
+
authToken: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class XyneApiError extends Error {
|
|
15
|
+
public readonly status: number;
|
|
16
|
+
public readonly bodyText: string;
|
|
17
|
+
|
|
18
|
+
constructor(message: string, status: number, bodyText: string) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "XyneApiError";
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.bodyText = bodyText;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class XyneClient {
|
|
27
|
+
public readonly chat: ChatModule;
|
|
28
|
+
public readonly tickets: TicketsModule;
|
|
29
|
+
public readonly files: FilesModule;
|
|
30
|
+
public readonly user: UserModule;
|
|
31
|
+
|
|
32
|
+
private readonly authToken: string;
|
|
33
|
+
|
|
34
|
+
constructor(options: XyneClientOptions) {
|
|
35
|
+
this.authToken = options.authToken;
|
|
36
|
+
this.chat = new ChatModule(this);
|
|
37
|
+
this.tickets = new TicketsModule(this);
|
|
38
|
+
this.files = new FilesModule(this);
|
|
39
|
+
this.user = new UserModule(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async request<TResponse = unknown>(args: {
|
|
43
|
+
method: HttpMethod;
|
|
44
|
+
path: string;
|
|
45
|
+
body?: unknown;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
}): Promise<TResponse> {
|
|
48
|
+
const url = `${BASE_URL}${args.path}`;
|
|
49
|
+
|
|
50
|
+
const headers: Record<string, string> = {
|
|
51
|
+
...(args.headers ?? {}),
|
|
52
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const init: RequestInit = { method: args.method, headers };
|
|
56
|
+
|
|
57
|
+
if (args.body !== undefined) {
|
|
58
|
+
const formDataCtor = (globalThis as Record<string, unknown>)["FormData"];
|
|
59
|
+
const isFormData = !!formDataCtor && args.body instanceof (formDataCtor as typeof FormData);
|
|
60
|
+
if (isFormData) {
|
|
61
|
+
// Let the runtime set the correct `Content-Type` boundary for multipart.
|
|
62
|
+
init.body = args.body as BodyInit;
|
|
63
|
+
} else {
|
|
64
|
+
headers["Content-Type"] = "application/json";
|
|
65
|
+
init.body = JSON.stringify(args.body);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const res = await globalThis.fetch(url, init);
|
|
70
|
+
const bodyText = await res.text();
|
|
71
|
+
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
throw new XyneApiError(
|
|
74
|
+
`Request failed with status ${res.status} for ${args.method} ${url}`,
|
|
75
|
+
res.status,
|
|
76
|
+
bodyText,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!bodyText) return undefined as TResponse;
|
|
81
|
+
return JSON.parse(bodyText) as TResponse;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function createClient(options: XyneClientOptions): XyneClient {
|
|
86
|
+
return new XyneClient(options);
|
|
87
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { createClient, XyneApiError, XyneClient } from "./client.js";
|
|
2
|
+
export type { XyneClientOptions } from "./client.js";
|
|
3
|
+
|
|
4
|
+
export { ChatModule } from "./modules/chat/index.js";
|
|
5
|
+
export { TicketsModule } from "./modules/tickets/index.js";
|
|
6
|
+
export { UserModule } from "./modules/user/index.js";
|
|
7
|
+
export { FilesModule } from "./modules/files/index.js";
|
|
8
|
+
export type {
|
|
9
|
+
ChatPostMessageParams,
|
|
10
|
+
ChatPostMessageResponse,
|
|
11
|
+
ChatUpdateMessageParams,
|
|
12
|
+
ChatUpdateMessageResponse,
|
|
13
|
+
AppEventAttachment,
|
|
14
|
+
ChannelHistoryQueryParams,
|
|
15
|
+
ChannelHistoryItem,
|
|
16
|
+
ConversationRepliesQueryParams,
|
|
17
|
+
ConversationRepliesItem,
|
|
18
|
+
ChatPaginatedResponse,
|
|
19
|
+
} from "./modules/chat/schema.js";
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
CreateTicketBodySchema,
|
|
23
|
+
type CreateTicketBodyParams,
|
|
24
|
+
type TicketActionResponse,
|
|
25
|
+
TicketPriority,
|
|
26
|
+
} from "./modules/tickets/schema.js";
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
UserInfoQuerySchema,
|
|
30
|
+
type UserInfoQueryParams,
|
|
31
|
+
type UserResponse,
|
|
32
|
+
} from "./modules/user/schema.js";
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
UploadFilesInputSchema,
|
|
36
|
+
type UploadFilesInput,
|
|
37
|
+
type FileUploadResponse,
|
|
38
|
+
} from "./modules/files/schema.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { XyneClient } from "../../client.js";
|
|
2
|
+
import {
|
|
3
|
+
ChatPostMessageSchema,
|
|
4
|
+
ChatUpdateMessageSchema,
|
|
5
|
+
ChannelHistoryQuerySchema,
|
|
6
|
+
ConversationRepliesQuerySchema,
|
|
7
|
+
type ChatPostMessageParams,
|
|
8
|
+
type ChatPostMessageResponse,
|
|
9
|
+
type ChatUpdateMessageParams,
|
|
10
|
+
type ChatUpdateMessageResponse,
|
|
11
|
+
type ChannelHistoryQueryParams,
|
|
12
|
+
type ConversationRepliesQueryParams,
|
|
13
|
+
type ChatPaginatedResponse,
|
|
14
|
+
} from "./schema.js";
|
|
15
|
+
|
|
16
|
+
export class ChatModule {
|
|
17
|
+
constructor(private readonly client: XyneClient) {}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sends a message to either a channel or a conversation.
|
|
21
|
+
*/
|
|
22
|
+
public async postMessage(
|
|
23
|
+
params: ChatPostMessageParams,
|
|
24
|
+
): Promise<ChatPostMessageResponse> {
|
|
25
|
+
const parsed = ChatPostMessageSchema.parse(params);
|
|
26
|
+
|
|
27
|
+
const body = {
|
|
28
|
+
text: parsed.text,
|
|
29
|
+
...(parsed.channelId && { channelId: parsed.channelId }),
|
|
30
|
+
...(parsed.conversationId && { conversationId: parsed.conversationId }),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return this.client.request<ChatPostMessageResponse>({
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/chat/postMessage",
|
|
36
|
+
body,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Updates an existing message.
|
|
42
|
+
*/
|
|
43
|
+
public async updateMessage(
|
|
44
|
+
params: ChatUpdateMessageParams,
|
|
45
|
+
): Promise<ChatUpdateMessageResponse> {
|
|
46
|
+
const parsed = ChatUpdateMessageSchema.parse(params);
|
|
47
|
+
|
|
48
|
+
const body = {
|
|
49
|
+
messageId: parsed.messageId,
|
|
50
|
+
text: parsed.text,
|
|
51
|
+
...(parsed.channelId
|
|
52
|
+
? { channelId: parsed.channelId }
|
|
53
|
+
: { conversationId: parsed.conversationId }),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return this.client.request<ChatUpdateMessageResponse>({
|
|
57
|
+
method: "POST",
|
|
58
|
+
path: "/chat/updateMessage",
|
|
59
|
+
body,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Fetches channel/conversation message history with pagination.
|
|
65
|
+
*/
|
|
66
|
+
public async channelHistory(
|
|
67
|
+
params: ChannelHistoryQueryParams,
|
|
68
|
+
): Promise<ChatPaginatedResponse> {
|
|
69
|
+
const parsed = ChannelHistoryQuerySchema.parse(params);
|
|
70
|
+
|
|
71
|
+
const queryParams = new URLSearchParams();
|
|
72
|
+
queryParams.set("channelId", parsed.channelId);
|
|
73
|
+
queryParams.set("limit", String(parsed.limit));
|
|
74
|
+
if (parsed.cursor) queryParams.set("cursor", parsed.cursor);
|
|
75
|
+
|
|
76
|
+
const result = await this.client.request<unknown>({
|
|
77
|
+
method: "GET",
|
|
78
|
+
path: `/chat/channelHistory?${queryParams.toString()}`,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return result as ChatPaginatedResponse;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Fetches replies for a given conversation with pagination.
|
|
86
|
+
*/
|
|
87
|
+
public async conversationReplies(
|
|
88
|
+
params: ConversationRepliesQueryParams,
|
|
89
|
+
): Promise<ChatPaginatedResponse> {
|
|
90
|
+
const parsed = ConversationRepliesQuerySchema.parse(params);
|
|
91
|
+
|
|
92
|
+
const queryParams = new URLSearchParams();
|
|
93
|
+
queryParams.set("conversationId", parsed.conversationId);
|
|
94
|
+
if (parsed.channelId) queryParams.set("channelId", parsed.channelId);
|
|
95
|
+
queryParams.set("limit", String(parsed.limit));
|
|
96
|
+
if (parsed.cursor) queryParams.set("cursor", parsed.cursor);
|
|
97
|
+
|
|
98
|
+
const result = await this.client.request<unknown>({
|
|
99
|
+
method: "GET",
|
|
100
|
+
path: `/chat/conversationReplies?${queryParams.toString()}`,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return result as ChatPaginatedResponse;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|