Skip to content

Commit

Permalink
Pull staging and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Jul 22, 2024
2 parents fe1c9f9 + 1a469c7 commit c548c78
Show file tree
Hide file tree
Showing 52 changed files with 8,082 additions and 18,878 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

19 changes: 14 additions & 5 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.14.0
node-version: 20.14.0
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: npm ci
run: yarn install
- name: Run linter
run: npm run lint
run: yarn lint
- name: Run migrations
run: npm run db:migrate:run:test
run: yarn db:migrate:run:test
- name: Run tests
run: npm run test
run: yarn test

publish:
needs: test
Expand All @@ -58,6 +60,13 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install

- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
Expand Down
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import _import from 'eslint-plugin-import';
import unusedImports from 'eslint-plugin-unused-imports';
import { fixupPluginRules } from '@eslint/compat';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['node_modules/*', 'dist/*'],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
),
{
plugins: {
import: fixupPluginRules(_import),
'unused-imports': unusedImports,
},

languageOptions: {
parser: tsParser,
},

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],

'prettier/prettier': [
'error',
{
arrowParens: 'avoid',
singleQuote: true,
semi: true,
tabWidth: 2,
useTabs: false,
trailingComma: 'all',
'jsdoc-format': false,
endOfLine: 'auto',
},
],

'import/order': [
'error',
{
groups: [
'builtin',
'external',
['internal', 'parent', 'sibling'],
'index',
'object',
'type',
],
},
],
},
},
];
6 changes: 3 additions & 3 deletions migrations/1678175596807-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -24,7 +24,7 @@ export class changeNotificationCopies1678175596807
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -339,7 +339,7 @@ export class changeNotificationCopies1678175596807
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -21,7 +21,7 @@ export class changeCancelProjectNotificationCopies1681206838965
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -84,7 +84,7 @@ export class changeCancelProjectNotificationCopies1681206838965
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import {
NotificationType,
SCHEMA_VALIDATORS_NAMES,
} from '../src/entities/notificationType';
import { MICRO_SERVICES, THIRD_PARTY_EMAIL_SERVICES } from '../src/utils/utils';
import { MICRO_SERVICES } from '../src/utils/utils';
import {
NOTIFICATION_CATEGORY,
NOTIFICATION_TYPE_NAMES,
} from '../src/types/general';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';
import { SegmentEvents } from '../src/services/segment/segmentAnalyticsSingleton';

// https://github.com/Giveth/notification-center/issues/6 , https://gist.github.com/MohammadPCh/24434d50bc9ccd9b74905c271ee05482
// icons https://gist.github.com/MohammadPCh/31e2b750dd9aa54edb21dcc6e7332efb
Expand Down
6 changes: 3 additions & 3 deletions migrations/1692698983844-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -21,7 +21,7 @@ export class changeNotificationCopies1692698983844
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -85,7 +85,7 @@ export class changeNotificationCopies1692698983844
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
44 changes: 23 additions & 21 deletions migrations/1712683625687-addSuperFluidNotificationForAllUsers.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addSuperFluidNotificationForAllUsers1712683625687 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
export class addSuperFluidNotificationForAllUsers1712683625687
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
SELECT DISTINCT "userAddressId" FROM "notification_setting";
`);

// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
INSERT INTO "notification_setting" (
"allowNotifications",
"allowEmailNotification",
Expand All @@ -24,22 +26,22 @@ export class addSuperFluidNotificationForAllUsers1712683625687 implements Migrat
"userAddressId"
) VALUES (true, true, true, ${notificationTypeId}, ${userAddressId});
`);
}
}
}
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any; }) => nt.id).join(', ');
// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any }) => nt.id).join(', ');

// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
DELETE FROM "notification_setting" WHERE "notificationTypeId" IN (${ids});
`);
}
}
}
84 changes: 44 additions & 40 deletions migrations/1713834025817-addGroupParentSuperFluid.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';
import { NOTIFICATION_CATEGORY } from '../src/types/general';
import { NotificationType } from '../src/entities/notificationType';
import { MICRO_SERVICES } from '../src/utils/utils';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';

export const superFluidNotificationTypes = [
{
isGlobal: false,
isGroupParent: true,
showOnSettingPage: true,
webDefaultValue: true,
emailDefaultValue: true,
isEmailEditable: true,
isWebEditable: true,
name: 'Stream balance warnings',
description: 'Notify me when any of my Stream Balances are running low',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS,
schemaValidator: null,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'Stream balance warnings',
},
]
{
isGlobal: false,
isGroupParent: true,
showOnSettingPage: true,
webDefaultValue: true,
emailDefaultValue: true,
isEmailEditable: true,
isWebEditable: true,
name: 'Stream balance warnings',
description: 'Notify me when any of my Stream Balances are running low',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS,
schemaValidator: null,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'Stream balance warnings',
},
];

export class addGroupParentSuperFluid1713834025817 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = (await queryRunner.query(`
export class addGroupParentSuperFluid1713834025817
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = (
await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`)).map((i: any) => i.id);
await queryRunner.query(
`UPDATE notification_type
`)
).map((i: any) => i.id);
await queryRunner.query(
`UPDATE notification_type
SET "showOnSettingPage" = false, "emailDefaultValue" = true, "category" = '${NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS}'
WHERE id IN (${notificationTypeIds.join(", ")})`
);
await queryRunner.manager.save(
NotificationType,
superFluidNotificationTypes,
);
}
WHERE id IN (${notificationTypeIds.join(', ')})`,
);
await queryRunner.manager.save(
NotificationType,
superFluidNotificationTypes,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "categoryGroup" = 'superfluid' AND "name" = 'Stream Balance Warnings';`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "categoryGroup" = 'superfluid' AND "name" = 'Stream Balance Warnings';`,
);
}
}
Loading

0 comments on commit c548c78

Please sign in to comment.