@cellaware/utils 8.5.2 → 8.5.4
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/chatwms/cosmos.js +5 -1
- package/dist/chatwms/datagrid.d.ts +3 -0
- package/dist/chatwms/datagrid.js +12 -3
- package/dist/llm/cost.js +25 -65
- package/dist/llm/model.d.ts +1 -1
- package/package.json +1 -1
package/dist/chatwms/cosmos.js
CHANGED
|
@@ -6,7 +6,7 @@ const COSMOS_SQL_ACTION_WORDS_REGEX = /\b(insert|update|delete|create|alter|drop
|
|
|
6
6
|
const COSMOS_SQL_SELECT_REGEX = /\b(select)\b/gmi;
|
|
7
7
|
const COSMOS_SQL_FROM_REGEX = /\b(from)\b/gmi;
|
|
8
8
|
const COSMOS_SQL_WHERE_REGEX = /\b(where)\b/gmi;
|
|
9
|
-
const COSMOS_SQL_APPROVED_TABLES_REGEX = /\b(alert_executions|alert_subscriptions|alerts|client_configs|conversation_details|conversation_feedback|conversation_headers|conversation_metadata|conversation_removed_details|conversation_sampled_details|conversation_sampled_metadata|dashboard_usage|dashboard_widgets|dashboards|notifications|report_lines|report_usage|reports|user_roles)\b/gmi;
|
|
9
|
+
const COSMOS_SQL_APPROVED_TABLES_REGEX = /\b(alert_executions|alert_subscriptions|alerts|client_configs|conversation_details|conversation_feedback|conversation_headers|conversation_metadata|conversation_removed_details|conversation_sampled_details|conversation_sampled_metadata|dashboard_usage|dashboard_widgets|dashboards|notifications|report_lines|report_schedules|report_usage|reports|user_roles)\b/gmi;
|
|
10
10
|
const _SUBQUERY_QUERY_PLACEHOLDER_UNWRAPPED = '{{query}}';
|
|
11
11
|
const SUBQUERY_QUERY_PLACEHOLDER = `(${_SUBQUERY_QUERY_PLACEHOLDER_UNWRAPPED})`;
|
|
12
12
|
const VARIABLE_COSMOS_USER_ID = '__USER_ID__';
|
|
@@ -124,6 +124,10 @@ const COSMOS_TABLES = [
|
|
|
124
124
|
table_name: 'report_lines',
|
|
125
125
|
table_description: 'Report Lines'
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
table_name: 'report_schedules',
|
|
129
|
+
table_description: 'Report Schedules'
|
|
130
|
+
},
|
|
127
131
|
{
|
|
128
132
|
table_name: 'report_usage',
|
|
129
133
|
table_description: 'Report Usage'
|
|
@@ -126,5 +126,8 @@ export declare function codifyCondition(condition: DatagridCondition): string;
|
|
|
126
126
|
* https://github.com/cellaware/chatwms-az-swa-ng/blob/development/src/app/utils/data.ts#L126
|
|
127
127
|
*/
|
|
128
128
|
export declare function stripNumericValueFormat(value: string | number | undefined): any;
|
|
129
|
+
/**
|
|
130
|
+
* **Important:** `html` output will be limited to **500 rows** and **6 columns**.
|
|
131
|
+
*/
|
|
129
132
|
export declare function transformDatagrid(rows: any[], datagridState: DatagridStateBase, locale: string, condition?: DatagridCondition): DatagridState;
|
|
130
133
|
export {};
|
package/dist/chatwms/datagrid.js
CHANGED
|
@@ -792,7 +792,7 @@ function buildHtmlTableHeader(columnNames) {
|
|
|
792
792
|
function buildHtmlTableFooter() {
|
|
793
793
|
return '\n\t</tbody>\n</table>';
|
|
794
794
|
}
|
|
795
|
-
function buildHtmlRow(rowValues, rowStyles, columnStyles) {
|
|
795
|
+
function buildHtmlRow(rowValues, rowStyles, columnStyles, columnCount) {
|
|
796
796
|
let buf = '';
|
|
797
797
|
// Apply row styles.
|
|
798
798
|
if (rowStyles.length > 0) {
|
|
@@ -815,7 +815,12 @@ function buildHtmlRow(rowValues, rowStyles, columnStyles) {
|
|
|
815
815
|
buf += '\n\t\t</tr>';
|
|
816
816
|
return buf;
|
|
817
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* **Important:** `html` output will be limited to **500 rows** and **6 columns**.
|
|
820
|
+
*/
|
|
818
821
|
export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
822
|
+
const HTML_ROWS = 500;
|
|
823
|
+
const HTML_COLS = 6;
|
|
819
824
|
const columnState = datagridState.columnState ?? [];
|
|
820
825
|
const filterModel = datagridState.filterModel ?? {};
|
|
821
826
|
const isPivotMode = !!datagridState.isPivotMode;
|
|
@@ -890,7 +895,9 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
890
895
|
}
|
|
891
896
|
});
|
|
892
897
|
chartRowData.push(chartRow);
|
|
893
|
-
|
|
898
|
+
if (rowIdx < HTML_ROWS) {
|
|
899
|
+
htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
|
|
900
|
+
}
|
|
894
901
|
rowIdx++;
|
|
895
902
|
});
|
|
896
903
|
if (!!condition) {
|
|
@@ -929,7 +936,9 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
929
936
|
}
|
|
930
937
|
});
|
|
931
938
|
chartRowData.push(chartRow);
|
|
932
|
-
|
|
939
|
+
if (rowIdx < HTML_ROWS) {
|
|
940
|
+
htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
|
|
941
|
+
}
|
|
933
942
|
rowIdx++;
|
|
934
943
|
});
|
|
935
944
|
if (!!condition) {
|
package/dist/llm/cost.js
CHANGED
|
@@ -1,71 +1,31 @@
|
|
|
1
1
|
// https://platform.openai.com/docs/pricing
|
|
2
|
+
const MODEL_COSTS = {
|
|
3
|
+
'gpt-5.2-pro': { inputCost: 21.00, outputCost: 168.00 },
|
|
4
|
+
'gpt-5.2': { inputCost: 1.75, outputCost: 14.00 },
|
|
5
|
+
'gpt-5.2-chat-latest': { inputCost: 1.75, outputCost: 14.00 },
|
|
6
|
+
'gpt-5.2-codex': { inputCost: 1.75, outputCost: 14.00 },
|
|
7
|
+
'gpt-5.1': { inputCost: 1.25, outputCost: 10.00 },
|
|
8
|
+
'gpt-5': { inputCost: 1.25, outputCost: 10.00 },
|
|
9
|
+
'gpt-5-mini': { inputCost: 0.25, outputCost: 2.00 },
|
|
10
|
+
'gpt-5-nano': { inputCost: 0.05, outputCost: 0.40 },
|
|
11
|
+
'gpt-4.1': { inputCost: 2.00, outputCost: 8.00 },
|
|
12
|
+
'gpt-4.1-mini': { inputCost: 0.40, outputCost: 1.60 },
|
|
13
|
+
'gpt-4.1-nano': { inputCost: 0.10, outputCost: 0.40 },
|
|
14
|
+
'gpt-4o': { inputCost: 2.50, outputCost: 10.00 },
|
|
15
|
+
'gpt-4o-mini': { inputCost: 0.15, outputCost: 0.60 },
|
|
16
|
+
'o1': { inputCost: 15.00, outputCost: 60.00 },
|
|
17
|
+
'o1-mini': { inputCost: 1.10, outputCost: 4.40 },
|
|
18
|
+
'o3': { inputCost: 2.00, outputCost: 8.00 },
|
|
19
|
+
'o3-mini': { inputCost: 1.10, outputCost: 4.40 },
|
|
20
|
+
'o4-mini': { inputCost: 1.10, outputCost: 4.40 },
|
|
21
|
+
};
|
|
2
22
|
export function getLLMCostPerToken(modelName) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
case 'gpt-5.2':
|
|
7
|
-
inputCost = 1.75;
|
|
8
|
-
outputCost = 14.00;
|
|
9
|
-
break;
|
|
10
|
-
case 'gpt-5.1':
|
|
11
|
-
inputCost = 1.25;
|
|
12
|
-
outputCost = 10.00;
|
|
13
|
-
break;
|
|
14
|
-
case 'gpt-5':
|
|
15
|
-
inputCost = 1.25;
|
|
16
|
-
outputCost = 10.00;
|
|
17
|
-
break;
|
|
18
|
-
case 'gpt-5-mini':
|
|
19
|
-
inputCost = 0.25;
|
|
20
|
-
outputCost = 2.00;
|
|
21
|
-
break;
|
|
22
|
-
case 'gpt-5-nano':
|
|
23
|
-
inputCost = 0.05;
|
|
24
|
-
outputCost = 0.40;
|
|
25
|
-
break;
|
|
26
|
-
case 'gpt-4.1':
|
|
27
|
-
inputCost = 2.00;
|
|
28
|
-
outputCost = 8.00;
|
|
29
|
-
break;
|
|
30
|
-
case 'gpt-4.1-mini':
|
|
31
|
-
inputCost = 0.40;
|
|
32
|
-
outputCost = 1.60;
|
|
33
|
-
break;
|
|
34
|
-
case 'gpt-4.1-nano':
|
|
35
|
-
inputCost = 0.10;
|
|
36
|
-
outputCost = 0.40;
|
|
37
|
-
break;
|
|
38
|
-
case 'gpt-4o':
|
|
39
|
-
inputCost = 2.50;
|
|
40
|
-
outputCost = 10.00;
|
|
41
|
-
break;
|
|
42
|
-
case 'gpt-4o-mini':
|
|
43
|
-
inputCost = 0.15;
|
|
44
|
-
outputCost = 0.60;
|
|
45
|
-
break;
|
|
46
|
-
case 'o1':
|
|
47
|
-
inputCost = 15.00;
|
|
48
|
-
outputCost = 60.00;
|
|
49
|
-
break;
|
|
50
|
-
case 'o1-mini':
|
|
51
|
-
inputCost = 1.10;
|
|
52
|
-
outputCost = 4.40;
|
|
53
|
-
break;
|
|
54
|
-
case 'o3':
|
|
55
|
-
inputCost = 10.00;
|
|
56
|
-
outputCost = 40.00;
|
|
57
|
-
break;
|
|
58
|
-
case 'o3-mini':
|
|
59
|
-
inputCost = 1.10;
|
|
60
|
-
outputCost = 4.40;
|
|
61
|
-
break;
|
|
62
|
-
case 'o4-mini':
|
|
63
|
-
inputCost = 1.10;
|
|
64
|
-
outputCost = 4.40;
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
throw new Error(`Model '${modelName}' cost is not configured`);
|
|
23
|
+
const cost = MODEL_COSTS[modelName];
|
|
24
|
+
if (!cost) {
|
|
25
|
+
throw new Error(`Model '${modelName}' cost is not configured`);
|
|
68
26
|
}
|
|
27
|
+
let inputCost = cost.inputCost;
|
|
28
|
+
let outputCost = cost.outputCost;
|
|
69
29
|
// OpenAI model costs are measured in millions of tokens -- therefore we need to divide each figure by 1,000,000 before returning.
|
|
70
30
|
const unit = 1_000_000.0;
|
|
71
31
|
inputCost /= unit;
|
package/dist/llm/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ModelName = 'gpt-5.2' | 'gpt-5.1' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o3' | 'o3-mini' | 'o4-mini';
|
|
1
|
+
export type ModelName = 'gpt-5.2-pro' | 'gpt-5.2-codex' | 'gpt-5.2-chat-latest' | 'gpt-5.2' | 'gpt-5.1' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o3' | 'o3-mini' | 'o4-mini';
|
|
2
2
|
export type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
|
|
3
3
|
export type Verbosity = 'low' | 'medium' | 'high';
|
|
4
4
|
export interface OpenAIModelOptions {
|