@azure/api-management-custom-widgets-scaffolder 1.0.0-beta.3 → 1.0.0-beta.5

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.
Files changed (88) hide show
  1. package/LICENSE +17 -17
  2. package/README.md +2 -2
  3. package/bin/{execute.js → execute.cjs} +120 -494
  4. package/bin/execute.cjs.map +1 -0
  5. package/bin/templates/react/package.json.mustache +1 -1
  6. package/bin/templates/typescript/package.json.mustache +1 -1
  7. package/bin/templates/vue/package.json.mustache +1 -1
  8. package/dist/commonjs/bin/execute-configs.d.ts +15 -0
  9. package/dist/commonjs/bin/execute-configs.d.ts.map +1 -0
  10. package/dist/commonjs/bin/execute-configs.js +157 -0
  11. package/dist/commonjs/bin/execute-configs.js.map +1 -0
  12. package/dist/commonjs/bin/execute-helpers.d.ts +12 -0
  13. package/dist/commonjs/bin/execute-helpers.d.ts.map +1 -0
  14. package/dist/commonjs/bin/execute-helpers.js +50 -0
  15. package/dist/commonjs/bin/execute-helpers.js.map +1 -0
  16. package/dist/commonjs/bin/execute.d.ts +3 -0
  17. package/dist/commonjs/bin/execute.d.ts.map +1 -0
  18. package/dist/commonjs/bin/execute.js +48 -0
  19. package/dist/commonjs/bin/execute.js.map +1 -0
  20. package/dist/commonjs/generateProject.d.ts +10 -0
  21. package/dist/commonjs/generateProject.d.ts.map +1 -0
  22. package/dist/commonjs/generateProject.js +74 -0
  23. package/dist/commonjs/generateProject.js.map +1 -0
  24. package/dist/commonjs/getTemplates.d.ts +3 -0
  25. package/dist/commonjs/getTemplates.d.ts.map +1 -0
  26. package/dist/commonjs/getTemplates.js +21 -0
  27. package/dist/commonjs/getTemplates.js.map +1 -0
  28. package/dist/commonjs/index.d.ts +7 -0
  29. package/dist/commonjs/index.d.ts.map +1 -0
  30. package/dist/commonjs/index.js +17 -0
  31. package/dist/commonjs/index.js.map +1 -0
  32. package/dist/commonjs/package.json +3 -0
  33. package/{types/latest/api-management-custom-widgets-scaffolder.d.ts → dist/commonjs/scaffolding.d.ts} +54 -74
  34. package/dist/commonjs/scaffolding.d.ts.map +1 -0
  35. package/dist/commonjs/scaffolding.js +35 -0
  36. package/dist/commonjs/scaffolding.js.map +1 -0
  37. package/dist/commonjs/sourceDir-cjs.cjs.map +1 -0
  38. package/dist/commonjs/sourceDir-cjs.d.cts.map +1 -0
  39. package/dist/commonjs/sourceDir.d.ts +2 -0
  40. package/dist/commonjs/sourceDir.js +7 -0
  41. package/dist/commonjs/tsdoc-metadata.json +11 -0
  42. package/dist/esm/bin/execute-configs.d.ts +15 -0
  43. package/dist/esm/bin/execute-configs.d.ts.map +1 -0
  44. package/dist/esm/bin/execute-configs.js +150 -0
  45. package/dist/esm/bin/execute-configs.js.map +1 -0
  46. package/dist/esm/bin/execute-helpers.d.ts +12 -0
  47. package/dist/esm/bin/execute-helpers.d.ts.map +1 -0
  48. package/{dist-esm/src → dist/esm}/bin/execute-helpers.js +3 -3
  49. package/dist/esm/bin/execute-helpers.js.map +1 -0
  50. package/dist/esm/bin/execute.d.ts +3 -0
  51. package/dist/esm/bin/execute.d.ts.map +1 -0
  52. package/{dist-esm/src → dist/esm}/bin/execute.js +4 -4
  53. package/dist/esm/bin/execute.js.map +1 -0
  54. package/dist/esm/generateProject.d.ts +10 -0
  55. package/dist/esm/generateProject.d.ts.map +1 -0
  56. package/{dist-esm/src → dist/esm}/generateProject.js +10 -9
  57. package/dist/esm/generateProject.js.map +1 -0
  58. package/dist/esm/getTemplates.d.ts +3 -0
  59. package/dist/esm/getTemplates.d.ts.map +1 -0
  60. package/{dist-esm/src → dist/esm}/getTemplates.js +5 -4
  61. package/dist/esm/getTemplates.js.map +1 -0
  62. package/dist/esm/index.d.ts +7 -0
  63. package/dist/esm/index.d.ts.map +1 -0
  64. package/dist/esm/index.js +8 -0
  65. package/dist/esm/index.js.map +1 -0
  66. package/dist/esm/package.json +3 -0
  67. package/dist/esm/scaffolding.d.ts +54 -0
  68. package/dist/esm/scaffolding.d.ts.map +1 -0
  69. package/{dist-esm/src → dist/esm}/scaffolding.js +3 -2
  70. package/dist/esm/scaffolding.js.map +1 -0
  71. package/dist/esm/sourceDir.d.ts +2 -0
  72. package/dist/esm/sourceDir.d.ts.map +1 -0
  73. package/dist/esm/sourceDir.js +8 -0
  74. package/dist/esm/sourceDir.js.map +1 -0
  75. package/package.json +70 -72
  76. package/dist/index.js +0 -122
  77. package/dist/index.js.map +0 -1
  78. package/dist-esm/src/bin/execute-configs.js +0 -139
  79. package/dist-esm/src/bin/execute-configs.js.map +0 -1
  80. package/dist-esm/src/bin/execute-helpers.js.map +0 -1
  81. package/dist-esm/src/bin/execute.js.map +0 -1
  82. package/dist-esm/src/generateProject.browser.js +0 -6
  83. package/dist-esm/src/generateProject.browser.js.map +0 -1
  84. package/dist-esm/src/generateProject.js.map +0 -1
  85. package/dist-esm/src/getTemplates.js.map +0 -1
  86. package/dist-esm/src/index.js +0 -8
  87. package/dist-esm/src/index.js.map +0 -1
  88. package/dist-esm/src/scaffolding.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/bin/execute.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // Copyright (c) Microsoft Corporation.
4
+ // Licensed under the MIT License.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tslib_1 = require("tslib");
7
+ const execute_helpers_js_1 = require("./execute-helpers.js");
8
+ const execute_configs_js_1 = require("./execute-configs.js");
9
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const generateProject_js_1 = require("../generateProject.js");
11
+ const log = console.log;
12
+ const white = (msg) => log(chalk_1.default.white(msg));
13
+ const green = (msg) => log(chalk_1.default.green(msg));
14
+ const red = (msg) => log(chalk_1.default.red(msg));
15
+ const gray = (msg) => log(chalk_1.default.gray(msg));
16
+ async function main() {
17
+ green("\nThis tool generates code scaffold for custom widgets in the Azure API Management’s developer portal. Learn more at https://aka.ms/apimdocs/portal/customwidgets.\n");
18
+ const getConfig = (0, execute_helpers_js_1.buildGetConfig)(gray, red);
19
+ white("Specify the custom widget configuration.");
20
+ const widgetConfig = await getConfig(execute_configs_js_1.promptWidgetConfig, execute_configs_js_1.validateWidgetConfig);
21
+ white("Specify the Azure API Management service configuration.");
22
+ const serviceInformation = await getConfig(execute_configs_js_1.promptServiceInformation, execute_configs_js_1.validateDeployConfig);
23
+ white("Specify other options");
24
+ const miscConfig = await getConfig(execute_configs_js_1.promptMiscConfig, execute_configs_js_1.validateMiscConfig);
25
+ if (serviceInformation.resourceId[0] === "/") {
26
+ serviceInformation.resourceId = serviceInformation.resourceId.slice(1);
27
+ }
28
+ if (serviceInformation.resourceId.slice(-1) === "/") {
29
+ serviceInformation.resourceId = serviceInformation.resourceId.slice(0, -1);
30
+ }
31
+ if (serviceInformation.apiVersion === "") {
32
+ delete serviceInformation.apiVersion;
33
+ }
34
+ serviceInformation.managementApiEndpoint = (0, execute_configs_js_1.prefixUrlProtocol)(serviceInformation.managementApiEndpoint);
35
+ miscConfig.openUrl = miscConfig.openUrl
36
+ ? (0, execute_configs_js_1.prefixUrlProtocol)(miscConfig.openUrl)
37
+ : miscConfig.openUrl;
38
+ return (0, generateProject_js_1.generateProject)(widgetConfig, serviceInformation, miscConfig)
39
+ .then(() => green("\nThe custom widget’s code scaffold has been successfully generated.\n"))
40
+ .catch(console.error);
41
+ }
42
+ main()
43
+ .then(() => process.exit(0))
44
+ .catch((err) => {
45
+ console.error(err);
46
+ process.exit(1);
47
+ });
48
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/bin/execute.ts"],"names":[],"mappings":";;AAEA,uCAAuC;AACvC,kCAAkC;;;AAGlC,6DAAsD;AACtD,6DAQ8B;AA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,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpD,kBAAkB,CAAC,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,kBAAkB,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;QACzC,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED,kBAAkB,CAAC,qBAAqB,GAAG,IAAA,sCAAiB,EAC1D,kBAAkB,CAAC,qBAAqB,CACzC,CAAC;IAEF,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO;QACrC,CAAC,CAAC,IAAA,sCAAiB,EAAC,UAAU,CAAC,OAAO,CAAC;QACvC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IAEvB,OAAO,IAAA,oCAAe,EAAC,YAAY,EAAE,kBAAkB,EAAE,UAAU,CAAC;SACjE,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;SAC3F,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Log } from \"./execute-helpers.js\";\nimport { buildGetConfig } from \"./execute-helpers.js\";\nimport {\n prefixUrlProtocol,\n promptServiceInformation,\n promptMiscConfig,\n promptWidgetConfig,\n validateDeployConfig,\n validateMiscConfig,\n validateWidgetConfig,\n} from \"./execute-configs.js\";\nimport chalk from \"chalk\";\nimport { generateProject } from \"../generateProject.js\";\n\nconst log = console.log;\nconst white: Log = (msg) => log(chalk.white(msg));\nconst green: Log = (msg) => log(chalk.green(msg));\nconst red: Log = (msg) => log(chalk.red(msg));\nconst gray: Log = (msg) => log(chalk.gray(msg));\n\nasync function main(): Promise<void> {\n green(\n \"\\nThis tool generates code scaffold for custom widgets in the Azure API Management’s developer portal. Learn more at https://aka.ms/apimdocs/portal/customwidgets.\\n\",\n );\n\n const getConfig = buildGetConfig(gray, red);\n\n white(\"Specify the custom widget configuration.\");\n const widgetConfig = await getConfig(promptWidgetConfig, validateWidgetConfig);\n white(\"Specify the Azure API Management service configuration.\");\n const serviceInformation = await getConfig(promptServiceInformation, validateDeployConfig);\n white(\"Specify other options\");\n const miscConfig = await getConfig(promptMiscConfig, validateMiscConfig);\n\n if (serviceInformation.resourceId[0] === \"/\") {\n serviceInformation.resourceId = serviceInformation.resourceId.slice(1);\n }\n if (serviceInformation.resourceId.slice(-1) === \"/\") {\n serviceInformation.resourceId = serviceInformation.resourceId.slice(0, -1);\n }\n if (serviceInformation.apiVersion === \"\") {\n delete serviceInformation.apiVersion;\n }\n\n serviceInformation.managementApiEndpoint = prefixUrlProtocol(\n serviceInformation.managementApiEndpoint,\n );\n\n miscConfig.openUrl = miscConfig.openUrl\n ? prefixUrlProtocol(miscConfig.openUrl)\n : miscConfig.openUrl;\n\n return generateProject(widgetConfig, serviceInformation, miscConfig)\n .then(() => green(\"\\nThe custom widget’s code scaffold has been successfully generated.\\n\"))\n .catch(console.error);\n}\n\nmain()\n .then(() => process.exit(0))\n .catch((err) => {\n console.error(err);\n process.exit(1);\n });\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ServiceInformation, Options, WidgetConfig } from "./scaffolding.js";
2
+ /**
3
+ * Generates a scaffold project of Custom widget for API Managements' Dev Portal.
4
+ *
5
+ * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.
6
+ * @param deploymentConfig - JSON object with data for deployment.
7
+ * @param options - JSON object with other data, which will not be stored in the DevPortal.
8
+ */
9
+ export declare function generateProject(widgetConfig: WidgetConfig, deploymentConfig: ServiceInformation, options?: Options): Promise<void>;
10
+ //# sourceMappingURL=generateProject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateProject.d.ts","sourceRoot":"","sources":["../../src/generateProject.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAelF;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,kBAAkB,EACpC,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CA8Df"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.generateProject = generateProject;
6
+ const tslib_1 = require("tslib");
7
+ const scaffolding_js_1 = require("./scaffolding.js");
8
+ const sourceDir_js_1 = require("./sourceDir.js");
9
+ const node_path_1 = require("node:path");
10
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
11
+ const getTemplates_js_1 = require("./getTemplates.js");
12
+ const mustache_1 = tslib_1.__importDefault(require("mustache"));
13
+ const templateSuffix = ".mustache";
14
+ /**
15
+ * Generates a scaffold project of Custom widget for API Managements' Dev Portal.
16
+ *
17
+ * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.
18
+ * @param deploymentConfig - JSON object with data for deployment.
19
+ * @param options - JSON object with other data, which will not be stored in the DevPortal.
20
+ */
21
+ async function generateProject(widgetConfig, deploymentConfig, options = {}) {
22
+ const { openUrl, configAdvancedTenantId, configAdvancedRedirectUri } = options;
23
+ const openUrlParsed = openUrl ? new URL(openUrl) : null;
24
+ if (openUrlParsed) {
25
+ openUrlParsed.searchParams.append(scaffolding_js_1.OVERRIDE_PORT_KEY, String(scaffolding_js_1.OVERRIDE_DEFAULT_PORT));
26
+ }
27
+ const name = (0, scaffolding_js_1.displayNameToName)(widgetConfig.displayName);
28
+ const serverSettings = {
29
+ port: scaffolding_js_1.OVERRIDE_DEFAULT_PORT,
30
+ open: openUrlParsed ? openUrlParsed.toString() : true,
31
+ };
32
+ const configAdditional = {
33
+ interactiveBrowserCredentialOptions: { redirectUri: "http://localhost:1337" },
34
+ };
35
+ if (configAdvancedTenantId) {
36
+ configAdditional.interactiveBrowserCredentialOptions.tenantId = configAdvancedTenantId;
37
+ }
38
+ if (configAdvancedRedirectUri) {
39
+ configAdditional.interactiveBrowserCredentialOptions.redirectUri = configAdvancedRedirectUri;
40
+ }
41
+ const renderTemplate = async (file) => {
42
+ const isTemplate = file.endsWith(templateSuffix);
43
+ const encoding = file.endsWith(".ttf") ? "binary" : "utf8";
44
+ let fileData = await promises_1.default.readFile(file, { encoding });
45
+ if (isTemplate) {
46
+ fileData = mustache_1.default.render(fileData, {
47
+ name,
48
+ displayName: widgetConfig.displayName,
49
+ config: JSON.stringify({ ...widgetConfig, name }, null, "\t"),
50
+ configDeploy: JSON.stringify(deploymentConfig, null, "\t"),
51
+ configAdditional: JSON.stringify(configAdditional, null, "\t"),
52
+ serverSettings: JSON.stringify(serverSettings, null, "\t"),
53
+ });
54
+ }
55
+ let relativePath = file;
56
+ if (sourceDir_js_1.sourceDir.includes("\\")) {
57
+ relativePath = relativePath.replace(/\//g, "\\");
58
+ }
59
+ relativePath = relativePath
60
+ .replace((0, node_path_1.join)(sourceDir_js_1.sourceDir, "..", "templates", "_shared"), "")
61
+ .replace((0, node_path_1.join)(sourceDir_js_1.sourceDir, "..", "templates", widgetConfig.technology), "")
62
+ .replace(templateSuffix, "");
63
+ const newFilePath = (0, node_path_1.join)(process.cwd(), (0, scaffolding_js_1.widgetFolderName)(name), relativePath);
64
+ const dir = (0, node_path_1.parse)(newFilePath).dir;
65
+ await promises_1.default.mkdir(dir, { recursive: true });
66
+ await promises_1.default.writeFile(newFilePath, fileData, { encoding });
67
+ };
68
+ const templates = await (0, getTemplates_js_1.getTemplates)(widgetConfig.technology);
69
+ for (const file of Object.values(templates)) {
70
+ await renderTemplate(file);
71
+ }
72
+ return;
73
+ }
74
+ //# sourceMappingURL=generateProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateProject.js","sourceRoot":"","sources":["../../src/generateProject.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwBlC,0CAkEC;;AAvFD,qDAK0B;AAC1B,iDAA2C;AAC3C,yCAAiE;AACjE,wEAAkC;AAClC,uDAAiD;AACjD,gEAAgC;AAEhC,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC;;;;;;GAMG;AACI,KAAK,UAAU,eAAe,CACnC,YAA0B,EAC1B,gBAAoC,EACpC,UAAmB,EAAE;IAErB,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC;IAC/E,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,kCAAiB,EAAE,MAAM,CAAC,sCAAqB,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,IAAI,GAAG,IAAA,kCAAiB,EAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,cAAc,GAAG;QACrB,IAAI,EAAE,sCAAqB;QAC3B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI;KACtD,CAAC;IAEF,MAAM,gBAAgB,GAAG;QACvB,mCAAmC,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAG1E;KACF,CAAC;IACF,IAAI,sBAAsB,EAAE,CAAC;QAC3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ACD,YAAY,GAAG,YAAY;aACxB,OAAO,CAAC,IAAA,gBAAQ,EAAC,wBAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;aAC9D,OAAO,CAAC,IAAA,gBAAQ,EAAC,wBAAS,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;aAC5E,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAC/B,MAAM,WAAW,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAA,iCAAgB,EAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;QAClF,MAAM,GAAG,GAAG,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,GAAG,CAAC;QAEvC,MAAM,kBAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,MAAM,kBAAE,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAA,8BAAY,EAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC9D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ServiceInformation, Options, WidgetConfig } from \"./scaffolding.js\";\nimport {\n OVERRIDE_DEFAULT_PORT,\n OVERRIDE_PORT_KEY,\n displayNameToName,\n widgetFolderName,\n} from \"./scaffolding.js\";\nimport { sourceDir } from \"./sourceDir.js\";\nimport { join as joinPath, parse as parsePath } from \"node:path\";\nimport fs from \"node:fs/promises\";\nimport { getTemplates } from \"./getTemplates.js\";\nimport mustache from \"mustache\";\n\nconst templateSuffix = \".mustache\";\n\n/**\n * Generates a scaffold project of Custom widget for API Managements' Dev Portal.\n *\n * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.\n * @param deploymentConfig - JSON object with data for deployment.\n * @param options - JSON object with other data, which will not be stored in the DevPortal.\n */\nexport async function generateProject(\n widgetConfig: WidgetConfig,\n deploymentConfig: ServiceInformation,\n options: Options = {},\n): Promise<void> {\n const { openUrl, configAdvancedTenantId, configAdvancedRedirectUri } = options;\n const openUrlParsed = openUrl ? new URL(openUrl) : null;\n if (openUrlParsed) {\n openUrlParsed.searchParams.append(OVERRIDE_PORT_KEY, String(OVERRIDE_DEFAULT_PORT));\n }\n\n const name = displayNameToName(widgetConfig.displayName);\n const serverSettings = {\n port: OVERRIDE_DEFAULT_PORT,\n open: openUrlParsed ? openUrlParsed.toString() : true,\n };\n\n const configAdditional = {\n interactiveBrowserCredentialOptions: { redirectUri: \"http://localhost:1337\" } as {\n redirectUri: string;\n tenantId?: string;\n },\n };\n if (configAdvancedTenantId) {\n configAdditional.interactiveBrowserCredentialOptions.tenantId = configAdvancedTenantId;\n }\n if (configAdvancedRedirectUri) {\n configAdditional.interactiveBrowserCredentialOptions.redirectUri = configAdvancedRedirectUri;\n }\n\n const renderTemplate = async (file: string): Promise<void> => {\n const isTemplate = file.endsWith(templateSuffix);\n const encoding = file.endsWith(\".ttf\") ? \"binary\" : \"utf8\";\n let fileData = await fs.readFile(file, { encoding });\n if (isTemplate) {\n fileData = mustache.render(fileData, {\n name,\n displayName: widgetConfig.displayName,\n config: JSON.stringify({ ...widgetConfig, name }, null, \"\\t\"),\n configDeploy: JSON.stringify(deploymentConfig, null, \"\\t\"),\n configAdditional: JSON.stringify(configAdditional, null, \"\\t\"),\n serverSettings: JSON.stringify(serverSettings, null, \"\\t\"),\n });\n }\n\n let relativePath = file;\n if (sourceDir.includes(\"\\\\\")) {\n relativePath = relativePath.replace(/\\//g, \"\\\\\");\n }\n relativePath = relativePath\n .replace(joinPath(sourceDir, \"..\", \"templates\", \"_shared\"), \"\")\n .replace(joinPath(sourceDir, \"..\", \"templates\", widgetConfig.technology), \"\")\n .replace(templateSuffix, \"\");\n const newFilePath = joinPath(process.cwd(), widgetFolderName(name), relativePath);\n const dir = parsePath(newFilePath).dir;\n\n await fs.mkdir(dir, { recursive: true });\n await fs.writeFile(newFilePath, fileData, { encoding });\n };\n\n const templates = await getTemplates(widgetConfig.technology);\n for (const file of Object.values(templates)) {\n await renderTemplate(file);\n }\n\n return;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ScaffoldTech } from "./scaffolding.js";
2
+ export declare function getTemplates(template: ScaffoldTech): Promise<string[]>;
3
+ //# sourceMappingURL=getTemplates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTemplates.d.ts","sourceRoot":"","sources":["../../src/getTemplates.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKrD,wBAAsB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ5E"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getTemplates = getTemplates;
6
+ const glob_1 = require("glob");
7
+ const node_path_1 = require("node:path");
8
+ const sourceDir_js_1 = require("./sourceDir.js");
9
+ async function getTemplates(template) {
10
+ const sharedFiles = await getFiles((0, node_path_1.join)(sourceDir_js_1.sourceDir, "..", "templates", "_shared", "**", "**", "*.*"));
11
+ const templateFiles = await getFiles((0, node_path_1.join)(sourceDir_js_1.sourceDir, "..", "templates", template, "**", "**", "*.*"));
12
+ return [...sharedFiles, ...templateFiles];
13
+ }
14
+ async function getFiles(path) {
15
+ // Starting from glob v8 `\` is only used as an escape character, and never as a path separator in glob patterns.
16
+ // Glob pattern paths must use forward-slashes as path separators.
17
+ // See https://github.com/isaacs/node-glob/blob/af57da21c7722bb6edb687ccd4ad3b99d3e7a333/changelog.md#80
18
+ const normalizedPath = path.replace(/\\/g, "/");
19
+ return (0, glob_1.glob)(normalizedPath, { dot: true });
20
+ }
21
+ //# sourceMappingURL=getTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTemplates.js","sourceRoot":"","sources":["../../src/getTemplates.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,oCAQC;AAZD,+BAA4B;AAC5B,yCAA6C;AAC7C,iDAA2C;AAEpC,KAAK,UAAU,YAAY,CAAC,QAAsB;IACvD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAChC,IAAA,gBAAQ,EAAC,wBAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CACrE,CAAC;IACF,MAAM,aAAa,GAAG,MAAM,QAAQ,CAClC,IAAA,gBAAQ,EAAC,wBAAS,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CACpE,CAAC;IACF,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,IAAY;IAClC,iHAAiH;IACjH,kEAAkE;IAClE,wGAAwG;IACxG,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,IAAA,WAAI,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ScaffoldTech } from \"./scaffolding.js\";\nimport { glob } from \"glob\";\nimport { join as pathJoin } from \"node:path\";\nimport { sourceDir } from \"./sourceDir.js\";\n\nexport async function getTemplates(template: ScaffoldTech): Promise<string[]> {\n const sharedFiles = await getFiles(\n pathJoin(sourceDir, \"..\", \"templates\", \"_shared\", \"**\", \"**\", \"*.*\"),\n );\n const templateFiles = await getFiles(\n pathJoin(sourceDir, \"..\", \"templates\", template, \"**\", \"**\", \"*.*\"),\n );\n return [...sharedFiles, ...templateFiles];\n}\n\nasync function getFiles(path: string): Promise<string[]> {\n // Starting from glob v8 `\\` is only used as an escape character, and never as a path separator in glob patterns.\n // Glob pattern paths must use forward-slashes as path separators.\n // See https://github.com/isaacs/node-glob/blob/af57da21c7722bb6edb687ccd4ad3b99d3e7a333/changelog.md#80\n const normalizedPath = path.replace(/\\\\/g, \"/\");\n return glob(normalizedPath, { dot: true });\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation https://aka.ms/apimdocs/portal/customwidgets
3
+ */
4
+ export { OVERRIDE_PORT_KEY, OVERRIDE_DEFAULT_PORT, TECHNOLOGIES, displayNameToName, widgetFolderName, } from "./scaffolding.js";
5
+ export { generateProject } from "./generateProject.js";
6
+ export type { WidgetConfig as CustomWidgetCommonConfig, ServiceInformation as DeploymentConfig, Options, ScaffoldTech, } from "./scaffolding.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EACV,YAAY,IAAI,wBAAwB,EACxC,kBAAkB,IAAI,gBAAgB,EACtC,OAAO,EACP,YAAY,GACb,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.generateProject = exports.widgetFolderName = exports.displayNameToName = exports.TECHNOLOGIES = exports.OVERRIDE_DEFAULT_PORT = exports.OVERRIDE_PORT_KEY = void 0;
6
+ /**
7
+ * @packageDocumentation https://aka.ms/apimdocs/portal/customwidgets
8
+ */
9
+ var scaffolding_js_1 = require("./scaffolding.js");
10
+ Object.defineProperty(exports, "OVERRIDE_PORT_KEY", { enumerable: true, get: function () { return scaffolding_js_1.OVERRIDE_PORT_KEY; } });
11
+ Object.defineProperty(exports, "OVERRIDE_DEFAULT_PORT", { enumerable: true, get: function () { return scaffolding_js_1.OVERRIDE_DEFAULT_PORT; } });
12
+ Object.defineProperty(exports, "TECHNOLOGIES", { enumerable: true, get: function () { return scaffolding_js_1.TECHNOLOGIES; } });
13
+ Object.defineProperty(exports, "displayNameToName", { enumerable: true, get: function () { return scaffolding_js_1.displayNameToName; } });
14
+ Object.defineProperty(exports, "widgetFolderName", { enumerable: true, get: function () { return scaffolding_js_1.widgetFolderName; } });
15
+ var generateProject_js_1 = require("./generateProject.js");
16
+ Object.defineProperty(exports, "generateProject", { enumerable: true, get: function () { return generateProject_js_1.generateProject; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AAEH,mDAM0B;AALxB,mHAAA,iBAAiB,OAAA;AACjB,uHAAA,qBAAqB,OAAA;AACrB,8GAAA,YAAY,OAAA;AACZ,mHAAA,iBAAiB,OAAA;AACjB,kHAAA,gBAAgB,OAAA;AAElB,2DAAuD;AAA9C,qHAAA,eAAe,OAAA","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 OVERRIDE_PORT_KEY,\n OVERRIDE_DEFAULT_PORT,\n TECHNOLOGIES,\n displayNameToName,\n widgetFolderName,\n} from \"./scaffolding.js\";\nexport { generateProject } from \"./generateProject.js\";\nexport type {\n WidgetConfig as CustomWidgetCommonConfig,\n ServiceInformation as DeploymentConfig,\n Options,\n ScaffoldTech,\n} from \"./scaffolding.js\";\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,74 +1,54 @@
1
- /**
2
- * @packageDocumentation https://aka.ms/apimdocs/portal/customwidgets
3
- */
4
-
5
- /** Main data which DevPortal needs for every custom widget. */
6
- export declare interface CustomWidgetCommonConfig {
7
- /** Name of the custom widget which is displayed in DevPortal. */
8
- displayName: string;
9
- /** Technology to use to scaffold the widget. */
10
- technology: ScaffoldTech;
11
- /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */
12
- iconUrl?: string;
13
- }
14
-
15
- /** Data needed for deployment. */
16
- export declare interface DeploymentConfig {
17
- /** Management API endpoint to use (e.g. management.azure.com). */
18
- managementApiEndpoint: string;
19
- /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */
20
- resourceId: string;
21
- /** optional override which API version to use during deployment */
22
- apiVersion?: string;
23
- }
24
-
25
- /**
26
- * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
27
- *
28
- * @param displayName - User defined name of the custom widget.
29
- */
30
- export declare const displayNameToName: (displayName: string) => string;
31
-
32
- /**
33
- * Generates a scaffold project of Custom widget for API Managements' Dev Portal.
34
- *
35
- * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.
36
- * @param deploymentConfig - JSON object with data for deployment.
37
- * @param options - JSON object with other data, which will not be stored in the DevPortal.
38
- */
39
- export declare function generateProject(widgetConfig: CustomWidgetCommonConfig, deploymentConfig: DeploymentConfig, options?: Options): Promise<void>;
40
-
41
- /** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */
42
- export declare interface Options {
43
- /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */
44
- openUrl?: string;
45
- /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */
46
- configAdvancedTenantId?: string;
47
- /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */
48
- configAdvancedRedirectUri?: string;
49
- }
50
-
51
- /**
52
- * Default port for running local dev server on.
53
- */
54
- export declare const OVERRIDE_DEFAULT_PORT = 3000;
55
-
56
- /**
57
- * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.
58
- */
59
- export declare const OVERRIDE_PORT_KEY = "MS_APIM_CW_localhost_port";
60
-
61
- /** All supported technologies to scaffold a widget in. */
62
- export declare type ScaffoldTech = "typescript" | "react" | "vue";
63
-
64
- /** List of all supported technologies to scaffold a widget in. */
65
- export declare const TECHNOLOGIES: ScaffoldTech[];
66
-
67
- /**
68
- * Returns name of the folder for widget project.
69
- *
70
- * @param name - name of the widget
71
- */
72
- export declare const widgetFolderName: (name: string) => string;
73
-
74
- export { }
1
+ /**
2
+ * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.
3
+ */
4
+ export declare const OVERRIDE_PORT_KEY = "MS_APIM_CW_localhost_port";
5
+ /**
6
+ * Default port for running local dev server on.
7
+ */
8
+ export declare const OVERRIDE_DEFAULT_PORT = 3000;
9
+ /** All supported technologies to scaffold a widget in. */
10
+ export type ScaffoldTech = "typescript" | "react" | "vue";
11
+ /** List of all supported technologies to scaffold a widget in. */
12
+ export declare const TECHNOLOGIES: ScaffoldTech[];
13
+ /** Main data which DevPortal needs for every custom widget. */
14
+ export interface WidgetConfig {
15
+ /** Name of the custom widget which is displayed in DevPortal. */
16
+ displayName: string;
17
+ /** Technology to use to scaffold the widget. */
18
+ technology: ScaffoldTech;
19
+ /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */
20
+ iconUrl?: string;
21
+ }
22
+ /** Data needed for deployment. */
23
+ export interface ServiceInformation {
24
+ /** Management API endpoint to use (e.g. management.azure.com). */
25
+ managementApiEndpoint: string;
26
+ /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */
27
+ resourceId: string;
28
+ /** optional override which API version to use during deployment */
29
+ apiVersion?: string;
30
+ }
31
+ /** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */
32
+ export interface Options {
33
+ /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */
34
+ openUrl?: string;
35
+ /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */
36
+ configAdvancedTenantId?: string;
37
+ /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */
38
+ configAdvancedRedirectUri?: string;
39
+ }
40
+ export type Configs = WidgetConfig | ServiceInformation | Options;
41
+ /**
42
+ * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
43
+ * Prefix "cw-" to avoid conflicts with existing widgets.
44
+ *
45
+ * @param displayName - User defined name of the custom widget.
46
+ */
47
+ export declare const displayNameToName: (displayName: string) => string;
48
+ /**
49
+ * Returns name of the folder for widget project.
50
+ *
51
+ * @param name - name of the widget
52
+ */
53
+ export declare const widgetFolderName: (name: string) => string;
54
+ //# sourceMappingURL=scaffolding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffolding.d.ts","sourceRoot":"","sources":["../../src/scaffolding.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAC7D;;GAEG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1D,kEAAkE;AAClE,eAAO,MAAM,YAAY,EAAE,YAAY,EAAmC,CAAC;AAE3E,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,UAAU,EAAE,YAAY,CAAC;IACzB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6LAA6L;IAC7L,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mGAAmG;AACnG,MAAM,WAAW,OAAO;IACtB,8NAA8N;IAC9N,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mHAAmH;IACnH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sHAAsH;IACtH,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,MAOrD,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAA+C,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.widgetFolderName = exports.displayNameToName = exports.TECHNOLOGIES = exports.OVERRIDE_DEFAULT_PORT = exports.OVERRIDE_PORT_KEY = void 0;
6
+ /**
7
+ * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.
8
+ */
9
+ exports.OVERRIDE_PORT_KEY = "MS_APIM_CW_localhost_port";
10
+ /**
11
+ * Default port for running local dev server on.
12
+ */
13
+ exports.OVERRIDE_DEFAULT_PORT = 3000;
14
+ /** List of all supported technologies to scaffold a widget in. */
15
+ exports.TECHNOLOGIES = ["typescript", "react", "vue"];
16
+ /**
17
+ * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
18
+ * Prefix "cw-" to avoid conflicts with existing widgets.
19
+ *
20
+ * @param displayName - User defined name of the custom widget.
21
+ */
22
+ const displayNameToName = (displayName) => encodeURIComponent(("cw-" + displayName)
23
+ .normalize("NFD")
24
+ .toLowerCase()
25
+ .replace(/[\u0300-\u036f]/g, "")
26
+ .replace(/[^a-z0-9-]/g, "-"));
27
+ exports.displayNameToName = displayNameToName;
28
+ /**
29
+ * Returns name of the folder for widget project.
30
+ *
31
+ * @param name - name of the widget
32
+ */
33
+ const widgetFolderName = (name) => `azure-api-management-widget-${name}`;
34
+ exports.widgetFolderName = widgetFolderName;
35
+ //# sourceMappingURL=scaffolding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffolding.js","sourceRoot":"","sources":["../../src/scaffolding.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AACU,QAAA,iBAAiB,GAAG,2BAA2B,CAAC;AAC7D;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAK1C,kEAAkE;AACrD,QAAA,YAAY,GAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAkC3E;;;;;GAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAC/D,kBAAkB,CAChB,CAAC,KAAK,GAAG,WAAW,CAAC;KAClB,SAAS,CAAC,KAAK,CAAC;KAChB,WAAW,EAAE;KACb,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAC/B,CAAC;AAPS,QAAA,iBAAiB,qBAO1B;AAEJ;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,+BAA+B,IAAI,EAAE,CAAC;AAAnF,QAAA,gBAAgB,oBAAmE","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.\n */\nexport const OVERRIDE_PORT_KEY = \"MS_APIM_CW_localhost_port\";\n/**\n * Default port for running local dev server on.\n */\nexport const OVERRIDE_DEFAULT_PORT = 3000;\n\n/** All supported technologies to scaffold a widget in. */\nexport type ScaffoldTech = \"typescript\" | \"react\" | \"vue\";\n\n/** List of all supported technologies to scaffold a widget in. */\nexport const TECHNOLOGIES: ScaffoldTech[] = [\"typescript\", \"react\", \"vue\"];\n\n/** Main data which DevPortal needs for every custom widget. */\nexport interface WidgetConfig {\n /** Name of the custom widget which is displayed in DevPortal. */\n displayName: string;\n /** Technology to use to scaffold the widget. */\n technology: ScaffoldTech;\n /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */\n iconUrl?: string;\n}\n\n/** Data needed for deployment. */\nexport interface ServiceInformation {\n /** Management API endpoint to use (e.g. management.azure.com). */\n managementApiEndpoint: string;\n /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */\n resourceId: string;\n /** optional override which API version to use during deployment */\n apiVersion?: string;\n}\n\n/** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */\nexport interface Options {\n /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */\n openUrl?: string;\n /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */\n configAdvancedTenantId?: string;\n /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */\n configAdvancedRedirectUri?: string;\n}\n\nexport type Configs = WidgetConfig | ServiceInformation | Options;\n\n/**\n * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as \"name\".\n * Prefix \"cw-\" to avoid conflicts with existing widgets.\n *\n * @param displayName - User defined name of the custom widget.\n */\nexport const displayNameToName = (displayName: string): string =>\n encodeURIComponent(\n (\"cw-\" + displayName)\n .normalize(\"NFD\")\n .toLowerCase()\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9-]/g, \"-\"),\n );\n\n/**\n * Returns name of the folder for widget project.\n *\n * @param name - name of the widget\n */\nexport const widgetFolderName = (name: string): string => `azure-api-management-widget-${name}`;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceDir-cjs.cjs","sourceRoot":"","sources":["../../src/sourceDir-cjs.cts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,SAAS,GAAG,SAAS,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const sourceDir = __dirname;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceDir-cjs.d.cts","sourceRoot":"","sources":["../../src/sourceDir-cjs.cts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,QAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const sourceDir: string;
2
+ //# sourceMappingURL=sourceDir-cjs.d.cts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sourceDir = void 0;
6
+ exports.sourceDir = __dirname;
7
+ //# sourceMappingURL=sourceDir-cjs.cjs.map
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.10"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,15 @@
1
+ import type { Configs, ServiceInformation, Options, WidgetConfig } from "../scaffolding.js";
2
+ export declare const fieldIdToName: Record<keyof (WidgetConfig & ServiceInformation & Options) | string, string>;
3
+ export declare const prefixUrlProtocol: (value: string) => string;
4
+ export type ReplaceTypesPreserveOptional<T extends Record<any, any>, V> = {
5
+ [Key in keyof T]: T[Key] extends undefined ? V | undefined : V;
6
+ };
7
+ export type ValidateFnc = (input: string) => boolean | string;
8
+ export type Validate<C extends Configs> = ReplaceTypesPreserveOptional<C, ValidateFnc>;
9
+ export declare const validateWidgetConfig: Validate<WidgetConfig>;
10
+ export declare const validateDeployConfig: Validate<ServiceInformation>;
11
+ export declare const validateMiscConfig: Validate<Options>;
12
+ export declare const promptWidgetConfig: (partial: Partial<WidgetConfig>) => Promise<WidgetConfig>;
13
+ export declare const promptServiceInformation: (partial: Partial<ServiceInformation>) => Promise<ServiceInformation>;
14
+ export declare const promptMiscConfig: (partial: Partial<Options>) => Promise<Options>;
15
+ //# sourceMappingURL=execute-configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-configs.d.ts","sourceRoot":"","sources":["../../../src/bin/execute-configs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG5F,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,MAAM,CAAC,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAC,GAAG,MAAM,EAC5D,MAAM,CAcP,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MACM,CAAC;AAwBzD,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI;KACvE,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;CAC/D,CA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