@ericminassian/platform-core 0.4.0 → 0.5.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.
- package/dist/api.d.ts +367 -226
- package/dist/api.js +148 -92
- package/dist/api.js.map +1 -1
- package/dist/config.d.ts +0 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +0 -17
- package/dist/constants.js +0 -17
- package/dist/constants.js.map +1 -1
- package/dist/explore.d.ts +367 -0
- package/dist/explore.js +440 -0
- package/dist/explore.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +1 -1
- package/dist/jobs.js +1 -1
- package/dist/manifest.d.ts +10 -47
- package/dist/manifest.js +7 -15
- package/dist/manifest.js.map +1 -1
- package/dist/naming.d.ts +7 -23
- package/dist/naming.js +7 -23
- package/dist/naming.js.map +1 -1
- package/dist/platform-api.d.ts +3511 -2211
- package/dist/platform-api.js +117 -36
- package/dist/platform-api.js.map +1 -1
- package/dist/runtime-config.d.ts +0 -20
- package/dist/runtime-config.js.map +1 -1
- package/dist/storage.d.ts +10 -0
- package/dist/storage.js +10 -0
- package/dist/storage.js.map +1 -1
- package/dist/telemetry.d.ts +52 -27
- package/dist/telemetry.js +67 -19
- package/dist/telemetry.js.map +1 -1
- package/dist/web-compute.js +2 -1
- package/dist/web-compute.js.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +176 -110
- package/src/config.ts +0 -2
- package/src/constants.ts +0 -19
- package/src/explore.ts +504 -0
- package/src/index.ts +1 -1
- package/src/jobs.ts +1 -1
- package/src/manifest.ts +15 -48
- package/src/naming.ts +7 -25
- package/src/platform-api.ts +140 -38
- package/src/runtime-config.ts +0 -21
- package/src/storage.ts +11 -0
- package/src/telemetry.ts +69 -19
- package/src/web-compute.ts +3 -1
- package/dist/compute.d.ts +0 -52
- package/dist/compute.js +0 -65
- package/dist/compute.js.map +0 -1
- package/src/compute.ts +0 -86
package/src/compute.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Container compute (ECS on Fargate): the sizes a container may have and
|
|
3
|
-
* what one costs while it runs. Shared by the manifest schema, the engine,
|
|
4
|
-
* the console's cost page and `plat deploy`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** vCPUs a Fargate task may have (the platform caps it at 4). */
|
|
8
|
-
export const FARGATE_CPUS = [0.25, 0.5, 1, 2, 4] as const;
|
|
9
|
-
export type FargateCpu = (typeof FARGATE_CPUS)[number];
|
|
10
|
-
|
|
11
|
-
/** Memory (MB) Fargate allows for each vCPU size. */
|
|
12
|
-
export function fargateMemoryOptions(cpu: FargateCpu): number[] {
|
|
13
|
-
if (cpu === 0.25) return [512, 1024, 2048];
|
|
14
|
-
const [from, to] = MEMORY_RANGES[cpu];
|
|
15
|
-
return Array.from({ length: (to - from) / 1024 + 1 }, (_, i) => from + i * 1024);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Above 0.25 vCPU, memory goes from..to in steps of 1024 MB. */
|
|
19
|
-
const MEMORY_RANGES: Record<Exclude<FargateCpu, 0.25>, readonly [number, number]> = {
|
|
20
|
-
0.5: [1024, 4096],
|
|
21
|
-
1: [2048, 8192],
|
|
22
|
-
2: [4096, 16384],
|
|
23
|
-
4: [8192, 30720],
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Why `cpu`/`memoryMb` isn't a size Fargate runs, or null when it is. */
|
|
27
|
-
export function fargateSizeIssue(cpu: number, memoryMb: number): string | null {
|
|
28
|
-
if (!(FARGATE_CPUS as readonly number[]).includes(cpu)) {
|
|
29
|
-
return `cpu must be one of ${FARGATE_CPUS.join(', ')}`;
|
|
30
|
-
}
|
|
31
|
-
const options = fargateMemoryOptions(cpu as FargateCpu);
|
|
32
|
-
if (options.includes(memoryMb)) return null;
|
|
33
|
-
const allowed =
|
|
34
|
-
cpu === 0.25 ? options.join(', ') : `${options[0]}-${options[options.length - 1]} in steps of 1024`;
|
|
35
|
-
return `memoryMb ${memoryMb} doesn't fit ${cpu} vCPU: use ${allowed}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** ECS task-definition units: 1024 per vCPU. */
|
|
39
|
-
export function fargateCpuUnits(cpu: number): number {
|
|
40
|
-
return Math.round(cpu * 1024);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Prices behind the estimates: us-east-1, Linux on ARM (Graviton), checked
|
|
45
|
-
* 2026-11-15. Spot prices move with supply and demand, so Spot estimates are
|
|
46
|
-
* approximate. Every task gets a public IPv4 address (there is no NAT), which
|
|
47
|
-
* AWS bills by the hour whatever the capacity.
|
|
48
|
-
*/
|
|
49
|
-
export const CONTAINER_PRICES_USD = {
|
|
50
|
-
onDemand: { vcpuHour: 0.03238, gbHour: 0.00356 },
|
|
51
|
-
spot: { vcpuHour: 0.00995, gbHour: 0.00109 },
|
|
52
|
-
publicIpv4Hour: 0.005,
|
|
53
|
-
} as const;
|
|
54
|
-
|
|
55
|
-
/** Hours AWS bills a month of always-on capacity for. */
|
|
56
|
-
export const HOURS_PER_MONTH = 730;
|
|
57
|
-
|
|
58
|
-
export interface ContainerCostEstimate {
|
|
59
|
-
/** vCPU and memory, per month. */
|
|
60
|
-
computeUsd: number;
|
|
61
|
-
/** The task's public IPv4 address, per month. */
|
|
62
|
-
publicIpv4Usd: number;
|
|
63
|
-
totalUsd: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** What one container of this size costs a month if it runs all the time. */
|
|
67
|
-
export function estimateContainerCost(size: {
|
|
68
|
-
cpu: number;
|
|
69
|
-
memoryMb: number;
|
|
70
|
-
spot: boolean;
|
|
71
|
-
}): ContainerCostEstimate {
|
|
72
|
-
const price = size.spot ? CONTAINER_PRICES_USD.spot : CONTAINER_PRICES_USD.onDemand;
|
|
73
|
-
const hourly = size.cpu * price.vcpuHour + (size.memoryMb / 1024) * price.gbHour;
|
|
74
|
-
const computeUsd = round2(hourly * HOURS_PER_MONTH);
|
|
75
|
-
const publicIpv4Usd = round2(CONTAINER_PRICES_USD.publicIpv4Hour * HOURS_PER_MONTH);
|
|
76
|
-
return { computeUsd, publicIpv4Usd, totalUsd: round2(computeUsd + publicIpv4Usd) };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** `0.25 vCPU · 512 MB · Spot`. */
|
|
80
|
-
export function describeContainerSize(size: { cpu: number; memoryMb: number; spot: boolean }): string {
|
|
81
|
-
return `${size.cpu} vCPU · ${size.memoryMb} MB · ${size.spot ? 'Spot' : 'on-demand'}`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function round2(n: number): number {
|
|
85
|
-
return Math.round(n * 100) / 100;
|
|
86
|
-
}
|