@azure/api-management-custom-widgets-tools
Advanced tools
Comparing version 1.0.0-alpha.20240112.1 to 1.0.0-alpha.20240116.1
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { __asyncValues } from "tslib"; | ||
import { BlobServiceClient } from "@azure/storage-blob"; | ||
@@ -40,5 +41,18 @@ import { buildBlobConfigPath, buildBlobDataPath } from "../paths"; | ||
async dirDelete(absolutePath) { | ||
for await (const blob of await this.containerClient.listBlobsFlat({ prefix: absolutePath })) { | ||
await this.containerClient.deleteBlob(blob.name); | ||
var _a, e_1, _b, _c; | ||
try { | ||
for (var _d = true, _e = __asyncValues(await this.containerClient.listBlobsFlat({ prefix: absolutePath })), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { | ||
_c = _f.value; | ||
_d = false; | ||
const blob = _c; | ||
await this.containerClient.deleteBlob(blob.name); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (!_d && !_a && (_b = _e.return)) await _b.call(_e); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
@@ -45,0 +59,0 @@ async uploadWidgetDataFile(file, content) { |
@@ -17,2 +17,3 @@ // Copyright (c) Microsoft Corporation. | ||
async function getStorageSasUrl({ managementApiEndpoint, resourceId, apiVersion = "2019-01-01", tokenOverride, }, interactiveBrowserCredentialOptions) { | ||
var _a; | ||
const httpClient = getClient(`${managementApiEndpoint}/${resourceId}`, { apiVersion }); | ||
@@ -25,7 +26,6 @@ const response = await httpClient | ||
"Content-Type": "application/json", | ||
Authorization: tokenOverride ?? | ||
(await getAccessToken(managementApiEndpoint, interactiveBrowserCredentialOptions)), | ||
Authorization: tokenOverride !== null && tokenOverride !== void 0 ? tokenOverride : (await getAccessToken(managementApiEndpoint, interactiveBrowserCredentialOptions)), | ||
}, | ||
}); | ||
if (!response?.body?.containerSasUrl) | ||
if (!((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.containerSasUrl)) | ||
throw new Error("Could not get storage SAS URL"); | ||
@@ -32,0 +32,0 @@ return response.body.containerSasUrl; |
@@ -16,4 +16,5 @@ // Copyright (c) Microsoft Corporation. | ||
function parseWidgetData(urlSearchParams) { | ||
var _a; | ||
try { | ||
const urlEditorParams = JSON.parse(decodeURIComponent(urlSearchParams.get(APIM_EDITOR_DATA_KEY) ?? "")); | ||
const urlEditorParams = JSON.parse(decodeURIComponent((_a = urlSearchParams.get(APIM_EDITOR_DATA_KEY)) !== null && _a !== void 0 ? _a : "")); | ||
// if (!("origin" in urlEditorParams)) { | ||
@@ -52,3 +53,3 @@ // console.error( | ||
export function getValuesPure(valuesDefault, urlSearchParams) { | ||
const values = { ...valuesDefault }; // set Obj to contain all possible values and prefill default value | ||
const values = Object.assign({}, valuesDefault); // set Obj to contain all possible values and prefill default value | ||
const urlValues = parseWidgetData(urlSearchParams).values; | ||
@@ -55,0 +56,0 @@ Object.keys(values).forEach((key) => { |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var tslib = require('tslib'); | ||
var storageBlob = require('@azure/storage-blob'); | ||
@@ -28,4 +29,5 @@ var mime = require('mime'); | ||
function parseWidgetData(urlSearchParams) { | ||
var _a; | ||
try { | ||
const urlEditorParams = JSON.parse(decodeURIComponent(urlSearchParams.get(APIM_EDITOR_DATA_KEY) ?? "")); | ||
const urlEditorParams = JSON.parse(decodeURIComponent((_a = urlSearchParams.get(APIM_EDITOR_DATA_KEY)) !== null && _a !== void 0 ? _a : "")); | ||
// if (!("origin" in urlEditorParams)) { | ||
@@ -64,3 +66,3 @@ // console.error( | ||
function getValuesPure(valuesDefault, urlSearchParams) { | ||
const values = { ...valuesDefault }; // set Obj to contain all possible values and prefill default value | ||
const values = Object.assign({}, valuesDefault); // set Obj to contain all possible values and prefill default value | ||
const urlValues = parseWidgetData(urlSearchParams).values; | ||
@@ -200,5 +202,18 @@ Object.keys(values).forEach((key) => { | ||
async dirDelete(absolutePath) { | ||
for await (const blob of await this.containerClient.listBlobsFlat({ prefix: absolutePath })) { | ||
await this.containerClient.deleteBlob(blob.name); | ||
var _a, e_1, _b, _c; | ||
try { | ||
for (var _d = true, _e = tslib.__asyncValues(await this.containerClient.listBlobsFlat({ prefix: absolutePath })), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { | ||
_c = _f.value; | ||
_d = false; | ||
const blob = _c; | ||
await this.containerClient.deleteBlob(blob.name); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (!_d && !_a && (_b = _e.return)) await _b.call(_e); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
@@ -235,2 +250,3 @@ async uploadWidgetDataFile(file, content) { | ||
async function getStorageSasUrl({ managementApiEndpoint, resourceId, apiVersion = "2019-01-01", tokenOverride, }, interactiveBrowserCredentialOptions) { | ||
var _a; | ||
const httpClient = coreClient.getClient(`${managementApiEndpoint}/${resourceId}`, { apiVersion }); | ||
@@ -243,7 +259,6 @@ const response = await httpClient | ||
"Content-Type": "application/json", | ||
Authorization: tokenOverride ?? | ||
(await getAccessToken(managementApiEndpoint, interactiveBrowserCredentialOptions)), | ||
Authorization: tokenOverride !== null && tokenOverride !== void 0 ? tokenOverride : (await getAccessToken(managementApiEndpoint, interactiveBrowserCredentialOptions)), | ||
}, | ||
}); | ||
if (!response?.body?.containerSasUrl) | ||
if (!((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.containerSasUrl)) | ||
throw new Error("Could not get storage SAS URL"); | ||
@@ -250,0 +265,0 @@ return response.body.containerSasUrl; |
{ | ||
"name": "@azure/api-management-custom-widgets-tools", | ||
"version": "1.0.0-alpha.20240112.1", | ||
"version": "1.0.0-alpha.20240116.1", | ||
"author": "Microsoft Corporation", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98638
825