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.
Files changed (53) hide show
  1. package/README.md +243 -0
  2. package/dist/client.d.ts +29 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +61 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/index.d.ts +11 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +9 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/modules/chat/index.d.ts +23 -0
  11. package/dist/modules/chat/index.d.ts.map +1 -0
  12. package/dist/modules/chat/index.js +76 -0
  13. package/dist/modules/chat/index.js.map +1 -0
  14. package/dist/modules/chat/schema.d.ts +124 -0
  15. package/dist/modules/chat/schema.d.ts.map +1 -0
  16. package/dist/modules/chat/schema.js +53 -0
  17. package/dist/modules/chat/schema.js.map +1 -0
  18. package/dist/modules/files/index.d.ts +8 -0
  19. package/dist/modules/files/index.d.ts.map +1 -0
  20. package/dist/modules/files/index.js +31 -0
  21. package/dist/modules/files/index.js.map +1 -0
  22. package/dist/modules/files/schema.d.ts +43 -0
  23. package/dist/modules/files/schema.d.ts.map +1 -0
  24. package/dist/modules/files/schema.js +14 -0
  25. package/dist/modules/files/schema.js.map +1 -0
  26. package/dist/modules/tickets/index.d.ts +8 -0
  27. package/dist/modules/tickets/index.d.ts.map +1 -0
  28. package/dist/modules/tickets/index.js +16 -0
  29. package/dist/modules/tickets/index.js.map +1 -0
  30. package/dist/modules/tickets/schema.d.ts +49 -0
  31. package/dist/modules/tickets/schema.d.ts.map +1 -0
  32. package/dist/modules/tickets/schema.js +20 -0
  33. package/dist/modules/tickets/schema.js.map +1 -0
  34. package/dist/modules/user/index.d.ts +8 -0
  35. package/dist/modules/user/index.d.ts.map +1 -0
  36. package/dist/modules/user/index.js +22 -0
  37. package/dist/modules/user/index.js.map +1 -0
  38. package/dist/modules/user/schema.d.ts +33 -0
  39. package/dist/modules/user/schema.d.ts.map +1 -0
  40. package/dist/modules/user/schema.js +16 -0
  41. package/dist/modules/user/schema.js.map +1 -0
  42. package/package.json +18 -0
  43. package/src/client.ts +87 -0
  44. package/src/index.ts +38 -0
  45. package/src/modules/chat/index.ts +106 -0
  46. package/src/modules/chat/schema.ts +119 -0
  47. package/src/modules/files/index.ts +37 -0
  48. package/src/modules/files/schema.ts +37 -0
  49. package/src/modules/tickets/index.ts +23 -0
  50. package/src/modules/tickets/schema.ts +31 -0
  51. package/src/modules/user/index.ts +28 -0
  52. package/src/modules/user/schema.ts +29 -0
  53. package/tsconfig.json +44 -0
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+
3
+ export const ChatPostMessageSchema = z
4
+ .object({
5
+ text: z.string().min(1, "text is required").trim(),
6
+ })
7
+ .extend({
8
+ channelId: z.string().min(1, "Channel ID is required").trim().optional(),
9
+ conversationId: z.string().trim().optional(),
10
+ })
11
+ .refine(
12
+ (data) => !!data.channelId || !!data.conversationId,
13
+ {
14
+ message: "Either channelId or conversationId is required",
15
+ path: ["channelId"],
16
+ },
17
+ );
18
+
19
+ export type ChatPostMessageParams = z.infer<typeof ChatPostMessageSchema>;
20
+
21
+ export interface ChatPostMessageResponse {
22
+ eventType: string;
23
+ conversationId: string;
24
+ messageId: string;
25
+ }
26
+
27
+ export const ChatUpdateMessageSchema = z
28
+ .object({
29
+ messageId: z.string().min(1, "messageId is required").trim(),
30
+ text: z.string().min(1, "text is required").trim(),
31
+ })
32
+ .extend({
33
+ channelId: z.string().min(1, "channelId is required").trim().optional(),
34
+ conversationId: z
35
+ .string()
36
+ .min(1, "conversationId is required")
37
+ .trim()
38
+ .optional(),
39
+ })
40
+ .refine((data) => !!data.channelId || !!data.conversationId, {
41
+ message: "At least one of channelId or conversationId is required",
42
+ path: ["channelId"],
43
+ });
44
+
45
+ export type ChatUpdateMessageParams = z.infer<typeof ChatUpdateMessageSchema>;
46
+
47
+ export interface ChatUpdateMessageResponse {
48
+ eventType: string;
49
+ conversationId: string;
50
+ messageId: string;
51
+ }
52
+
53
+
54
+ export const ChannelHistoryQuerySchema = z
55
+ .object({
56
+ channelId: z.string().min(1, "Channel ID is required").trim(),
57
+ limit: z
58
+ .string()
59
+ .optional()
60
+ .transform((val) => (val ? parseInt(val, 10) : 1000)),
61
+ cursor: z.string().optional(),
62
+ })
63
+ ;
64
+
65
+ export type ChannelHistoryQueryParams = z.input<
66
+ typeof ChannelHistoryQuerySchema
67
+ >;
68
+
69
+ export const ConversationRepliesQuerySchema = z
70
+ .object({
71
+ conversationId: z
72
+ .string()
73
+ .min(1, "Conversation ID is required")
74
+ .trim(),
75
+ channelId: z.string().min(1, "Channel ID is required").trim().optional(),
76
+ limit: z
77
+ .string()
78
+ .optional()
79
+ .transform((val) => (val ? parseInt(val, 10) : 1000)),
80
+ cursor: z.string().optional(),
81
+ });
82
+
83
+ export type ConversationRepliesQueryParams = z.input<
84
+ typeof ConversationRepliesQuerySchema
85
+ >;
86
+
87
+ export interface AppEventAttachment {
88
+ attachmentId: string;
89
+ fileName: string;
90
+ fileSize: number;
91
+ mimeType: string;
92
+ fileUrl: string;
93
+ }
94
+
95
+ export interface ChannelHistoryItem {
96
+ initialMessageId: string;
97
+ conversationId: string;
98
+ content: string;
99
+ cleanContent: string;
100
+ userId: string;
101
+ createdAt: Date;
102
+ attachments?: AppEventAttachment[];
103
+ }
104
+
105
+ export interface ConversationRepliesItem {
106
+ messageId: string;
107
+ conversationId: string;
108
+ content: string;
109
+ cleanContent: string;
110
+ userId: string;
111
+ createdAt: Date;
112
+ attachments?: AppEventAttachment[];
113
+ }
114
+
115
+ export interface ChatPaginatedResponse {
116
+ items: ChannelHistoryItem[] | ConversationRepliesItem[];
117
+ nextCursor?: string;
118
+ hasMore: boolean;
119
+ }
@@ -0,0 +1,37 @@
1
+ import type { XyneClient } from "../../client.js";
2
+ import {
3
+ type UploadFilesInput,
4
+ UploadFilesInputSchema,
5
+ type FileUploadResponse,
6
+ } from "./schema.js";
7
+
8
+ export class FilesModule {
9
+ constructor(private readonly client: XyneClient) {}
10
+
11
+ public async filesUpload(params: UploadFilesInput): Promise<FileUploadResponse> {
12
+ const parsed = UploadFilesInputSchema.parse(params);
13
+ const { files, channelId, text, conversationId } = parsed;
14
+
15
+ const formData = new FormData();
16
+
17
+ if (channelId) formData.append("channelId", channelId);
18
+ if (text) formData.append("text", text);
19
+ if (conversationId) formData.append("conversationId", conversationId);
20
+
21
+ for (const f of files) {
22
+ const nameFromBlob = (f as any).name;
23
+ const multipartName =
24
+ typeof nameFromBlob === "string" && nameFromBlob.length > 0
25
+ ? nameFromBlob
26
+ : "file";
27
+ formData.append("files", f as any, multipartName);
28
+ }
29
+
30
+ return this.client.request<FileUploadResponse>({
31
+ method: "POST",
32
+ path: "/files/filesUpload",
33
+ body: formData,
34
+ });
35
+ }
36
+ }
37
+
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+
3
+ export const UploadFilesInputSchema = z
4
+ .object({
5
+ // Multipart payload expects `files` entries.
6
+ files: z.array(z.instanceof(Blob)).min(1, "Missing file uploads. Provide `files`."),
7
+ channelId: z.string().min(1, "Channel ID is required").trim().optional(),
8
+ text: z.string().trim().optional(),
9
+ conversationId: z.string().trim().optional(),
10
+ })
11
+ .refine(
12
+ (data) => !!data.channelId || !!data.conversationId,
13
+ {
14
+ message: "Either channelId or conversationId is required",
15
+ path: ["channelId"],
16
+ },
17
+ );
18
+
19
+ export type UploadFilesInput = z.input<typeof UploadFilesInputSchema>;
20
+
21
+ export interface FileAttachment {
22
+ fileid: string;
23
+ originalFilename: string;
24
+ url: string;
25
+ size: number;
26
+ mimeType: string;
27
+ }
28
+
29
+ export type FileUploadEventType = string;
30
+
31
+ export interface FileUploadResponse {
32
+ eventType: FileUploadEventType;
33
+ conversationId: string;
34
+ messageId: string;
35
+ attachments: Array<FileAttachment>;
36
+ }
37
+
@@ -0,0 +1,23 @@
1
+ import type { XyneClient } from "../../client.js";
2
+ import {
3
+ CreateTicketBodySchema,
4
+ type CreateTicketBodyParams,
5
+ type TicketActionResponse,
6
+ } from "./schema.js";
7
+
8
+ export class TicketsModule {
9
+ constructor(private readonly client: XyneClient) {}
10
+
11
+ public async createTicket(
12
+ params: CreateTicketBodyParams,
13
+ ): Promise<TicketActionResponse> {
14
+ const body = CreateTicketBodySchema.parse(params);
15
+
16
+ return this.client.request<TicketActionResponse>({
17
+ method: "POST",
18
+ path: "/ticket/createTicket",
19
+ body,
20
+ });
21
+ }
22
+ }
23
+
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+
3
+ export enum TicketPriority {
4
+ LOW = "LOW",
5
+ MEDIUM = "MEDIUM",
6
+ HIGH = "HIGH",
7
+ }
8
+
9
+ export const CreateTicketBodySchema = z.object({
10
+ title: z.string().min(1, "Title is required").trim(),
11
+ description: z.string().min(1, "Description is required").trim(),
12
+ projectId: z.string().min(1, "Project ID is required").trim(),
13
+ boardId: z.string().min(1, "Board ID is required").trim(),
14
+ channelId: z.string().min(1, "Channel ID is required").trim(),
15
+ text: z.string().trim().optional(),
16
+ priority: z.nativeEnum(TicketPriority).optional(),
17
+ assignedToEmail: z.string().email("Invalid email format").trim().optional(),
18
+ assignedUserGroupAlias: z.string().trim().optional(),
19
+ userId: z.string().min(1, "User ID is required").trim(),
20
+ });
21
+
22
+ export type CreateTicketBodyParams = z.infer<typeof CreateTicketBodySchema>;
23
+
24
+ export interface TicketActionResponse {
25
+ eventType: string;
26
+ ticketId: string;
27
+ xyneId: string;
28
+ conversationId: string;
29
+ messageId: string;
30
+ }
31
+
@@ -0,0 +1,28 @@
1
+ import type { XyneClient } from "../../client.js";
2
+ import {
3
+ UserInfoQuerySchema,
4
+ type UserInfoQueryParams,
5
+ type UserResponse,
6
+ } from "./schema.js";
7
+
8
+ export class UserModule {
9
+ constructor(private readonly client: XyneClient) {}
10
+
11
+ public async info(params: UserInfoQueryParams): Promise<UserResponse> {
12
+ const parsed = UserInfoQuerySchema.parse(params);
13
+
14
+ const queryParams = new URLSearchParams();
15
+ if (parsed.channelId) queryParams.set("channelId", parsed.channelId);
16
+ if (parsed.conversationId)
17
+ queryParams.set("conversationId", parsed.conversationId);
18
+ queryParams.set("user", parsed.user);
19
+
20
+ const result = await this.client.request<unknown>({
21
+ method: "GET",
22
+ path: `/user/info?${queryParams.toString()}`,
23
+ });
24
+
25
+ return result as UserResponse;
26
+ }
27
+ }
28
+
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+
3
+ export const UserInfoQuerySchema = z
4
+ .object({
5
+ channelId: z.string().min(1, "Channel ID is required").trim().optional(),
6
+ conversationId: z
7
+ .string()
8
+ .min(1, "Conversation ID is required")
9
+ .trim()
10
+ .optional(),
11
+ user: z.string().min(1, "User is required").trim(),
12
+ })
13
+ .refine((data) => !!data.channelId || !!data.conversationId, {
14
+ message: "Either channelId or conversationId is required",
15
+ path: ["channelId"],
16
+ });
17
+
18
+ export type UserInfoQueryParams = z.input<typeof UserInfoQuerySchema>;
19
+
20
+ export interface UserResponse {
21
+ userId: string;
22
+ name: string;
23
+ email: string;
24
+ picture: string | null;
25
+ userType: string;
26
+ status: string;
27
+ joined: Date;
28
+ }
29
+
package/tsconfig.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ // Visit https://aka.ms/tsconfig to read more about this file
3
+ "compilerOptions": {
4
+ // File Layout
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+
8
+ // Environment Settings
9
+ // See also https://aka.ms/tsconfig/module
10
+ "module": "nodenext",
11
+ "target": "esnext",
12
+ "types": [],
13
+ // For nodejs:
14
+ // "lib": ["esnext"],
15
+ // "types": ["node"],
16
+ // and npm install -D @types/node
17
+
18
+ // Other Outputs
19
+ "sourceMap": true,
20
+ "declaration": true,
21
+ "declarationMap": true,
22
+
23
+ // Stricter Typechecking Options
24
+ "noUncheckedIndexedAccess": true,
25
+ "exactOptionalPropertyTypes": true,
26
+
27
+ // Style Options
28
+ // "noImplicitReturns": true,
29
+ // "noImplicitOverride": true,
30
+ // "noUnusedLocals": true,
31
+ // "noUnusedParameters": true,
32
+ // "noFallthroughCasesInSwitch": true,
33
+ // "noPropertyAccessFromIndexSignature": true,
34
+
35
+ // Recommended Options
36
+ "strict": true,
37
+ "jsx": "react-jsx",
38
+ "verbatimModuleSyntax": true,
39
+ "isolatedModules": true,
40
+ "noUncheckedSideEffectImports": true,
41
+ "moduleDetection": "force",
42
+ "skipLibCheck": true,
43
+ }
44
+ }