@checkfirst/nestjs-outlook
Version:
An opinionated NestJS module for Microsoft Outlook integration that provides easy access to Microsoft Graph API for emails, calendars, and more.
104 lines • 3.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddMicrosoftUserTable1699000000000 = void 0;
const typeorm_1 = require("typeorm");
class AddMicrosoftUserTable1699000000000 {
async up(queryRunner) {
await queryRunner.createTable(new typeorm_1.Table({
name: 'microsoft_users',
columns: [
{
name: 'id',
type: 'INTEGER',
isPrimary: true,
isGenerated: true,
generationStrategy: 'increment',
},
{
name: 'external_user_id',
type: 'varchar',
length: '255',
isNullable: false,
},
{
name: 'access_token',
type: 'text',
isNullable: false,
},
{
name: 'refresh_token',
type: 'text',
isNullable: false,
},
{
name: 'token_expiry',
type: 'timestamp',
isNullable: false,
},
{
name: 'scopes',
type: 'text',
isNullable: false,
},
{
name: 'is_active',
type: 'boolean',
default: true,
isNullable: false,
},
{
name: 'created_at',
type: 'timestamp',
default: 'now()',
isNullable: false,
},
{
name: 'updated_at',
type: 'timestamp',
default: 'now()',
isNullable: false,
},
],
}), true);
await queryRunner.createIndex('microsoft_users', new typeorm_1.TableIndex({
name: 'IDX_microsoft_users_external_user_id',
columnNames: ['external_user_id'],
}));
const table = await queryRunner.getTable('outlook_webhook_subscriptions');
if (table) {
const accessTokenColumn = table.findColumnByName('access_token');
const refreshTokenColumn = table.findColumnByName('refresh_token');
if (accessTokenColumn) {
await queryRunner.dropColumn('outlook_webhook_subscriptions', 'access_token');
}
if (refreshTokenColumn) {
await queryRunner.dropColumn('outlook_webhook_subscriptions', 'refresh_token');
}
}
}
async down(queryRunner) {
const table = await queryRunner.getTable('outlook_webhook_subscriptions');
if (table) {
const accessTokenColumn = table.findColumnByName('access_token');
const refreshTokenColumn = table.findColumnByName('refresh_token');
if (!accessTokenColumn) {
await queryRunner.addColumn('outlook_webhook_subscriptions', new typeorm_1.TableColumn({
name: 'access_token',
type: 'text',
isNullable: true,
}));
}
if (!refreshTokenColumn) {
await queryRunner.addColumn('outlook_webhook_subscriptions', new typeorm_1.TableColumn({
name: 'refresh_token',
type: 'text',
isNullable: true,
}));
}
}
await queryRunner.dropIndex('microsoft_users', 'IDX_microsoft_users_external_user_id');
await queryRunner.dropTable('microsoft_users');
}
}
exports.AddMicrosoftUserTable1699000000000 = AddMicrosoftUserTable1699000000000;
//# sourceMappingURL=1699000000000-AddMicrosoftUserTable.js.map