@pagopa/dx-savemoney 0.3.2 → 0.4.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/README.md +12 -0
- package/dist/__tests__/finding.test.js +22 -0
- package/dist/__tests__/finding.test.js.map +1 -1
- package/dist/azure/__tests__/analyzer-tags.test.js +28 -1
- package/dist/azure/__tests__/analyzer-tags.test.js.map +1 -1
- package/dist/azure/__tests__/config.test.js +10 -0
- package/dist/azure/__tests__/config.test.js.map +1 -1
- package/dist/azure/__tests__/report.test.js +71 -0
- package/dist/azure/__tests__/report.test.js.map +1 -1
- package/dist/azure/analyzer.d.ts +8 -1
- package/dist/azure/analyzer.d.ts.map +1 -1
- package/dist/azure/analyzer.js +55 -37
- package/dist/azure/analyzer.js.map +1 -1
- package/dist/azure/analyzers/registry.d.ts.map +1 -1
- package/dist/azure/analyzers/registry.js +4 -4
- package/dist/azure/analyzers/registry.js.map +1 -1
- package/dist/azure/analyzers/types.d.ts +6 -0
- package/dist/azure/analyzers/types.d.ts.map +1 -1
- package/dist/azure/pricing/__tests__/cache.test.d.ts +8 -0
- package/dist/azure/pricing/__tests__/cache.test.d.ts.map +1 -0
- package/dist/azure/pricing/__tests__/cache.test.js +56 -0
- package/dist/azure/pricing/__tests__/cache.test.js.map +1 -0
- package/dist/azure/pricing/__tests__/client.test.d.ts +9 -0
- package/dist/azure/pricing/__tests__/client.test.d.ts.map +1 -0
- package/dist/azure/pricing/__tests__/client.test.js +181 -0
- package/dist/azure/pricing/__tests__/client.test.js.map +1 -0
- package/dist/azure/pricing/__tests__/pricing-service.test.d.ts +6 -0
- package/dist/azure/pricing/__tests__/pricing-service.test.d.ts.map +1 -0
- package/dist/azure/pricing/__tests__/pricing-service.test.js +283 -0
- package/dist/azure/pricing/__tests__/pricing-service.test.js.map +1 -0
- package/dist/azure/pricing/cache.d.ts +45 -0
- package/dist/azure/pricing/cache.d.ts.map +1 -0
- package/dist/azure/pricing/cache.js +79 -0
- package/dist/azure/pricing/cache.js.map +1 -0
- package/dist/azure/pricing/client.d.ts +67 -0
- package/dist/azure/pricing/client.d.ts.map +1 -0
- package/dist/azure/pricing/client.js +96 -0
- package/dist/azure/pricing/client.js.map +1 -0
- package/dist/azure/pricing/index.d.ts +6 -0
- package/dist/azure/pricing/index.d.ts.map +1 -0
- package/dist/azure/pricing/index.js +6 -0
- package/dist/azure/pricing/index.js.map +1 -0
- package/dist/azure/pricing/pricing-service.d.ts +46 -0
- package/dist/azure/pricing/pricing-service.d.ts.map +1 -0
- package/dist/azure/pricing/pricing-service.js +84 -0
- package/dist/azure/pricing/pricing-service.js.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/app-service.test.d.ts +5 -0
- package/dist/azure/pricing/resolvers/__tests__/app-service.test.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/app-service.test.js +137 -0
- package/dist/azure/pricing/resolvers/__tests__/app-service.test.js.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/disk.test.d.ts +5 -0
- package/dist/azure/pricing/resolvers/__tests__/disk.test.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/disk.test.js +160 -0
- package/dist/azure/pricing/resolvers/__tests__/disk.test.js.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/public-ip.test.d.ts +5 -0
- package/dist/azure/pricing/resolvers/__tests__/public-ip.test.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/public-ip.test.js +113 -0
- package/dist/azure/pricing/resolvers/__tests__/public-ip.test.js.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/vm.test.d.ts +9 -0
- package/dist/azure/pricing/resolvers/__tests__/vm.test.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/__tests__/vm.test.js +204 -0
- package/dist/azure/pricing/resolvers/__tests__/vm.test.js.map +1 -0
- package/dist/azure/pricing/resolvers/app-service.d.ts +27 -0
- package/dist/azure/pricing/resolvers/app-service.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/app-service.js +67 -0
- package/dist/azure/pricing/resolvers/app-service.js.map +1 -0
- package/dist/azure/pricing/resolvers/disk.d.ts +59 -0
- package/dist/azure/pricing/resolvers/disk.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/disk.js +140 -0
- package/dist/azure/pricing/resolvers/disk.js.map +1 -0
- package/dist/azure/pricing/resolvers/index.d.ts +12 -0
- package/dist/azure/pricing/resolvers/index.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/index.js +8 -0
- package/dist/azure/pricing/resolvers/index.js.map +1 -0
- package/dist/azure/pricing/resolvers/public-ip.d.ts +32 -0
- package/dist/azure/pricing/resolvers/public-ip.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/public-ip.js +56 -0
- package/dist/azure/pricing/resolvers/public-ip.js.map +1 -0
- package/dist/azure/pricing/resolvers/vm.d.ts +51 -0
- package/dist/azure/pricing/resolvers/vm.d.ts.map +1 -0
- package/dist/azure/pricing/resolvers/vm.js +89 -0
- package/dist/azure/pricing/resolvers/vm.js.map +1 -0
- package/dist/azure/pricing/schema.d.ts +88 -0
- package/dist/azure/pricing/schema.d.ts.map +1 -0
- package/dist/azure/pricing/schema.js +64 -0
- package/dist/azure/pricing/schema.js.map +1 -0
- package/dist/azure/pricing/test-cache-dir.d.ts +3 -0
- package/dist/azure/pricing/test-cache-dir.d.ts.map +1 -0
- package/dist/azure/pricing/test-cache-dir.js +17 -0
- package/dist/azure/pricing/test-cache-dir.js.map +1 -0
- package/dist/azure/report.d.ts.map +1 -1
- package/dist/azure/report.js +57 -18
- package/dist/azure/report.js.map +1 -1
- package/dist/azure/resources/__tests__/app-service.test.d.ts +5 -0
- package/dist/azure/resources/__tests__/app-service.test.d.ts.map +1 -0
- package/dist/azure/resources/__tests__/app-service.test.js +105 -0
- package/dist/azure/resources/__tests__/app-service.test.js.map +1 -0
- package/dist/azure/resources/app-service.d.ts +8 -3
- package/dist/azure/resources/app-service.d.ts.map +1 -1
- package/dist/azure/resources/app-service.js +35 -2
- package/dist/azure/resources/app-service.js.map +1 -1
- package/dist/azure/resources/disk.d.ts +3 -1
- package/dist/azure/resources/disk.d.ts.map +1 -1
- package/dist/azure/resources/disk.js +35 -3
- package/dist/azure/resources/disk.js.map +1 -1
- package/dist/azure/resources/public-ip.d.ts +3 -1
- package/dist/azure/resources/public-ip.d.ts.map +1 -1
- package/dist/azure/resources/public-ip.js +41 -3
- package/dist/azure/resources/public-ip.js.map +1 -1
- package/dist/azure/resources/vm.d.ts +4 -1
- package/dist/azure/resources/vm.d.ts.map +1 -1
- package/dist/azure/resources/vm.js +49 -6
- package/dist/azure/resources/vm.js.map +1 -1
- package/dist/azure/types.d.ts +13 -0
- package/dist/azure/types.d.ts.map +1 -1
- package/dist/finding.d.ts +3 -3
- package/dist/finding.d.ts.map +1 -1
- package/dist/finding.js +7 -0
- package/dist/finding.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
- package/src/__tests__/finding.test.ts +24 -0
- package/src/azure/__tests__/analyzer-tags.test.ts +36 -1
- package/src/azure/__tests__/config.test.ts +12 -0
- package/src/azure/__tests__/report.test.ts +78 -0
- package/src/azure/analyzer.ts +67 -43
- package/src/azure/analyzers/registry.ts +8 -2
- package/src/azure/analyzers/types.ts +6 -0
- package/src/azure/pricing/__tests__/cache.test.ts +67 -0
- package/src/azure/pricing/__tests__/client.test.ts +212 -0
- package/src/azure/pricing/__tests__/fixtures/vm-b2s-westeurope.json +51 -0
- package/src/azure/pricing/__tests__/pricing-service.test.ts +315 -0
- package/src/azure/pricing/cache.ts +92 -0
- package/src/azure/pricing/client.ts +137 -0
- package/src/azure/pricing/index.ts +6 -0
- package/src/azure/pricing/pricing-service.ts +125 -0
- package/src/azure/pricing/resolvers/__tests__/app-service.test.ts +154 -0
- package/src/azure/pricing/resolvers/__tests__/disk.test.ts +189 -0
- package/src/azure/pricing/resolvers/__tests__/public-ip.test.ts +130 -0
- package/src/azure/pricing/resolvers/__tests__/vm.test.ts +232 -0
- package/src/azure/pricing/resolvers/app-service.ts +102 -0
- package/src/azure/pricing/resolvers/disk.ts +170 -0
- package/src/azure/pricing/resolvers/index.ts +31 -0
- package/src/azure/pricing/resolvers/public-ip.ts +87 -0
- package/src/azure/pricing/resolvers/vm.ts +125 -0
- package/src/azure/pricing/schema.ts +69 -0
- package/src/azure/pricing/test-cache-dir.ts +26 -0
- package/src/azure/report.ts +86 -21
- package/src/azure/resources/__tests__/app-service.test.ts +165 -0
- package/src/azure/resources/app-service.ts +65 -4
- package/src/azure/resources/disk.ts +46 -4
- package/src/azure/resources/public-ip.ts +61 -2
- package/src/azure/resources/vm.ts +89 -11
- package/src/azure/types.ts +14 -0
- package/src/finding.ts +10 -3
- package/src/index.ts +3 -3
- package/src/types.ts +12 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Managed Disk.
|
|
3
|
+
*
|
|
4
|
+
* Azure prices managed disks per discrete capacity tier (P1…P80,
|
|
5
|
+
* E1…E80, S4…S80) rather than per actual `diskSizeGB`. The resolver:
|
|
6
|
+
*
|
|
7
|
+
* 1. Maps the disk SKU (`Premium_LRS`, `StandardSSD_ZRS`, …) and
|
|
8
|
+
* `diskSizeGB` to the corresponding billing tier (e.g. `P10 LRS`).
|
|
9
|
+
* 2. Queries the Azure Retail Prices API with the tier-derived
|
|
10
|
+
* `skuName` for the right service / region.
|
|
11
|
+
* 3. Returns the consumption price (already `1/Month` in the API) as
|
|
12
|
+
* `Money`, or `undefined` if no match (e.g. Ultra disks, which use
|
|
13
|
+
* a different per-GB / IOPS / throughput pricing model and are not
|
|
14
|
+
* yet supported).
|
|
15
|
+
*
|
|
16
|
+
* The mapping is intentionally encoded in a single Zod-validated
|
|
17
|
+
* lookup table so a malformed input fails fast and loud rather than
|
|
18
|
+
* silently producing a wrong tier.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
import type { Money } from "../../../finding.js";
|
|
22
|
+
import type { PricingClient } from "../client.js";
|
|
23
|
+
/**
|
|
24
|
+
* Replication mode supported by the resolver. Ultra disks (`UltraSSD_LRS`)
|
|
25
|
+
* are intentionally excluded because their pricing is multi-dimensional
|
|
26
|
+
* (capacity + IOPS + throughput) and would need a dedicated resolver.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DiskSkuSchema: z.ZodEnum<{
|
|
29
|
+
Premium_LRS: "Premium_LRS";
|
|
30
|
+
Premium_ZRS: "Premium_ZRS";
|
|
31
|
+
StandardSSD_LRS: "StandardSSD_LRS";
|
|
32
|
+
StandardSSD_ZRS: "StandardSSD_ZRS";
|
|
33
|
+
Standard_LRS: "Standard_LRS";
|
|
34
|
+
}>;
|
|
35
|
+
export type DiskSku = z.infer<typeof DiskSkuSchema>;
|
|
36
|
+
export declare const ResolveDiskInputSchema: z.ZodObject<{
|
|
37
|
+
armRegionName: z.ZodString;
|
|
38
|
+
diskSizeGiB: z.ZodNumber;
|
|
39
|
+
sku: z.ZodEnum<{
|
|
40
|
+
Premium_LRS: "Premium_LRS";
|
|
41
|
+
Premium_ZRS: "Premium_ZRS";
|
|
42
|
+
StandardSSD_LRS: "StandardSSD_LRS";
|
|
43
|
+
StandardSSD_ZRS: "StandardSSD_ZRS";
|
|
44
|
+
Standard_LRS: "Standard_LRS";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type ResolveDiskInput = z.infer<typeof ResolveDiskInputSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* Pure helper exposed for testing: resolves the size→tier mapping
|
|
50
|
+
* without touching the network.
|
|
51
|
+
*/
|
|
52
|
+
export declare function pickTier(diskSizeGiB: number): number | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Resolves the estimated monthly cost for a Managed Disk. Returns
|
|
55
|
+
* `undefined` if the SKU/size combo is unsupported (e.g. exceeds the
|
|
56
|
+
* largest tier) or if no matching Retail Prices entry is found.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveDiskMonthlyPrice(client: PricingClient, rawInput: ResolveDiskInput): Promise<Money | undefined>;
|
|
59
|
+
//# sourceMappingURL=disk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk.d.ts","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/disk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;EAMxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AA0DpD,eAAO,MAAM,sBAAsB;;;;;;;;;;iBAOjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAuB5B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Managed Disk.
|
|
3
|
+
*
|
|
4
|
+
* Azure prices managed disks per discrete capacity tier (P1…P80,
|
|
5
|
+
* E1…E80, S4…S80) rather than per actual `diskSizeGB`. The resolver:
|
|
6
|
+
*
|
|
7
|
+
* 1. Maps the disk SKU (`Premium_LRS`, `StandardSSD_ZRS`, …) and
|
|
8
|
+
* `diskSizeGB` to the corresponding billing tier (e.g. `P10 LRS`).
|
|
9
|
+
* 2. Queries the Azure Retail Prices API with the tier-derived
|
|
10
|
+
* `skuName` for the right service / region.
|
|
11
|
+
* 3. Returns the consumption price (already `1/Month` in the API) as
|
|
12
|
+
* `Money`, or `undefined` if no match (e.g. Ultra disks, which use
|
|
13
|
+
* a different per-GB / IOPS / throughput pricing model and are not
|
|
14
|
+
* yet supported).
|
|
15
|
+
*
|
|
16
|
+
* The mapping is intentionally encoded in a single Zod-validated
|
|
17
|
+
* lookup table so a malformed input fails fast and loud rather than
|
|
18
|
+
* silently producing a wrong tier.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
import { normalizeArmRegion } from "./vm.js";
|
|
22
|
+
/**
|
|
23
|
+
* Replication mode supported by the resolver. Ultra disks (`UltraSSD_LRS`)
|
|
24
|
+
* are intentionally excluded because their pricing is multi-dimensional
|
|
25
|
+
* (capacity + IOPS + throughput) and would need a dedicated resolver.
|
|
26
|
+
*/
|
|
27
|
+
export const DiskSkuSchema = z.enum([
|
|
28
|
+
"Premium_LRS",
|
|
29
|
+
"Premium_ZRS",
|
|
30
|
+
"StandardSSD_LRS",
|
|
31
|
+
"StandardSSD_ZRS",
|
|
32
|
+
"Standard_LRS",
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Inclusive upper bound (GiB) → tier name. Order matters: the resolver
|
|
36
|
+
* picks the FIRST entry whose `maxSizeGiB` is greater-or-equal to the
|
|
37
|
+
* requested size.
|
|
38
|
+
*
|
|
39
|
+
* See https://learn.microsoft.com/azure/virtual-machines/disks-types for
|
|
40
|
+
* the canonical tier table.
|
|
41
|
+
*/
|
|
42
|
+
const TIER_TABLE = [
|
|
43
|
+
{ maxSizeGiB: 4, tier: 1 },
|
|
44
|
+
{ maxSizeGiB: 8, tier: 2 },
|
|
45
|
+
{ maxSizeGiB: 16, tier: 3 },
|
|
46
|
+
{ maxSizeGiB: 32, tier: 4 },
|
|
47
|
+
{ maxSizeGiB: 64, tier: 6 },
|
|
48
|
+
{ maxSizeGiB: 128, tier: 10 },
|
|
49
|
+
{ maxSizeGiB: 256, tier: 15 },
|
|
50
|
+
{ maxSizeGiB: 512, tier: 20 },
|
|
51
|
+
{ maxSizeGiB: 1024, tier: 30 },
|
|
52
|
+
{ maxSizeGiB: 2048, tier: 40 },
|
|
53
|
+
{ maxSizeGiB: 4096, tier: 50 },
|
|
54
|
+
{ maxSizeGiB: 8192, tier: 60 },
|
|
55
|
+
{ maxSizeGiB: 16384, tier: 70 },
|
|
56
|
+
{ maxSizeGiB: 32768, tier: 80 },
|
|
57
|
+
];
|
|
58
|
+
const SKU_METADATA = {
|
|
59
|
+
Premium_LRS: {
|
|
60
|
+
prefix: "P",
|
|
61
|
+
productName: "Premium SSD Managed Disks",
|
|
62
|
+
replication: "LRS",
|
|
63
|
+
},
|
|
64
|
+
Premium_ZRS: {
|
|
65
|
+
prefix: "P",
|
|
66
|
+
productName: "Premium SSD Managed Disks",
|
|
67
|
+
replication: "ZRS",
|
|
68
|
+
},
|
|
69
|
+
Standard_LRS: {
|
|
70
|
+
prefix: "S",
|
|
71
|
+
productName: "Standard HDD Managed Disks",
|
|
72
|
+
replication: "LRS",
|
|
73
|
+
},
|
|
74
|
+
StandardSSD_LRS: {
|
|
75
|
+
prefix: "E",
|
|
76
|
+
productName: "Standard SSD Managed Disks",
|
|
77
|
+
replication: "LRS",
|
|
78
|
+
},
|
|
79
|
+
StandardSSD_ZRS: {
|
|
80
|
+
prefix: "E",
|
|
81
|
+
productName: "Standard SSD Managed Disks",
|
|
82
|
+
replication: "ZRS",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
export const ResolveDiskInputSchema = z.object({
|
|
86
|
+
/** ARM region name, e.g. `westeurope`. */
|
|
87
|
+
armRegionName: z.string().min(1),
|
|
88
|
+
/** Disk capacity in GiB as reported by the Compute API (`diskSizeGB`). */
|
|
89
|
+
diskSizeGiB: z.number().int().positive(),
|
|
90
|
+
/** Managed disk SKU. */
|
|
91
|
+
sku: DiskSkuSchema,
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Pure helper exposed for testing: resolves the size→tier mapping
|
|
95
|
+
* without touching the network.
|
|
96
|
+
*/
|
|
97
|
+
export function pickTier(diskSizeGiB) {
|
|
98
|
+
return TIER_TABLE.find((row) => diskSizeGiB <= row.maxSizeGiB)?.tier;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolves the estimated monthly cost for a Managed Disk. Returns
|
|
102
|
+
* `undefined` if the SKU/size combo is unsupported (e.g. exceeds the
|
|
103
|
+
* largest tier) or if no matching Retail Prices entry is found.
|
|
104
|
+
*/
|
|
105
|
+
export async function resolveDiskMonthlyPrice(client, rawInput) {
|
|
106
|
+
const input = ResolveDiskInputSchema.parse(rawInput);
|
|
107
|
+
const tier = pickTier(input.diskSizeGiB);
|
|
108
|
+
if (tier === undefined)
|
|
109
|
+
return undefined;
|
|
110
|
+
const { prefix, productName, replication } = SKU_METADATA[input.sku];
|
|
111
|
+
const skuName = `${prefix}${tier} ${replication}`;
|
|
112
|
+
const filter = [
|
|
113
|
+
"serviceName eq 'Storage'",
|
|
114
|
+
`armRegionName eq '${normalizeArmRegion(input.armRegionName)}'`,
|
|
115
|
+
`productName eq '${productName}'`,
|
|
116
|
+
`skuName eq '${skuName}'`,
|
|
117
|
+
].join(" and ");
|
|
118
|
+
const items = await client.query(filter);
|
|
119
|
+
const item = pickDiskItem(items, skuName);
|
|
120
|
+
if (!item)
|
|
121
|
+
return undefined;
|
|
122
|
+
return {
|
|
123
|
+
amount: round2(item.unitPrice),
|
|
124
|
+
currency: item.currencyCode,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function pickDiskItem(items, skuName) {
|
|
128
|
+
// Managed Disk meters are reported as `1/Month`; we keep the filter
|
|
129
|
+
// explicit to avoid accidentally picking a per-hour or per-IOPS entry.
|
|
130
|
+
const candidates = items.filter((it) => it.type === "Consumption" &&
|
|
131
|
+
it.unitOfMeasure === "1/Month" &&
|
|
132
|
+
it.skuName === skuName);
|
|
133
|
+
if (candidates.length === 0)
|
|
134
|
+
return undefined;
|
|
135
|
+
return candidates.reduce((cheapest, it) => it.unitPrice < cheapest.unitPrice ? it : cheapest);
|
|
136
|
+
}
|
|
137
|
+
function round2(value) {
|
|
138
|
+
return Math.round(value * 100) / 100;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=disk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk.js","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/disk.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public exports for resolvers.
|
|
3
|
+
*/
|
|
4
|
+
export type { AppServicePlanOs, ResolveAppServicePlanInput, } from "./app-service.js";
|
|
5
|
+
export { resolveAppServicePlanMonthlyPrice } from "./app-service.js";
|
|
6
|
+
export type { DiskSku, ResolveDiskInput } from "./disk.js";
|
|
7
|
+
export { DiskSkuSchema, pickTier, ResolveDiskInputSchema, resolveDiskMonthlyPrice, } from "./disk.js";
|
|
8
|
+
export type { PublicIpAllocation, PublicIpSku, ResolvePublicIpInput, } from "./public-ip.js";
|
|
9
|
+
export { resolvePublicIpMonthlyPrice } from "./public-ip.js";
|
|
10
|
+
export type { ResolveVmInput, VmOs } from "./vm.js";
|
|
11
|
+
export { HOURS_PER_MONTH, normalizeArmRegion, resolveVmMonthlyPrice, } from "./vm.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAErE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public exports for resolvers.
|
|
3
|
+
*/
|
|
4
|
+
export { resolveAppServicePlanMonthlyPrice } from "./app-service.js";
|
|
5
|
+
export { DiskSkuSchema, pickTier, ResolveDiskInputSchema, resolveDiskMonthlyPrice, } from "./disk.js";
|
|
6
|
+
export { resolvePublicIpMonthlyPrice } from "./public-ip.js";
|
|
7
|
+
export { HOURS_PER_MONTH, normalizeArmRegion, resolveVmMonthlyPrice, } from "./vm.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EACL,aAAa,EACb,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AAOnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Public IP address.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Azure Retail Prices API to look up the pay-as-you-go price for
|
|
5
|
+
* the given SKU + region + allocation method combination, then converts
|
|
6
|
+
* the hourly rate (when reported as `1 Hour`) to a monthly figure using
|
|
7
|
+
* the conventional 730-hours-per-month constant.
|
|
8
|
+
*
|
|
9
|
+
* Public IP pricing is published per `(sku, allocation)` pair. Both
|
|
10
|
+
* Standard SKU and a Static Basic SKU carry a billable hourly rate; a
|
|
11
|
+
* Dynamic Basic SKU is typically free when associated, and the lookup
|
|
12
|
+
* returns `undefined` in that case.
|
|
13
|
+
*/
|
|
14
|
+
import type { Money } from "../../../finding.js";
|
|
15
|
+
import type { PricingClient } from "../client.js";
|
|
16
|
+
export type PublicIpAllocation = "dynamic" | "static";
|
|
17
|
+
export type PublicIpSku = "basic" | "standard";
|
|
18
|
+
export type ResolvePublicIpInput = {
|
|
19
|
+
/** Allocation method (`Static` / `Dynamic`). */
|
|
20
|
+
allocation: PublicIpAllocation;
|
|
21
|
+
/** ARM region name, e.g. `westeurope`. */
|
|
22
|
+
armRegionName: string;
|
|
23
|
+
/** SKU (`Basic` / `Standard`). */
|
|
24
|
+
sku: PublicIpSku;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the estimated monthly cost for a Public IP. Returns
|
|
28
|
+
* `undefined` when no matching consumption meter is found (e.g. the
|
|
29
|
+
* combination is genuinely free).
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolvePublicIpMonthlyPrice(client: PricingClient, input: ResolvePublicIpInput): Promise<Money | undefined>;
|
|
32
|
+
//# sourceMappingURL=public-ip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-ip.d.ts","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/public-ip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/C,MAAM,MAAM,oBAAoB,GAAG;IACjC,gDAAgD;IAChD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAkB5B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Public IP address.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Azure Retail Prices API to look up the pay-as-you-go price for
|
|
5
|
+
* the given SKU + region + allocation method combination, then converts
|
|
6
|
+
* the hourly rate (when reported as `1 Hour`) to a monthly figure using
|
|
7
|
+
* the conventional 730-hours-per-month constant.
|
|
8
|
+
*
|
|
9
|
+
* Public IP pricing is published per `(sku, allocation)` pair. Both
|
|
10
|
+
* Standard SKU and a Static Basic SKU carry a billable hourly rate; a
|
|
11
|
+
* Dynamic Basic SKU is typically free when associated, and the lookup
|
|
12
|
+
* returns `undefined` in that case.
|
|
13
|
+
*/
|
|
14
|
+
import { HOURS_PER_MONTH, normalizeArmRegion } from "./vm.js";
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the estimated monthly cost for a Public IP. Returns
|
|
17
|
+
* `undefined` when no matching consumption meter is found (e.g. the
|
|
18
|
+
* combination is genuinely free).
|
|
19
|
+
*/
|
|
20
|
+
export async function resolvePublicIpMonthlyPrice(client, input) {
|
|
21
|
+
// Public IPs are billed under the "Virtual Network" service.
|
|
22
|
+
const filter = [
|
|
23
|
+
"serviceName eq 'Virtual Network'",
|
|
24
|
+
`armRegionName eq '${normalizeArmRegion(input.armRegionName)}'`,
|
|
25
|
+
`skuName eq '${capitalize(input.sku)}'`,
|
|
26
|
+
].join(" and ");
|
|
27
|
+
const items = await client.query(filter);
|
|
28
|
+
const item = pickPublicIpItem(items, input.allocation);
|
|
29
|
+
if (!item) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
amount: round2(item.unitPrice * HOURS_PER_MONTH),
|
|
34
|
+
currency: item.currencyCode,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function capitalize(value) {
|
|
38
|
+
if (value.length === 0)
|
|
39
|
+
return value;
|
|
40
|
+
return value[0].toUpperCase() + value.slice(1).toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
function pickPublicIpItem(items, allocation) {
|
|
43
|
+
const allocationToken = allocation === "static" ? "static" : "dynamic";
|
|
44
|
+
const candidates = items.filter((it) => it.type === "Consumption" &&
|
|
45
|
+
it.unitOfMeasure === "1 Hour" &&
|
|
46
|
+
(it.meterName?.toLowerCase().includes("ip address") ?? false) &&
|
|
47
|
+
(it.meterName?.toLowerCase().includes(allocationToken) ?? false));
|
|
48
|
+
if (candidates.length === 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
// Pick the cheapest entry as a conservative lower bound.
|
|
51
|
+
return candidates.reduce((cheapest, it) => it.unitPrice < cheapest.unitPrice ? it : cheapest);
|
|
52
|
+
}
|
|
53
|
+
function round2(value) {
|
|
54
|
+
return Math.round(value * 100) / 100;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=public-ip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-ip.js","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/public-ip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAc9D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAqB,EACrB,KAA2B;IAE3B,6DAA6D;IAC7D,MAAM,MAAM,GAAG;QACb,kCAAkC;QAClC,qBAAqB,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG;QAC/D,eAAe,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;KACxC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;QAChD,QAAQ,EAAE,IAAI,CAAC,YAAY;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;AAED,SAAS,gBAAgB,CACvB,KAAkB,EAClB,UAA8B;IAE9B,MAAM,eAAe,GAAG,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,EAAE,EAAE,EAAE,CACL,EAAE,CAAC,IAAI,KAAK,aAAa;QACzB,EAAE,CAAC,aAAa,KAAK,QAAQ;QAC7B,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;QAC7D,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CACnE,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,yDAAyD;IACzD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CACxC,EAAE,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Virtual Machine SKU.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Azure Retail Prices API to look up the pay-as-you-go consumption
|
|
5
|
+
* price for the given `armSkuName` in the given region, then converts the
|
|
6
|
+
* hourly rate to a monthly figure assuming the conventional `730 hours`
|
|
7
|
+
* (365.25 * 24 / 12) for "always-on" workloads.
|
|
8
|
+
*
|
|
9
|
+
* The lookup is intentionally conservative:
|
|
10
|
+
* - It restricts results to `type === "Consumption"` (no Reservations,
|
|
11
|
+
* no Spot/Low Priority, no Savings Plans).
|
|
12
|
+
* - It defaults to the Linux variant (cheapest) when the resource OS is
|
|
13
|
+
* unknown, so the returned figure is a LOWER BOUND of the real cost.
|
|
14
|
+
* - It returns `undefined` whenever it cannot identify a single
|
|
15
|
+
* unambiguous price item, so callers can treat the savings estimate
|
|
16
|
+
* as best-effort.
|
|
17
|
+
*/
|
|
18
|
+
import type { Money } from "../../../finding.js";
|
|
19
|
+
import type { PricingClient } from "../client.js";
|
|
20
|
+
/**
|
|
21
|
+
* Conventional hours-per-month used across Azure cost calculators
|
|
22
|
+
* (365.25 days × 24 h / 12 months ≈ 730).
|
|
23
|
+
*/
|
|
24
|
+
export declare const HOURS_PER_MONTH = 730;
|
|
25
|
+
export type ResolveVmInput = {
|
|
26
|
+
/** ARM region name, e.g. `westeurope`. */
|
|
27
|
+
armRegionName: string;
|
|
28
|
+
/** ARM SKU name, e.g. `Standard_B2s`. */
|
|
29
|
+
armSkuName: string;
|
|
30
|
+
/** Optional OS hint. Defaults to `linux`. */
|
|
31
|
+
os?: VmOs;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Operating system hint used to disambiguate Windows vs. Linux meters.
|
|
35
|
+
* When unset (default) the cheapest Linux variant is picked.
|
|
36
|
+
*/
|
|
37
|
+
export type VmOs = "linux" | "windows";
|
|
38
|
+
/**
|
|
39
|
+
* Normalises a region string to the `armRegionName` format expected by
|
|
40
|
+
* the Retail Prices API (lowercase, no spaces). The Azure SDK sometimes
|
|
41
|
+
* returns the display name (`"West Europe"`) instead of the ARM name
|
|
42
|
+
* (`"westeurope"`); without this normalisation the OData filter would
|
|
43
|
+
* silently miss every entry.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeArmRegion(region: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the estimated monthly cost for a VM SKU. Returns `undefined`
|
|
48
|
+
* if no matching consumption meter can be found.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveVmMonthlyPrice(client: PricingClient, input: ResolveVmInput): Promise<Money | undefined>;
|
|
51
|
+
//# sourceMappingURL=vm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/vm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG;IAC3B,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,EAAE,CAAC,EAAE,IAAI,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAiB5B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolver: estimated monthly cost of an Azure Virtual Machine SKU.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Azure Retail Prices API to look up the pay-as-you-go consumption
|
|
5
|
+
* price for the given `armSkuName` in the given region, then converts the
|
|
6
|
+
* hourly rate to a monthly figure assuming the conventional `730 hours`
|
|
7
|
+
* (365.25 * 24 / 12) for "always-on" workloads.
|
|
8
|
+
*
|
|
9
|
+
* The lookup is intentionally conservative:
|
|
10
|
+
* - It restricts results to `type === "Consumption"` (no Reservations,
|
|
11
|
+
* no Spot/Low Priority, no Savings Plans).
|
|
12
|
+
* - It defaults to the Linux variant (cheapest) when the resource OS is
|
|
13
|
+
* unknown, so the returned figure is a LOWER BOUND of the real cost.
|
|
14
|
+
* - It returns `undefined` whenever it cannot identify a single
|
|
15
|
+
* unambiguous price item, so callers can treat the savings estimate
|
|
16
|
+
* as best-effort.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Conventional hours-per-month used across Azure cost calculators
|
|
20
|
+
* (365.25 days × 24 h / 12 months ≈ 730).
|
|
21
|
+
*/
|
|
22
|
+
export const HOURS_PER_MONTH = 730;
|
|
23
|
+
/**
|
|
24
|
+
* Normalises a region string to the `armRegionName` format expected by
|
|
25
|
+
* the Retail Prices API (lowercase, no spaces). The Azure SDK sometimes
|
|
26
|
+
* returns the display name (`"West Europe"`) instead of the ARM name
|
|
27
|
+
* (`"westeurope"`); without this normalisation the OData filter would
|
|
28
|
+
* silently miss every entry.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeArmRegion(region) {
|
|
31
|
+
return region.toLowerCase().replace(/\s+/g, "");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the estimated monthly cost for a VM SKU. Returns `undefined`
|
|
35
|
+
* if no matching consumption meter can be found.
|
|
36
|
+
*/
|
|
37
|
+
export async function resolveVmMonthlyPrice(client, input) {
|
|
38
|
+
const filter = [
|
|
39
|
+
"serviceName eq 'Virtual Machines'",
|
|
40
|
+
`armRegionName eq '${normalizeArmRegion(input.armRegionName)}'`,
|
|
41
|
+
`armSkuName eq '${input.armSkuName}'`,
|
|
42
|
+
].join(" and ");
|
|
43
|
+
const items = await client.query(filter);
|
|
44
|
+
const item = pickVmItem(items, input.os ?? "linux");
|
|
45
|
+
if (!item) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
amount: round2(item.unitPrice * HOURS_PER_MONTH),
|
|
50
|
+
currency: item.currencyCode,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function isSpotOrLowPriority(item) {
|
|
54
|
+
const sku = item.skuName?.toLowerCase() ?? "";
|
|
55
|
+
const meter = item.meterName?.toLowerCase() ?? "";
|
|
56
|
+
return (sku.includes("spot") ||
|
|
57
|
+
sku.includes("low priority") ||
|
|
58
|
+
meter.includes("spot") ||
|
|
59
|
+
meter.includes("low priority"));
|
|
60
|
+
}
|
|
61
|
+
function matchesOs(item, os) {
|
|
62
|
+
const product = item.productName?.toLowerCase() ?? "";
|
|
63
|
+
const isWindowsItem = product.includes("windows");
|
|
64
|
+
return os === "windows" ? isWindowsItem : !isWindowsItem;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Picks the most appropriate Retail Prices entry for the given OS hint.
|
|
68
|
+
*
|
|
69
|
+
* Filters out:
|
|
70
|
+
* - non-Consumption entries (Reservations, Savings Plans, …)
|
|
71
|
+
* - Spot / Low Priority entries (variable pricing)
|
|
72
|
+
* - Windows entries when the hint is `linux` and vice versa
|
|
73
|
+
*
|
|
74
|
+
* Then prefers the entry with the lowest `unitPrice` to act as a
|
|
75
|
+
* conservative lower bound.
|
|
76
|
+
*/
|
|
77
|
+
function pickVmItem(items, os) {
|
|
78
|
+
const candidates = items.filter((it) => it.type === "Consumption" &&
|
|
79
|
+
it.unitOfMeasure === "1 Hour" &&
|
|
80
|
+
!isSpotOrLowPriority(it) &&
|
|
81
|
+
matchesOs(it, os));
|
|
82
|
+
if (candidates.length === 0)
|
|
83
|
+
return undefined;
|
|
84
|
+
return candidates.reduce((cheapest, it) => it.unitPrice < cheapest.unitPrice ? it : cheapest);
|
|
85
|
+
}
|
|
86
|
+
function round2(value) {
|
|
87
|
+
return Math.round(value * 100) / 100;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=vm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.js","sourceRoot":"","sources":["../../../../src/azure/pricing/resolvers/vm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAiBnC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAqB,EACrB,KAAqB;IAErB,MAAM,MAAM,GAAG;QACb,mCAAmC;QACnC,qBAAqB,kBAAkB,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG;QAC/D,kBAAkB,KAAK,CAAC,UAAU,GAAG;KACtC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;QAChD,QAAQ,EAAE,IAAI,CAAC,YAAY;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAe;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAClD,OAAO,CACL,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpB,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC5B,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACtB,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAe,EAAE,EAAQ;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACtD,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,KAAkB,EAAE,EAAQ;IAC9C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,EAAE,EAAE,EAAE,CACL,EAAE,CAAC,IAAI,KAAK,aAAa;QACzB,EAAE,CAAC,aAAa,KAAK,QAAQ;QAC7B,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACxB,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CACpB,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CACxC,EAAE,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the Azure Retail Prices REST API.
|
|
3
|
+
*
|
|
4
|
+
* Endpoint: https://prices.azure.com/api/retail/prices
|
|
5
|
+
* Docs: https://learn.microsoft.com/rest/api/cost-management/retail-prices/azure-retail-prices
|
|
6
|
+
*
|
|
7
|
+
* The API returns a flat list of `Items` (one per meter) plus an optional
|
|
8
|
+
* `NextPageLink` for pagination. Extra fields returned by Azure are tolerated,
|
|
9
|
+
* but the fields used by pricing logic are validated with narrow shapes.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/**
|
|
13
|
+
* A single priced meter returned by the Retail Prices API.
|
|
14
|
+
*
|
|
15
|
+
* Notable fields:
|
|
16
|
+
* - `unitPrice`: list price per `unitOfMeasure` (e.g. "1 Hour", "1 GB/Month")
|
|
17
|
+
* - `retailPrice`: typically equals `unitPrice` but kept distinct by Azure
|
|
18
|
+
* - `armSkuName`: ARM SKU identifier (e.g. "Standard_B2s") — present for
|
|
19
|
+
* VM/compute meters, absent for some services (Bandwidth, Support, …)
|
|
20
|
+
* - `reservationTerm`: present ONLY for Reservation meters; consumers that
|
|
21
|
+
* want on-demand pricing must filter by `type === "Consumption"`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PriceItemSchema: z.ZodObject<{
|
|
24
|
+
armRegionName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
armSkuName: z.ZodOptional<z.ZodString>;
|
|
26
|
+
currencyCode: z.ZodString;
|
|
27
|
+
effectiveStartDate: z.ZodOptional<z.ZodString>;
|
|
28
|
+
isPrimaryMeterRegion: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
location: z.ZodOptional<z.ZodString>;
|
|
30
|
+
meterId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
meterName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
productName: z.ZodOptional<z.ZodString>;
|
|
34
|
+
reservationTerm: z.ZodOptional<z.ZodString>;
|
|
35
|
+
retailPrice: z.ZodNumber;
|
|
36
|
+
serviceFamily: z.ZodOptional<z.ZodString>;
|
|
37
|
+
serviceId: z.ZodOptional<z.ZodString>;
|
|
38
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
39
|
+
skuId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
skuName: z.ZodOptional<z.ZodString>;
|
|
41
|
+
tierMinimumUnits: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
type: z.ZodEnum<{
|
|
43
|
+
Consumption: "Consumption";
|
|
44
|
+
DevTestConsumption: "DevTestConsumption";
|
|
45
|
+
Reservation: "Reservation";
|
|
46
|
+
}>;
|
|
47
|
+
unitOfMeasure: z.ZodString;
|
|
48
|
+
unitPrice: z.ZodNumber;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type PriceItem = z.infer<typeof PriceItemSchema>;
|
|
51
|
+
/**
|
|
52
|
+
* Top-level response envelope. `Count` reflects the number of items in the
|
|
53
|
+
* current page, not the grand total.
|
|
54
|
+
*/
|
|
55
|
+
export declare const PricingResponseSchema: z.ZodObject<{
|
|
56
|
+
BillingCurrency: z.ZodOptional<z.ZodString>;
|
|
57
|
+
Count: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
Items: z.ZodArray<z.ZodObject<{
|
|
59
|
+
armRegionName: z.ZodOptional<z.ZodString>;
|
|
60
|
+
armSkuName: z.ZodOptional<z.ZodString>;
|
|
61
|
+
currencyCode: z.ZodString;
|
|
62
|
+
effectiveStartDate: z.ZodOptional<z.ZodString>;
|
|
63
|
+
isPrimaryMeterRegion: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
location: z.ZodOptional<z.ZodString>;
|
|
65
|
+
meterId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
meterName: z.ZodOptional<z.ZodString>;
|
|
67
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
productName: z.ZodOptional<z.ZodString>;
|
|
69
|
+
reservationTerm: z.ZodOptional<z.ZodString>;
|
|
70
|
+
retailPrice: z.ZodNumber;
|
|
71
|
+
serviceFamily: z.ZodOptional<z.ZodString>;
|
|
72
|
+
serviceId: z.ZodOptional<z.ZodString>;
|
|
73
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
74
|
+
skuId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
skuName: z.ZodOptional<z.ZodString>;
|
|
76
|
+
tierMinimumUnits: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
type: z.ZodEnum<{
|
|
78
|
+
Consumption: "Consumption";
|
|
79
|
+
DevTestConsumption: "DevTestConsumption";
|
|
80
|
+
Reservation: "Reservation";
|
|
81
|
+
}>;
|
|
82
|
+
unitOfMeasure: z.ZodString;
|
|
83
|
+
unitPrice: z.ZodNumber;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
NextPageLink: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type PricingResponse = z.infer<typeof PricingResponseSchema>;
|
|
88
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/azure/pricing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuB1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the Azure Retail Prices REST API.
|
|
3
|
+
*
|
|
4
|
+
* Endpoint: https://prices.azure.com/api/retail/prices
|
|
5
|
+
* Docs: https://learn.microsoft.com/rest/api/cost-management/retail-prices/azure-retail-prices
|
|
6
|
+
*
|
|
7
|
+
* The API returns a flat list of `Items` (one per meter) plus an optional
|
|
8
|
+
* `NextPageLink` for pagination. Extra fields returned by Azure are tolerated,
|
|
9
|
+
* but the fields used by pricing logic are validated with narrow shapes.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
const NonEmptyStringSchema = z.string().min(1);
|
|
13
|
+
const PriceTypeSchema = z.enum([
|
|
14
|
+
"Consumption",
|
|
15
|
+
"DevTestConsumption",
|
|
16
|
+
"Reservation",
|
|
17
|
+
]);
|
|
18
|
+
const PriceValueSchema = z.number().finite().nonnegative();
|
|
19
|
+
/**
|
|
20
|
+
* A single priced meter returned by the Retail Prices API.
|
|
21
|
+
*
|
|
22
|
+
* Notable fields:
|
|
23
|
+
* - `unitPrice`: list price per `unitOfMeasure` (e.g. "1 Hour", "1 GB/Month")
|
|
24
|
+
* - `retailPrice`: typically equals `unitPrice` but kept distinct by Azure
|
|
25
|
+
* - `armSkuName`: ARM SKU identifier (e.g. "Standard_B2s") — present for
|
|
26
|
+
* VM/compute meters, absent for some services (Bandwidth, Support, …)
|
|
27
|
+
* - `reservationTerm`: present ONLY for Reservation meters; consumers that
|
|
28
|
+
* want on-demand pricing must filter by `type === "Consumption"`.
|
|
29
|
+
*/
|
|
30
|
+
export const PriceItemSchema = z.object({
|
|
31
|
+
armRegionName: NonEmptyStringSchema.optional(),
|
|
32
|
+
armSkuName: NonEmptyStringSchema.optional(),
|
|
33
|
+
currencyCode: z.string().length(3),
|
|
34
|
+
effectiveStartDate: NonEmptyStringSchema.optional(),
|
|
35
|
+
isPrimaryMeterRegion: z.boolean().optional(),
|
|
36
|
+
location: NonEmptyStringSchema.optional(),
|
|
37
|
+
meterId: NonEmptyStringSchema.optional(),
|
|
38
|
+
meterName: NonEmptyStringSchema.optional(),
|
|
39
|
+
productId: NonEmptyStringSchema.optional(),
|
|
40
|
+
productName: NonEmptyStringSchema.optional(),
|
|
41
|
+
reservationTerm: NonEmptyStringSchema.optional(),
|
|
42
|
+
retailPrice: PriceValueSchema,
|
|
43
|
+
serviceFamily: NonEmptyStringSchema.optional(),
|
|
44
|
+
serviceId: NonEmptyStringSchema.optional(),
|
|
45
|
+
serviceName: NonEmptyStringSchema.optional(),
|
|
46
|
+
skuId: NonEmptyStringSchema.optional(),
|
|
47
|
+
skuName: NonEmptyStringSchema.optional(),
|
|
48
|
+
tierMinimumUnits: PriceValueSchema.optional(),
|
|
49
|
+
/** "Consumption" | "Reservation" | "DevTestConsumption". */
|
|
50
|
+
type: PriceTypeSchema,
|
|
51
|
+
unitOfMeasure: NonEmptyStringSchema,
|
|
52
|
+
unitPrice: PriceValueSchema,
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Top-level response envelope. `Count` reflects the number of items in the
|
|
56
|
+
* current page, not the grand total.
|
|
57
|
+
*/
|
|
58
|
+
export const PricingResponseSchema = z.object({
|
|
59
|
+
BillingCurrency: z.string().length(3).optional(),
|
|
60
|
+
Count: z.number().int().nonnegative().optional(),
|
|
61
|
+
Items: z.array(PriceItemSchema),
|
|
62
|
+
NextPageLink: z.string().url().nullable().optional(),
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=schema.js.map
|