@khester/create-dynamics-app 2.7.0 → 2.8.0
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/README.md +3 -0
- package/dist/artifacts/registry.d.ts.map +1 -1
- package/dist/artifacts/registry.js +44 -0
- package/dist/artifacts/registry.js.map +1 -1
- package/dist/artifacts/types.d.ts +1 -1
- package/dist/artifacts/types.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/scaffold.d.ts +1 -0
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +2 -0
- package/dist/scaffold.js.map +1 -1
- package/package.json +1 -1
- package/templates/teams-app/_variants/tab.basic/appPackage/manifest.template.json +2 -2
- package/templates/teams-app/_variants/tab.dashboard/appPackage/manifest.template.json +2 -2
- package/templates/teams-app/_variants/tab.sso/appPackage/manifest.template.json +2 -2
- package/templates/teams-bot/.env.example +18 -0
- package/templates/teams-bot/README.md +52 -0
- package/templates/teams-bot/_variants/bot.echo/appPackage/manifest.template.json +25 -0
- package/templates/teams-bot/_variants/bot.echo/src/bot/TeamsBot.ts +142 -0
- package/templates/teams-bot/_variants/bot.echo/src/bot/welcomeCard.ts +134 -0
- package/templates/teams-bot/_variants/bot.echo/src/index.ts +59 -0
- package/templates/teams-bot/_variants/bot.echo/src/mock/mockMode.ts +104 -0
- package/templates/teams-bot/_variants/bot.notification/appPackage/manifest.template.json +25 -0
- package/templates/teams-bot/_variants/bot.notification/src/bot/NotificationBot.ts +54 -0
- package/templates/teams-bot/_variants/bot.notification/src/index.ts +136 -0
- package/templates/teams-bot/_variants/bot.notification/src/mock/mockMode.ts +55 -0
- package/templates/teams-bot/_variants/bot.notification/src/storage/conversationStore.ts +84 -0
- package/templates/teams-bot/appPackage/color.png +0 -0
- package/templates/teams-bot/appPackage/outline.png +0 -0
- package/templates/teams-bot/gitignore +8 -0
- package/templates/teams-bot/nodemon.json +6 -0
- package/templates/teams-bot/package.json +24 -0
- package/templates/teams-bot/src/adapters/botAdapter.ts +45 -0
- package/templates/teams-bot/src/config.ts +34 -0
- package/templates/teams-bot/tsconfig.json +17 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "{{projectName}} — Microsoft Teams bot (Bot Framework SDK v4)",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "nodemon src/index.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/index.js",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"botbuilder": "^4.22.1",
|
|
14
|
+
"dotenv": "^16.4.1",
|
|
15
|
+
"express": "^4.18.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/express": "^4.17.21",
|
|
19
|
+
"@types/node": "^20.11.0",
|
|
20
|
+
"nodemon": "^3.0.3",
|
|
21
|
+
"ts-node": "^10.9.2",
|
|
22
|
+
"typescript": "^5.3.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloudAdapter,
|
|
3
|
+
ConfigurationBotFrameworkAuthentication,
|
|
4
|
+
ConfigurationBotFrameworkAuthenticationOptions,
|
|
5
|
+
TurnContext,
|
|
6
|
+
} from 'botbuilder';
|
|
7
|
+
import { config } from '../config';
|
|
8
|
+
|
|
9
|
+
// Error handler for the adapter
|
|
10
|
+
const onTurnErrorHandler = async (context: TurnContext, error: Error): Promise<void> => {
|
|
11
|
+
console.error(`\n [onTurnError] unhandled error: ${error}`);
|
|
12
|
+
console.error(error.stack);
|
|
13
|
+
|
|
14
|
+
await context.sendActivity('The bot encountered an error or bug.');
|
|
15
|
+
|
|
16
|
+
// Send a trace activity (visible in Bot Framework Emulator)
|
|
17
|
+
await context.sendTraceActivity(
|
|
18
|
+
'OnTurnError Trace',
|
|
19
|
+
`${error}`,
|
|
20
|
+
'https://www.botframework.com/schemas/error',
|
|
21
|
+
'TurnError'
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function createBotAdapter(): CloudAdapter {
|
|
26
|
+
// MicrosoftAppTenantId only applies to SingleTenant — a MultiTenant bot must
|
|
27
|
+
// authenticate against the common Bot Framework authority, so omit it there.
|
|
28
|
+
const authConfig: ConfigurationBotFrameworkAuthenticationOptions = config.mockMode
|
|
29
|
+
? {} // Empty config for mock mode
|
|
30
|
+
: {
|
|
31
|
+
MicrosoftAppId: config.botId,
|
|
32
|
+
MicrosoftAppPassword: config.botPassword,
|
|
33
|
+
MicrosoftAppType: config.appType,
|
|
34
|
+
...(config.appType === 'SingleTenant'
|
|
35
|
+
? { MicrosoftAppTenantId: config.botTenantId }
|
|
36
|
+
: {}),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const botFrameworkAuth = new ConfigurationBotFrameworkAuthentication(authConfig);
|
|
40
|
+
const adapter = new CloudAdapter(botFrameworkAuth);
|
|
41
|
+
|
|
42
|
+
adapter.onTurnError = onTurnErrorHandler;
|
|
43
|
+
|
|
44
|
+
return adapter;
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
|
|
3
|
+
// .env.local first (the teams-app-manager identity stage writes secrets there),
|
|
4
|
+
// then .env — dotenv never overwrites a key that is already set.
|
|
5
|
+
dotenv.config({ path: ['.env.local', '.env'] });
|
|
6
|
+
|
|
7
|
+
export type AppType = 'SingleTenant' | 'MultiTenant';
|
|
8
|
+
|
|
9
|
+
export const config = {
|
|
10
|
+
// Bot Framework credentials
|
|
11
|
+
botId: process.env.MICROSOFT_APP_ID || '',
|
|
12
|
+
botPassword: process.env.MICROSOFT_APP_PASSWORD || '',
|
|
13
|
+
botTenantId: process.env.MICROSOFT_APP_TENANT_ID || '',
|
|
14
|
+
// Must match the Azure Bot resource's app type; MultiTenant needs no tenant id.
|
|
15
|
+
appType: (process.env.MICROSOFT_APP_TYPE as AppType) || 'SingleTenant',
|
|
16
|
+
|
|
17
|
+
// Shared secret for POST /api/notify (notification bots). Empty = endpoint disabled.
|
|
18
|
+
notifyApiKey: process.env.NOTIFY_API_KEY || '',
|
|
19
|
+
|
|
20
|
+
// Conversation-reference persistence (notification bots).
|
|
21
|
+
conversationStorePath: process.env.CONVERSATION_STORE_PATH || './.data/conversations.json',
|
|
22
|
+
|
|
23
|
+
// Server configuration
|
|
24
|
+
port: parseInt(process.env.PORT || '3978', 10),
|
|
25
|
+
|
|
26
|
+
// Mock mode for development without an Azure registration
|
|
27
|
+
mockMode: process.env.MOCK_MODE === 'true',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function validateConfig(): void {
|
|
31
|
+
if (!config.mockMode && !config.botId) {
|
|
32
|
+
console.warn('Warning: MICROSOFT_APP_ID not set. Set MOCK_MODE=true for local development.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"sourceMap": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist"]
|
|
17
|
+
}
|