@cellaware/utils 8.6.31 → 8.6.33

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