@scryme/chat 2.81.5 → 2.85.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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './custom-instance';
2
2
  export * from './generated/v3-client';
3
3
  export * from './sdk';
4
+ export { CustomMessageSchema, MessageNodeSchema, ConditionSchema, ValidationSchema, DataSourceSchema, CustomMessageThemeSchema, PredefinedCustomMessageTypeSchema, MessageActionSchema, createApprovalMessage, createReportMessage, createFormMessage, createTaskCardMessage, type CustomMessage, type MessageNode, type ConditionSchemaType, type ValidationSchemaType, type CustomMessageTheme, type PredefinedCustomMessageType, type MessageAction, type CreateApprovalMessageOptions, type CreateReportMessageOptions, type CreateFormMessageOptions, type CreateTaskCardMessageOptions, type FormFieldConfig, } from '@repo/shared';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './custom-instance';
2
2
  export * from './generated/v3-client';
3
3
  export * from './sdk';
4
+ export { CustomMessageSchema, MessageNodeSchema, ConditionSchema, ValidationSchema, DataSourceSchema, CustomMessageThemeSchema, PredefinedCustomMessageTypeSchema, MessageActionSchema, createApprovalMessage, createReportMessage, createFormMessage, createTaskCardMessage, } from '@repo/shared';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scryme/chat",
3
- "version": "2.81.5",
3
+ "version": "2.85.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -28,12 +28,14 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@tanstack/react-query": "5.96.2",
31
- "axios": "^1.7.9"
31
+ "axios": "^1.7.9",
32
+ "@repo/shared": "0.1.0-dev.31"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "react": "^18.0.0 || ^19.0.0"
35
36
  },
36
37
  "devDependencies": {
38
+ "@openapitools/openapi-generator-cli": "^2.13.5",
37
39
  "@types/node": "^22.10.7",
38
40
  "@types/react": "^19.2.14",
39
41
  "orval": "^6.31.0",
@@ -42,7 +44,9 @@
42
44
  "@repo/typescript-config": "0.1.0-dev.31"
43
45
  },
44
46
  "scripts": {
45
- "generate": "orval",
47
+ "generate:ts": "orval",
48
+ "generate:rust": "openapi-generator-cli generate -i ../../apps/api/openapi.json -g rust -o rust --skip-validate-spec --additional-properties=packageName=scryme-sdk,packageVersion=2.81.5,useSingleRequestParameter=true",
49
+ "generate": "pnpm generate:ts && pnpm generate:rust",
46
50
  "build": "tsc",
47
51
  "type-check": "tsc --noEmit",
48
52
  "test": "vitest run"
@@ -0,0 +1,133 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ CustomMessageSchema,
4
+ createApprovalMessage,
5
+ createReportMessage,
6
+ createFormMessage,
7
+ createTaskCardMessage,
8
+ } from '../index';
9
+
10
+ describe('Custom Message Schema & Helper Builders', () => {
11
+ describe('createApprovalMessage', () => {
12
+ it('should generate a valid CustomMessage for approvals', () => {
13
+ const approval = createApprovalMessage({
14
+ title: 'Expense Reimbursement',
15
+ description: '$250 travel expense request',
16
+ fields: [
17
+ { label: 'Category', value: 'Travel' },
18
+ { label: 'Amount', value: '$250.00' },
19
+ ],
20
+ callbackId: 'reimbursement_123',
21
+ priority: 'urgent',
22
+ });
23
+
24
+ expect(approval.type).toBe('APPROVAL');
25
+ expect(approval.context.title).toBe('Expense Reimbursement');
26
+ expect(approval.context.priority).toBe('urgent');
27
+ expect(approval.actions).toHaveLength(2);
28
+ expect(approval.actions?.[0].id).toBe('approve');
29
+ expect(approval.actions?.[1].id).toBe('reject');
30
+
31
+ const validationResult = CustomMessageSchema.safeParse(approval);
32
+ expect(validationResult.success).toBe(true);
33
+ });
34
+ });
35
+
36
+ describe('createReportMessage', () => {
37
+ it('should generate a valid CustomMessage for reports', () => {
38
+ const report = createReportMessage({
39
+ title: 'Weekly Analytics Summary',
40
+ reportId: 'rep-456',
41
+ summary: 'Traffic increased by 25% this week.',
42
+ metrics: [
43
+ { label: 'Total Visits', value: '45,200' },
44
+ { label: 'Conversion Rate', value: '3.4%' },
45
+ ],
46
+ });
47
+
48
+ expect(report.type).toBe('REPORT');
49
+ expect(report.actions?.[0].handler.url).toBe('/reports/rep-456');
50
+
51
+ const validationResult = CustomMessageSchema.safeParse(report);
52
+ expect(validationResult.success).toBe(true);
53
+ });
54
+ });
55
+
56
+ describe('createFormMessage', () => {
57
+ it('should generate a valid CustomMessage for forms and surveys', () => {
58
+ const form = createFormMessage({
59
+ title: 'User Feedback Survey',
60
+ description: 'Please rate your experience',
61
+ submitCallbackId: 'survey_submit_1',
62
+ fields: [
63
+ {
64
+ id: 'satisfaction',
65
+ label: 'Overall Satisfaction',
66
+ type: 'select',
67
+ required: true,
68
+ options: [
69
+ { label: 'High', value: 'high' },
70
+ { label: 'Medium', value: 'medium' },
71
+ { label: 'Low', value: 'low' },
72
+ ],
73
+ },
74
+ {
75
+ id: 'comments',
76
+ label: 'Additional Comments',
77
+ type: 'textarea',
78
+ },
79
+ ],
80
+ });
81
+
82
+ expect(form.type).toBe('FORM');
83
+ expect(form.root.children).toHaveLength(2);
84
+ expect(form.root.children?.[0].type).toBe('Input.Select');
85
+ expect(form.root.children?.[0].validation?.required).toBe(true);
86
+
87
+ const validationResult = CustomMessageSchema.safeParse(form);
88
+ expect(validationResult.success).toBe(true);
89
+ });
90
+ });
91
+
92
+ describe('createTaskCardMessage', () => {
93
+ it('should generate a valid CustomMessage for task cards', () => {
94
+ const taskCard = createTaskCardMessage({
95
+ title: 'Design System Update',
96
+ description: 'Refactor button component variants',
97
+ status: 'In Progress',
98
+ assignee: 'Alice',
99
+ dueDate: '2025-04-01',
100
+ callbackId: 'task_complete_99',
101
+ });
102
+
103
+ expect(taskCard.type).toBe('TASK_CARD');
104
+ expect(taskCard.actions?.[0].id).toBe('complete_task');
105
+
106
+ const validationResult = CustomMessageSchema.safeParse(taskCard);
107
+ expect(validationResult.success).toBe(true);
108
+ });
109
+ });
110
+
111
+ describe('Customization and Theming', () => {
112
+ it('should validate custom message theme overrides', () => {
113
+ const customMessage = createApprovalMessage({
114
+ title: 'Custom Brand Approval',
115
+ fields: [],
116
+ callbackId: 'cb_1',
117
+ theme: {
118
+ backgroundColor: '#0f172a',
119
+ textColor: '#f8fafc',
120
+ borderColor: '#334155',
121
+ accentColor: '#38bdf8',
122
+ className: 'custom-dark-card',
123
+ },
124
+ });
125
+
126
+ expect(customMessage.theme?.backgroundColor).toBe('#0f172a');
127
+ expect(customMessage.theme?.className).toBe('custom-dark-card');
128
+
129
+ const validationResult = CustomMessageSchema.safeParse(customMessage);
130
+ expect(validationResult.success).toBe(true);
131
+ });
132
+ });
133
+ });
package/src/index.ts CHANGED
@@ -1,3 +1,29 @@
1
1
  export * from './custom-instance';
2
2
  export * from './generated/v3-client';
3
3
  export * from './sdk';
4
+ export {
5
+ CustomMessageSchema,
6
+ MessageNodeSchema,
7
+ ConditionSchema,
8
+ ValidationSchema,
9
+ DataSourceSchema,
10
+ CustomMessageThemeSchema,
11
+ PredefinedCustomMessageTypeSchema,
12
+ MessageActionSchema,
13
+ createApprovalMessage,
14
+ createReportMessage,
15
+ createFormMessage,
16
+ createTaskCardMessage,
17
+ type CustomMessage,
18
+ type MessageNode,
19
+ type ConditionSchemaType,
20
+ type ValidationSchemaType,
21
+ type CustomMessageTheme,
22
+ type PredefinedCustomMessageType,
23
+ type MessageAction,
24
+ type CreateApprovalMessageOptions,
25
+ type CreateReportMessageOptions,
26
+ type CreateFormMessageOptions,
27
+ type CreateTaskCardMessageOptions,
28
+ type FormFieldConfig,
29
+ } from '@repo/shared';