@scryme/chat 2.57.1 → 2.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.d.ts CHANGED
@@ -349,6 +349,140 @@ export interface UserProfile {
349
349
  /** ISO timestamp when the user account was created. */
350
350
  createdAt?: string;
351
351
  }
352
+ /**
353
+ * Represents a customer profile for support and CRM tracking.
354
+ */
355
+ export interface CustomerProfile {
356
+ /** Unique customer profile identifier. */
357
+ id: string;
358
+ /** Unique user identifier. */
359
+ userId: string;
360
+ /** Associated workspace identifier. */
361
+ workspaceId: string;
362
+ /** Optional company name. */
363
+ company?: string | null;
364
+ /** Optional job title. */
365
+ jobTitle?: string | null;
366
+ /** External CRM identifier. */
367
+ crmId?: string | null;
368
+ /** Custom metadata key-value store. */
369
+ metadata?: Record<string, unknown> | null;
370
+ /** Array of customer tags. */
371
+ tags?: string[];
372
+ /** Associated user profile details. */
373
+ user?: UserProfile;
374
+ }
375
+ /**
376
+ * Represents a support ticket.
377
+ */
378
+ export interface SupportTicket {
379
+ /** Unique ticket identifier. */
380
+ id: string;
381
+ /** Subject line or title of the ticket. */
382
+ subject: string;
383
+ /** Status of the ticket (OPEN, IN_PROGRESS, RESOLVED, CLOSED). */
384
+ status: string;
385
+ /** Unique workspace identifier. */
386
+ workspaceId: string;
387
+ /** Unique customer profile identifier. */
388
+ customerId: string;
389
+ /** Unique channel identifier created for ticket messages. */
390
+ channelId?: string | null;
391
+ /** Optional assigned agent user identifier. */
392
+ assigneeId?: string | null;
393
+ /** ISO timestamp when the ticket was created. */
394
+ createdAt: string;
395
+ /** ISO timestamp when the last message was sent. */
396
+ lastMessageAt: string;
397
+ /** Optional customer details. */
398
+ customer?: {
399
+ id: string;
400
+ userId: string;
401
+ user?: UserProfile;
402
+ };
403
+ /** Optional assignee details. */
404
+ assignee?: UserProfile;
405
+ /** Associated channel details. */
406
+ channel?: WorkspaceChannel;
407
+ }
408
+ /**
409
+ * Represents an active or ended live chat session.
410
+ */
411
+ export interface LiveChatSession {
412
+ /** Unique session identifier. */
413
+ id: string;
414
+ /** Associated workspace identifier. */
415
+ workspaceId: string;
416
+ /** Optional customer profile identifier. */
417
+ customerId?: string | null;
418
+ /** Unique channel identifier for live chat. */
419
+ channelId: string;
420
+ /** Session status (ACTIVE, ENDED). */
421
+ status: string;
422
+ /** Custom metadata key-value store. */
423
+ metadata?: Record<string, unknown> | null;
424
+ /** Associated support ticket identifier if escalated. */
425
+ ticketId?: string | null;
426
+ /** ISO timestamp when live chat started. */
427
+ createdAt: string;
428
+ /** ISO timestamp when live chat ended. */
429
+ endedAt?: string | null;
430
+ /** Associated live chat channel details. */
431
+ channel?: WorkspaceChannel;
432
+ }
433
+ /**
434
+ * Options for creating a new support ticket.
435
+ */
436
+ export interface CreateSupportTicketDto {
437
+ /** Unique workspace identifier where ticket is filed. */
438
+ workspaceId: string;
439
+ /** Subject or title of the support ticket. */
440
+ subject: string;
441
+ /** Initial message content to start the ticket conversation. */
442
+ initialMessage?: string;
443
+ }
444
+ /**
445
+ * Options for updating support ticket status.
446
+ */
447
+ export interface UpdateSupportTicketStatusDto {
448
+ /** Target status (OPEN, IN_PROGRESS, RESOLVED, CLOSED). */
449
+ status: string;
450
+ }
451
+ /**
452
+ * Options for assigning or unassigning an agent to a support ticket.
453
+ */
454
+ export interface AssignSupportTicketDto {
455
+ /** User ID of the agent to assign, or null to unassign. */
456
+ assigneeId: string | null;
457
+ }
458
+ /**
459
+ * Options for starting a new live chat session.
460
+ */
461
+ export interface StartLiveChatDto {
462
+ /** Unique workspace identifier where live chat is initialized. */
463
+ workspaceId: string;
464
+ /** Optional metadata associated with the live chat session. */
465
+ metadata?: Record<string, unknown>;
466
+ }
467
+ /**
468
+ * Options for creating or updating a customer profile.
469
+ */
470
+ export interface CreateCustomerProfileDto {
471
+ /** Associated workspace identifier. */
472
+ workspaceId: string;
473
+ /** User ID of the customer. */
474
+ userId: string;
475
+ /** Optional company name. */
476
+ company?: string;
477
+ /** Optional job title. */
478
+ jobTitle?: string;
479
+ /** External CRM identifier. */
480
+ crmId?: string;
481
+ /** Additional metadata key-value pairs. */
482
+ metadata?: Record<string, unknown>;
483
+ /** Tags for segmenting customers. */
484
+ tags?: string[];
485
+ }
352
486
  /**
353
487
  * Configuration options for initializing the Scryme SDK.
354
488
  */
@@ -871,6 +1005,102 @@ export declare class ScrymeSDK {
871
1005
  executeByChannelId: (channelId: string, data: ExecuteChannelIncomingWebhookDto, params?: V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdParams, options?: AxiosRequestConfig) => Promise<V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdResult>;
872
1006
  };
873
1007
  };
1008
+ /**
1009
+ * Operations for managing support tickets, live chat sessions, and customer profiles.
1010
+ */
1011
+ get support(): {
1012
+ /**
1013
+ * Creates a new support ticket in a workspace.
1014
+ * @param data Details for creating the ticket including workspaceId, subject, and optional initialMessage.
1015
+ * @param options Optional request config override.
1016
+ */
1017
+ createTicket: (data: CreateSupportTicketDto, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1018
+ /**
1019
+ * Retrieves all support tickets for a given workspace.
1020
+ * @param workspaceId Unique workspace identifier.
1021
+ * @param options Optional request config override.
1022
+ */
1023
+ getTickets: (workspaceId: string, options?: AxiosRequestConfig) => Promise<SupportTicket[]>;
1024
+ /**
1025
+ * Updates the status of an existing support ticket.
1026
+ * @param ticketId Unique identifier of the support ticket.
1027
+ * @param status New status string (e.g. OPEN, IN_PROGRESS, RESOLVED, CLOSED).
1028
+ * @param options Optional request config override.
1029
+ */
1030
+ updateStatus: (ticketId: string, status: string, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1031
+ /**
1032
+ * Assigns a support ticket to an agent or unassigns it.
1033
+ * @param ticketId Unique identifier of the support ticket.
1034
+ * @param assigneeId User ID of the assigned agent or null to unassign.
1035
+ * @param options Optional request config override.
1036
+ */
1037
+ assignTicket: (ticketId: string, assigneeId: string | null, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1038
+ /**
1039
+ * Sub-namespace for managing support tickets.
1040
+ */
1041
+ tickets: {
1042
+ /**
1043
+ * Creates a new support ticket in a workspace.
1044
+ * @param data Details for creating the ticket.
1045
+ * @param options Optional request config override.
1046
+ */
1047
+ create: (data: CreateSupportTicketDto, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1048
+ /**
1049
+ * Lists all support tickets in a workspace.
1050
+ * @param workspaceId Unique workspace identifier.
1051
+ * @param options Optional request config override.
1052
+ */
1053
+ list: (workspaceId: string, options?: AxiosRequestConfig) => Promise<SupportTicket[]>;
1054
+ /**
1055
+ * Updates ticket status.
1056
+ * @param ticketId Unique ticket identifier.
1057
+ * @param status New status string.
1058
+ * @param options Optional request config override.
1059
+ */
1060
+ updateStatus: (ticketId: string, status: string, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1061
+ /**
1062
+ * Assigns or unassigns an agent to/from a support ticket.
1063
+ * @param ticketId Unique ticket identifier.
1064
+ * @param assigneeId Agent user ID or null.
1065
+ * @param options Optional request config override.
1066
+ */
1067
+ assign: (ticketId: string, assigneeId: string | null, options?: AxiosRequestConfig) => Promise<SupportTicket>;
1068
+ };
1069
+ /**
1070
+ * Sub-namespace for live chat sessions.
1071
+ */
1072
+ liveChat: {
1073
+ /**
1074
+ * Starts a new live chat session for support.
1075
+ * @param data Details for starting live chat session.
1076
+ * @param options Optional request config override.
1077
+ */
1078
+ start: (data: StartLiveChatDto, options?: AxiosRequestConfig) => Promise<LiveChatSession>;
1079
+ /**
1080
+ * Ends an active live chat session.
1081
+ * @param sessionId Unique session identifier.
1082
+ * @param options Optional request config override.
1083
+ */
1084
+ end: (sessionId: string, options?: AxiosRequestConfig) => Promise<LiveChatSession>;
1085
+ };
1086
+ /**
1087
+ * Sub-namespace for managing customer profiles.
1088
+ */
1089
+ customer: {
1090
+ /**
1091
+ * Creates or updates a customer profile in a workspace.
1092
+ * @param data Profile details including workspaceId and userId.
1093
+ * @param options Optional request config override.
1094
+ */
1095
+ createProfile: (data: CreateCustomerProfileDto, options?: AxiosRequestConfig) => Promise<CustomerProfile>;
1096
+ /**
1097
+ * Retrieves customer profiles in a workspace.
1098
+ * @param workspaceId Unique workspace identifier.
1099
+ * @param options Optional request config override.
1100
+ */
1101
+ getProfiles: (workspaceId: string, options?: AxiosRequestConfig) => Promise<CustomerProfile[]>;
1102
+ };
1103
+ };
874
1104
  /**
875
1105
  * First-class namespace for Machine-to-Machine (M2M) operations,
876
1106
  * grouping V3 Enterprise M2M APIs into logical, highly cohesive spaces.
package/dist/sdk.js CHANGED
@@ -957,6 +957,157 @@ var ScrymeSDK = /** @class */ (function () {
957
957
  enumerable: false,
958
958
  configurable: true
959
959
  });
960
+ Object.defineProperty(ScrymeSDK.prototype, "support", {
961
+ /**
962
+ * Operations for managing support tickets, live chat sessions, and customer profiles.
963
+ */
964
+ get: function () {
965
+ var _this = this;
966
+ return {
967
+ /**
968
+ * Creates a new support ticket in a workspace.
969
+ * @param data Details for creating the ticket including workspaceId, subject, and optional initialMessage.
970
+ * @param options Optional request config override.
971
+ */
972
+ createTicket: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
973
+ return __generator(this, function (_a) {
974
+ return [2 /*return*/, this.raw.supportControllerCreateTicket(__assign(__assign({}, options), { data: data }))];
975
+ });
976
+ }); },
977
+ /**
978
+ * Retrieves all support tickets for a given workspace.
979
+ * @param workspaceId Unique workspace identifier.
980
+ * @param options Optional request config override.
981
+ */
982
+ getTickets: function (workspaceId, options) { return __awaiter(_this, void 0, void 0, function () {
983
+ return __generator(this, function (_a) {
984
+ return [2 /*return*/, this.raw.supportControllerGetTickets({ workspaceId: workspaceId }, options)];
985
+ });
986
+ }); },
987
+ /**
988
+ * Updates the status of an existing support ticket.
989
+ * @param ticketId Unique identifier of the support ticket.
990
+ * @param status New status string (e.g. OPEN, IN_PROGRESS, RESOLVED, CLOSED).
991
+ * @param options Optional request config override.
992
+ */
993
+ updateStatus: function (ticketId, status, options) { return __awaiter(_this, void 0, void 0, function () {
994
+ return __generator(this, function (_a) {
995
+ return [2 /*return*/, this.raw.supportControllerUpdateTicketStatus(ticketId, __assign(__assign({}, options), { data: { status: status } }))];
996
+ });
997
+ }); },
998
+ /**
999
+ * Assigns a support ticket to an agent or unassigns it.
1000
+ * @param ticketId Unique identifier of the support ticket.
1001
+ * @param assigneeId User ID of the assigned agent or null to unassign.
1002
+ * @param options Optional request config override.
1003
+ */
1004
+ assignTicket: function (ticketId, assigneeId, options) { return __awaiter(_this, void 0, void 0, function () {
1005
+ return __generator(this, function (_a) {
1006
+ return [2 /*return*/, this.raw.supportControllerAssignTicket(ticketId, __assign(__assign({}, options), { data: { assigneeId: assigneeId } }))];
1007
+ });
1008
+ }); },
1009
+ /**
1010
+ * Sub-namespace for managing support tickets.
1011
+ */
1012
+ tickets: {
1013
+ /**
1014
+ * Creates a new support ticket in a workspace.
1015
+ * @param data Details for creating the ticket.
1016
+ * @param options Optional request config override.
1017
+ */
1018
+ create: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
1019
+ return __generator(this, function (_a) {
1020
+ return [2 /*return*/, this.support.createTicket(data, options)];
1021
+ });
1022
+ }); },
1023
+ /**
1024
+ * Lists all support tickets in a workspace.
1025
+ * @param workspaceId Unique workspace identifier.
1026
+ * @param options Optional request config override.
1027
+ */
1028
+ list: function (workspaceId, options) { return __awaiter(_this, void 0, void 0, function () {
1029
+ return __generator(this, function (_a) {
1030
+ return [2 /*return*/, this.support.getTickets(workspaceId, options)];
1031
+ });
1032
+ }); },
1033
+ /**
1034
+ * Updates ticket status.
1035
+ * @param ticketId Unique ticket identifier.
1036
+ * @param status New status string.
1037
+ * @param options Optional request config override.
1038
+ */
1039
+ updateStatus: function (ticketId, status, options) { return __awaiter(_this, void 0, void 0, function () {
1040
+ return __generator(this, function (_a) {
1041
+ return [2 /*return*/, this.support.updateStatus(ticketId, status, options)];
1042
+ });
1043
+ }); },
1044
+ /**
1045
+ * Assigns or unassigns an agent to/from a support ticket.
1046
+ * @param ticketId Unique ticket identifier.
1047
+ * @param assigneeId Agent user ID or null.
1048
+ * @param options Optional request config override.
1049
+ */
1050
+ assign: function (ticketId, assigneeId, options) { return __awaiter(_this, void 0, void 0, function () {
1051
+ return __generator(this, function (_a) {
1052
+ return [2 /*return*/, this.support.assignTicket(ticketId, assigneeId, options)];
1053
+ });
1054
+ }); },
1055
+ },
1056
+ /**
1057
+ * Sub-namespace for live chat sessions.
1058
+ */
1059
+ liveChat: {
1060
+ /**
1061
+ * Starts a new live chat session for support.
1062
+ * @param data Details for starting live chat session.
1063
+ * @param options Optional request config override.
1064
+ */
1065
+ start: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
1066
+ return __generator(this, function (_a) {
1067
+ return [2 /*return*/, this.raw.supportControllerStartLiveChat(__assign(__assign({}, options), { data: data }))];
1068
+ });
1069
+ }); },
1070
+ /**
1071
+ * Ends an active live chat session.
1072
+ * @param sessionId Unique session identifier.
1073
+ * @param options Optional request config override.
1074
+ */
1075
+ end: function (sessionId, options) { return __awaiter(_this, void 0, void 0, function () {
1076
+ return __generator(this, function (_a) {
1077
+ return [2 /*return*/, this.raw.supportControllerEndLiveChat(sessionId, options)];
1078
+ });
1079
+ }); },
1080
+ },
1081
+ /**
1082
+ * Sub-namespace for managing customer profiles.
1083
+ */
1084
+ customer: {
1085
+ /**
1086
+ * Creates or updates a customer profile in a workspace.
1087
+ * @param data Profile details including workspaceId and userId.
1088
+ * @param options Optional request config override.
1089
+ */
1090
+ createProfile: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
1091
+ return __generator(this, function (_a) {
1092
+ return [2 /*return*/, this.raw.supportControllerCreateCustomerProfile(__assign(__assign({}, options), { data: data }))];
1093
+ });
1094
+ }); },
1095
+ /**
1096
+ * Retrieves customer profiles in a workspace.
1097
+ * @param workspaceId Unique workspace identifier.
1098
+ * @param options Optional request config override.
1099
+ */
1100
+ getProfiles: function (workspaceId, options) { return __awaiter(_this, void 0, void 0, function () {
1101
+ return __generator(this, function (_a) {
1102
+ return [2 /*return*/, this.raw.supportControllerGetCustomerProfiles({ workspaceId: workspaceId }, options)];
1103
+ });
1104
+ }); },
1105
+ },
1106
+ };
1107
+ },
1108
+ enumerable: false,
1109
+ configurable: true
1110
+ });
960
1111
  Object.defineProperty(ScrymeSDK.prototype, "m2m", {
961
1112
  /**
962
1113
  * First-class namespace for Machine-to-Machine (M2M) operations,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scryme/chat",
3
- "version": "2.57.1",
3
+ "version": "2.81.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -154,6 +154,32 @@ vi.mock('../generated/v3-server', () => {
154
154
  v3OAuthControllerGetToken: vi.fn(async (data, options) => {
155
155
  return { success: true, data, options };
156
156
  }),
157
+
158
+ // Support Controller Mock
159
+ supportControllerCreateTicket: vi.fn(async (options) => {
160
+ return { success: true, ticket: options?.data, options };
161
+ }),
162
+ supportControllerGetTickets: vi.fn(async (params, options) => {
163
+ return { success: true, workspaceId: params?.workspaceId, tickets: [], options };
164
+ }),
165
+ supportControllerStartLiveChat: vi.fn(async (options) => {
166
+ return { success: true, session: options?.data, options };
167
+ }),
168
+ supportControllerEndLiveChat: vi.fn(async (sessionId, options) => {
169
+ return { success: true, sessionId, options };
170
+ }),
171
+ supportControllerUpdateTicketStatus: vi.fn(async (ticketId, options) => {
172
+ return { success: true, ticketId, status: options?.data?.status, options };
173
+ }),
174
+ supportControllerAssignTicket: vi.fn(async (ticketId, options) => {
175
+ return { success: true, ticketId, assigneeId: options?.data?.assigneeId, options };
176
+ }),
177
+ supportControllerCreateCustomerProfile: vi.fn(async (options) => {
178
+ return { success: true, profile: options?.data, options };
179
+ }),
180
+ supportControllerGetCustomerProfiles: vi.fn(async (params, options) => {
181
+ return { success: true, workspaceId: params?.workspaceId, profiles: [], options };
182
+ }),
157
183
  })),
158
184
  };
159
185
  });
@@ -451,5 +477,63 @@ describe('ScrymeSDK', () => {
451
477
  const tokenRes = await sdk.m2m.auth.token('cid', 'sec') as any;
452
478
  expect(tokenRes.data.client_id).toBe('cid');
453
479
  });
480
+
481
+ it('should support sdk.support ticketing and customer operations', async () => {
482
+ const sdk = new ScrymeSDK({
483
+ baseURL: 'https://api.test.com',
484
+ token: 'active-token',
485
+ });
486
+
487
+ // support.createTicket
488
+ const ticketDto = { workspaceId: 'ws-123', subject: 'Billing Issue', initialMessage: 'Need help with invoice' };
489
+ const createRes = await sdk.support.createTicket(ticketDto) as any;
490
+ expect(createRes.success).toBe(true);
491
+ expect(createRes.ticket).toEqual(ticketDto);
492
+
493
+ // support.getTickets
494
+ const getRes = await sdk.support.getTickets('ws-123') as any;
495
+ expect(getRes.success).toBe(true);
496
+ expect(getRes.workspaceId).toBe('ws-123');
497
+
498
+ // support.updateStatus
499
+ const statusRes = await sdk.support.updateStatus('t-1', 'RESOLVED') as any;
500
+ expect(statusRes.success).toBe(true);
501
+ expect(statusRes.ticketId).toBe('t-1');
502
+ expect(statusRes.status).toBe('RESOLVED');
503
+
504
+ // support.assignTicket
505
+ const assignRes = await sdk.support.assignTicket('t-1', 'agent-99') as any;
506
+ expect(assignRes.success).toBe(true);
507
+ expect(assignRes.ticketId).toBe('t-1');
508
+ expect(assignRes.assigneeId).toBe('agent-99');
509
+
510
+ // support.tickets sub-namespace
511
+ const ticketSubCreate = await sdk.support.tickets.create(ticketDto) as any;
512
+ expect(ticketSubCreate.ticket).toEqual(ticketDto);
513
+
514
+ const ticketSubList = await sdk.support.tickets.list('ws-123') as any;
515
+ expect(ticketSubList.workspaceId).toBe('ws-123');
516
+
517
+ const ticketSubStatus = await sdk.support.tickets.updateStatus('t-2', 'CLOSED') as any;
518
+ expect(ticketSubStatus.status).toBe('CLOSED');
519
+
520
+ const ticketSubAssign = await sdk.support.tickets.assign('t-2', null) as any;
521
+ expect(ticketSubAssign.assigneeId).toBeNull();
522
+
523
+ // support.liveChat sub-namespace
524
+ const liveChatStart = await sdk.support.liveChat.start({ workspaceId: 'ws-123', metadata: { source: 'web' } }) as any;
525
+ expect(liveChatStart.session.workspaceId).toBe('ws-123');
526
+
527
+ const liveChatEnd = await sdk.support.liveChat.end('session-789') as any;
528
+ expect(liveChatEnd.sessionId).toBe('session-789');
529
+
530
+ // support.customer sub-namespace
531
+ const custDto = { workspaceId: 'ws-123', userId: 'usr-1', company: 'Acme Corp' };
532
+ const custCreate = await sdk.support.customer.createProfile(custDto) as any;
533
+ expect(custCreate.profile).toEqual(custDto);
534
+
535
+ const custGet = await sdk.support.customer.getProfiles('ws-123') as any;
536
+ expect(custGet.workspaceId).toBe('ws-123');
537
+ });
454
538
  });
455
539
  });