@stack0/sdk 0.5.17 → 0.5.18
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/cdn/index.d.mts +77 -1
- package/dist/cdn/index.d.ts +77 -1
- package/dist/cdn/index.js +30 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +30 -0
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1953,6 +1953,36 @@ var CDN = class {
|
|
|
1953
1953
|
const query = params.toString();
|
|
1954
1954
|
return this.http.get(`/cdn/usage/storage-breakdown${query ? `?${query}` : ""}`);
|
|
1955
1955
|
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Get total stored bytes for a project or folder, derived assets included.
|
|
1958
|
+
*
|
|
1959
|
+
* Totals uploads plus everything the pipelines derived from them — video renditions, HLS
|
|
1960
|
+
* segments and manifests, thumbnails, GIFs — in one call. Use this to meter a plan limit:
|
|
1961
|
+
* paging `list()` and summing `size` counts uploads only, and an HLS ladder typically runs
|
|
1962
|
+
* well past the size of the source it came from.
|
|
1963
|
+
*
|
|
1964
|
+
* Check `unmeasuredAssets`. A nonzero value means some assets have derivatives whose bytes
|
|
1965
|
+
* have not been measured, so `totalBytes` is a floor rather than the full number.
|
|
1966
|
+
*
|
|
1967
|
+
* @example
|
|
1968
|
+
* ```typescript
|
|
1969
|
+
* const usage = await cdn.getStorageUsage({
|
|
1970
|
+
* projectSlug: 'my-project',
|
|
1971
|
+
* folder: '/customers/acme',
|
|
1972
|
+
* });
|
|
1973
|
+
* console.log(`${usage.totalFormatted} across ${usage.objectCount} objects`);
|
|
1974
|
+
* console.log(` uploads: ${usage.breakdown.originals.bytesFormatted}`);
|
|
1975
|
+
* console.log(` derived: ${usage.breakdown.derived.bytesFormatted}`);
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
async getStorageUsage(request = {}) {
|
|
1979
|
+
const params = new URLSearchParams();
|
|
1980
|
+
if (request.projectSlug) params.set("projectSlug", request.projectSlug);
|
|
1981
|
+
if (request.environment) params.set("environment", request.environment);
|
|
1982
|
+
if (request.folder) params.set("folder", request.folder);
|
|
1983
|
+
const query = params.toString();
|
|
1984
|
+
return this.http.get(`/cdn/usage/storage${query ? `?${query}` : ""}`);
|
|
1985
|
+
}
|
|
1956
1986
|
convertUsageDates(usage) {
|
|
1957
1987
|
if (typeof usage.periodStart === "string") {
|
|
1958
1988
|
usage.periodStart = new Date(usage.periodStart);
|