@cellaware/utils 7.3.0 → 8.0.0

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.
@@ -0,0 +1,86 @@
1
+ import { DataContext } from "./client.js";
2
+ import { DatagridCondition, DatagridStateBase } from "./datagrid.js";
3
+ export declare const ALERT_VISIBILITY_PRIVATE = "private";
4
+ export declare const ALERT_VISIBILITY_PUBLIC = "public";
5
+ /**
6
+ * Alert Strategy
7
+ *
8
+ * The strategy influences alert sending behavior when the previous alert execution
9
+ * resulted in the condition being met/alert being sent. Traditionally, alert systems
10
+ * will just send notifications over and over while the condition is met. This may be
11
+ * good sometimes, but could be very annoying otherwise. The strategy allows users to
12
+ * configure this behavior.
13
+ *
14
+ * - once: will send once when the condition is met and will not send again until the condition
15
+ * is no longer met
16
+ * - change: if the condition is met, will send if there was a meaningful change in the data
17
+ * since last execution
18
+ * - always: sends every time as long as the condition is met
19
+ */
20
+ export declare const ALERT_STRATEGY_ONCE = "once";
21
+ export declare const ALERT_STRATEGY_CHANGE = "change";
22
+ export declare const ALERT_STRATEGY_ALWAYS = "always";
23
+ export interface Alert {
24
+ alertId: string;
25
+ alertTitle: string;
26
+ enabled: boolean;
27
+ visibility: string;
28
+ readonly: boolean;
29
+ folder: string;
30
+ strategy: string;
31
+ contentInfo: AlertContentInfo;
32
+ conditionInfo: DatagridCondition;
33
+ clientId: string;
34
+ userId: string;
35
+ }
36
+ export declare function initAlert(): Alert;
37
+ export interface InstanceAlert extends Alert {
38
+ subscriptions: AlertSubscription[];
39
+ }
40
+ export interface AlertWithSubscriptions extends Alert {
41
+ subscriptions: AlertSubscriptionType[];
42
+ lastMet: string;
43
+ lastSent: string;
44
+ }
45
+ export interface AlertContentInfo extends DatagridStateBase {
46
+ contextName: DataContext;
47
+ specification: string;
48
+ query: string;
49
+ summary: string;
50
+ reviewOk?: boolean;
51
+ reviewConfidence?: string;
52
+ reviewFeedback?: string;
53
+ tableGroups?: string[];
54
+ developer?: boolean;
55
+ }
56
+ export interface AlertTestResult {
57
+ met: boolean;
58
+ rows: any[];
59
+ hashedRows: string[];
60
+ }
61
+ export declare function initAlertTestResult(): AlertTestResult;
62
+ export interface AlertExecution {
63
+ alertId: string;
64
+ alertTitle: string;
65
+ strategy: string;
66
+ conditionInfo: DatagridCondition;
67
+ met: boolean;
68
+ hashedRows: string[];
69
+ error: string;
70
+ sent: boolean;
71
+ clientId: string;
72
+ customer: string;
73
+ warehouse: string;
74
+ userId: string;
75
+ datetime: Date;
76
+ }
77
+ export type AlertSubscriptionType = 'popup' | 'email' | 'teams';
78
+ export declare const ALERT_SUBSCRIPTION_TYPES: string[];
79
+ export interface AlertSubscription {
80
+ alertId: string;
81
+ type: AlertSubscriptionType;
82
+ clientId: string;
83
+ userId: string;
84
+ userDetails: string;
85
+ }
86
+ export declare function initAlertSubscription(): AlertSubscription;
@@ -0,0 +1,62 @@
1
+ import { CHATWMS_CONTEXT_NAME } from "./client.js";
2
+ import { initDatagridCondition } from "./datagrid.js";
3
+ export const ALERT_VISIBILITY_PRIVATE = 'private';
4
+ export const ALERT_VISIBILITY_PUBLIC = 'public';
5
+ /**
6
+ * Alert Strategy
7
+ *
8
+ * The strategy influences alert sending behavior when the previous alert execution
9
+ * resulted in the condition being met/alert being sent. Traditionally, alert systems
10
+ * will just send notifications over and over while the condition is met. This may be
11
+ * good sometimes, but could be very annoying otherwise. The strategy allows users to
12
+ * configure this behavior.
13
+ *
14
+ * - once: will send once when the condition is met and will not send again until the condition
15
+ * is no longer met
16
+ * - change: if the condition is met, will send if there was a meaningful change in the data
17
+ * since last execution
18
+ * - always: sends every time as long as the condition is met
19
+ */
20
+ export const ALERT_STRATEGY_ONCE = 'once';
21
+ export const ALERT_STRATEGY_CHANGE = 'change';
22
+ export const ALERT_STRATEGY_ALWAYS = 'always';
23
+ export function initAlert() {
24
+ return {
25
+ alertId: '',
26
+ alertTitle: '',
27
+ enabled: false,
28
+ visibility: ALERT_VISIBILITY_PRIVATE,
29
+ readonly: false,
30
+ folder: '',
31
+ strategy: ALERT_STRATEGY_ONCE,
32
+ contentInfo: initAlertContentInfo(),
33
+ conditionInfo: initDatagridCondition(),
34
+ clientId: '',
35
+ userId: ''
36
+ };
37
+ }
38
+ function initAlertContentInfo() {
39
+ return {
40
+ contextName: CHATWMS_CONTEXT_NAME,
41
+ specification: '',
42
+ query: '',
43
+ summary: ''
44
+ };
45
+ }
46
+ export function initAlertTestResult() {
47
+ return {
48
+ met: false,
49
+ rows: [],
50
+ hashedRows: []
51
+ };
52
+ }
53
+ export const ALERT_SUBSCRIPTION_TYPES = ['popup', 'email', 'teams'];
54
+ export function initAlertSubscription() {
55
+ return {
56
+ alertId: '',
57
+ type: 'email',
58
+ clientId: '',
59
+ userId: '',
60
+ userDetails: ''
61
+ };
62
+ }
@@ -1,4 +1,8 @@
1
1
  export declare const CHATWMS_GENERIC_CLIENT_ID = "chatwms";
2
+ export declare const CHATWMS_CONTEXT_NAME = "chatwms";
3
+ export declare const DATABASE_CONTEXT_NAME = "database";
4
+ export declare const COSMOS_CONTEXT_NAME = "cosmos";
5
+ export type DataContext = 'chatwms' | 'database' | 'cosmos';
2
6
  export declare function chatwmsGetClientId(customer: string, warehouse: string): string;
3
7
  export declare function chatwmsGetWarehouseFromClientId(clientId: string, customer: string): string;
4
8
  export declare function chatwmsGetWarehouse(warehouse: string, organization?: string): string;
@@ -1,4 +1,7 @@
1
1
  export const CHATWMS_GENERIC_CLIENT_ID = 'chatwms';
2
+ export const CHATWMS_CONTEXT_NAME = 'chatwms';
3
+ export const DATABASE_CONTEXT_NAME = 'database';
4
+ export const COSMOS_CONTEXT_NAME = 'cosmos';
2
5
  export function chatwmsGetClientId(customer, warehouse) {
3
6
  return `${customer}_${warehouse}`;
4
7
  }
@@ -0,0 +1,80 @@
1
+ import { DataContext } from "./client.js";
2
+ import { DatagridStateBase } from "./datagrid.js";
3
+ export declare const DASHBOARD_VISIBILITY_PRIVATE = "private";
4
+ export declare const DASHBOARD_VISIBILITY_PUBLIC = "public";
5
+ export declare const DASHBOARD_VISIBILITY_GLOBAL = "global";
6
+ export interface DashboardFilter {
7
+ sequence: number;
8
+ name: string;
9
+ sortDescending: boolean;
10
+ defaultValue: boolean;
11
+ }
12
+ export interface DashboardParameter {
13
+ sequence: number;
14
+ name: string;
15
+ required: boolean;
16
+ exampleValue: string;
17
+ }
18
+ export interface Dashboard {
19
+ dashboardId: string;
20
+ dashboardTitle: string;
21
+ dashboardRoute: string;
22
+ visibility: string;
23
+ readonly: boolean;
24
+ filters: DashboardFilter[];
25
+ parameters: DashboardParameter[];
26
+ folder: string;
27
+ clientId: string;
28
+ userId: string;
29
+ }
30
+ export declare function initDashboard(): Dashboard;
31
+ export interface WidgetDashboardFilter {
32
+ sequence: number;
33
+ filterName: string;
34
+ columnName: string;
35
+ }
36
+ export interface WidgetDashboardParameter {
37
+ sequence: number;
38
+ parameterName: string;
39
+ columnName: string;
40
+ }
41
+ export interface DashboardWidgetContentInfo extends DatagridStateBase {
42
+ visualizationOption: string;
43
+ dashboardFilters: WidgetDashboardFilter[];
44
+ dashboardParameters: WidgetDashboardParameter[];
45
+ contextName: DataContext;
46
+ specification: string;
47
+ query: string;
48
+ summary: string;
49
+ reviewOk?: boolean;
50
+ reviewConfidence?: string;
51
+ reviewFeedback?: string;
52
+ tableGroups?: string[];
53
+ developer?: boolean;
54
+ archive?: boolean;
55
+ referenceWidgetId?: string;
56
+ }
57
+ export interface DashboardWidgetLayoutInfo {
58
+ id: string;
59
+ x: number;
60
+ y: number;
61
+ w: number;
62
+ h: number;
63
+ }
64
+ export interface DashboardWidget {
65
+ widgetId: string;
66
+ widgetTitle: string;
67
+ dashboardId: string;
68
+ contentInfo: DashboardWidgetContentInfo;
69
+ layoutInfo: DashboardWidgetLayoutInfo;
70
+ clientId: string;
71
+ userId: string;
72
+ }
73
+ export interface DashboardUsage {
74
+ dashboardId: string;
75
+ dashboardTitle: string;
76
+ visibility: string;
77
+ clientId: string;
78
+ userId: string;
79
+ datetime: Date;
80
+ }
@@ -0,0 +1,17 @@
1
+ export const DASHBOARD_VISIBILITY_PRIVATE = 'private';
2
+ export const DASHBOARD_VISIBILITY_PUBLIC = 'public';
3
+ export const DASHBOARD_VISIBILITY_GLOBAL = 'global';
4
+ export function initDashboard() {
5
+ return {
6
+ dashboardId: '',
7
+ dashboardTitle: '',
8
+ dashboardRoute: '',
9
+ visibility: DASHBOARD_VISIBILITY_PRIVATE,
10
+ readonly: false,
11
+ filters: [],
12
+ parameters: [],
13
+ folder: '',
14
+ clientId: '',
15
+ userId: ''
16
+ };
17
+ }
@@ -0,0 +1,27 @@
1
+ import { KeyValuePair } from "../util.js";
2
+ import { DataContext } from "./client.js";
3
+ export interface SqlCacheContext {
4
+ contextName: DataContext;
5
+ variables: KeyValuePair[];
6
+ tables: {
7
+ table_name: string;
8
+ table_description: string;
9
+ }[];
10
+ columns: {
11
+ table_name: string;
12
+ column_id: number;
13
+ column_name: string;
14
+ data_type: string;
15
+ column_description: string;
16
+ column_comment: string;
17
+ }[];
18
+ functions: {
19
+ name: string;
20
+ type: string;
21
+ args: string[];
22
+ description: string;
23
+ }[];
24
+ tableMappings: KeyValuePair[];
25
+ columnMappings: KeyValuePair[];
26
+ }
27
+ export declare function initSqlCacheContext(): SqlCacheContext;
@@ -0,0 +1,12 @@
1
+ import { CHATWMS_CONTEXT_NAME } from "./client.js";
2
+ export function initSqlCacheContext() {
3
+ return {
4
+ contextName: CHATWMS_CONTEXT_NAME,
5
+ variables: [],
6
+ tables: [],
7
+ columns: [],
8
+ functions: [],
9
+ tableMappings: [],
10
+ columnMappings: []
11
+ };
12
+ }
@@ -0,0 +1,66 @@
1
+ import { DataContext } from "./client.js";
2
+ import { DatagridStateBase } from "./datagrid.js";
3
+ export declare const REPORT_VISIBILITY_PRIVATE = "private";
4
+ export declare const REPORT_VISIBILITY_PUBLIC = "public";
5
+ export declare const REPORT_VISIBILITY_GLOBAL = "global";
6
+ export interface ReportParameter {
7
+ sequence: number;
8
+ name: string;
9
+ /** `text` | `number` | `date` | `boolean` */
10
+ type: string;
11
+ }
12
+ export interface Report {
13
+ reportId: string;
14
+ reportTitle: string;
15
+ reportRoute: string;
16
+ visibility: string;
17
+ readonly: boolean;
18
+ parameters: ReportParameter[];
19
+ folder: string;
20
+ brief: string;
21
+ clientId: string;
22
+ userId: string;
23
+ }
24
+ export declare function initReport(): Report;
25
+ export interface LineReportParameter {
26
+ sequence: number;
27
+ parameterName: string;
28
+ columnName: string;
29
+ }
30
+ export interface ReportLineContentInfo extends DatagridStateBase {
31
+ visualizationOption: string;
32
+ reportParameters: LineReportParameter[];
33
+ contextName: DataContext;
34
+ specification: string;
35
+ query: string;
36
+ summary: string;
37
+ reviewOk?: boolean;
38
+ reviewConfidence?: string;
39
+ reviewFeedback?: string;
40
+ tableGroups?: string[];
41
+ developer?: boolean;
42
+ archive?: boolean;
43
+ }
44
+ export interface ReportLine {
45
+ lineId: string;
46
+ lineTitle: string;
47
+ reportId: string;
48
+ contentInfo: ReportLineContentInfo;
49
+ sequence: number;
50
+ clientId: string;
51
+ userId: string;
52
+ }
53
+ export interface ReportLineResult {
54
+ rows: any[];
55
+ rowsStr: string;
56
+ chartRows: any[];
57
+ }
58
+ export declare function initReportLineResult(): ReportLineResult;
59
+ export interface ReportUsage {
60
+ reportId: string;
61
+ reportTitle: string;
62
+ visibility: string;
63
+ clientId: string;
64
+ userId: string;
65
+ datetime: Date;
66
+ }
@@ -0,0 +1,24 @@
1
+ export const REPORT_VISIBILITY_PRIVATE = 'private';
2
+ export const REPORT_VISIBILITY_PUBLIC = 'public';
3
+ export const REPORT_VISIBILITY_GLOBAL = 'global';
4
+ export function initReport() {
5
+ return {
6
+ reportId: '',
7
+ reportTitle: '',
8
+ reportRoute: '',
9
+ visibility: REPORT_VISIBILITY_PRIVATE,
10
+ readonly: false,
11
+ parameters: [],
12
+ folder: '',
13
+ brief: '',
14
+ clientId: '',
15
+ userId: ''
16
+ };
17
+ }
18
+ export function initReportLineResult() {
19
+ return {
20
+ rows: [],
21
+ rowsStr: '',
22
+ chartRows: []
23
+ };
24
+ }
@@ -0,0 +1,12 @@
1
+ export declare enum SearchRecordType {
2
+ DASHBOARD = "dashboard",
3
+ DASHBOARD_WIDGET = "dashboard_widget",
4
+ DASHBOARD_FOLDER = "dashboard_folder",
5
+ REPORT = "report",
6
+ REPORT_LINE = "report_line",
7
+ REPORT_FOLDER = "report_folder"
8
+ }
9
+ export interface SearchRecord {
10
+ type: SearchRecordType;
11
+ data: any;
12
+ }
@@ -0,0 +1,9 @@
1
+ export var SearchRecordType;
2
+ (function (SearchRecordType) {
3
+ SearchRecordType["DASHBOARD"] = "dashboard";
4
+ SearchRecordType["DASHBOARD_WIDGET"] = "dashboard_widget";
5
+ SearchRecordType["DASHBOARD_FOLDER"] = "dashboard_folder";
6
+ SearchRecordType["REPORT"] = "report";
7
+ SearchRecordType["REPORT_LINE"] = "report_line";
8
+ SearchRecordType["REPORT_FOLDER"] = "report_folder";
9
+ })(SearchRecordType || (SearchRecordType = {}));
package/dist/util.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export interface KeyValuePair {
2
+ key: string;
3
+ value: any;
4
+ }
1
5
  export declare function sleep(ms: number): Promise<any>;
2
6
  export declare function reverse(str: string): string;
3
7
  export declare function base64Encode(str: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "7.3.0",
3
+ "version": "8.0.0",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",