@azure/api-management-custom-widgets-tools 1.0.0-beta.1 → 1.0.0-beta.3
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/LICENSE +17 -17
- package/README.md +3 -3
- package/dist/browser/index.d.ts +10 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/index.js +4 -4
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/node/CustomWidgetBlobService.d.ts +27 -0
- package/dist/browser/node/CustomWidgetBlobService.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/node/CustomWidgetBlobService.js +10 -17
- package/dist/browser/node/CustomWidgetBlobService.js.map +1 -0
- package/dist/browser/node/deploy-browser.d.mts.map +1 -0
- package/dist/browser/node/deploy-browser.mjs.map +1 -0
- package/dist/browser/node/deploy.d.ts +3 -0
- package/dist/browser/node/deploy.js +7 -0
- package/dist/browser/node/getStorageSasUrl.d.ts +10 -0
- package/dist/browser/node/getStorageSasUrl.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/node/getStorageSasUrl.js +8 -8
- package/dist/browser/node/getStorageSasUrl.js.map +1 -0
- package/dist/browser/node/readdir-browser.d.mts.map +1 -0
- package/dist/browser/node/readdir-browser.mjs.map +1 -0
- package/dist/browser/node/readdir.d.ts +3 -0
- package/dist/browser/node/readdir.js +7 -0
- package/dist/browser/node/types.d.ts +24 -0
- package/dist/browser/node/types.d.ts.map +1 -0
- package/dist/browser/node/types.js +4 -0
- package/dist/browser/node/types.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/paths.d.ts +21 -0
- package/dist/browser/paths.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/paths.js +1 -1
- package/{dist-esm/src → dist/browser}/paths.js.map +1 -1
- package/{types/latest/api-management-custom-widgets-tools.d.ts → dist/browser/utils.d.ts} +98 -154
- package/dist/browser/utils.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/utils.js +4 -5
- package/dist/browser/utils.js.map +1 -0
- package/dist/commonjs/index.d.ts +10 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +29 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/node/CustomWidgetBlobService.d.ts +27 -0
- package/dist/commonjs/node/CustomWidgetBlobService.d.ts.map +1 -0
- package/dist/commonjs/node/CustomWidgetBlobService.js +68 -0
- package/dist/commonjs/node/CustomWidgetBlobService.js.map +1 -0
- package/dist/commonjs/node/deploy.d.ts +12 -0
- package/dist/commonjs/node/deploy.d.ts.map +1 -0
- package/dist/commonjs/node/deploy.js +59 -0
- package/dist/commonjs/node/deploy.js.map +1 -0
- package/dist/commonjs/node/getStorageSasUrl.d.ts +10 -0
- package/dist/commonjs/node/getStorageSasUrl.d.ts.map +1 -0
- package/dist/commonjs/node/getStorageSasUrl.js +35 -0
- package/dist/commonjs/node/getStorageSasUrl.js.map +1 -0
- package/dist/commonjs/node/readdir.d.ts +3 -0
- package/dist/commonjs/node/readdir.d.ts.map +1 -0
- package/dist/commonjs/node/readdir.js +22 -0
- package/dist/commonjs/node/readdir.js.map +1 -0
- package/dist/commonjs/node/types.d.ts +24 -0
- package/dist/commonjs/node/types.d.ts.map +1 -0
- package/dist/commonjs/node/types.js +5 -0
- package/dist/commonjs/node/types.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/paths.d.ts +21 -0
- package/dist/commonjs/paths.d.ts.map +1 -0
- package/dist/commonjs/paths.js +32 -0
- package/dist/commonjs/paths.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/utils.d.ts +98 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +134 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node/CustomWidgetBlobService.d.ts +27 -0
- package/dist/esm/node/CustomWidgetBlobService.d.ts.map +1 -0
- package/dist/esm/node/CustomWidgetBlobService.js +64 -0
- package/dist/esm/node/CustomWidgetBlobService.js.map +1 -0
- package/dist/esm/node/deploy.d.ts +12 -0
- package/dist/esm/node/deploy.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/node/deploy.js +9 -9
- package/dist/esm/node/deploy.js.map +1 -0
- package/dist/esm/node/getStorageSasUrl.d.ts +10 -0
- package/dist/esm/node/getStorageSasUrl.d.ts.map +1 -0
- package/dist/esm/node/getStorageSasUrl.js +33 -0
- package/dist/esm/node/getStorageSasUrl.js.map +1 -0
- package/dist/esm/node/readdir.d.ts +3 -0
- package/dist/esm/node/readdir.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/node/readdir.js +3 -3
- package/dist/esm/node/readdir.js.map +1 -0
- package/dist/esm/node/types.d.ts +24 -0
- package/dist/esm/node/types.d.ts.map +1 -0
- package/dist/esm/node/types.js +4 -0
- package/dist/esm/node/types.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/paths.d.ts +21 -0
- package/dist/esm/paths.d.ts.map +1 -0
- package/dist/esm/paths.js +27 -0
- package/dist/esm/paths.js.map +1 -0
- package/dist/esm/utils.d.ts +98 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +122 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +70 -85
- package/dist/index.js +0 -344
- package/dist/index.js.map +0 -1
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/node/CustomWidgetBlobService.js.map +0 -1
- package/dist-esm/src/node/deploy.browser.js +0 -7
- package/dist-esm/src/node/deploy.browser.js.map +0 -1
- package/dist-esm/src/node/deploy.js.map +0 -1
- package/dist-esm/src/node/getStorageSasUrl.js.map +0 -1
- package/dist-esm/src/node/readdir.js.map +0 -1
- package/dist-esm/src/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/api-management-custom-widgets-tools",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sdk-type": "client",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/apimanagement/api-management-custom-widgets-tools/README.md",
|
|
8
9
|
"repository": "github:Azure/azure-sdk-for-js",
|
|
9
|
-
"browser": {
|
|
10
|
-
"./dist-esm/src/node/deploy.js": "./dist-esm/src/node/deploy.browser.js"
|
|
11
|
-
},
|
|
12
10
|
"bugs": {
|
|
13
11
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
14
12
|
},
|
|
15
13
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
14
|
+
"node": ">=20.0.0"
|
|
17
15
|
},
|
|
18
16
|
"keywords": [
|
|
19
17
|
"azure",
|
|
@@ -25,89 +23,76 @@
|
|
|
25
23
|
"sideEffects": false,
|
|
26
24
|
"files": [
|
|
27
25
|
"dist/",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"LICENSE"
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"README.md"
|
|
31
28
|
],
|
|
32
|
-
"main": "dist/index.js",
|
|
33
|
-
"module": "dist-esm/src/index.js",
|
|
34
|
-
"types": "types/latest/api-management-custom-widgets-tools.d.ts",
|
|
35
|
-
"scripts": {
|
|
36
|
-
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
37
|
-
"build:browser": "tsc -p . && dev-tool run bundle --browser-test=false",
|
|
38
|
-
"build:node": "tsc -p . && dev-tool run bundle",
|
|
39
|
-
"build:test": "npm run clean && tsc -p . && dev-tool run bundle",
|
|
40
|
-
"build:samples": "echo skip",
|
|
41
|
-
"build": "npm run clean && tsc -p . && dev-tool run bundle --browser-test=false && api-extractor run --local",
|
|
42
|
-
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
43
|
-
"clean": "rimraf dist dist-* types *.tgz *.log",
|
|
44
|
-
"extract-api": "tsc -p . && api-extractor run --local",
|
|
45
|
-
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
46
|
-
"integration-test:browser": "dev-tool run test:browser",
|
|
47
|
-
"integration-test:node": "echo skip",
|
|
48
|
-
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
49
|
-
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
|
50
|
-
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
|
51
|
-
"pack": "npm pack 2>&1",
|
|
52
|
-
"test:browser": "echo skip",
|
|
53
|
-
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
54
|
-
"test": "npm run clean && npm run build:test && npm run unit-test && npm run integration-test",
|
|
55
|
-
"unit-test:browser": "echo skip",
|
|
56
|
-
"unit-test:node": "npm run integration-test:node",
|
|
57
|
-
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
58
|
-
},
|
|
59
29
|
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.19.0",
|
|
31
|
+
"@vitest/browser": "^3.2.3",
|
|
32
|
+
"@vitest/coverage-istanbul": "^3.2.3",
|
|
33
|
+
"eslint": "^9.33.0",
|
|
34
|
+
"playwright": "^1.50.1",
|
|
35
|
+
"typescript": "~5.8.3",
|
|
36
|
+
"vitest": "^3.2.3",
|
|
60
37
|
"@azure/dev-tool": "^1.0.0",
|
|
61
|
-
"@azure
|
|
62
|
-
"@microsoft/api-extractor": "7.18.11",
|
|
63
|
-
"@types/chai": "^4.1.6",
|
|
64
|
-
"@types/mocha": "^7.0.2",
|
|
65
|
-
"@types/mime": "~2.0.3",
|
|
66
|
-
"@types/node": "^12.0.0",
|
|
67
|
-
"@types/glob": "^7.1.1",
|
|
68
|
-
"@types/inquirer": "^8.2.1",
|
|
69
|
-
"@types/yargs": "^17.0.10",
|
|
70
|
-
"@types/yargs-parser": "^21.0.0",
|
|
71
|
-
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
72
|
-
"chai": "^4.2.0",
|
|
73
|
-
"cross-env": "^7.0.2",
|
|
74
|
-
"eslint": "^7.15.0",
|
|
75
|
-
"mocha": "^7.1.1",
|
|
76
|
-
"mocha-junit-reporter": "^2.0.0",
|
|
77
|
-
"prettier": "^2.5.1",
|
|
78
|
-
"nyc": "^15.0.0",
|
|
79
|
-
"rimraf": "^3.0.0",
|
|
80
|
-
"typescript": "~4.6.0",
|
|
81
|
-
"util": "^0.12.1",
|
|
82
|
-
"dotenv": "^8.2.0",
|
|
83
|
-
"@azure/test-utils": "^1.0.0",
|
|
84
|
-
"@types/mustache": "4.1.2",
|
|
85
|
-
"sinon": "^9.0.4",
|
|
86
|
-
"karma": "^6.2.0",
|
|
87
|
-
"karma-chrome-launcher": "^3.0.0",
|
|
88
|
-
"karma-coverage": "^2.0.0",
|
|
89
|
-
"karma-edge-launcher": "^0.4.2",
|
|
90
|
-
"karma-env-preprocessor": "^0.1.1",
|
|
91
|
-
"karma-firefox-launcher": "^1.1.0",
|
|
92
|
-
"karma-ie-launcher": "^1.0.0",
|
|
93
|
-
"karma-json-preprocessor": "^0.3.3",
|
|
94
|
-
"karma-json-to-file-reporter": "^1.0.1",
|
|
95
|
-
"karma-junit-reporter": "^2.0.1",
|
|
96
|
-
"karma-mocha": "^2.0.1",
|
|
97
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
98
|
-
"@types/sinon": "^9.0.4"
|
|
38
|
+
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
|
|
99
39
|
},
|
|
100
40
|
"dependencies": {
|
|
101
|
-
"@azure/
|
|
102
|
-
"@azure
|
|
103
|
-
"@azure/storage-blob": "^12.
|
|
104
|
-
"mime": "^
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
41
|
+
"@azure-rest/core-client": "^1.3.1",
|
|
42
|
+
"@azure/identity": "^4.0.1",
|
|
43
|
+
"@azure/storage-blob": "^12.17.0",
|
|
44
|
+
"mime": "^4.0.1",
|
|
45
|
+
"tslib": "^2.6.2"
|
|
46
|
+
},
|
|
47
|
+
"tshy": {
|
|
48
|
+
"exports": {
|
|
49
|
+
"./package.json": "./package.json",
|
|
50
|
+
".": "./src/index.ts"
|
|
51
|
+
},
|
|
52
|
+
"dialects": [
|
|
53
|
+
"esm",
|
|
54
|
+
"commonjs"
|
|
55
|
+
],
|
|
56
|
+
"esmDialects": [
|
|
57
|
+
"browser"
|
|
58
|
+
],
|
|
59
|
+
"selfLink": false,
|
|
60
|
+
"project": "../../../tsconfig.src.build.json"
|
|
61
|
+
},
|
|
62
|
+
"exports": {
|
|
63
|
+
"./package.json": "./package.json",
|
|
64
|
+
".": {
|
|
65
|
+
"browser": {
|
|
66
|
+
"types": "./dist/browser/index.d.ts",
|
|
67
|
+
"default": "./dist/browser/index.js"
|
|
68
|
+
},
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./dist/esm/index.d.ts",
|
|
71
|
+
"default": "./dist/esm/index.js"
|
|
72
|
+
},
|
|
73
|
+
"require": {
|
|
74
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
75
|
+
"default": "./dist/commonjs/index.js"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"main": "./dist/commonjs/index.js",
|
|
80
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
81
|
+
"module": "./dist/esm/index.js",
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
|
|
84
|
+
"build:samples": "echo Skipped.",
|
|
85
|
+
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
86
|
+
"clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log",
|
|
87
|
+
"extract-api": "tsc -p . && dev-tool run extract-api",
|
|
88
|
+
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
89
|
+
"lint": "eslint package.json src test",
|
|
90
|
+
"lint:fix": "eslint package.json src test --fix --fix-type [problem,suggestion]",
|
|
91
|
+
"pack": "pnpm pack 2>&1",
|
|
92
|
+
"test": "npm run test:node && npm run test:browser",
|
|
93
|
+
"test:browser": "dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser",
|
|
94
|
+
"test:node": "dev-tool run test:vitest --no-test-proxy",
|
|
95
|
+
"test:node:esm": "dev-tool run test:vitest --esm --no-test-proxy",
|
|
96
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
112
97
|
}
|
|
113
|
-
}
|
|
98
|
+
}
|
package/dist/index.js
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var storageBlob = require('@azure/storage-blob');
|
|
7
|
-
var mime = require('mime');
|
|
8
|
-
var fs = require('fs');
|
|
9
|
-
var identity = require('@azure/identity');
|
|
10
|
-
var coreClient = require('@azure-rest/core-client');
|
|
11
|
-
var path = require('path');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
|
|
16
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
17
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
18
|
-
|
|
19
|
-
// Copyright (c) Microsoft Corporation.
|
|
20
|
-
// Licensed under the MIT license.
|
|
21
|
-
/**
|
|
22
|
-
* Key for a search param, from which editor data will be loaded from.
|
|
23
|
-
*/
|
|
24
|
-
const APIM_EDITOR_DATA_KEY = "editorData";
|
|
25
|
-
/**
|
|
26
|
-
* Key for a post message object, it's used to propagate changes from editor to the DevPortal. Used to prevent interference with other applications.
|
|
27
|
-
*/
|
|
28
|
-
const APIM_ON_CHANGE_MESSAGE_KEY = "customInputValueChangedMSAPIM";
|
|
29
|
-
/**
|
|
30
|
-
* Key for a post message object, it's used to request and send secrets - token and user id, from the DevPortal. Used to prevent interference with other applications.
|
|
31
|
-
*/
|
|
32
|
-
const APIM_ASK_FOR_SECRETS_MESSAGE_KEY = "askForSecretsMSAPIM";
|
|
33
|
-
function parseWidgetData(urlSearchParams) {
|
|
34
|
-
var _a;
|
|
35
|
-
try {
|
|
36
|
-
const urlEditorParams = JSON.parse(decodeURIComponent((_a = urlSearchParams.get(APIM_EDITOR_DATA_KEY)) !== null && _a !== void 0 ? _a : ""));
|
|
37
|
-
// if (!("origin" in urlEditorParams)) {
|
|
38
|
-
// console.error(
|
|
39
|
-
// "Could not get 'origin' from the search params of the URL:\n" + self.location.href
|
|
40
|
-
// );
|
|
41
|
-
// }
|
|
42
|
-
return urlEditorParams;
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
console.error(`Could not get '${APIM_EDITOR_DATA_KEY}' from the search params of the URL:\n` +
|
|
46
|
-
self.location, e);
|
|
47
|
-
return { values: {}, environment: "error", instanceId: "error" };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function getWidgetDataPure(urlSearchParams) {
|
|
51
|
-
return parseWidgetData(urlSearchParams);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Function to get all data related to the widget including technical values not expected to be needed in most cases.
|
|
55
|
-
* Intended mostly for internal use, API might change. Consider using getValues or getEditorValues instead.
|
|
56
|
-
*/
|
|
57
|
-
function getWidgetData() {
|
|
58
|
-
return getWidgetDataPure(new URLSearchParams(self.location.search));
|
|
59
|
-
}
|
|
60
|
-
function getEditorValuesPure(urlSearchParams) {
|
|
61
|
-
return getWidgetDataPure(urlSearchParams).values;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Function to get values you've set in the admin editor window.
|
|
65
|
-
*/
|
|
66
|
-
function getEditorValues() {
|
|
67
|
-
return getEditorValuesPure(new URLSearchParams(self.location.search));
|
|
68
|
-
}
|
|
69
|
-
function getValuesPure(valuesDefault, urlSearchParams) {
|
|
70
|
-
const values = Object.assign({}, valuesDefault); // set Obj to contain all possible values and prefill default value
|
|
71
|
-
const urlValues = parseWidgetData(urlSearchParams).values;
|
|
72
|
-
Object.keys(values).forEach((key) => {
|
|
73
|
-
const value = urlValues[key];
|
|
74
|
-
if (value != null && value !== "")
|
|
75
|
-
values[key] = value; // if value is specified in the URL, replace the default value
|
|
76
|
-
});
|
|
77
|
-
return values;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Function to get values you've set in the admin editor window. Undefined/empty values are replaced with default values.
|
|
81
|
-
*
|
|
82
|
-
* @param valuesDefault - object with your default values to use, just import valuesDefault object from values.ts folder
|
|
83
|
-
*/
|
|
84
|
-
function getValues(valuesDefault) {
|
|
85
|
-
return getValuesPure(valuesDefault, new URLSearchParams(self.location.search));
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* The onChange function itself with 'origin' provided as a param.
|
|
89
|
-
*
|
|
90
|
-
* @param origin - web content's origin (URL) of your Dev Portal to send changes to
|
|
91
|
-
* @param instanceId - ID of this particular instance of the widget
|
|
92
|
-
* @param values - values that changed
|
|
93
|
-
*/
|
|
94
|
-
function onChangeWithOrigin(origin, instanceId, values) {
|
|
95
|
-
Object.entries(values).forEach(([key, value]) => {
|
|
96
|
-
self.parent.postMessage({ [APIM_ON_CHANGE_MESSAGE_KEY]: { key, value, instanceId } }, origin);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Build onChange function, which you can use, to send changed data from the editor.
|
|
101
|
-
*/
|
|
102
|
-
function buildOnChange() {
|
|
103
|
-
const { instanceId } = getWidgetData();
|
|
104
|
-
return (values) => onChangeWithOrigin("*", instanceId, values);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Request secrets - token & userId, from the Dev portal parent window.
|
|
108
|
-
*
|
|
109
|
-
* @param targetModule - is the function invoke from the main "app" window or the admin "editor"?
|
|
110
|
-
*/
|
|
111
|
-
async function askForSecrets(targetModule) {
|
|
112
|
-
let receiveSecrets;
|
|
113
|
-
const promise = new Promise((resolve, reject) => {
|
|
114
|
-
const { instanceId, environment } = getWidgetData();
|
|
115
|
-
receiveSecrets = ({ data }) => {
|
|
116
|
-
if (!(APIM_ASK_FOR_SECRETS_MESSAGE_KEY in data))
|
|
117
|
-
return;
|
|
118
|
-
const secrets = data[APIM_ASK_FOR_SECRETS_MESSAGE_KEY];
|
|
119
|
-
if (typeof secrets !== "object" || !("managementApiUrl" in secrets)) {
|
|
120
|
-
reject("Secrets send by Dev Portal are invalid");
|
|
121
|
-
}
|
|
122
|
-
resolve(secrets);
|
|
123
|
-
};
|
|
124
|
-
self.addEventListener("message", receiveSecrets);
|
|
125
|
-
const message = {
|
|
126
|
-
[APIM_ASK_FOR_SECRETS_MESSAGE_KEY]: {
|
|
127
|
-
instanceId,
|
|
128
|
-
origin: self.location.origin,
|
|
129
|
-
targetModule,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
if (targetModule === "app" && environment === "development") {
|
|
133
|
-
self.parent.parent.postMessage(message, "*");
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
self.parent.postMessage(message, "*");
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
return promise.finally(() => self.removeEventListener("message", receiveSecrets));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Copyright (c) Microsoft Corporation.
|
|
143
|
-
// Licensed under the MIT license.
|
|
144
|
-
/** root of the blob storage folder */
|
|
145
|
-
const BLOB_ROOT = "custom-widgets";
|
|
146
|
-
/** name of the blob storage folder with widget implementation */
|
|
147
|
-
const BLOB_DATA_FOLDER = "data";
|
|
148
|
-
/** name of the blob storage folder with widget configs */
|
|
149
|
-
const BLOB_CONFIGS_FOLDER = "configs";
|
|
150
|
-
/** name of the configuration file */
|
|
151
|
-
const APIM_CONFIG_FILE_NAME = "config.msapim.json";
|
|
152
|
-
/**
|
|
153
|
-
* Generate relative path for widgets' data on the blob storage
|
|
154
|
-
*
|
|
155
|
-
* @param name - name of the widget
|
|
156
|
-
*/
|
|
157
|
-
function buildBlobDataPath(name) {
|
|
158
|
-
return `${BLOB_ROOT}/${BLOB_DATA_FOLDER}/${name}/`;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Generate relative path for widgets' config on the blob storage
|
|
162
|
-
*
|
|
163
|
-
* @param name - name of the widget
|
|
164
|
-
*/
|
|
165
|
-
function buildBlobConfigPath(name) {
|
|
166
|
-
return `${BLOB_ROOT}/${BLOB_CONFIGS_FOLDER}/${name}/${APIM_CONFIG_FILE_NAME}`;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Copyright (c) Microsoft Corporation.
|
|
170
|
-
/**
|
|
171
|
-
* A service wrapping ContainerClient class to simplify blob handling
|
|
172
|
-
*/
|
|
173
|
-
class CustomWidgetBlobService {
|
|
174
|
-
/**
|
|
175
|
-
* @param blobStorageUrl - blob storage SAS URL
|
|
176
|
-
* @param name - name of the custom widget to be taken care of
|
|
177
|
-
*/
|
|
178
|
-
constructor(blobStorageUrl, name) {
|
|
179
|
-
const container = "content";
|
|
180
|
-
const blobServiceClient = new storageBlob.BlobServiceClient(blobStorageUrl.replace(`/${container}`, ""));
|
|
181
|
-
this.containerClient = blobServiceClient.getContainerClient(container);
|
|
182
|
-
this.name = name;
|
|
183
|
-
this.pathWidget = buildBlobDataPath(name);
|
|
184
|
-
this.pathConfig = buildBlobConfigPath(name);
|
|
185
|
-
}
|
|
186
|
-
extractFileName(path) {
|
|
187
|
-
return path.split("/").pop();
|
|
188
|
-
}
|
|
189
|
-
async blobUpload(absolutePath, content) {
|
|
190
|
-
const fileName = this.extractFileName(absolutePath);
|
|
191
|
-
if (!fileName)
|
|
192
|
-
throw new Error("a fileName was not found in the absolutePath");
|
|
193
|
-
return this.containerClient.getBlockBlobClient(absolutePath).upload(content, content.length, {
|
|
194
|
-
blobHTTPHeaders: { blobContentType: mime__default["default"].getType(fileName) || "application/octet-stream" },
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
async jsonUpload(absolutePath, json) {
|
|
198
|
-
return this.blobUpload(absolutePath, Buffer.from(JSON.stringify(json)));
|
|
199
|
-
}
|
|
200
|
-
async blobDownload(absolutePath) {
|
|
201
|
-
return this.containerClient.getBlockBlobClient(absolutePath).downloadToBuffer();
|
|
202
|
-
}
|
|
203
|
-
async dirDelete(absolutePath) {
|
|
204
|
-
var e_1, _a;
|
|
205
|
-
try {
|
|
206
|
-
for (var _b = tslib.__asyncValues(await this.containerClient.listBlobsFlat({ prefix: absolutePath })), _c; _c = await _b.next(), !_c.done;) {
|
|
207
|
-
const blob = _c.value;
|
|
208
|
-
await this.containerClient.deleteBlob(blob.name);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
212
|
-
finally {
|
|
213
|
-
try {
|
|
214
|
-
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
|
215
|
-
}
|
|
216
|
-
finally { if (e_1) throw e_1.error; }
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
async uploadWidgetDataFile(file, content) {
|
|
220
|
-
return this.blobUpload(this.pathWidget + file, content);
|
|
221
|
-
}
|
|
222
|
-
async cleanDataDir() {
|
|
223
|
-
return this.dirDelete(this.pathWidget);
|
|
224
|
-
}
|
|
225
|
-
async getConfig() {
|
|
226
|
-
const buffer = await this.blobDownload(this.pathConfig);
|
|
227
|
-
return JSON.parse(buffer.toString());
|
|
228
|
-
}
|
|
229
|
-
async uploadConfig(config) {
|
|
230
|
-
return this.jsonUpload(this.pathConfig, config);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
var CustomWidgetBlobService$1 = CustomWidgetBlobService;
|
|
234
|
-
|
|
235
|
-
// Copyright (c) Microsoft Corporation.
|
|
236
|
-
async function getAccessToken(managementApiEndpoint) {
|
|
237
|
-
const credentials = new identity.InteractiveBrowserCredential();
|
|
238
|
-
const scope = `${managementApiEndpoint}/user_impersonation`;
|
|
239
|
-
const { token } = await credentials.getToken(scope);
|
|
240
|
-
return `Bearer ${token}`;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Function to get storage SAS URL.
|
|
244
|
-
*
|
|
245
|
-
* @returns storage SAS URL
|
|
246
|
-
*/
|
|
247
|
-
async function getStorageSasUrl({ managementApiEndpoint, resourceId, apiVersion = "2019-01-01", tokenOverride, }) {
|
|
248
|
-
var _a;
|
|
249
|
-
const httpClient = coreClient.getClient(`${managementApiEndpoint}/${resourceId}`, { apiVersion });
|
|
250
|
-
const response = await httpClient
|
|
251
|
-
.pathUnchecked(`/portalSettings/mediaContent/listSecrets?apiVersion=${apiVersion}`) // TODO
|
|
252
|
-
.post({
|
|
253
|
-
headers: {
|
|
254
|
-
"If-Match": "*",
|
|
255
|
-
"Content-Type": "application/json",
|
|
256
|
-
Authorization: tokenOverride !== null && tokenOverride !== void 0 ? tokenOverride : (await getAccessToken(managementApiEndpoint)),
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
if (!((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.containerSasUrl))
|
|
260
|
-
throw new Error("Could not get storage SAS URL");
|
|
261
|
-
return response.body.containerSasUrl;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Copyright (c) Microsoft Corporation.
|
|
265
|
-
function readdir(dir, root) {
|
|
266
|
-
const results = [];
|
|
267
|
-
fs__default["default"].readdirSync(root + dir).forEach((file) => {
|
|
268
|
-
const stat = fs__default["default"].statSync(root + dir + path__default["default"].sep + file);
|
|
269
|
-
if (stat && stat.isDirectory()) {
|
|
270
|
-
results.push(...readdir(dir + file + path__default["default"].sep, root));
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
results.push(dir + file);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
return results;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Copyright (c) Microsoft Corporation.
|
|
280
|
-
/**
|
|
281
|
-
* Deploys everything from /dist folder to the API Management DevPortals' blob storage.
|
|
282
|
-
*
|
|
283
|
-
* @param serviceInformation - service information for deployment
|
|
284
|
-
* @param name - name of the widget to be deployed
|
|
285
|
-
* @param fallbackConfigPath - local path to the config file (by default "./static/config.msapim.json")
|
|
286
|
-
* @param rootLocal - optional, root of the local folder with compiled project to be exported (by default "./dist")
|
|
287
|
-
*/
|
|
288
|
-
async function deploy(serviceInformation, name, fallbackConfigPath = "./static/" + APIM_CONFIG_FILE_NAME, rootLocal = "./dist/") {
|
|
289
|
-
console.log("\n\n");
|
|
290
|
-
console.log("Starting deploy process of custom widget: " + name);
|
|
291
|
-
console.log("Please, sign in to your Azure account when prompted\n");
|
|
292
|
-
const blobStorageUrl = await getStorageSasUrl(serviceInformation);
|
|
293
|
-
const customWidgetBlobService = new CustomWidgetBlobService$1(blobStorageUrl, name);
|
|
294
|
-
let config;
|
|
295
|
-
try {
|
|
296
|
-
console.log("Looking for config file in the Azure blob storage");
|
|
297
|
-
config = await customWidgetBlobService.getConfig();
|
|
298
|
-
}
|
|
299
|
-
catch (e) {
|
|
300
|
-
console.log("Config not found.");
|
|
301
|
-
}
|
|
302
|
-
if (!config) {
|
|
303
|
-
console.log("Looking for a local config file in: " + fallbackConfigPath);
|
|
304
|
-
config = JSON.parse(fs__default["default"].readFileSync(fallbackConfigPath).toString());
|
|
305
|
-
}
|
|
306
|
-
if (!config) {
|
|
307
|
-
throw new Error("Config file could not be loaded.");
|
|
308
|
-
}
|
|
309
|
-
console.log("Config file loaded\n");
|
|
310
|
-
const files = readdir("", rootLocal);
|
|
311
|
-
console.log("Starting upload of data files from the '" + rootLocal + "' folder\n");
|
|
312
|
-
await customWidgetBlobService.cleanDataDir();
|
|
313
|
-
const promises = [];
|
|
314
|
-
files.forEach((file) => {
|
|
315
|
-
const content = fs__default["default"].readFileSync(rootLocal + file);
|
|
316
|
-
const promise = customWidgetBlobService
|
|
317
|
-
.uploadWidgetDataFile(file, content)
|
|
318
|
-
.then(() => console.log("Uploaded file: " + file));
|
|
319
|
-
promises.push(promise);
|
|
320
|
-
});
|
|
321
|
-
await Promise.all(promises);
|
|
322
|
-
console.log(files.length + " files has been uploaded\n");
|
|
323
|
-
config.deployedOn = new Date();
|
|
324
|
-
await customWidgetBlobService.uploadConfig(config);
|
|
325
|
-
console.log("Uploaded updated config");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
exports.APIM_ASK_FOR_SECRETS_MESSAGE_KEY = APIM_ASK_FOR_SECRETS_MESSAGE_KEY;
|
|
329
|
-
exports.APIM_CONFIG_FILE_NAME = APIM_CONFIG_FILE_NAME;
|
|
330
|
-
exports.APIM_EDITOR_DATA_KEY = APIM_EDITOR_DATA_KEY;
|
|
331
|
-
exports.APIM_ON_CHANGE_MESSAGE_KEY = APIM_ON_CHANGE_MESSAGE_KEY;
|
|
332
|
-
exports.BLOB_CONFIGS_FOLDER = BLOB_CONFIGS_FOLDER;
|
|
333
|
-
exports.BLOB_DATA_FOLDER = BLOB_DATA_FOLDER;
|
|
334
|
-
exports.BLOB_ROOT = BLOB_ROOT;
|
|
335
|
-
exports.askForSecrets = askForSecrets;
|
|
336
|
-
exports.buildBlobConfigPath = buildBlobConfigPath;
|
|
337
|
-
exports.buildBlobDataPath = buildBlobDataPath;
|
|
338
|
-
exports.buildOnChange = buildOnChange;
|
|
339
|
-
exports.deployNodeJS = deploy;
|
|
340
|
-
exports.getEditorValues = getEditorValues;
|
|
341
|
-
exports.getValues = getValues;
|
|
342
|
-
exports.getWidgetData = getWidgetData;
|
|
343
|
-
exports.onChangeWithOrigin = onChangeWithOrigin;
|
|
344
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/paths.ts","../src/node/CustomWidgetBlobService.ts","../src/node/getStorageSasUrl.ts","../src/node/readdir.ts","../src/node/deploy.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Key for a search param, from which editor data will be loaded from.\n */\nexport const APIM_EDITOR_DATA_KEY = \"editorData\";\n/**\n * Key for a post message object, it's used to propagate changes from editor to the DevPortal. Used to prevent interference with other applications.\n */\nexport const APIM_ON_CHANGE_MESSAGE_KEY = \"customInputValueChangedMSAPIM\";\n/**\n * Key for a post message object, it's used to request and send secrets - token and user id, from the DevPortal. Used to prevent interference with other applications.\n */\nexport const APIM_ASK_FOR_SECRETS_MESSAGE_KEY = \"askForSecretsMSAPIM\";\n\n/**\n * Base of a values obj\n */\nexport type ValuesCommon = Record<string, unknown>;\n/**\n * All possible runtime environments\n */\nexport type Environment = \"development\" | \"publishing\" | \"runtime\" | \"error\";\n\n/** Information about the widget instance received from the Dev Portal */\nexport interface PortalData {\n // /** web content's origin (URL) of your Dev Portal */\n // origin: string;\n /** current runtime environment */\n environment: Environment;\n /** ID of this particular instance of the widget */\n instanceId: string;\n}\n\n/** JSON object with all the data you'll receive from the Dev Portal */\nexport interface EditorData<Values extends ValuesCommon> extends PortalData {\n /** values you've set in the admin editor window */\n values: Partial<Values>;\n}\n\nfunction parseWidgetData<Values extends ValuesCommon>(\n urlSearchParams: URLSearchParams\n): EditorData<Values> {\n try {\n const urlEditorParams: EditorData<Values> = JSON.parse(\n decodeURIComponent(urlSearchParams.get(APIM_EDITOR_DATA_KEY) ?? \"\")\n );\n\n // if (!(\"origin\" in urlEditorParams)) {\n // console.error(\n // \"Could not get 'origin' from the search params of the URL:\\n\" + self.location.href\n // );\n // }\n return urlEditorParams;\n } catch (e) {\n console.error(\n `Could not get '${APIM_EDITOR_DATA_KEY}' from the search params of the URL:\\n` +\n self.location,\n e\n );\n return { values: {}, environment: \"error\", instanceId: \"error\" };\n }\n}\n\nexport function getWidgetDataPure<Values extends ValuesCommon>(\n urlSearchParams: URLSearchParams\n): EditorData<Values> {\n return parseWidgetData<Values>(urlSearchParams);\n}\n\n/**\n * Function to get all data related to the widget including technical values not expected to be needed in most cases.\n * Intended mostly for internal use, API might change. Consider using getValues or getEditorValues instead.\n */\nexport function getWidgetData<Values extends ValuesCommon>(): EditorData<Values> {\n return getWidgetDataPure(new URLSearchParams(self.location.search));\n}\n\nexport function getEditorValuesPure<Values extends ValuesCommon>(\n urlSearchParams: URLSearchParams\n): Partial<Values> {\n return getWidgetDataPure<Values>(urlSearchParams).values;\n}\n\n/**\n * Function to get values you've set in the admin editor window.\n */\nexport function getEditorValues<Values extends ValuesCommon>(): Partial<Values> {\n return getEditorValuesPure<Values>(new URLSearchParams(self.location.search));\n}\n\nexport function getValuesPure<Values extends ValuesCommon>(\n valuesDefault: Values,\n urlSearchParams: URLSearchParams\n): Values {\n const values = { ...valuesDefault }; // set Obj to contain all possible values and prefill default value\n const urlValues = parseWidgetData<Values>(urlSearchParams).values;\n\n Object.keys(values).forEach((key: keyof Values) => {\n const value = urlValues[key];\n if (value != null && value !== \"\") values[key] = value as Values[typeof key]; // if value is specified in the URL, replace the default value\n });\n return values;\n}\n\n/**\n * Function to get values you've set in the admin editor window. Undefined/empty values are replaced with default values.\n *\n * @param valuesDefault - object with your default values to use, just import valuesDefault object from values.ts folder\n */\nexport function getValues<Values extends ValuesCommon>(valuesDefault: Values): Values {\n return getValuesPure(valuesDefault, new URLSearchParams(self.location.search));\n}\n\n/**\n * Type of the onChange function.\n */\nexport type OnChange<Values extends ValuesCommon> = (values: Partial<Values>) => void;\n\n/**\n * The onChange function itself with 'origin' provided as a param.\n *\n * @param origin - web content's origin (URL) of your Dev Portal to send changes to\n * @param instanceId - ID of this particular instance of the widget\n * @param values - values that changed\n */\nexport function onChangeWithOrigin<Values extends ValuesCommon>(\n origin: string,\n instanceId: string,\n values: Values\n): void {\n Object.entries(values).forEach(([key, value]) => {\n self.parent.postMessage({ [APIM_ON_CHANGE_MESSAGE_KEY]: { key, value, instanceId } }, origin);\n });\n}\n\n/**\n * Build onChange function, which you can use, to send changed data from the editor.\n */\nexport function buildOnChange<Values extends ValuesCommon>(): OnChange<Values> {\n const { instanceId } = getWidgetData();\n return (values: Partial<Values>) => onChangeWithOrigin(\"*\", instanceId, values);\n}\n\n/**\n * Possible target modules\n * \"app\" for main application which is embedded in your Dev Portal\n * \"editor\" for form in admin panel\n */\nexport type TargetModule = \"app\" | \"editor\";\n/**\n * Secrets needed for communication with Dev Portal back-end\n */\nexport type Secrets = {\n managementApiUrl: string;\n apiVersion: string;\n userId?: string;\n token?: string;\n};\n\n/**\n * Request secrets - token & userId, from the Dev portal parent window.\n *\n * @param targetModule - is the function invoke from the main \"app\" window or the admin \"editor\"?\n */\nexport async function askForSecrets(targetModule: TargetModule): Promise<Secrets> {\n let receiveSecrets: (e: MessageEvent) => void;\n\n const promise = new Promise<Secrets>((resolve, reject) => {\n const { instanceId, environment }: PortalData = getWidgetData();\n\n receiveSecrets = ({ data }) => {\n if (!(APIM_ASK_FOR_SECRETS_MESSAGE_KEY in data)) return;\n\n const secrets = data[APIM_ASK_FOR_SECRETS_MESSAGE_KEY];\n if (typeof secrets !== \"object\" || !(\"managementApiUrl\" in secrets)) {\n reject(\"Secrets send by Dev Portal are invalid\");\n }\n\n resolve(secrets);\n };\n\n self.addEventListener(\"message\", receiveSecrets);\n\n const message = {\n [APIM_ASK_FOR_SECRETS_MESSAGE_KEY]: {\n instanceId,\n origin: self.location.origin,\n targetModule,\n },\n };\n\n if (targetModule === \"app\" && environment === \"development\") {\n self.parent.parent.postMessage(message, \"*\");\n } else {\n self.parent.postMessage(message, \"*\");\n }\n });\n\n return promise.finally(() => self.removeEventListener(\"message\", receiveSecrets));\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** root of the blob storage folder */\nexport const BLOB_ROOT = \"custom-widgets\";\n/** name of the blob storage folder with widget implementation */\nexport const BLOB_DATA_FOLDER = \"data\";\n/** name of the blob storage folder with widget configs */\nexport const BLOB_CONFIGS_FOLDER = \"configs\";\n/** name of the configuration file */\nexport const APIM_CONFIG_FILE_NAME = \"config.msapim.json\";\n\n/**\n * Generate relative path for widgets' data on the blob storage\n *\n * @param name - name of the widget\n */\nexport function buildBlobDataPath(name: string): string {\n return `${BLOB_ROOT}/${BLOB_DATA_FOLDER}/${name}/`;\n}\n\n/**\n * Generate relative path for widgets' config on the blob storage\n *\n * @param name - name of the widget\n */\nexport function buildBlobConfigPath(name: string): string {\n return `${BLOB_ROOT}/${BLOB_CONFIGS_FOLDER}/${name}/${APIM_CONFIG_FILE_NAME}`;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BlobServiceClient, BlockBlobUploadResponse } from \"@azure/storage-blob\";\nimport { buildBlobConfigPath, buildBlobDataPath } from \"../paths\";\nimport mime from \"mime\";\n\nexport type Config = Record<string, unknown>;\n\n/**\n * A service wrapping ContainerClient class to simplify blob handling\n */\nexport class CustomWidgetBlobService {\n readonly containerClient;\n readonly name;\n readonly pathWidget;\n readonly pathConfig;\n\n /**\n * @param blobStorageUrl - blob storage SAS URL\n * @param name - name of the custom widget to be taken care of\n */\n constructor(blobStorageUrl: string, name: string) {\n const container = \"content\";\n const blobServiceClient = new BlobServiceClient(blobStorageUrl.replace(`/${container}`, \"\"));\n this.containerClient = blobServiceClient.getContainerClient(container);\n this.name = name;\n this.pathWidget = buildBlobDataPath(name);\n this.pathConfig = buildBlobConfigPath(name);\n }\n\n private extractFileName(path: string): string | undefined {\n return path.split(\"/\").pop();\n }\n\n async blobUpload(absolutePath: string, content: Buffer): Promise<BlockBlobUploadResponse> {\n const fileName = this.extractFileName(absolutePath);\n if (!fileName) throw new Error(\"a fileName was not found in the absolutePath\");\n return this.containerClient.getBlockBlobClient(absolutePath).upload(content, content.length, {\n blobHTTPHeaders: { blobContentType: mime.getType(fileName) || \"application/octet-stream\" },\n });\n }\n\n async jsonUpload(\n absolutePath: string,\n json: Record<string, unknown>\n ): Promise<BlockBlobUploadResponse> {\n return this.blobUpload(absolutePath, Buffer.from(JSON.stringify(json)));\n }\n\n async blobDownload(absolutePath: string): Promise<Buffer> {\n return this.containerClient.getBlockBlobClient(absolutePath).downloadToBuffer();\n }\n\n async dirDelete(absolutePath: string): Promise<void> {\n for await (const blob of await this.containerClient.listBlobsFlat({ prefix: absolutePath })) {\n await this.containerClient.deleteBlob(blob.name);\n }\n }\n\n async uploadWidgetDataFile(file: string, content: Buffer): Promise<BlockBlobUploadResponse> {\n return this.blobUpload(this.pathWidget + file, content);\n }\n\n async cleanDataDir(): Promise<void> {\n return this.dirDelete(this.pathWidget);\n }\n\n async getConfig(): Promise<Config> {\n const buffer = await this.blobDownload(this.pathConfig);\n return JSON.parse(buffer.toString());\n }\n\n async uploadConfig(config: Config): Promise<BlockBlobUploadResponse> {\n return this.jsonUpload(this.pathConfig, config);\n }\n}\n\nexport default CustomWidgetBlobService;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { InteractiveBrowserCredential } from \"@azure/identity\";\nimport { ServiceInformation } from \"./deploy\";\nimport { getClient } from \"@azure-rest/core-client\";\n\nasync function getAccessToken(managementApiEndpoint: string): Promise<string> {\n const credentials = new InteractiveBrowserCredential();\n const scope = `${managementApiEndpoint}/user_impersonation`;\n const { token } = await credentials.getToken(scope);\n return `Bearer ${token}`;\n}\n\n/**\n * Function to get storage SAS URL.\n *\n * @returns storage SAS URL\n */\nasync function getStorageSasUrl({\n managementApiEndpoint,\n resourceId,\n apiVersion = \"2019-01-01\",\n tokenOverride,\n}: ServiceInformation): Promise<string> {\n const httpClient = getClient(`${managementApiEndpoint}/${resourceId}`, { apiVersion });\n const response = await httpClient\n .pathUnchecked(`/portalSettings/mediaContent/listSecrets?apiVersion=${apiVersion}`) // TODO\n .post({\n headers: {\n \"If-Match\": \"*\",\n \"Content-Type\": \"application/json\",\n Authorization: tokenOverride ?? (await getAccessToken(managementApiEndpoint)),\n },\n });\n\n if (!response?.body?.containerSasUrl) throw new Error(\"Could not get storage SAS URL\");\n return response.body.containerSasUrl;\n}\n\nexport default getStorageSasUrl;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nfunction readdir(dir: string, root: string): string[] {\n const results: string[] = [];\n\n fs.readdirSync(root + dir).forEach((file) => {\n const stat = fs.statSync(root + dir + path.sep + file);\n if (stat && stat.isDirectory()) {\n results.push(...readdir(dir + file + path.sep, root));\n } else {\n results.push(dir + file);\n }\n });\n\n return results;\n}\n\nexport default readdir;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport CustomWidgetBlobService, { Config } from \"./CustomWidgetBlobService\";\nimport { APIM_CONFIG_FILE_NAME } from \"../paths\";\nimport fs from \"fs\";\nimport getStorageSasUrl from \"./getStorageSasUrl\";\nimport readdir from \"./readdir\";\n\n/**\n * resourceId - resource ID of API Management service \"subscriptions/[subscription-id]/resourceGroups/[resource-group-name]/providers/Microsoft.ApiManagement/service/[service-name]\"\n * managementApiEndpoint - URL with protocol (e.g. https://management.azure.com)\n * apiVersion - optional to override default (e.g. \"2019-01-01\")\n * tokenOverride - optional, provides token to use for auth, instead of 'az login' approach\n */\nexport type ServiceInformation = {\n resourceId: string;\n managementApiEndpoint: string;\n apiVersion?: string;\n tokenOverride?: string;\n};\n\n/**\n * Deploys everything from /dist folder to the API Management DevPortals' blob storage.\n *\n * @param serviceInformation - service information for deployment\n * @param name - name of the widget to be deployed\n * @param fallbackConfigPath - local path to the config file (by default \"./static/config.msapim.json\")\n * @param rootLocal - optional, root of the local folder with compiled project to be exported (by default \"./dist\")\n */\nasync function deploy(\n serviceInformation: ServiceInformation,\n name: string,\n fallbackConfigPath = \"./static/\" + APIM_CONFIG_FILE_NAME,\n rootLocal: string = \"./dist/\"\n): Promise<void> {\n console.log(\"\\n\\n\");\n console.log(\"Starting deploy process of custom widget: \" + name);\n console.log(\"Please, sign in to your Azure account when prompted\\n\");\n\n const blobStorageUrl = await getStorageSasUrl(serviceInformation);\n const customWidgetBlobService = new CustomWidgetBlobService(blobStorageUrl, name);\n\n let config: Config | undefined;\n try {\n console.log(\"Looking for config file in the Azure blob storage\");\n config = await customWidgetBlobService.getConfig();\n } catch (e) {\n console.log(\"Config not found.\");\n }\n if (!config) {\n console.log(\"Looking for a local config file in: \" + fallbackConfigPath);\n config = JSON.parse(fs.readFileSync(fallbackConfigPath).toString());\n }\n if (!config) {\n throw new Error(\"Config file could not be loaded.\");\n }\n\n console.log(\"Config file loaded\\n\");\n\n const files = readdir(\"\", rootLocal);\n\n console.log(\"Starting upload of data files from the '\" + rootLocal + \"' folder\\n\");\n\n await customWidgetBlobService.cleanDataDir();\n\n const promises: Promise<void>[] = [];\n files.forEach((file) => {\n const content = fs.readFileSync(rootLocal + file);\n const promise = customWidgetBlobService\n .uploadWidgetDataFile(file, content)\n .then(() => console.log(\"Uploaded file: \" + file));\n promises.push(promise);\n });\n await Promise.all(promises);\n\n console.log(files.length + \" files has been uploaded\\n\");\n\n config.deployedOn = new Date();\n await customWidgetBlobService.uploadConfig(config);\n console.log(\"Uploaded updated config\");\n}\n\nexport default deploy;\n"],"names":["BlobServiceClient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AAO,EACL,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @packageDocumentation https://aka.ms/apimdocs/portal/customwidgets\n */\n\nexport {\n APIM_EDITOR_DATA_KEY,\n APIM_ON_CHANGE_MESSAGE_KEY,\n APIM_ASK_FOR_SECRETS_MESSAGE_KEY,\n getWidgetData,\n getEditorValues,\n getValues,\n askForSecrets,\n buildOnChange,\n onChangeWithOrigin,\n} from \"./utils\";\nexport type {\n PortalData,\n EditorData,\n OnChange,\n Secrets,\n TargetModule,\n ValuesCommon,\n Environment,\n} from \"./utils\";\nexport {\n BLOB_ROOT,\n APIM_CONFIG_FILE_NAME,\n BLOB_DATA_FOLDER,\n BLOB_CONFIGS_FOLDER,\n buildBlobDataPath,\n buildBlobConfigPath,\n} from \"./paths\";\n\nimport deployNodeJS from \"./node/deploy\";\nexport { deployNodeJS };\nexport type { ServiceInformation } from \"./node/deploy\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomWidgetBlobService.js","sourceRoot":"","sources":["../../../src/node/CustomWidgetBlobService.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAMlC;;;OAGG;IACH,YAAY,cAAsB,EAAE,IAAY;QAC9C,MAAM,SAAS,GAAG,SAAS,CAAC;QAC5B,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,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AAC,YAAoB;;;YAClC,KAAyB,IAAA,KAAA,cAAA,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA,IAAA;gBAAhF,MAAM,IAAI,WAAA,CAAA;gBACnB,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAClD;;;;;;;;;IACH,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,IAAY,EAAE,OAAe;QACtD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CACF;AAED,eAAe,uBAAuB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BlobServiceClient, BlockBlobUploadResponse } from \"@azure/storage-blob\";\nimport { buildBlobConfigPath, buildBlobDataPath } from \"../paths\";\nimport mime from \"mime\";\n\nexport type Config = Record<string, unknown>;\n\n/**\n * A service wrapping ContainerClient class to simplify blob handling\n */\nexport class CustomWidgetBlobService {\n readonly containerClient;\n readonly name;\n readonly pathWidget;\n readonly pathConfig;\n\n /**\n * @param blobStorageUrl - blob storage SAS URL\n * @param name - name of the custom widget to be taken care of\n */\n constructor(blobStorageUrl: string, name: string) {\n const container = \"content\";\n const blobServiceClient = new BlobServiceClient(blobStorageUrl.replace(`/${container}`, \"\"));\n this.containerClient = blobServiceClient.getContainerClient(container);\n this.name = name;\n this.pathWidget = buildBlobDataPath(name);\n this.pathConfig = buildBlobConfigPath(name);\n }\n\n private extractFileName(path: string): string | undefined {\n return path.split(\"/\").pop();\n }\n\n async blobUpload(absolutePath: string, content: Buffer): Promise<BlockBlobUploadResponse> {\n const fileName = this.extractFileName(absolutePath);\n if (!fileName) throw new Error(\"a fileName was not found in the absolutePath\");\n return this.containerClient.getBlockBlobClient(absolutePath).upload(content, content.length, {\n blobHTTPHeaders: { blobContentType: mime.getType(fileName) || \"application/octet-stream\" },\n });\n }\n\n async jsonUpload(\n absolutePath: string,\n json: Record<string, unknown>\n ): Promise<BlockBlobUploadResponse> {\n return this.blobUpload(absolutePath, Buffer.from(JSON.stringify(json)));\n }\n\n async blobDownload(absolutePath: string): Promise<Buffer> {\n return this.containerClient.getBlockBlobClient(absolutePath).downloadToBuffer();\n }\n\n async dirDelete(absolutePath: string): Promise<void> {\n for await (const blob of await this.containerClient.listBlobsFlat({ prefix: absolutePath })) {\n await this.containerClient.deleteBlob(blob.name);\n }\n }\n\n async uploadWidgetDataFile(file: string, content: Buffer): Promise<BlockBlobUploadResponse> {\n return this.blobUpload(this.pathWidget + file, content);\n }\n\n async cleanDataDir(): Promise<void> {\n return this.dirDelete(this.pathWidget);\n }\n\n async getConfig(): Promise<Config> {\n const buffer = await this.blobDownload(this.pathConfig);\n return JSON.parse(buffer.toString());\n }\n\n async uploadConfig(config: Config): Promise<BlockBlobUploadResponse> {\n return this.jsonUpload(this.pathConfig, config);\n }\n}\n\nexport default CustomWidgetBlobService;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.browser.js","sourceRoot":"","sources":["../../../src/node/deploy.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,KAAK,UAAU,MAAM,CACnB,mBAA4B,EAC5B,KAAa,EACb,mBAA2B;IAE3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACtC,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nasync function deploy(\n _serviceInformation: unknown,\n _name: string,\n _fallbackConfigPath: string\n): Promise<void> {\n throw new Error(\"Only for Node.js\");\n}\n\nexport default deploy;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/node/deploy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,uBAAmC,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAehC;;;;;;;GAOG;AACH,KAAK,UAAU,MAAM,CACnB,kBAAsC,EACtC,IAAY,EACZ,kBAAkB,GAAG,WAAW,GAAG,qBAAqB,EACxD,YAAoB,SAAS;IAE7B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,4CAA4C,GAAG,IAAI,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAClE,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAElF,IAAI,MAA0B,CAAC;IAC/B,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,MAAM,GAAG,MAAM,uBAAuB,CAAC,SAAS,EAAE,CAAC;KACpD;IAAC,OAAO,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,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport CustomWidgetBlobService, { Config } from \"./CustomWidgetBlobService\";\nimport { APIM_CONFIG_FILE_NAME } from \"../paths\";\nimport fs from \"fs\";\nimport getStorageSasUrl from \"./getStorageSasUrl\";\nimport readdir from \"./readdir\";\n\n/**\n * resourceId - resource ID of API Management service \"subscriptions/[subscription-id]/resourceGroups/[resource-group-name]/providers/Microsoft.ApiManagement/service/[service-name]\"\n * managementApiEndpoint - URL with protocol (e.g. https://management.azure.com)\n * apiVersion - optional to override default (e.g. \"2019-01-01\")\n * tokenOverride - optional, provides token to use for auth, instead of 'az login' approach\n */\nexport type ServiceInformation = {\n resourceId: string;\n managementApiEndpoint: string;\n apiVersion?: string;\n tokenOverride?: string;\n};\n\n/**\n * Deploys everything from /dist folder to the API Management DevPortals' blob storage.\n *\n * @param serviceInformation - service information for deployment\n * @param name - name of the widget to be deployed\n * @param fallbackConfigPath - local path to the config file (by default \"./static/config.msapim.json\")\n * @param rootLocal - optional, root of the local folder with compiled project to be exported (by default \"./dist\")\n */\nasync function deploy(\n serviceInformation: ServiceInformation,\n name: string,\n fallbackConfigPath = \"./static/\" + APIM_CONFIG_FILE_NAME,\n rootLocal: string = \"./dist/\"\n): Promise<void> {\n console.log(\"\\n\\n\");\n console.log(\"Starting deploy process of custom widget: \" + name);\n console.log(\"Please, sign in to your Azure account when prompted\\n\");\n\n const blobStorageUrl = await getStorageSasUrl(serviceInformation);\n const customWidgetBlobService = new CustomWidgetBlobService(blobStorageUrl, name);\n\n let config: Config | undefined;\n try {\n console.log(\"Looking for config file in the Azure blob storage\");\n config = await customWidgetBlobService.getConfig();\n } catch (e) {\n console.log(\"Config not found.\");\n }\n if (!config) {\n console.log(\"Looking for a local config file in: \" + fallbackConfigPath);\n config = JSON.parse(fs.readFileSync(fallbackConfigPath).toString());\n }\n if (!config) {\n throw new Error(\"Config file could not be loaded.\");\n }\n\n console.log(\"Config file loaded\\n\");\n\n const files = readdir(\"\", rootLocal);\n\n console.log(\"Starting upload of data files from the '\" + rootLocal + \"' folder\\n\");\n\n await customWidgetBlobService.cleanDataDir();\n\n const promises: Promise<void>[] = [];\n files.forEach((file) => {\n const content = fs.readFileSync(rootLocal + file);\n const promise = customWidgetBlobService\n .uploadWidgetDataFile(file, content)\n .then(() => console.log(\"Uploaded file: \" + file));\n promises.push(promise);\n });\n await Promise.all(promises);\n\n console.log(files.length + \" files has been uploaded\\n\");\n\n config.deployedOn = new Date();\n await customWidgetBlobService.uploadConfig(config);\n console.log(\"Uploaded updated config\");\n}\n\nexport default deploy;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStorageSasUrl.js","sourceRoot":"","sources":["../../../src/node/getStorageSasUrl.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,KAAK,UAAU,cAAc,CAAC,qBAA6B;IACzD,MAAM,WAAW,GAAG,IAAI,4BAA4B,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,GAAG,qBAAqB,qBAAqB,CAAC;IAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,UAAU,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,gBAAgB,CAAC,EAC9B,qBAAqB,EACrB,UAAU,EACV,UAAU,GAAG,YAAY,EACzB,aAAa,GACM;;IACnB,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,qBAAqB,IAAI,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACvF,MAAM,QAAQ,GAAG,MAAM,UAAU;SAC9B,aAAa,CAAC,uDAAuD,UAAU,EAAE,CAAC,CAAC,OAAO;SAC1F,IAAI,CAAC;QACJ,OAAO,EAAE;YACP,UAAU,EAAE,GAAG;YACf,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,CAAC,MAAM,cAAc,CAAC,qBAAqB,CAAC,CAAC;SAC9E;KACF,CAAC,CAAC;IAEL,IAAI,CAAC,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,eAAe,CAAA;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACvF,OAAO,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC;AACvC,CAAC;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { InteractiveBrowserCredential } from \"@azure/identity\";\nimport { ServiceInformation } from \"./deploy\";\nimport { getClient } from \"@azure-rest/core-client\";\n\nasync function getAccessToken(managementApiEndpoint: string): Promise<string> {\n const credentials = new InteractiveBrowserCredential();\n const scope = `${managementApiEndpoint}/user_impersonation`;\n const { token } = await credentials.getToken(scope);\n return `Bearer ${token}`;\n}\n\n/**\n * Function to get storage SAS URL.\n *\n * @returns storage SAS URL\n */\nasync function getStorageSasUrl({\n managementApiEndpoint,\n resourceId,\n apiVersion = \"2019-01-01\",\n tokenOverride,\n}: ServiceInformation): Promise<string> {\n const httpClient = getClient(`${managementApiEndpoint}/${resourceId}`, { apiVersion });\n const response = await httpClient\n .pathUnchecked(`/portalSettings/mediaContent/listSecrets?apiVersion=${apiVersion}`) // TODO\n .post({\n headers: {\n \"If-Match\": \"*\",\n \"Content-Type\": \"application/json\",\n Authorization: tokenOverride ?? (await getAccessToken(managementApiEndpoint)),\n },\n });\n\n if (!response?.body?.containerSasUrl) throw new Error(\"Could not get storage SAS URL\");\n return response.body.containerSasUrl;\n}\n\nexport default getStorageSasUrl;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readdir.js","sourceRoot":"","sources":["../../../src/node/readdir.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,SAAS,OAAO,CAAC,GAAW,EAAE,IAAY;IACxC,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,EAAE,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QACvD,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;SACvD;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,OAAO,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nfunction readdir(dir: string, root: string): string[] {\n const results: string[] = [];\n\n fs.readdirSync(root + dir).forEach((file) => {\n const stat = fs.statSync(root + dir + path.sep + file);\n if (stat && stat.isDirectory()) {\n results.push(...readdir(dir + file + path.sep, root));\n } else {\n results.push(dir + file);\n }\n });\n\n return results;\n}\n\nexport default readdir;\n"]}
|