@scryme/chat 2.91.119 → 2.91.120

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.
@@ -645,31 +645,3 @@ export interface CreateTaskCardMessageOptions {
645
645
  * Creates a Task Card Custom Message schema structure.
646
646
  */
647
647
  export declare const createTaskCardMessage: (options: CreateTaskCardMessageOptions) => CustomMessage;
648
- /**
649
- * Helper to format product item name combining productName and variantName.
650
- * If variantName is missing, empty, or 'default' (case-insensitive), returns productName.
651
- */
652
- export declare const formatLowStockItemName: (options: {
653
- productName: string;
654
- variantName?: string | null;
655
- }) => string;
656
- /**
657
- * Builder options for creating a Low Stock Alert custom message schema.
658
- */
659
- export interface CreateLowStockAlertMessageOptions {
660
- productName: string;
661
- variantName?: string | null;
662
- currentQuantity: number;
663
- thresholdQuantity: number;
664
- sku?: string;
665
- location?: string;
666
- reorderUrl?: string;
667
- callbackId?: string;
668
- priority?: 'low' | 'normal' | 'high' | 'urgent';
669
- data?: Record<string, any>;
670
- theme?: CustomMessageTheme;
671
- }
672
- /**
673
- * Creates a standard Low Stock Alert Custom Message schema structure.
674
- */
675
- export declare const createLowStockAlertMessage: (options: CreateLowStockAlertMessageOptions) => CustomMessage;
@@ -397,96 +397,3 @@ export var createTaskCardMessage = function (options) { return ({
397
397
  ],
398
398
  data: options.data,
399
399
  }); };
400
- /**
401
- * Helper to format product item name combining productName and variantName.
402
- * If variantName is missing, empty, or 'default' (case-insensitive), returns productName.
403
- */
404
- export var formatLowStockItemName = function (options) {
405
- var trimmedProduct = options.productName.trim();
406
- var trimmedVariant = options.variantName ? options.variantName.trim() : '';
407
- if (!trimmedVariant || trimmedVariant.toLowerCase() === 'default') {
408
- return trimmedProduct;
409
- }
410
- return "".concat(trimmedProduct, " - ").concat(trimmedVariant);
411
- };
412
- /**
413
- * Creates a standard Low Stock Alert Custom Message schema structure.
414
- */
415
- export var createLowStockAlertMessage = function (options) {
416
- var itemName = formatLowStockItemName({
417
- productName: options.productName,
418
- variantName: options.variantName,
419
- });
420
- var fields = [
421
- { label: 'Item Name', value: itemName },
422
- { label: 'Current Stock', value: "".concat(options.currentQuantity, " units") },
423
- { label: 'Reorder Threshold', value: "".concat(options.thresholdQuantity, " units") },
424
- ];
425
- if (options.sku) {
426
- fields.push({ label: 'SKU', value: options.sku });
427
- }
428
- if (options.location) {
429
- fields.push({ label: 'Location', value: options.location });
430
- }
431
- var actions = [];
432
- if (options.reorderUrl) {
433
- actions.push({
434
- id: 'reorder',
435
- label: 'Reorder Stock',
436
- type: 'PRIMARY',
437
- icon: 'ExternalLink',
438
- handler: {
439
- type: 'LINK',
440
- url: options.reorderUrl,
441
- },
442
- });
443
- }
444
- else if (options.callbackId) {
445
- actions.push({
446
- id: 'reorder',
447
- label: 'Reorder Stock',
448
- type: 'PRIMARY',
449
- icon: 'Send',
450
- handler: {
451
- type: 'CALLBACK',
452
- callbackId: options.callbackId,
453
- payload: {
454
- action: 'reorder',
455
- productName: options.productName,
456
- variantName: options.variantName || undefined,
457
- itemName: itemName,
458
- currentQuantity: options.currentQuantity,
459
- thresholdQuantity: options.thresholdQuantity,
460
- sku: options.sku,
461
- },
462
- includeFormState: false,
463
- },
464
- });
465
- }
466
- return {
467
- version: 'v1',
468
- type: 'LOW_STOCK_ALERT',
469
- context: {
470
- title: 'Low Stock Alert',
471
- description: "Stock level for ".concat(itemName, " has dropped below threshold."),
472
- icon: 'AlertCircle',
473
- priority: options.priority || 'high',
474
- },
475
- theme: options.theme,
476
- root: {
477
- type: 'Layout.Card',
478
- children: [
479
- {
480
- type: 'Layout.Grid',
481
- properties: { columns: 2 },
482
- children: fields.map(function (f) { return ({
483
- type: 'Display.Field',
484
- properties: { label: f.label, value: f.value },
485
- }); }),
486
- },
487
- ],
488
- },
489
- actions: actions.length > 0 ? actions : undefined,
490
- data: options.data,
491
- };
492
- };
package/dist/index.d.ts CHANGED
@@ -1,4 +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, createLowStockAlertMessage, formatLowStockItemName, type CustomMessage, type MessageNode, type ConditionSchemaType, type ValidationSchemaType, type CustomMessageTheme, type PredefinedCustomMessageType, type MessageAction, type CreateApprovalMessageOptions, type CreateReportMessageOptions, type CreateFormMessageOptions, type CreateTaskCardMessageOptions, type CreateLowStockAlertMessageOptions, type FormFieldConfig, } from './custom-message-schema';
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 './custom-message-schema';
package/dist/index.js CHANGED
@@ -1,4 +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, createLowStockAlertMessage, formatLowStockItemName, } from './custom-message-schema';
4
+ export { CustomMessageSchema, MessageNodeSchema, ConditionSchema, ValidationSchema, DataSourceSchema, CustomMessageThemeSchema, PredefinedCustomMessageTypeSchema, MessageActionSchema, createApprovalMessage, createReportMessage, createFormMessage, createTaskCardMessage, } from './custom-message-schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scryme/chat",
3
- "version": "2.91.119",
3
+ "version": "2.91.120",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -5,8 +5,6 @@ import {
5
5
  createReportMessage,
6
6
  createFormMessage,
7
7
  createTaskCardMessage,
8
- createLowStockAlertMessage,
9
- formatLowStockItemName,
10
8
  } from '../index';
11
9
 
12
10
  describe('Custom Message Schema & Helper Builders', () => {
@@ -110,70 +108,6 @@ describe('Custom Message Schema & Helper Builders', () => {
110
108
  });
111
109
  });
112
110
 
113
- describe('createLowStockAlertMessage & formatLowStockItemName', () => {
114
- it('should omit variant name if variant is missing, empty, or default (case-insensitive)', () => {
115
- expect(formatLowStockItemName({ productName: 'Wireless Mouse' })).toBe('Wireless Mouse');
116
- expect(formatLowStockItemName({ productName: 'Wireless Mouse', variantName: 'default' })).toBe('Wireless Mouse');
117
- expect(formatLowStockItemName({ productName: 'Wireless Mouse', variantName: 'DEFAULT' })).toBe('Wireless Mouse');
118
- expect(formatLowStockItemName({ productName: 'Wireless Mouse', variantName: ' Default ' })).toBe('Wireless Mouse');
119
-
120
- expect(createLowStockAlertMessage({
121
- productName: 'Wireless Mouse',
122
- currentQuantity: 2,
123
- thresholdQuantity: 5,
124
- }).context.description).toContain('Wireless Mouse');
125
-
126
- const msg1 = createLowStockAlertMessage({
127
- productName: 'Wireless Mouse',
128
- variantName: 'default',
129
- currentQuantity: 2,
130
- thresholdQuantity: 5,
131
- });
132
-
133
- const gridChildren1 = msg1.root.children?.[0]?.children || [];
134
- const itemNameField1 = gridChildren1.find((c: any) => c.properties?.label === 'Item Name');
135
- expect(itemNameField1?.properties?.value).toBe('Wireless Mouse');
136
-
137
- const msg2 = createLowStockAlertMessage({
138
- productName: 'Mechanical Keyboard',
139
- variantName: 'DEFAULT',
140
- currentQuantity: 1,
141
- thresholdQuantity: 10,
142
- });
143
- const gridChildren2 = msg2.root.children?.[0]?.children || [];
144
- const itemNameField2 = gridChildren2.find((c: any) => c.properties?.label === 'Item Name');
145
- expect(itemNameField2?.properties?.value).toBe('Mechanical Keyboard');
146
- });
147
-
148
- it('should include variant name when variant is not default', () => {
149
- expect(formatLowStockItemName({ productName: 'Ergonomic Chair', variantName: 'Mesh Black' })).toBe('Ergonomic Chair - Mesh Black');
150
-
151
- const msg = createLowStockAlertMessage({
152
- productName: 'Ergonomic Chair',
153
- variantName: 'Mesh Black',
154
- currentQuantity: 3,
155
- thresholdQuantity: 8,
156
- sku: 'CHAIR-BLK-01',
157
- location: 'Warehouse A',
158
- reorderUrl: 'https://inventory.example.com/reorder/CHAIR-BLK-01',
159
- });
160
-
161
- expect(msg.type).toBe('LOW_STOCK_ALERT');
162
- expect(msg.context.title).toBe('Low Stock Alert');
163
- expect(msg.context.priority).toBe('high');
164
-
165
- const gridChildren = msg.root.children?.[0]?.children || [];
166
- const itemNameField = gridChildren.find((c: any) => c.properties?.label === 'Item Name');
167
- expect(itemNameField?.properties?.value).toBe('Ergonomic Chair - Mesh Black');
168
-
169
- expect(msg.actions?.[0].handler.type).toBe('LINK');
170
- expect(msg.actions?.[0].handler.url).toBe('https://inventory.example.com/reorder/CHAIR-BLK-01');
171
-
172
- const validationResult = CustomMessageSchema.safeParse(msg);
173
- expect(validationResult.success).toBe(true);
174
- });
175
- });
176
-
177
111
  describe('Customization and Theming', () => {
178
112
  it('should validate custom message theme overrides', () => {
179
113
  const customMessage = createApprovalMessage({
@@ -519,122 +519,3 @@ export const createTaskCardMessage = (options: CreateTaskCardMessageOptions): Cu
519
519
  ],
520
520
  data: options.data,
521
521
  });
522
-
523
- /**
524
- * Helper to format product item name combining productName and variantName.
525
- * If variantName is missing, empty, or 'default' (case-insensitive), returns productName.
526
- */
527
- export const formatLowStockItemName = (options: { productName: string; variantName?: string | null }): string => {
528
- const trimmedProduct = options.productName.trim();
529
- const trimmedVariant = options.variantName ? options.variantName.trim() : '';
530
-
531
- if (!trimmedVariant || trimmedVariant.toLowerCase() === 'default') {
532
- return trimmedProduct;
533
- }
534
-
535
- return `${trimmedProduct} - ${trimmedVariant}`;
536
- };
537
-
538
- /**
539
- * Builder options for creating a Low Stock Alert custom message schema.
540
- */
541
- export interface CreateLowStockAlertMessageOptions {
542
- productName: string;
543
- variantName?: string | null;
544
- currentQuantity: number;
545
- thresholdQuantity: number;
546
- sku?: string;
547
- location?: string;
548
- reorderUrl?: string;
549
- callbackId?: string;
550
- priority?: 'low' | 'normal' | 'high' | 'urgent';
551
- data?: Record<string, any>;
552
- theme?: CustomMessageTheme;
553
- }
554
-
555
- /**
556
- * Creates a standard Low Stock Alert Custom Message schema structure.
557
- */
558
- export const createLowStockAlertMessage = (options: CreateLowStockAlertMessageOptions): CustomMessage => {
559
- const itemName = formatLowStockItemName({
560
- productName: options.productName,
561
- variantName: options.variantName,
562
- });
563
-
564
- const fields: Array<{ label: string; value: string }> = [
565
- { label: 'Item Name', value: itemName },
566
- { label: 'Current Stock', value: `${options.currentQuantity} units` },
567
- { label: 'Reorder Threshold', value: `${options.thresholdQuantity} units` },
568
- ];
569
-
570
- if (options.sku) {
571
- fields.push({ label: 'SKU', value: options.sku });
572
- }
573
-
574
- if (options.location) {
575
- fields.push({ label: 'Location', value: options.location });
576
- }
577
-
578
- const actions: MessageAction[] = [];
579
-
580
- if (options.reorderUrl) {
581
- actions.push({
582
- id: 'reorder',
583
- label: 'Reorder Stock',
584
- type: 'PRIMARY',
585
- icon: 'ExternalLink',
586
- handler: {
587
- type: 'LINK',
588
- url: options.reorderUrl,
589
- },
590
- });
591
- } else if (options.callbackId) {
592
- actions.push({
593
- id: 'reorder',
594
- label: 'Reorder Stock',
595
- type: 'PRIMARY',
596
- icon: 'Send',
597
- handler: {
598
- type: 'CALLBACK',
599
- callbackId: options.callbackId,
600
- payload: {
601
- action: 'reorder',
602
- productName: options.productName,
603
- variantName: options.variantName || undefined,
604
- itemName,
605
- currentQuantity: options.currentQuantity,
606
- thresholdQuantity: options.thresholdQuantity,
607
- sku: options.sku,
608
- },
609
- includeFormState: false,
610
- },
611
- });
612
- }
613
-
614
- return {
615
- version: 'v1',
616
- type: 'LOW_STOCK_ALERT',
617
- context: {
618
- title: 'Low Stock Alert',
619
- description: `Stock level for ${itemName} has dropped below threshold.`,
620
- icon: 'AlertCircle',
621
- priority: options.priority || 'high',
622
- },
623
- theme: options.theme,
624
- root: {
625
- type: 'Layout.Card',
626
- children: [
627
- {
628
- type: 'Layout.Grid',
629
- properties: { columns: 2 },
630
- children: fields.map(f => ({
631
- type: 'Display.Field',
632
- properties: { label: f.label, value: f.value },
633
- })),
634
- },
635
- ],
636
- },
637
- actions: actions.length > 0 ? actions : undefined,
638
- data: options.data,
639
- };
640
- };
package/src/index.ts CHANGED
@@ -14,8 +14,6 @@ export {
14
14
  createReportMessage,
15
15
  createFormMessage,
16
16
  createTaskCardMessage,
17
- createLowStockAlertMessage,
18
- formatLowStockItemName,
19
17
  type CustomMessage,
20
18
  type MessageNode,
21
19
  type ConditionSchemaType,
@@ -27,6 +25,5 @@ export {
27
25
  type CreateReportMessageOptions,
28
26
  type CreateFormMessageOptions,
29
27
  type CreateTaskCardMessageOptions,
30
- type CreateLowStockAlertMessageOptions,
31
28
  type FormFieldConfig,
32
29
  } from './custom-message-schema';