@cellaware/utils 8.0.1 → 8.0.3

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.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/dist/azure/cosmos.d.ts +0 -98
  3. package/dist/azure/cosmos.js +0 -276
  4. package/dist/azure/email.d.ts +0 -3
  5. package/dist/azure/email.js +0 -20
  6. package/dist/azure/function.d.ts +0 -14
  7. package/dist/azure/function.js +0 -124
  8. package/dist/azure/slot.d.ts +0 -1
  9. package/dist/azure/slot.js +0 -4
  10. package/dist/azure/storage.d.ts +0 -4
  11. package/dist/azure/storage.js +0 -67
  12. package/dist/chatwms/alert.d.ts +0 -86
  13. package/dist/chatwms/alert.js +0 -62
  14. package/dist/chatwms/azure/cosmos.d.ts +0 -21
  15. package/dist/chatwms/azure/cosmos.js +0 -34
  16. package/dist/chatwms/azure/function.d.ts +0 -21
  17. package/dist/chatwms/azure/function.js +0 -29
  18. package/dist/chatwms/azure/storage.d.ts +0 -5
  19. package/dist/chatwms/azure/storage.js +0 -17
  20. package/dist/chatwms/client.d.ts +0 -18
  21. package/dist/chatwms/client.js +0 -48
  22. package/dist/chatwms/dashboard.d.ts +0 -80
  23. package/dist/chatwms/dashboard.js +0 -17
  24. package/dist/chatwms/datagrid.d.ts +0 -120
  25. package/dist/chatwms/datagrid.js +0 -781
  26. package/dist/chatwms/developer.d.ts +0 -27
  27. package/dist/chatwms/developer.js +0 -12
  28. package/dist/chatwms/github/issue.d.ts +0 -1
  29. package/dist/chatwms/github/issue.js +0 -4
  30. package/dist/chatwms/instance.d.ts +0 -16
  31. package/dist/chatwms/instance.js +0 -18
  32. package/dist/chatwms/report.d.ts +0 -66
  33. package/dist/chatwms/report.js +0 -24
  34. package/dist/chatwms/response.d.ts +0 -12
  35. package/dist/chatwms/response.js +0 -13
  36. package/dist/chatwms/search.d.ts +0 -12
  37. package/dist/chatwms/search.js +0 -9
  38. package/dist/chatwms/user.d.ts +0 -27
  39. package/dist/chatwms/user.js +0 -40
  40. package/dist/github/issue.d.ts +0 -1
  41. package/dist/github/issue.js +0 -23
  42. package/dist/llm/chain-store.d.ts +0 -49
  43. package/dist/llm/chain-store.js +0 -284
  44. package/dist/llm/cost.d.ts +0 -3
  45. package/dist/llm/cost.js +0 -78
  46. package/dist/llm/model.d.ts +0 -12
  47. package/dist/llm/model.js +0 -1
  48. package/dist/stopwatch.d.ts +0 -8
  49. package/dist/stopwatch.js +0 -36
  50. package/dist/util.d.ts +0 -36
  51. package/dist/util.js +0 -257
  52. package/dist/version.d.ts +0 -4
  53. package/dist/version.js +0 -12
package/dist/llm/cost.js DELETED
@@ -1,78 +0,0 @@
1
- // https://platform.openai.com/docs/pricing
2
- export function getLLMCostPerToken(modelName) {
3
- let inputCost = 0.0;
4
- let outputCost = 0.0;
5
- switch (modelName) {
6
- case 'gpt-5.1':
7
- inputCost = 1.25;
8
- outputCost = 10.00;
9
- break;
10
- case 'gpt-5':
11
- inputCost = 1.25;
12
- outputCost = 10.00;
13
- break;
14
- case 'gpt-5-mini':
15
- inputCost = 0.25;
16
- outputCost = 2.00;
17
- break;
18
- case 'gpt-5-nano':
19
- inputCost = 0.05;
20
- outputCost = 0.40;
21
- break;
22
- case 'gpt-4.1':
23
- inputCost = 2.00;
24
- outputCost = 8.00;
25
- break;
26
- case 'gpt-4.1-mini':
27
- inputCost = 0.40;
28
- outputCost = 1.60;
29
- break;
30
- case 'gpt-4.1-nano':
31
- inputCost = 0.10;
32
- outputCost = 0.40;
33
- break;
34
- case 'gpt-4o':
35
- inputCost = 2.50;
36
- outputCost = 10.00;
37
- break;
38
- case 'gpt-4o-mini':
39
- inputCost = 0.15;
40
- outputCost = 0.60;
41
- break;
42
- case 'o1':
43
- inputCost = 15.00;
44
- outputCost = 60.00;
45
- break;
46
- case 'o1-mini':
47
- inputCost = 1.10;
48
- outputCost = 4.40;
49
- break;
50
- case 'o3':
51
- inputCost = 10.00;
52
- outputCost = 40.00;
53
- break;
54
- case 'o3-mini':
55
- inputCost = 1.10;
56
- outputCost = 4.40;
57
- break;
58
- case 'o4-mini':
59
- inputCost = 1.10;
60
- outputCost = 4.40;
61
- break;
62
- default:
63
- throw new Error(`Model '${modelName}' cost is not configured`);
64
- }
65
- // OpenAI model costs are measured in millions of tokens -- therefore we need to divide each figure by 1,000,000 before returning.
66
- const unit = 1_000_000.0;
67
- inputCost /= unit;
68
- outputCost /= unit;
69
- return { inputCost, outputCost };
70
- }
71
- export function getLLMTransactionCost(tokenUsage, modelName) {
72
- let cost = 0.0;
73
- if (!!tokenUsage) {
74
- const { inputCost, outputCost } = getLLMCostPerToken(modelName);
75
- cost = (tokenUsage.promptTokens * inputCost) + (tokenUsage.completionTokens * outputCost);
76
- }
77
- return cost;
78
- }
@@ -1,12 +0,0 @@
1
- export type ModelName = '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
- export type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
3
- export type Verbosity = 'low' | 'medium' | 'high';
4
- export interface OpenAIModelOptions {
5
- reasoning_effort?: ReasoningEffort;
6
- verbosity?: Verbosity;
7
- }
8
- export interface ModelOptions {
9
- modelName: string;
10
- temperature?: number;
11
- openai?: OpenAIModelOptions;
12
- }
package/dist/llm/model.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- export declare class Stopwatch {
2
- private startTime?;
3
- private elapsed;
4
- start(): void;
5
- stop(): void;
6
- reset(): void;
7
- getElapsedMs(): number;
8
- }
package/dist/stopwatch.js DELETED
@@ -1,36 +0,0 @@
1
- export class Stopwatch {
2
- constructor() {
3
- Object.defineProperty(this, "startTime", {
4
- enumerable: true,
5
- configurable: true,
6
- writable: true,
7
- value: void 0
8
- });
9
- Object.defineProperty(this, "elapsed", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: 0n
14
- });
15
- }
16
- start() {
17
- if (!this.startTime) {
18
- this.startTime = process.hrtime.bigint();
19
- }
20
- }
21
- stop() {
22
- if (!!this.startTime) {
23
- this.elapsed += process.hrtime.bigint() - this.startTime;
24
- this.startTime = undefined;
25
- }
26
- }
27
- reset() {
28
- this.elapsed = 0n;
29
- this.startTime = undefined;
30
- }
31
- getElapsedMs() {
32
- const now = this.startTime ? process.hrtime.bigint() : 0n;
33
- const total = this.elapsed + (this.startTime ? now - this.startTime : 0n);
34
- return Number(total) / 1e6;
35
- }
36
- }
package/dist/util.d.ts DELETED
@@ -1,36 +0,0 @@
1
- export interface KeyValuePair {
2
- key: string;
3
- value: any;
4
- }
5
- export declare function sleep(ms: number): Promise<any>;
6
- export declare function reverse(str: string): string;
7
- export declare function base64Encode(str: string): string;
8
- export declare function base64Decode(str: string): string;
9
- export declare function initDate(timeZone?: string): Date;
10
- export declare function convertDateTimeZone(date: Date, timeZone: string): Date;
11
- export declare function isDaylightSavingTime(timeZone?: string): boolean;
12
- export declare function isLeapYear(timeZone?: string): boolean;
13
- export declare function getDaysInMonth(timeZone?: string): number;
14
- export declare function getCurrentDayInMonth(timeZone?: string): number;
15
- export declare function getDaysInYear(timeZone?: string): 366 | 365;
16
- export declare function getCurrentMonth(timeZone?: string): number;
17
- export declare function getCurrentYear(timeZone?: string): number;
18
- export declare function isDateString(value: any): boolean;
19
- /**
20
- * NOTE: `stopIdx` represents last character index of word
21
- * ex: ABC -> `startIdx`: 0 `stopIdx`: 2
22
- */
23
- export interface QueryRegexMatch {
24
- word: string;
25
- startIdx: number;
26
- stopIdx: number;
27
- }
28
- /**
29
- * Will only return matches that **are not** contained in single quotes,
30
- * double quotes, single line, or multiline comments.
31
- */
32
- export declare function getQueryMatches(query: string, regex: RegExp): QueryRegexMatch[];
33
- export declare function removeQueryMatches(query: string, matches: QueryRegexMatch[]): string;
34
- export declare function replaceQueryMatches(query: string, matches: QueryRegexMatch[], replacement: string): string;
35
- export declare function removeMarkdownIndicators(input: string): string;
36
- export declare function removePrefixIndicators(input: string, prefixes: string[]): string;
package/dist/util.js DELETED
@@ -1,257 +0,0 @@
1
- // Miscellaneous --------------------------------------------------------------------------
2
- export async function sleep(ms) {
3
- return new Promise(resolve => setTimeout(resolve, ms));
4
- }
5
- export function reverse(str) {
6
- return str.split('').reverse().join('');
7
- }
8
- export function base64Encode(str) {
9
- return Buffer.from(str, 'utf-8').toString('base64');
10
- }
11
- export function base64Decode(str) {
12
- return Buffer.from(str, 'base64').toString('utf-8');
13
- }
14
- // Dates --------------------------------------------------------------------------
15
- export function initDate(timeZone) {
16
- const date = new Date();
17
- if (!!timeZone) {
18
- return new Date(date.toLocaleString('en-US', { timeZone }));
19
- }
20
- else {
21
- return date;
22
- }
23
- }
24
- export function convertDateTimeZone(date, timeZone) {
25
- if (!!timeZone) {
26
- return new Date(date.toLocaleString('en-US', { timeZone }));
27
- }
28
- else {
29
- return date;
30
- }
31
- }
32
- export function isDaylightSavingTime(timeZone) {
33
- const date = initDate(timeZone);
34
- const jan = new Date(date.getFullYear(), 0, 1);
35
- const jul = new Date(date.getFullYear(), 6, 1);
36
- return date.getTimezoneOffset() < Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
37
- }
38
- export function isLeapYear(timeZone) {
39
- let year = initDate(timeZone).getFullYear();
40
- return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
41
- }
42
- export function getDaysInMonth(timeZone) {
43
- let date = initDate(timeZone);
44
- // NOTE: month is 0-based.
45
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
46
- }
47
- export function getCurrentDayInMonth(timeZone) {
48
- let date = initDate(timeZone);
49
- return date.getDate();
50
- }
51
- export function getDaysInYear(timeZone) {
52
- return isLeapYear(timeZone) ? 366 : 365;
53
- }
54
- export function getCurrentMonth(timeZone) {
55
- let date = initDate(timeZone);
56
- // NOTE: month is 0-based.
57
- return date.getMonth() + 1;
58
- }
59
- export function getCurrentYear(timeZone) {
60
- let date = initDate(timeZone);
61
- return date.getFullYear();
62
- }
63
- export function isDateString(value) {
64
- if (typeof value !== 'string')
65
- return false;
66
- const str = value.trim();
67
- /* To be considered a date string, the string:
68
- - Must contain at least one digit
69
- - Must include a common date separator (e.g. '-', '/', ':', '.', or 'T')
70
- - Must not contain any letters other than 'T' or 'Z'
71
- - Must successfully parse
72
-
73
- NOTE: We are not worried about month/day names or AM/PM. If these exist,
74
- the user has clearly elected to format the date in the query itself. */
75
- if (/[^TZ0-9\s:./-]/i.test(str))
76
- return false;
77
- /* Handle some edge cases:
78
- - If 2 separators, should be at least 6 total characters
79
- - Every part separated by '-' or '/' must be 1, 2, or >=4 chars long */
80
- if (str.includes('-')) {
81
- const dashes = str.split('-');
82
- if (dashes.length > 1 && str.length < 6) {
83
- return false;
84
- }
85
- }
86
- else if (str.includes('/')) {
87
- const slashes = str.split('/');
88
- if (slashes.length > 1 && str.length < 6) {
89
- return false;
90
- }
91
- }
92
- const sections = str.split(/[-/]+/).filter(Boolean);
93
- if (sections.some(s => !(s.length === 1 || s.length === 2 || s.length >= 4))) {
94
- return false;
95
- }
96
- return !isNaN(Date.parse(str));
97
- }
98
- /**
99
- * Will only return matches that **are not** contained in single quotes,
100
- * double quotes, single line, or multiline comments.
101
- */
102
- export function getQueryMatches(query, regex) {
103
- let matches = [];
104
- // Find quote ranges first.
105
- let singleQuoteRanges = [];
106
- {
107
- let open = false;
108
- let startIdx = -1;
109
- for (let i = 0; i < query.length; i++) {
110
- if (query[i] === "'") {
111
- if (open) {
112
- singleQuoteRanges.push({ startIdx, stopIdx: i });
113
- }
114
- else {
115
- startIdx = i;
116
- }
117
- open = !open;
118
- }
119
- }
120
- }
121
- let doubleQuoteRanges = [];
122
- {
123
- let open = false;
124
- let startIdx = -1;
125
- for (let i = 0; i < query.length; i++) {
126
- if (query[i] === '"') {
127
- if (open) {
128
- doubleQuoteRanges.push({ startIdx, stopIdx: i });
129
- }
130
- else {
131
- startIdx = i;
132
- }
133
- open = !open;
134
- }
135
- }
136
- }
137
- let singleLineCommentRanges = [];
138
- {
139
- let open = false;
140
- let startIdx = -1;
141
- for (let i = 0; i < query.length; i++) {
142
- if (!open && query[i] === '-' && (i < query.length - 1 && query[i + 1] === '-')) {
143
- open = true;
144
- startIdx = i;
145
- }
146
- else if (open && (query[i] === '\n' || query[i] === '\r')) {
147
- open = false;
148
- singleLineCommentRanges.push({ startIdx, stopIdx: i });
149
- }
150
- }
151
- }
152
- let multilineCommentRanges = [];
153
- {
154
- let open = false;
155
- let startIdx = -1;
156
- for (let i = 0; i < query.length; i++) {
157
- if (!open && query[i] === '/' && (i < query.length - 1 && query[i + 1] === '*')) {
158
- open = true;
159
- startIdx = i;
160
- }
161
- else if (open && query[i] === '/' && (i > 0 && query[i - 1] === '*')) {
162
- open = false;
163
- multilineCommentRanges.push({ startIdx, stopIdx: i });
164
- }
165
- }
166
- }
167
- // Now find matches and filter out the ones that are contained in quotes.
168
- {
169
- let match;
170
- while ((match = regex.exec(query)) != null) {
171
- let startIdx = match.index;
172
- let stopIdx = match.index + match[0].length - 1;
173
- let contained = false;
174
- for (const quoteRange of singleQuoteRanges) {
175
- if (quoteRange.startIdx <= startIdx && quoteRange.stopIdx >= stopIdx) {
176
- contained = true;
177
- break;
178
- }
179
- }
180
- if (!contained) {
181
- for (const quoteRange of doubleQuoteRanges) {
182
- if (quoteRange.startIdx <= startIdx && quoteRange.stopIdx >= stopIdx) {
183
- contained = true;
184
- break;
185
- }
186
- }
187
- }
188
- if (!contained) {
189
- for (const singleLineCommentRange of singleLineCommentRanges) {
190
- if (singleLineCommentRange.startIdx <= startIdx && singleLineCommentRange.stopIdx >= stopIdx) {
191
- contained = true;
192
- break;
193
- }
194
- }
195
- }
196
- if (!contained) {
197
- for (const multilineCommentRange of multilineCommentRanges) {
198
- if (multilineCommentRange.startIdx <= startIdx && multilineCommentRange.stopIdx >= stopIdx) {
199
- contained = true;
200
- break;
201
- }
202
- }
203
- }
204
- if (!contained) {
205
- matches.push({ word: match[0], startIdx, stopIdx });
206
- }
207
- }
208
- }
209
- return matches;
210
- }
211
- export function removeQueryMatches(query, matches) {
212
- let adjQuery = query;
213
- let offset = 0;
214
- for (const match of matches) {
215
- const start = match.startIdx - offset;
216
- const stop = match.stopIdx + 1 - offset;
217
- adjQuery = adjQuery.substring(0, start) + adjQuery.substring(stop);
218
- offset += match.word.length;
219
- }
220
- return adjQuery;
221
- }
222
- export function replaceQueryMatches(query, matches, replacement) {
223
- let adjQuery = query;
224
- let offset = 0;
225
- for (const match of matches) {
226
- const start = match.startIdx - offset;
227
- const stop = match.stopIdx + 1 - offset;
228
- adjQuery =
229
- adjQuery.substring(0, start) +
230
- replacement +
231
- adjQuery.substring(stop);
232
- offset += (match.word.length - replacement.length);
233
- }
234
- return adjQuery;
235
- }
236
- // LLMs --------------------------------------------------------------------------
237
- export function removeMarkdownIndicators(input) {
238
- let output = input;
239
- // Make sure markdown indicator exists.
240
- if (output.includes('```')) {
241
- // Remove first markdown indicator.
242
- output = output.substring(output.indexOf('```'));
243
- output = output.substring(output.indexOf('\n'));
244
- // First markdown indicator removed, now do the last.
245
- output = output.substring(0, output.indexOf('```')).trim();
246
- }
247
- return output;
248
- }
249
- export function removePrefixIndicators(input, prefixes) {
250
- let output = input;
251
- for (const prefix of prefixes) {
252
- if (output.includes(prefix)) {
253
- output = output.substring(output.indexOf(prefix) + prefix.length);
254
- }
255
- }
256
- return output;
257
- }
package/dist/version.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Extracts `version` from `package.json`.
3
- */
4
- export declare function getVersion(): string;
package/dist/version.js DELETED
@@ -1,12 +0,0 @@
1
- import fs from 'fs';
2
- /**
3
- * Extracts `version` from `package.json`.
4
- */
5
- export function getVersion() {
6
- const path = 'package.json';
7
- if (!fs.existsSync(path)) {
8
- throw new Error(`VERSION: '${path}' not found`);
9
- }
10
- const content = JSON.parse(fs.readFileSync(path, 'utf8'));
11
- return content.version ?? '';
12
- }