@cellaware/utils 8.11.19 → 8.11.20
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/azure/cosmos.d.ts +112 -0
- package/dist/azure/cosmos.js +305 -0
- package/dist/azure/email.d.ts +3 -0
- package/dist/azure/email.js +20 -0
- package/dist/azure/function.d.ts +14 -0
- package/dist/azure/function.js +124 -0
- package/dist/azure/slot.d.ts +1 -0
- package/dist/azure/slot.js +4 -0
- package/dist/azure/storage.d.ts +14 -0
- package/dist/azure/storage.js +81 -0
- package/dist/chatwms/alert.d.ts +97 -0
- package/dist/chatwms/alert.js +74 -0
- package/dist/chatwms/azure/cosmos.d.ts +25 -0
- package/dist/chatwms/azure/cosmos.js +43 -0
- package/dist/chatwms/azure/function.d.ts +21 -0
- package/dist/chatwms/azure/function.js +29 -0
- package/dist/chatwms/azure/storage.d.ts +15 -0
- package/dist/chatwms/azure/storage.js +27 -0
- package/dist/chatwms/client.d.ts +18 -0
- package/dist/chatwms/client.js +48 -0
- package/dist/chatwms/cosmos.d.ts +24 -0
- package/dist/chatwms/cosmos.js +532 -0
- package/dist/chatwms/dashboard.d.ts +80 -0
- package/dist/chatwms/dashboard.js +17 -0
- package/dist/chatwms/datagrid.d.ts +215 -0
- package/dist/chatwms/datagrid.js +1454 -0
- package/dist/chatwms/developer.d.ts +27 -0
- package/dist/chatwms/developer.js +12 -0
- package/dist/chatwms/github/issue.d.ts +1 -0
- package/dist/chatwms/github/issue.js +4 -0
- package/dist/chatwms/instance.d.ts +16 -0
- package/dist/chatwms/instance.js +18 -0
- package/dist/chatwms/integration.d.ts +24 -0
- package/dist/chatwms/integration.js +19 -0
- package/dist/chatwms/pdf.d.ts +95 -0
- package/dist/chatwms/pdf.js +147 -0
- package/dist/chatwms/report.d.ts +126 -0
- package/dist/chatwms/report.js +55 -0
- package/dist/chatwms/response.d.ts +18 -0
- package/dist/chatwms/response.js +25 -0
- package/dist/chatwms/search.d.ts +12 -0
- package/dist/chatwms/search.js +9 -0
- package/dist/chatwms/teams.d.ts +237 -0
- package/dist/chatwms/teams.js +205 -0
- package/dist/chatwms/user.d.ts +31 -0
- package/dist/chatwms/user.js +42 -0
- package/dist/chatwms/warehouse.d.ts +3 -0
- package/dist/chatwms/warehouse.js +3 -0
- package/dist/github/issue.d.ts +1 -0
- package/dist/github/issue.js +23 -0
- package/dist/llm/chain-store.d.ts +49 -0
- package/dist/llm/chain-store.js +284 -0
- package/dist/llm/cost.d.ts +3 -0
- package/dist/llm/cost.js +42 -0
- package/dist/llm/model.d.ts +12 -0
- package/dist/llm/model.js +1 -0
- package/dist/stopwatch.d.ts +8 -0
- package/dist/stopwatch.js +36 -0
- package/dist/util.d.ts +45 -0
- package/dist/util.js +288 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DataContext } from "./client.js";
|
|
2
|
+
import { DatagridCondition, DatagridStateBase } from "./datagrid.js";
|
|
3
|
+
import { SubscriptionIntegration } from "./integration.js";
|
|
4
|
+
export declare const ALERT_VISIBILITY_PRIVATE = "private";
|
|
5
|
+
export declare const ALERT_VISIBILITY_PUBLIC = "public";
|
|
6
|
+
/**
|
|
7
|
+
* Alert Strategy
|
|
8
|
+
*
|
|
9
|
+
* The strategy influences alert sending behavior when the previous alert execution
|
|
10
|
+
* resulted in the condition being met/alert being sent. Traditionally, alert systems
|
|
11
|
+
* will just send notifications over and over while the condition is met. This may be
|
|
12
|
+
* good sometimes, but could be very annoying otherwise. The strategy allows users to
|
|
13
|
+
* configure this behavior.
|
|
14
|
+
*
|
|
15
|
+
* - temporary: will send once when the condition is met and will automatically be deleted
|
|
16
|
+
* - once: will send once when the condition is met and will not send again until the condition
|
|
17
|
+
* is no longer met
|
|
18
|
+
* - change: if the condition is met, will send if there was a meaningful change in the data
|
|
19
|
+
* since last execution
|
|
20
|
+
* - always: sends every time as long as the condition is met
|
|
21
|
+
*/
|
|
22
|
+
export declare const ALERT_STRATEGY_TEMPORARY = "temporary";
|
|
23
|
+
export declare const ALERT_STRATEGY_ONCE = "once";
|
|
24
|
+
export declare const ALERT_STRATEGY_CHANGE = "change";
|
|
25
|
+
export declare const ALERT_STRATEGY_ALWAYS = "always";
|
|
26
|
+
export interface Alert {
|
|
27
|
+
alertId: string;
|
|
28
|
+
alertTitle: string;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
visibility: string;
|
|
31
|
+
readonly: boolean;
|
|
32
|
+
folder: string;
|
|
33
|
+
strategy: string;
|
|
34
|
+
contentInfo: AlertContentInfo;
|
|
35
|
+
conditionInfo: DatagridCondition;
|
|
36
|
+
clientId: string;
|
|
37
|
+
userId: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function initAlert(): Alert;
|
|
40
|
+
export interface AlertWithSubscription extends Alert {
|
|
41
|
+
subscription: AlertSubscription;
|
|
42
|
+
lastMet: string;
|
|
43
|
+
lastSent: string;
|
|
44
|
+
}
|
|
45
|
+
export interface InstanceAlert extends Alert {
|
|
46
|
+
subscription: InstanceAlertSubscription;
|
|
47
|
+
}
|
|
48
|
+
export interface AlertContentInfo extends DatagridStateBase {
|
|
49
|
+
contextName: DataContext;
|
|
50
|
+
specification: string;
|
|
51
|
+
query: string;
|
|
52
|
+
summary: string;
|
|
53
|
+
reviewOk?: boolean;
|
|
54
|
+
reviewConfidence?: string;
|
|
55
|
+
reviewFeedback?: string;
|
|
56
|
+
tableGroups?: string[];
|
|
57
|
+
developer?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface AlertTestResult {
|
|
60
|
+
met: boolean;
|
|
61
|
+
rows: any[];
|
|
62
|
+
hashedRows: string[];
|
|
63
|
+
}
|
|
64
|
+
export declare function initAlertTestResult(): AlertTestResult;
|
|
65
|
+
export interface AlertExecution {
|
|
66
|
+
alertId: string;
|
|
67
|
+
alertTitle: string;
|
|
68
|
+
strategy: string;
|
|
69
|
+
conditionInfo: DatagridCondition;
|
|
70
|
+
met: boolean;
|
|
71
|
+
hashedRows: string[];
|
|
72
|
+
error: string;
|
|
73
|
+
sent: boolean;
|
|
74
|
+
clientId: string;
|
|
75
|
+
customer: string;
|
|
76
|
+
warehouse: string;
|
|
77
|
+
userId: string;
|
|
78
|
+
datetime: Date;
|
|
79
|
+
}
|
|
80
|
+
export interface AlertSubscription {
|
|
81
|
+
alertId: string;
|
|
82
|
+
popup?: boolean;
|
|
83
|
+
email?: boolean;
|
|
84
|
+
additionalEmails?: string[];
|
|
85
|
+
integrations?: string[];
|
|
86
|
+
clientId: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
userDetails: string;
|
|
89
|
+
}
|
|
90
|
+
export declare function initAlertSubscription(): AlertSubscription;
|
|
91
|
+
export interface InstanceAlertSubscription {
|
|
92
|
+
alertId: string;
|
|
93
|
+
popups: Set<string>;
|
|
94
|
+
emails: Set<string>;
|
|
95
|
+
integrations: Set<SubscriptionIntegration>;
|
|
96
|
+
}
|
|
97
|
+
export declare function initInstanceAlertSubscription(): InstanceAlertSubscription;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
* - temporary: will send once when the condition is met and will automatically be deleted
|
|
15
|
+
* - once: will send once when the condition is met and will not send again until the condition
|
|
16
|
+
* is no longer met
|
|
17
|
+
* - change: if the condition is met, will send if there was a meaningful change in the data
|
|
18
|
+
* since last execution
|
|
19
|
+
* - always: sends every time as long as the condition is met
|
|
20
|
+
*/
|
|
21
|
+
export const ALERT_STRATEGY_TEMPORARY = 'temporary';
|
|
22
|
+
export const ALERT_STRATEGY_ONCE = 'once';
|
|
23
|
+
export const ALERT_STRATEGY_CHANGE = 'change';
|
|
24
|
+
export const ALERT_STRATEGY_ALWAYS = 'always';
|
|
25
|
+
export function initAlert() {
|
|
26
|
+
return {
|
|
27
|
+
alertId: '',
|
|
28
|
+
alertTitle: '',
|
|
29
|
+
enabled: false,
|
|
30
|
+
visibility: ALERT_VISIBILITY_PRIVATE,
|
|
31
|
+
readonly: false,
|
|
32
|
+
folder: '',
|
|
33
|
+
strategy: ALERT_STRATEGY_ONCE,
|
|
34
|
+
contentInfo: initAlertContentInfo(),
|
|
35
|
+
conditionInfo: initDatagridCondition(),
|
|
36
|
+
clientId: '',
|
|
37
|
+
userId: ''
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function initAlertContentInfo() {
|
|
41
|
+
return {
|
|
42
|
+
contextName: CHATWMS_CONTEXT_NAME,
|
|
43
|
+
specification: '',
|
|
44
|
+
query: '',
|
|
45
|
+
summary: ''
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function initAlertTestResult() {
|
|
49
|
+
return {
|
|
50
|
+
met: false,
|
|
51
|
+
rows: [],
|
|
52
|
+
hashedRows: []
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function initAlertSubscription() {
|
|
56
|
+
return {
|
|
57
|
+
alertId: '',
|
|
58
|
+
popup: false,
|
|
59
|
+
email: false,
|
|
60
|
+
additionalEmails: [],
|
|
61
|
+
integrations: [],
|
|
62
|
+
clientId: '',
|
|
63
|
+
userId: '',
|
|
64
|
+
userDetails: ''
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function initInstanceAlertSubscription() {
|
|
68
|
+
return {
|
|
69
|
+
alertId: '',
|
|
70
|
+
popups: new Set(),
|
|
71
|
+
emails: new Set(),
|
|
72
|
+
integrations: new Set()
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const CHATWMS_DATABASE_ID = "chatwms";
|
|
2
|
+
export declare const CLIENT_PARTITION_KEY = "/clientId";
|
|
3
|
+
export declare const PRODUCT_PARTITION_KEY = "/productId";
|
|
4
|
+
export declare const COSMOS_SYSTEM_FIELDS: string[];
|
|
5
|
+
export declare function stripCosmosSystemFields(obj: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* Default `partitionKey` is '/clientId'
|
|
8
|
+
*/
|
|
9
|
+
export declare function chatwmsCosmosSelect(collectionId: string, query: string, partitionKey?: string): Promise<any[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Default `partitionKey` is '/clientId'
|
|
12
|
+
*/
|
|
13
|
+
export declare function chatwmsCosmosInsert(collectionId: string, data: any, partitionKey?: string): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Default `partitionKey` is '/clientId'
|
|
16
|
+
*/
|
|
17
|
+
export declare function chatwmsCosmosDelete(collectionId: string, query: string, partitionKey?: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Default `partitionKey` is '/clientId'
|
|
20
|
+
*/
|
|
21
|
+
export declare function chatwmsCosmosUpdate(collectionId: string, query: string, data: any, partitionKey?: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Default `partitionKey` is '/clientId'
|
|
24
|
+
*/
|
|
25
|
+
export declare function chatwmsCosmosUpsert(collectionId: string, query: string, data: any, partitionKey?: string): Promise<boolean>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cosmosDelete, cosmosInsert, cosmosSelect, cosmosUpdate, cosmosUpsert } from "../../azure/cosmos.js";
|
|
2
|
+
const DATABASE_ID = 'chatwms';
|
|
3
|
+
const PARTITION_KEY = '/clientId';
|
|
4
|
+
export const CHATWMS_DATABASE_ID = DATABASE_ID;
|
|
5
|
+
export const CLIENT_PARTITION_KEY = PARTITION_KEY;
|
|
6
|
+
export const PRODUCT_PARTITION_KEY = '/productId';
|
|
7
|
+
export const COSMOS_SYSTEM_FIELDS = ['id', '_rid', '_self', '_etag', '_attachments', '_ts'];
|
|
8
|
+
export function stripCosmosSystemFields(obj) {
|
|
9
|
+
for (const field of COSMOS_SYSTEM_FIELDS) {
|
|
10
|
+
delete obj[field];
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Default `partitionKey` is '/clientId'
|
|
16
|
+
*/
|
|
17
|
+
export async function chatwmsCosmosSelect(collectionId, query, partitionKey) {
|
|
18
|
+
return cosmosSelect(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Default `partitionKey` is '/clientId'
|
|
22
|
+
*/
|
|
23
|
+
export async function chatwmsCosmosInsert(collectionId, data, partitionKey) {
|
|
24
|
+
return cosmosInsert(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, data);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Default `partitionKey` is '/clientId'
|
|
28
|
+
*/
|
|
29
|
+
export async function chatwmsCosmosDelete(collectionId, query, partitionKey) {
|
|
30
|
+
return cosmosDelete(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Default `partitionKey` is '/clientId'
|
|
34
|
+
*/
|
|
35
|
+
export async function chatwmsCosmosUpdate(collectionId, query, data, partitionKey) {
|
|
36
|
+
return cosmosUpdate(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query, data);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default `partitionKey` is '/clientId'
|
|
40
|
+
*/
|
|
41
|
+
export async function chatwmsCosmosUpsert(collectionId, query, data, partitionKey) {
|
|
42
|
+
return cosmosUpsert(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query, data);
|
|
43
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function chatwmsFunctionFetch(path: string, method: string, principal: string, body?: any): Promise<Response>;
|
|
2
|
+
export declare function chatwmsFunctionFetchText(path: string, method: string, principal: string, body?: any): Promise<Response>;
|
|
3
|
+
export declare function chatwmsFunctionStream(path: string, method: string, principal: string, body?: any): Promise<{
|
|
4
|
+
headers: {
|
|
5
|
+
"Content-Type": string;
|
|
6
|
+
"Cache-Control": string;
|
|
7
|
+
"Transfer-Encoding": string;
|
|
8
|
+
};
|
|
9
|
+
body: import("stream").Readable;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function chatwmsGatewayFunctionFetch(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
|
|
12
|
+
export declare function chatwmsGatewayFunctionFetchWithText(url: string, method: string, key: string, principal: string, text: string): Promise<Response>;
|
|
13
|
+
export declare function chatwmsGatewayFunctionFetchText(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
|
|
14
|
+
export declare function chatwmsGatewayFunctionStream(url: string, method: string, key: string, principal: string, body?: any): Promise<{
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": string;
|
|
17
|
+
"Cache-Control": string;
|
|
18
|
+
"Transfer-Encoding": string;
|
|
19
|
+
};
|
|
20
|
+
body: import("stream").Readable;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { functionFetchJson, functionFetchJsonWithText, functionFetchText, functionStreamJson } from "../../azure/function.js";
|
|
2
|
+
const STREAM_ERROR_BODY = {
|
|
3
|
+
answer: 'chatwms-unavailable-error',
|
|
4
|
+
error: 'chatwms-unavailable-error'
|
|
5
|
+
};
|
|
6
|
+
export function chatwmsFunctionFetch(path, method, principal, body) {
|
|
7
|
+
const url = `${process.env['CHATWMS_URL']}/${path}`;
|
|
8
|
+
return functionFetchJson(url, method, process.env['CHATWMS_KEY'] ?? '', principal, body);
|
|
9
|
+
}
|
|
10
|
+
export function chatwmsFunctionFetchText(path, method, principal, body) {
|
|
11
|
+
const url = `${process.env['CHATWMS_URL']}/${path}`;
|
|
12
|
+
return functionFetchText(url, method, process.env['CHATWMS_KEY'] ?? '', principal, body);
|
|
13
|
+
}
|
|
14
|
+
export function chatwmsFunctionStream(path, method, principal, body) {
|
|
15
|
+
const url = `${process.env['CHATWMS_URL']}/${path}`;
|
|
16
|
+
return functionStreamJson(url, method, process.env['CHATWMS_KEY'] ?? '', principal, body, STREAM_ERROR_BODY);
|
|
17
|
+
}
|
|
18
|
+
export function chatwmsGatewayFunctionFetch(url, method, key, principal, body) {
|
|
19
|
+
return functionFetchJson(url, method, key, principal, body);
|
|
20
|
+
}
|
|
21
|
+
export function chatwmsGatewayFunctionFetchWithText(url, method, key, principal, text) {
|
|
22
|
+
return functionFetchJsonWithText(url, method, key, principal, text);
|
|
23
|
+
}
|
|
24
|
+
export function chatwmsGatewayFunctionFetchText(url, method, key, principal, body) {
|
|
25
|
+
return functionFetchText(url, method, key, principal, body);
|
|
26
|
+
}
|
|
27
|
+
export function chatwmsGatewayFunctionStream(url, method, key, principal, body) {
|
|
28
|
+
return functionStreamJson(url, method, key, principal, body, STREAM_ERROR_BODY);
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function chatwmsStorageGetBlobId(clientId: string, blobName: string): string;
|
|
2
|
+
export declare function chatwmsStorageContainerCreate(): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Stringifies `data` and uploads to blob storage.
|
|
5
|
+
*
|
|
6
|
+
* **Important:** `data` must not be a string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function chatwmsStorageBlobUpload(blobId: string, data: any): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Parses string data downloaded from blob storage and returns JSON object/JSON array.
|
|
11
|
+
*
|
|
12
|
+
* **Important:** will return `undefined` if any issues or blob does not exist.
|
|
13
|
+
*/
|
|
14
|
+
export declare function chatwmsStorageBlobDownload(blobId: string): Promise<any>;
|
|
15
|
+
export declare function chatwmsStorageBlobDelete(blobId: string): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { storageBlobDelete, storageBlobDownload, storageBlobUpload, storageContainerCreate } from "../../azure/storage.js";
|
|
2
|
+
const CONTAINER_CLIENT_ID = 'chatwms';
|
|
3
|
+
export function chatwmsStorageGetBlobId(clientId, blobName) {
|
|
4
|
+
return clientId.replaceAll('_', '-') + '-' + blobName;
|
|
5
|
+
}
|
|
6
|
+
export async function chatwmsStorageContainerCreate() {
|
|
7
|
+
return storageContainerCreate(CONTAINER_CLIENT_ID);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Stringifies `data` and uploads to blob storage.
|
|
11
|
+
*
|
|
12
|
+
* **Important:** `data` must not be a string.
|
|
13
|
+
*/
|
|
14
|
+
export async function chatwmsStorageBlobUpload(blobId, data) {
|
|
15
|
+
return storageBlobUpload(CONTAINER_CLIENT_ID, blobId, data);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parses string data downloaded from blob storage and returns JSON object/JSON array.
|
|
19
|
+
*
|
|
20
|
+
* **Important:** will return `undefined` if any issues or blob does not exist.
|
|
21
|
+
*/
|
|
22
|
+
export async function chatwmsStorageBlobDownload(blobId) {
|
|
23
|
+
return storageBlobDownload(CONTAINER_CLIENT_ID, blobId);
|
|
24
|
+
}
|
|
25
|
+
export async function chatwmsStorageBlobDelete(blobId) {
|
|
26
|
+
return storageBlobDelete(CONTAINER_CLIENT_ID, blobId);
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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';
|
|
6
|
+
export declare function chatwmsGetClientId(customer: string, warehouse: string): string;
|
|
7
|
+
export declare function chatwmsGetWarehouseFromClientId(clientId: string, customer: string): string;
|
|
8
|
+
export declare function chatwmsGetWarehouse(warehouse: string, organization?: string): string;
|
|
9
|
+
export declare function chatwmsGetOrganizationFromWarehouse(warehouse: string): string | undefined;
|
|
10
|
+
export declare function chatwmsGetOrganizationFromClientId(clientId: string, customer: string): string | undefined;
|
|
11
|
+
export declare function chatwmsExtractWarehouseAndOrganizationFromWarehouse(warehouse: string): {
|
|
12
|
+
warehouse: string;
|
|
13
|
+
organization: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare function chatwmsExtractWarehouseAndOrganizationFromClientId(clientId: string, customer: string): {
|
|
16
|
+
warehouse: string;
|
|
17
|
+
organization: string | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
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';
|
|
5
|
+
export function chatwmsGetClientId(customer, warehouse) {
|
|
6
|
+
return `${customer}_${warehouse}`;
|
|
7
|
+
}
|
|
8
|
+
export function chatwmsGetWarehouseFromClientId(clientId, customer) {
|
|
9
|
+
const prefix = `${customer}_`;
|
|
10
|
+
return clientId.substring(clientId.indexOf(prefix) + prefix.length);
|
|
11
|
+
}
|
|
12
|
+
export function chatwmsGetWarehouse(warehouse, organization) {
|
|
13
|
+
return !!organization ? `${organization}_${warehouse}` : warehouse;
|
|
14
|
+
}
|
|
15
|
+
export function chatwmsGetOrganizationFromWarehouse(warehouse) {
|
|
16
|
+
const lastIdx = warehouse.lastIndexOf('_');
|
|
17
|
+
if (lastIdx === -1) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const organization = warehouse.substring(0, lastIdx);
|
|
21
|
+
// We could have multiple organization levels.
|
|
22
|
+
const startIdx = organization.lastIndexOf('_');
|
|
23
|
+
if (startIdx > -1) {
|
|
24
|
+
return organization.substring(startIdx + 1);
|
|
25
|
+
}
|
|
26
|
+
return organization;
|
|
27
|
+
}
|
|
28
|
+
export function chatwmsGetOrganizationFromClientId(clientId, customer) {
|
|
29
|
+
return chatwmsGetOrganizationFromWarehouse(chatwmsGetWarehouseFromClientId(clientId, customer));
|
|
30
|
+
}
|
|
31
|
+
export function chatwmsExtractWarehouseAndOrganizationFromWarehouse(warehouse) {
|
|
32
|
+
const organization = chatwmsGetOrganizationFromWarehouse(warehouse);
|
|
33
|
+
if (!!organization) {
|
|
34
|
+
return {
|
|
35
|
+
warehouse: warehouse.substring(warehouse.lastIndexOf('_') + 1),
|
|
36
|
+
organization
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return {
|
|
41
|
+
warehouse,
|
|
42
|
+
organization: undefined
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function chatwmsExtractWarehouseAndOrganizationFromClientId(clientId, customer) {
|
|
47
|
+
return chatwmsExtractWarehouseAndOrganizationFromWarehouse(chatwmsGetWarehouseFromClientId(clientId, customer));
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DatagridCondition } from "./datagrid.js";
|
|
2
|
+
import { SqlCacheContext } from "./developer.js";
|
|
3
|
+
export interface CosmosVariable {
|
|
4
|
+
key: string;
|
|
5
|
+
value: any;
|
|
6
|
+
}
|
|
7
|
+
export declare function createCosmosVariables(userId: string): CosmosVariable[];
|
|
8
|
+
export declare function loadCosmosDeveloperCache(userId: string): SqlCacheContext;
|
|
9
|
+
export interface CosmosQuery {
|
|
10
|
+
table: string;
|
|
11
|
+
query: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CosmosQueryContext {
|
|
14
|
+
customer?: string;
|
|
15
|
+
organization?: string;
|
|
16
|
+
warehouse?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extracts the first word after the `FROM` and replaces it with the necessary contents based on the context.
|
|
20
|
+
*
|
|
21
|
+
* Returns the adjusted query and the extracted lowercase table name.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createCosmosQuery(query: string, variables: CosmosVariable[], context?: CosmosQueryContext): CosmosQuery;
|
|
24
|
+
export declare function executeCosmosQuery(cosmosQuery: CosmosQuery, parameters: DatagridCondition[], rowLimit?: number): Promise<any[]>;
|