@lssm/lib.cost-tracking 0.0.0-canary-20251207012602 → 0.0.0-canary-20251207043720
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/package.json +7 -3
- package/dist/budget-alert-manager.d.ts +0 -22
- package/dist/cost-model.d.ts +0 -14
- package/dist/cost-tracker.d.ts +0 -21
- package/dist/index.d.ts +0 -6
- package/dist/optimization-recommender.d.ts +0 -8
- package/dist/types.d.ts +0 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.cost-tracking",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251207043720",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -31,10 +31,14 @@
|
|
|
31
31
|
"typescript": "^5.9.3"
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
34
|
-
".": "./
|
|
34
|
+
".": "./src/index.ts",
|
|
35
35
|
"./*": "./*"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
|
-
"access": "public"
|
|
38
|
+
"access": "public",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./dist/index.js",
|
|
41
|
+
"./*": "./*"
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { OperationCostSummary, TenantBudget } from "./types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/budget-alert-manager.d.ts
|
|
4
|
-
interface BudgetAlertManagerOptions {
|
|
5
|
-
budgets: TenantBudget[];
|
|
6
|
-
onAlert?: (payload: {
|
|
7
|
-
tenantId: string;
|
|
8
|
-
limit: number;
|
|
9
|
-
total: number;
|
|
10
|
-
summary: OperationCostSummary;
|
|
11
|
-
}) => void;
|
|
12
|
-
}
|
|
13
|
-
declare class BudgetAlertManager {
|
|
14
|
-
private readonly options;
|
|
15
|
-
private readonly limits;
|
|
16
|
-
private readonly spend;
|
|
17
|
-
constructor(options: BudgetAlertManagerOptions);
|
|
18
|
-
track(summary: OperationCostSummary): void;
|
|
19
|
-
getSpend(tenantId: string): number;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { BudgetAlertManager, BudgetAlertManagerOptions };
|
package/dist/cost-model.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CostModel, CostSample } from "./types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/cost-model.d.ts
|
|
4
|
-
declare const defaultCostModel: CostModel;
|
|
5
|
-
declare function calculateSampleCost(sample: CostSample, model: CostModel): {
|
|
6
|
-
dbReads: number;
|
|
7
|
-
dbWrites: number;
|
|
8
|
-
compute: number;
|
|
9
|
-
memory: number;
|
|
10
|
-
external: number;
|
|
11
|
-
custom: number;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { calculateSampleCost, defaultCostModel };
|
package/dist/cost-tracker.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CostModel, CostSample, OperationCostSummary } from "./types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/cost-tracker.d.ts
|
|
4
|
-
interface CostTrackerOptions {
|
|
5
|
-
costModel?: CostModel;
|
|
6
|
-
onSampleRecorded?: (sample: CostSample, total: number) => void;
|
|
7
|
-
}
|
|
8
|
-
declare class CostTracker {
|
|
9
|
-
private readonly options;
|
|
10
|
-
private readonly totals;
|
|
11
|
-
private readonly costModel;
|
|
12
|
-
constructor(options?: CostTrackerOptions);
|
|
13
|
-
recordSample(sample: CostSample): OperationCostSummary;
|
|
14
|
-
getTotals(filter?: {
|
|
15
|
-
tenantId?: string;
|
|
16
|
-
}): OperationCostSummary[];
|
|
17
|
-
reset(): void;
|
|
18
|
-
private buildKey;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { CostTracker, CostTrackerOptions };
|
package/dist/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BudgetAlert, CostModel, CostSample, ExternalCallCost, OperationCostSummary, OptimizationSuggestion, TenantBudget } from "./types.js";
|
|
2
|
-
import { calculateSampleCost, defaultCostModel } from "./cost-model.js";
|
|
3
|
-
import { CostTracker, CostTrackerOptions } from "./cost-tracker.js";
|
|
4
|
-
import { BudgetAlertManager, BudgetAlertManagerOptions } from "./budget-alert-manager.js";
|
|
5
|
-
import { OptimizationRecommender } from "./optimization-recommender.js";
|
|
6
|
-
export { BudgetAlert, BudgetAlertManager, BudgetAlertManagerOptions, CostModel, CostSample, CostTracker, CostTrackerOptions, ExternalCallCost, OperationCostSummary, OptimizationRecommender, OptimizationSuggestion, TenantBudget, calculateSampleCost, defaultCostModel };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperationCostSummary, OptimizationSuggestion } from "./types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/optimization-recommender.d.ts
|
|
4
|
-
declare class OptimizationRecommender {
|
|
5
|
-
generate(summary: OperationCostSummary): OptimizationSuggestion[];
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { OptimizationRecommender };
|
package/dist/types.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
interface ExternalCallCost {
|
|
3
|
-
provider: string;
|
|
4
|
-
cost?: number;
|
|
5
|
-
durationMs?: number;
|
|
6
|
-
requestCount?: number;
|
|
7
|
-
}
|
|
8
|
-
interface CostSample {
|
|
9
|
-
operation: string;
|
|
10
|
-
tenantId?: string;
|
|
11
|
-
environment?: 'dev' | 'staging' | 'prod';
|
|
12
|
-
dbReads?: number;
|
|
13
|
-
dbWrites?: number;
|
|
14
|
-
computeMs?: number;
|
|
15
|
-
memoryMbMs?: number;
|
|
16
|
-
externalCalls?: ExternalCallCost[];
|
|
17
|
-
customCost?: number;
|
|
18
|
-
timestamp?: Date;
|
|
19
|
-
metadata?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
interface CostModel {
|
|
22
|
-
dbReadCost: number;
|
|
23
|
-
dbWriteCost: number;
|
|
24
|
-
computeMsCost: number;
|
|
25
|
-
memoryMbMsCost: number;
|
|
26
|
-
}
|
|
27
|
-
interface OperationCostSummary {
|
|
28
|
-
operation: string;
|
|
29
|
-
tenantId?: string;
|
|
30
|
-
total: number;
|
|
31
|
-
breakdown: {
|
|
32
|
-
dbReads: number;
|
|
33
|
-
dbWrites: number;
|
|
34
|
-
compute: number;
|
|
35
|
-
memory: number;
|
|
36
|
-
external: number;
|
|
37
|
-
custom: number;
|
|
38
|
-
};
|
|
39
|
-
samples: number;
|
|
40
|
-
}
|
|
41
|
-
interface TenantBudget {
|
|
42
|
-
tenantId: string;
|
|
43
|
-
monthlyLimit: number;
|
|
44
|
-
currency?: string;
|
|
45
|
-
alertThreshold?: number;
|
|
46
|
-
currentSpend?: number;
|
|
47
|
-
}
|
|
48
|
-
interface OptimizationSuggestion {
|
|
49
|
-
operation: string;
|
|
50
|
-
tenantId?: string;
|
|
51
|
-
category: 'n_plus_one' | 'caching' | 'batching' | 'external';
|
|
52
|
-
message: string;
|
|
53
|
-
evidence: Record<string, unknown>;
|
|
54
|
-
}
|
|
55
|
-
interface BudgetAlert {
|
|
56
|
-
tenantId: string;
|
|
57
|
-
limit: number;
|
|
58
|
-
actual: number;
|
|
59
|
-
triggeredAt: Date;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { BudgetAlert, CostModel, CostSample, ExternalCallCost, OperationCostSummary, OptimizationSuggestion, TenantBudget };
|