diff --git a/libraries/swagger/ConnectorAPI.md b/libraries/swagger/ConnectorAPI.md deleted file mode 100644 index 60412abefb..0000000000 --- a/libraries/swagger/ConnectorAPI.md +++ /dev/null @@ -1,34 +0,0 @@ -# BotFramework Connector - -> see https://aka.ms/autorest - -Configuration for generating BotFramework Connector SDK. - -``` yaml -add-credentials: true -openapi-type: data-plane -``` -The current release for the BotFramework Connector is v3.0. - -# Releases - -## Connector API 3.0 - -``` yaml -input-file: ConnectorAPI.json -``` - -### Connector API 3.0 - TypeScript Settings -These settings apply only when `--typescript` is specified on the command line. -``` yaml $(typescript) - -typescript: - override-client-name: ConnectorClient - package-name: botframework-connector - package-version: 4.0.0 - azure-arm: false - clear-output-folder: true - output-folder: ./connectorApi - generate-metadata: true - enum-types: true -``` \ No newline at end of file diff --git a/libraries/swagger/generateClient.cmd b/libraries/swagger/generateClient.cmd deleted file mode 100644 index c631985758..0000000000 --- a/libraries/swagger/generateClient.cmd +++ /dev/null @@ -1,30 +0,0 @@ -@echo off - -echo Removing any preexisting output folders ("connectorApi/", "tokenApi/") -rd /s /q connectorApi -rd /s /q tokenApi - -@echo on -call npx autorest connectorAPI.md --typescript --use=".\node_modules\@microsoft.azure\autorest.typescript" - -call node model_fixes.js - -echo Move models to botbuilder-schema -del /q ..\botframework-schema\src\index.ts -move connectorAPI\lib\models\index.ts ..\botframework-schema\src\index.ts - -echo Move client to botframework-connector -rd /s /q ..\botframework-connector\src\connectorApi -move connectorApi\lib ..\botframework-connector\src\connectorApi - -@echo on -call npx autorest tokenAPI.md --typescript --use=".\node_modules\@microsoft.azure\autorest.typescript" -@echo off - -echo Move tokenAPI to botframework-connector -rd /s /q ..\botframework-connector\src\tokenApi -move tokenApi\lib ..\botframework-connector\src\tokenApi - -echo Removing generated folders ("connectorApi/", "tokenApi/") -rd /s /q connectorApi -rd /s /q tokenApi diff --git a/libraries/swagger/generateClient.sh b/libraries/swagger/generateClient.sh deleted file mode 100755 index 7cc2a8c8f3..0000000000 --- a/libraries/swagger/generateClient.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# clean up any left over folders -echo "Cleaning up temp folders" -rm -rf ./connectorAPI -rm -rf ./tokenApi - -# install replace-in-file, used by `node model_fixes.js` -echo "Installing local node modules" -npm i replace-in-file - -# generate connector API client -echo "Generating Connector API client" -autorest ConnectorAPI.md --typescript - -node model_fixes.js - -# move models to botbuilder-schema -echo "Moving models to botbuilder-schema folder" -rm -rf ../botframework-schema/src/index.ts -mv ./connectorAPI/lib/models/index.ts ../botframework-schema/src/index.ts - -# move client to botframework-connector -echo "Moving client to botframework-connector folder" -rm -rf ../botframework-connector/src/connectorApi -mv ./connectorApi/lib ../botframework-connector/src/connectorApi - -# generate tokenAPI client -echo "Generating Token API client" -autorest TokenAPI.md --typescript - -# move tokenAPI to botframework-connector -echo "Moving tokenAPI to botframework-connector folder" -rm -rf ../botframework-connector/src/tokenApi -mv ./tokenApi/lib ../botframework-connector/src/tokenApi - -# removing generated folders ("connectorApi/", "tokenApi/") -echo "Removing temp folders ('./connectApi', './tokenApi')" -rm -rf ./connectorApi -rm -rf ./tokenApi - -# removing local node_modules folder -echo "Removing local node_modules" -rm -rf ./node_modules - -echo "Done generating autorest clients" - - - diff --git a/libraries/swagger/model_fixes.js b/libraries/swagger/model_fixes.js deleted file mode 100644 index 95dc48e65e..0000000000 --- a/libraries/swagger/model_fixes.js +++ /dev/null @@ -1,111 +0,0 @@ -// replace.js - -const fs = require('fs'); -const replace = require('replace-in-file'); - -var modelsPaths = './connectorApi/lib/models/index.ts'; -var optionalModelProperties = { - 'Activity': ['id', 'timestamp', 'localTimestamp', 'textFormat', 'attachmentLayout', 'membersAdded', 'membersRemoved', 'reactionsAdded', 'reactionsRemoved', 'topicName', 'historyDisclosed', 'locale', 'speak', 'inputHint', 'summary', 'suggestedActions', 'attachments', 'entities', 'channelData', 'action', 'replyToId', 'value', 'name', 'relatesTo', 'code', 'expiration', 'importance', 'deliveryMode', 'textHighlights'], - 'ConversationReference': ['activityId', 'user'], - 'ConversationParameters': ['members', 'topicName'], - 'SigninCard': ['text'], - 'Attachment': ['content', 'contentUrl', 'name', 'thumbnailUrl'], - 'CardImage': ['alt', 'tap'], - 'CardAction': ['channelData', 'displayText', 'image', 'text'], - 'ChannelAccount': ['aadObjectId', 'role'], - 'ConversationAccount': ['aadObjectId', 'role'], - 'MediaUrl': ['profile'] -}; - - -var replaceOptions = [ - { - "files": "connectorApi/**/*.ts", - "from": "as Models from \"./models\"", - "to": "as Models from \"botframework-schema\"" - }, { - "files": "connectorApi/**/*.ts", - "from": "as Models from \"../models\"", - "to": "as Models from \"botframework-schema\"" - }, { - "files": "connectorApi/lib/models/index.ts", - "from": "\/*\n * Code connectorApi by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is\n * regenerated.\n *\/", - "to": "\/**\n * @module botbuilder\n *\/\n\/**\n * Copyright (c) Microsoft Corporation. All rights reserved. \n * Licensed under the MIT License.\n *\/" - }, - { "files": "connectorApi/lib/models/index.ts", "from": "{Buffer} [originalBase64]", "to": "{any} [originalBase64]" }, - { "files": "connectorApi/lib/models/index.ts", "from": ": Buffer", "to": ": any" }, - { "files": "connectorApi/lib/models/index.ts", "from": "{Buffer} [thumbnailBase64]", "to": "{any} [thumbnailBase64]" }, - { "files": "connectorApi/lib/models/index.ts", "from": ": Buffer", "to": ": any" }, - { - "files": "connectorApi/**/*.ts", - "from": "\/*\n * Code connectorApi by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is\n * regenerated.\n *\/", - "to": "\/**\n * @module botbuilder\n *\/\n\/**\n * Copyright (c) Microsoft Corporation. All rights reserved. \n * Licensed under the MIT License.\n *\/" - } -]; - -function replaceNext() { - if (replaceOptions.length === 0) { - return Promise.resolve(); - } - - return replace(replaceOptions.shift()) - .then(changes => { - return replaceNext(); - }) - .catch(error => { - console.error('Error occurred:', error); - }); -} - -function fixModelsProps(models, optionalModelProperties) { - - // 1. Make all properties required - // name: string; - models = models.replace(/\?: /g, ': '); - - // 2. Make some properties optional - // id?: string; - Object.keys(optionalModelProperties).forEach(modelName => { - var requiredProperties = optionalModelProperties[modelName]; - - var startIx = models.indexOf(`export interface ${modelName} {`); - var endIx = models.indexOf('\n}', startIx) + 2; - var model = models.substring(startIx, endIx); - - var updated = requiredProperties.reduce( - (updated, propName) => updated.replace(`${propName}: `, `${propName}?: `), - model); - - // console.log(interfaceName, 'OLD:\n', model, 'UPDATED:\n', updated); - - models = models.substring(0, startIx) + updated + models.substring(endIx); - }); - - // 3. get enums - var enums = []; - let exportEnum = 'export enum '; - var start = models.indexOf(exportEnum); - while(start > 0) - { - start = start + exportEnum.length; - end = models.indexOf(' ', start); - enums.push(models.substring(start, end)); - start = models.indexOf(exportEnum, end); - } - - // 4. change enums to be EnumType|string - for(iEnum in enums) - { - var target = enums[iEnum]; - models = models.replace(': '+target+';', ': '+target+' | string;'); - } - - return models; -} - -replaceNext().then(() => { - var models = fs.readFileSync(modelsPaths, 'UTF8'); - var updatedModels = fixModelsProps(models, optionalModelProperties); - fs.writeFileSync(modelsPaths, updatedModels, { encoding: 'UTF8' }); - console.log('Model fixes completed.'); -}); diff --git a/libraries/swagger/package.json b/libraries/swagger/package.json deleted file mode 100644 index e90c282590..0000000000 --- a/libraries/swagger/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "generateclient-via-swagger", - "private": true, - "version": "1.0.0", - "description": "To regenerate the botframework-connector and botframework-schema libraries, install the dependencies for autorest via `npm i`, then run generateClient.cmd.", - "main": "generateClient.cmd", - "scripts": { - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Microsoft/botbuilder-js.git" - }, - "author": "Microsoft", - "license": "MIT", - "bugs": { - "url": "https://github.com/Microsoft/botbuilder-js/issues" - }, - "homepage": "https://github.com/Microsoft/botbuilder-js#readme", - "dependencies": { - "@microsoft.azure/autorest.typescript": "^2.3.3", - "autorest": "^2.0.4283" - } -} diff --git a/libraries/swagger/tokenAPI.md b/libraries/swagger/tokenAPI.md deleted file mode 100644 index 35fb0942bb..0000000000 --- a/libraries/swagger/tokenAPI.md +++ /dev/null @@ -1,34 +0,0 @@ -# BotFramework Token - -> see https://aka.ms/autorest - -Configuration for generating BotFramework Token SDK. - -``` yaml -add-credentials: true -openapi-type: data-plane -``` -The current release for the BotFramework Token is v3.0. - -# Releases - -## Token API 3.0 - -``` yaml -input-file: TokenAPI.json -``` - -### Token API 3.0 - TypeScript Settings -These settings apply only when `--typescript` is specified on the command line. -``` yaml $(typescript) - -typescript: - override-client-name: TokenApiClient - package-name: botframework-Token - package-version: 4.0.0 - azure-arm: false - clear-output-folder: true - output-folder: ./tokenApi - generate-metadata: true - enum-types: true -``` \ No newline at end of file