@stacksjs/ts-cloud 0.2.9 → 0.2.11
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/aws/cost-explorer-cache.d.ts +40 -0
- package/dist/aws/cost-explorer.d.ts +33 -0
- package/dist/aws/credentials.d.ts +12 -0
- package/dist/aws/index.d.ts +1 -0
- package/dist/aws/s3.d.ts +3 -10
- package/dist/bin/cli.js +633 -610
- package/dist/generators/infrastructure.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7239 -2157
- package/package.json +3 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-backed cache for Cost Explorer responses.
|
|
3
|
+
*
|
|
4
|
+
* Cost Explorer charges $0.01 per GetCostAndUsage request. Running cost:analyze
|
|
5
|
+
* a few times in a day adds up — and closed-month data never changes, so we
|
|
6
|
+
* shouldn't keep paying to fetch it. This cache persists across CLI invocations
|
|
7
|
+
* under ~/.cache/ts-cloud/cost-explorer/<profile>/<sha>.json.
|
|
8
|
+
*
|
|
9
|
+
* TTL:
|
|
10
|
+
* - Open period (end is on/after the first of the current UTC month): 1 hour
|
|
11
|
+
* - Closed period (end is before the first of the current UTC month): 30 days
|
|
12
|
+
* Closed months are immutable in Cost Explorer, so this is effectively
|
|
13
|
+
* infinite while still bounding disk usage if many historical periods are
|
|
14
|
+
* queried.
|
|
15
|
+
*/
|
|
16
|
+
export interface CostCacheKey {
|
|
17
|
+
start: string;
|
|
18
|
+
end: string;
|
|
19
|
+
granularity: string;
|
|
20
|
+
metrics: string[];
|
|
21
|
+
groupBy: Array<{
|
|
22
|
+
Type: string;
|
|
23
|
+
Key: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface CacheHit<T> {
|
|
27
|
+
response: T;
|
|
28
|
+
ageSeconds: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function loadCache<T>(profile: string | undefined, key: CostCacheKey): CacheHit<T> | null;
|
|
31
|
+
export declare function saveCache<T>(profile: string | undefined, key: CostCacheKey, response: T): void;
|
|
32
|
+
export interface ClearResult {
|
|
33
|
+
deletedFiles: number;
|
|
34
|
+
scope: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Wipe cache entries. Pass a profile to scope; pass nothing to wipe everything.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearCache(profile?: string): ClearResult;
|
|
40
|
+
export declare function cacheLocation(profile?: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Cost Explorer Client
|
|
3
|
+
* Direct JSON-RPC calls (no AWS SDK / CLI dependency).
|
|
4
|
+
*
|
|
5
|
+
* Endpoint is global but lives in us-east-1.
|
|
6
|
+
*
|
|
7
|
+
* Cost Explorer requests are billed at $0.01 each, so getCostByService is
|
|
8
|
+
* served from a filesystem cache by default. Pass `useCache: false` to bypass.
|
|
9
|
+
*/
|
|
10
|
+
export interface ServiceCost {
|
|
11
|
+
service: string;
|
|
12
|
+
amount: number;
|
|
13
|
+
unit: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CostExplorerOptions {
|
|
16
|
+
useCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class CostExplorerClient {
|
|
19
|
+
private client;
|
|
20
|
+
private profile;
|
|
21
|
+
private useCache;
|
|
22
|
+
/** Set after each call so callers can render a "(cached, NNN seconds old)" hint. */
|
|
23
|
+
lastCacheAgeSeconds: number | null;
|
|
24
|
+
constructor(profile?: string, options?: CostExplorerOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Group total cost by SERVICE for a single time period, sorted descending.
|
|
27
|
+
*/
|
|
28
|
+
getCostByService(params: {
|
|
29
|
+
start: string;
|
|
30
|
+
end: string;
|
|
31
|
+
granularity?: 'DAILY' | 'MONTHLY';
|
|
32
|
+
}): Promise<ServiceCost[]>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AWS credential resolution.
|
|
3
|
+
*
|
|
4
|
+
* Two modes:
|
|
5
|
+
* - Explicit profile (caller passed a profile name): strict — use only that
|
|
6
|
+
* profile, throw if it isn't in the credentials file. Mirrors the AWS CLI's
|
|
7
|
+
* behavior with `--profile`.
|
|
8
|
+
* - Implicit (no profile passed): standard precedence —
|
|
9
|
+
* AWS_ACCESS_KEY_ID/SECRET env vars > AWS_PROFILE > 'default'.
|
|
10
|
+
*/
|
|
11
|
+
import type { AWSCredentials } from './client';
|
|
12
|
+
export declare function resolveCredentials(profile?: string): AWSCredentials;
|
package/dist/aws/index.d.ts
CHANGED
package/dist/aws/s3.d.ts
CHANGED
|
@@ -41,20 +41,13 @@ export interface S3Object {
|
|
|
41
41
|
export declare class S3Client {
|
|
42
42
|
private client;
|
|
43
43
|
private region;
|
|
44
|
-
private
|
|
44
|
+
private explicitProfile?;
|
|
45
45
|
constructor(region?: string, profile?: string);
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
private resolveProfileCredentialsSync;
|
|
50
|
-
/**
|
|
51
|
-
* Get AWS credentials from environment or credentials file
|
|
47
|
+
* Get AWS credentials (used by presigned URL / bucket-policy paths that bypass AWSClient.request).
|
|
48
|
+
* Honors the same explicit-vs-implicit profile semantics as the constructor.
|
|
52
49
|
*/
|
|
53
50
|
private getCredentials;
|
|
54
|
-
/**
|
|
55
|
-
* Load credentials from ~/.aws/credentials file
|
|
56
|
-
*/
|
|
57
|
-
private loadCredentialsFromFile;
|
|
58
51
|
/**
|
|
59
52
|
* List all S3 buckets in the account
|
|
60
53
|
*/
|