@cellaware/utils 8.6.30 → 8.6.32

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.
@@ -25,7 +25,7 @@ export declare function createTeamsTableItem(rows: any[]): ({
25
25
  }[];
26
26
  }[];
27
27
  })[];
28
- export declare function createTeamsTableCard(title: string, table: any[], summary: string): {
28
+ export declare function createTeamsReportBriefCard(briefMarkdown: string, reportTitle: string): {
29
29
  type: string;
30
30
  version: string;
31
31
  msteams: {
@@ -35,6 +35,54 @@ export declare function createTeamsTableCard(title: string, table: any[], summar
35
35
  type: string;
36
36
  text: string;
37
37
  size: string;
38
+ weight: string;
39
+ } | {
40
+ type: string;
41
+ text: string;
42
+ size: string;
43
+ isSubtle: boolean;
44
+ wrap: boolean;
45
+ } | {
46
+ type: string;
47
+ layouts: {
48
+ type: string;
49
+ horizontalItemsAlignment: string;
50
+ minItemWidth: string;
51
+ }[];
52
+ items: {
53
+ type: string;
54
+ text: string;
55
+ }[];
56
+ } | {
57
+ type: string;
58
+ items: {
59
+ type: string;
60
+ text: string;
61
+ wrap: boolean;
62
+ }[];
63
+ })[];
64
+ };
65
+ export declare function createTeamsReportTableCard(lineTitle: string, table: any[], summary: string, reportTitle: string): {
66
+ type: string;
67
+ version: string;
68
+ msteams: {
69
+ width: string;
70
+ };
71
+ body: ({
72
+ type: string;
73
+ text: string;
74
+ size: string;
75
+ } | {
76
+ type: string;
77
+ layouts: {
78
+ type: string;
79
+ horizontalItemsAlignment: string;
80
+ minItemWidth: string;
81
+ }[];
82
+ items: {
83
+ type: string;
84
+ text: string;
85
+ }[];
38
86
  } | {
39
87
  type: string;
40
88
  roundedCorners: boolean;
@@ -43,7 +91,7 @@ export declare function createTeamsTableCard(title: string, table: any[], summar
43
91
  rows: any[];
44
92
  })[];
45
93
  };
46
- export declare function createTeamsValueCard(title: string, columnName: string, value: any, styles: string[], summary: string): {
94
+ export declare function createTeamsReportValueCard(lineTitle: string, columnName: string, value: any, styles: string[], summary: string, reportTitle: string): {
47
95
  type: string;
48
96
  version: string;
49
97
  msteams: {
@@ -60,6 +108,17 @@ export declare function createTeamsValueCard(title: string, columnName: string,
60
108
  size: string;
61
109
  isSubtle: boolean;
62
110
  wrap: boolean;
111
+ } | {
112
+ type: string;
113
+ layouts: {
114
+ type: string;
115
+ horizontalItemsAlignment: string;
116
+ minItemWidth: string;
117
+ }[];
118
+ items: {
119
+ type: string;
120
+ text: string;
121
+ }[];
63
122
  } | {
64
123
  type: string;
65
124
  roundedCorners: boolean;
@@ -75,7 +134,7 @@ export declare function createTeamsValueCard(title: string, columnName: string,
75
134
  }[];
76
135
  })[];
77
136
  };
78
- export declare function createTeamsChartCard(title: string, png: string, summary: string): {
137
+ export declare function createTeamsReportChartCard(lineTitle: string, png: string, summary: string, reportTitle: string): {
79
138
  type: string;
80
139
  version: string;
81
140
  msteams: {
@@ -92,9 +151,79 @@ export declare function createTeamsChartCard(title: string, png: string, summary
92
151
  size: string;
93
152
  isSubtle: boolean;
94
153
  wrap: boolean;
154
+ } | {
155
+ type: string;
156
+ layouts: {
157
+ type: string;
158
+ horizontalItemsAlignment: string;
159
+ minItemWidth: string;
160
+ }[];
161
+ items: {
162
+ type: string;
163
+ text: string;
164
+ }[];
95
165
  } | {
96
166
  type: string;
97
167
  url: string;
98
168
  })[];
99
169
  };
170
+ export declare function createTeamsAlertTableCard(condition: string, rows: any[], alertTitle: string): {
171
+ type: string;
172
+ version: string;
173
+ msteams: {
174
+ width: string;
175
+ };
176
+ body: ({
177
+ type: string;
178
+ text: string;
179
+ size: string;
180
+ } | {
181
+ type: string;
182
+ items: ({
183
+ type: string;
184
+ text: string;
185
+ size: string;
186
+ style: string;
187
+ } | {
188
+ type: string;
189
+ text: string;
190
+ size?: undefined;
191
+ style?: undefined;
192
+ })[];
193
+ } | {
194
+ type: string;
195
+ roundedCorners: boolean;
196
+ firstRowAsHeaders: boolean;
197
+ columns: {
198
+ width: number;
199
+ }[];
200
+ rows: ({
201
+ type: string;
202
+ cells: {
203
+ type: string;
204
+ items: {
205
+ type: string;
206
+ text: any;
207
+ size: string;
208
+ weight: string;
209
+ }[];
210
+ }[];
211
+ } | {
212
+ type: string;
213
+ style: string | undefined;
214
+ cells: {
215
+ type: string;
216
+ style: string | undefined;
217
+ items: {
218
+ type: string;
219
+ text: any;
220
+ size: string;
221
+ color: string | undefined;
222
+ weight: string | undefined;
223
+ isSubtle: true | undefined;
224
+ }[];
225
+ }[];
226
+ })[];
227
+ })[];
228
+ };
100
229
  export declare function sendTeamsWebhook(url: string, card: any): Promise<Response>;
@@ -7,7 +7,7 @@ function createTeamsTitleItem(title) {
7
7
  weight: "Bolder"
8
8
  };
9
9
  }
10
- function createTeamsTitleItemQualifier() {
10
+ function createTeamsTableQualifierItem() {
11
11
  return {
12
12
  type: "TextBlock",
13
13
  text: `Displaying first **${DATAGRID_TEAMS_ROWS} rows** and **${DATAGRID_HTML_COLS} columns**`,
@@ -23,6 +23,41 @@ function createTeamsSummaryItem(summary) {
23
23
  wrap: true
24
24
  };
25
25
  }
26
+ function createTeamsReportSourceItem(reportTitle) {
27
+ return {
28
+ type: "Container",
29
+ layouts: [
30
+ {
31
+ type: "Layout.Flow",
32
+ horizontalItemsAlignment: "Left",
33
+ minItemWidth: "0px"
34
+ }
35
+ ],
36
+ items: [
37
+ {
38
+ type: "TextBlock",
39
+ text: `Report: **${reportTitle}**`
40
+ }
41
+ ]
42
+ };
43
+ }
44
+ function createTeamsAlertSourceItem(alertTitle) {
45
+ return {
46
+ type: "Container",
47
+ items: [
48
+ {
49
+ type: "Badge",
50
+ text: "Alert",
51
+ size: "Large",
52
+ style: "Attention"
53
+ },
54
+ {
55
+ type: "TextBlock",
56
+ text: `Alert: **${alertTitle}**`
57
+ }
58
+ ]
59
+ };
60
+ }
26
61
  export function createTeamsTableItem(rows) {
27
62
  if (rows.length === 0) {
28
63
  return [];
@@ -34,14 +69,36 @@ export function createTeamsTableItem(rows) {
34
69
  ...teamsRows
35
70
  ];
36
71
  }
37
- export function createTeamsTableCard(title, table, summary) {
72
+ export function createTeamsReportBriefCard(briefMarkdown, reportTitle) {
73
+ return {
74
+ type: "AdaptiveCard",
75
+ version: "1.5",
76
+ msteams: { width: "Full" },
77
+ body: [
78
+ createTeamsTitleItem('Brief'),
79
+ {
80
+ type: "Container",
81
+ items: [
82
+ {
83
+ type: "TextBlock",
84
+ text: briefMarkdown,
85
+ wrap: true,
86
+ }
87
+ ]
88
+ },
89
+ createTeamsSummaryItem('ChatWMS can make mistakes. [Check important info.](https://chatwms.io/user-manual/chatwms/disclaimer)'),
90
+ createTeamsReportSourceItem(reportTitle)
91
+ ]
92
+ };
93
+ }
94
+ export function createTeamsReportTableCard(lineTitle, table, summary, reportTitle) {
38
95
  return {
39
96
  type: "AdaptiveCard",
40
97
  version: "1.5",
41
98
  msteams: { width: "Full" },
42
99
  body: [
43
- createTeamsTitleItem(title),
44
- createTeamsTitleItemQualifier(),
100
+ createTeamsTitleItem(lineTitle),
101
+ createTeamsTableQualifierItem(),
45
102
  {
46
103
  type: "Table",
47
104
  roundedCorners: true,
@@ -49,11 +106,12 @@ export function createTeamsTableCard(title, table, summary) {
49
106
  columns: table.length === 0 ? [] : table[0].cells.map(() => ({ width: 3 })),
50
107
  rows: table
51
108
  },
52
- createTeamsSummaryItem(summary)
109
+ createTeamsSummaryItem(summary),
110
+ createTeamsReportSourceItem(reportTitle)
53
111
  ]
54
112
  };
55
113
  }
56
- export function createTeamsValueCard(title, columnName, value, styles, summary) {
114
+ export function createTeamsReportValueCard(lineTitle, columnName, value, styles, summary, reportTitle) {
57
115
  // NOTE: we only care about mapping style string (represented as row styles) to column styles.
58
116
  let rowStyles = [];
59
117
  let columnStyles = [];
@@ -88,7 +146,7 @@ export function createTeamsValueCard(title, columnName, value, styles, summary)
88
146
  version: "1.5",
89
147
  msteams: { width: "Full" },
90
148
  body: [
91
- createTeamsTitleItem(title),
149
+ createTeamsTitleItem(lineTitle),
92
150
  {
93
151
  type: "Container",
94
152
  roundedCorners: true,
@@ -105,22 +163,44 @@ export function createTeamsValueCard(title, columnName, value, styles, summary)
105
163
  }
106
164
  ]
107
165
  },
108
- createTeamsSummaryItem(summary)
166
+ createTeamsSummaryItem(summary),
167
+ createTeamsReportSourceItem(reportTitle)
109
168
  ]
110
169
  };
111
170
  }
112
- export function createTeamsChartCard(title, png, summary) {
171
+ export function createTeamsReportChartCard(lineTitle, png, summary, reportTitle) {
113
172
  return {
114
173
  type: "AdaptiveCard",
115
174
  version: "1.5",
116
175
  msteams: { width: "Full" },
117
176
  body: [
118
- createTeamsTitleItem(title),
177
+ createTeamsTitleItem(lineTitle),
119
178
  {
120
179
  type: "Image",
121
180
  url: png
122
181
  },
123
- createTeamsSummaryItem(summary)
182
+ createTeamsSummaryItem(summary),
183
+ createTeamsReportSourceItem(reportTitle)
184
+ ]
185
+ };
186
+ }
187
+ export function createTeamsAlertTableCard(condition, rows, alertTitle) {
188
+ const table = createTeamsTableItem(rows);
189
+ return {
190
+ type: "AdaptiveCard",
191
+ version: "1.5",
192
+ msteams: { width: "Full" },
193
+ body: [
194
+ createTeamsTitleItem(condition),
195
+ createTeamsTableQualifierItem(),
196
+ {
197
+ type: "Table",
198
+ roundedCorners: true,
199
+ firstRowAsHeaders: true,
200
+ columns: table.length === 0 ? [] : table[0].cells.map(() => ({ width: 3 })),
201
+ rows: table
202
+ },
203
+ createTeamsAlertSourceItem(alertTitle)
124
204
  ]
125
205
  };
126
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.6.30",
3
+ "version": "8.6.32",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",