Skip to content

Commit

Permalink
Update prod (#371)
Browse files Browse the repository at this point in the history
* Create pr-to-prod.yml (#346)

* remove deploy rule (#349)

* remove deploy rule

* Update build-and-push-docker-image.yml

* Update build-and-push-docker-image.yml

* unblock wksp on plan changing (#352)

* Email notifications with priority (#339)

* Email notifications with priority

* Fix linter errors

* Remove sign-up email from templates

* Renamed default priority

* Added password-reset and workspace-invite emails (#356)

* improvement(repetitions): title and type added to Repetition payload (#358)

* [Feature] New integration token format (#357)

* upgrade hawk.types

* create project with new integration token format

* add resolver for regenerating token

* refactor generating token

* fix import

* refactor type of returned object

* Update projectsFactory.ts

* Update project.ts

* refactor generating integration id

* Update projectsFactory.ts

* generate integration id if not any (#360)

* Fix catcher problems

* Event repetitions pagination (#363)

* feat: Event repetitions load

* Fix lint

* Fix lint

* Add seed resolver for e2e env (#366)

* Add seed resolver for e2e env

* Add workspace model back

* Fix lint

* [Feature] Date from objectid (#370)

* add function for getting timestamp from object id

* return date from function, add resolver for project

* add resolvers for user and workspace to

* add test

* Send commits on build (#367)

* send commits on build

* add name to release id

* Bump version up to 1.0.1

* remove commits.sh

* update workflow

* Update build-and-push-docker-image.yml

* Update package.json

* test

* remove log

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Bump tmpl from 1.0.4 to 1.0.5 (#374)

Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump object-path from 0.11.5 to 0.11.8 (#373)

Bumps [object-path](https://github.com/mariocasciaro/object-path) from 0.11.5 to 0.11.8.
- [Release notes](https://github.com/mariocasciaro/object-path/releases)
- [Commits](https://github.com/mariocasciaro/object-path/commits)

---
updated-dependencies:
- dependency-name: object-path
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Taly <vitalik7tv@yandex.ru>

* Bump axios from 0.21.1 to 0.21.2 (#372)

* Bump axios from 0.21.1 to 0.21.2

Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.21.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](axios/axios@v0.21.1...v0.21.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump version up to 1.0.4

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Taly <vitalik7tv@yandex.ru>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Bump passport-oauth2 from 1.5.0 to 1.6.1 (#375)

Bumps [passport-oauth2](https://github.com/jaredhanson/passport-oauth2) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/jaredhanson/passport-oauth2/releases)
- [Changelog](https://github.com/jaredhanson/passport-oauth2/blob/master/CHANGELOG.md)
- [Commits](jaredhanson/passport-oauth2@v1.5.0...v1.6.1)

---
updated-dependencies:
- dependency-name: passport-oauth2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix workspace editing (#376)

* fix Validator importing

* remove JWT_SECRET_PROJECT_TOKEN from .env.sample

* Bump version up to 1.0.5

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Update user.ts

Co-authored-by: Taly <vitalik7tv@yandex.ru>
Co-authored-by: Mikhail Popov <geekan@bk.ru>
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: Ilya Moroz <37909603+ilyamore88@users.noreply.github.com>
Co-authored-by: Nikita Melnikov <nikmel2803@gmail.com>
Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com>
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
9 people authored Oct 20, 2021
1 parent 7bf7270 commit dd5d2e4
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ JWT_SECRET_REFRESH_TOKEN=abacaba
# JWT secret for user's access token
JWT_SECRET_ACCESS_TOKEN=belarus

# JWT secret for project's tokens (used in catcher)
JWT_SECRET_PROJECT_TOKEN=qwerty

# JWT secret for signing tokens for processing billing requests
JWT_SECRET_BILLING_CHECKSUM=checksum_secret
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Build and push docker image

on: [push]
on:
push:
branches:
- prod
- stage

env:
DOCKER_REPO: ${{ secrets.DOCKER_USERNAME }}/hawk-api
HAWK_TOKEN: ${{ secrets.HAWK_TOKEN }}

jobs:
build:
Expand All @@ -12,6 +17,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Get package info
id: packageInfo
uses: codex-team/action-nodejs-package-info@v1

- name: Send release data
uses: codex-team/hawk.releases@v1
with:
release: ${{ steps.packageInfo.outputs.name }}-${{ steps.packageInfo.outputs.version }}
token: ${{ secrets.HAWK_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v1
with:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bump version in PR

on: [pull_request]

jobs:
# If pull request was merged then we should check for a package version update
check-version-update:
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
with:
fetch-depth: 0

# Get package new version name
- name: Get package info
id: packageNew
uses: codex-team/action-nodejs-package-info@v1

# Checkout to the base commit before merge
- name: Checkout to the base commit before merge
run: git checkout ${{ github.event.pull_request.base.sha }}

# Get package old version name
- name: Get package info
id: packageOld
uses: codex-team/action-nodejs-package-info@v1

# Stop workflow and do not bump version if it was changed already
- name: Stop workflow and do not bump version if it was changed already
uses: andymckay/cancel-action@0.2
if: steps.packageOld.outputs.version != steps.packageNew.outputs.version

bump-version:
needs: check-version-update
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2

# Setup node environment
- uses: actions/setup-node@v1
with:
node-version: 15
registry-url: https://registry.npmjs.org/

# Bump version to the next prerelease (patch) with rc suffix
- name: Suggest the new version
run: yarn version --patch --no-git-tag-version

# Get package new version name
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1

# Commit version upgrade
- uses: EndBug/add-and-commit@v7
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: "Bump version up to ${{ steps.package.outputs.version }}"
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import './src/env';
import HawkAPI from './src';
import HawkCatcher from '@hawk.so/nodejs';
import { name, version } from './package.json';

/** Enable HawkCatcher */
if (process.env.HAWK_CATCHER_TOKEN) {
HawkCatcher.init(process.env.HAWK_CATCHER_TOKEN);
HawkCatcher.init({
token: process.env.HAWK_CATCHER_TOKEN,
release: `${name}-${version}`,
});
}

const app = new HawkAPI();
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.0.0",
"version": "1.0.5",
"main": "index.ts",
"license": "UNLICENSED",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"typescript": "^3.7.5"
},
"dependencies": {
"@hawk.so/nodejs": "^3.0.10",
"@hawk.so/nodejs": "^3.1.1",
"@types/amqp-connection-manager": "^2.0.4",
"@types/debug": "^4.1.5",
"@types/escape-html": "^1.0.0",
Expand All @@ -46,7 +46,7 @@
"amqplib": "^0.5.5",
"apollo-server-express": "^2.14.2",
"argon2": "^0.26.2",
"axios": "^0.21.1",
"axios": "^0.21.2",
"body-parser": "^1.19.0",
"cloudpayments": "^5.0.4",
"codex-accounting-sdk": "https://github.com/codex-team/codex-accounting-sdk/",
Expand Down
12 changes: 12 additions & 0 deletions src/resolvers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Validator = require('../utils/validator');
const UserInProject = require('../models/userInProject');
const EventsFactory = require('../models/eventsFactory');
const ProjectToWorkspace = require('../models/projectToWorkspace');
const { dateFromObjectId } = require('../utils/dates');
const ProjectModel = require('../models/project').default;

const EVENTS_GROUP_HASH_INDEX_NAME = 'groupHashUnique';
Expand Down Expand Up @@ -220,6 +221,17 @@ module.exports = {
},
},
Project: {
/**
* Returns project creation date
*
* @param {ProjectDBScheme} project - result of parent resolver
*
* @returns {Date}
*/
creationDate(project) {
return dateFromObjectId(project._id);
},

/**
* Find project's event
*
Expand Down
14 changes: 14 additions & 0 deletions src/resolvers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Validator from '../utils/validator';
import { SenderWorkerTaskType } from '../types/userNotifications';
import { TaskPriorities, emailNotification } from '../utils/emailNotifications';
import isE2E from '../utils/isE2E';
import { dateFromObjectId } from '../utils/dates';
import { UserDBScheme } from 'hawk.types';

/**
* See all types and fields here {@see ../typeDefs/user.graphql}
Expand Down Expand Up @@ -241,4 +243,16 @@ export default {
return true;
},
},
User: {
/**
* Returns user registration date
*
* @param {UserDBScheme} user - result of parent resolver
*
* @returns {Date}
*/
registrationDate(user: UserDBScheme): Date {
return dateFromObjectId(user._id);
},
},
};
14 changes: 13 additions & 1 deletion src/resolvers/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import cloudPaymentsApi from '../utils/cloudPaymentsApi';
import { emailNotification, TaskPriorities } from '../utils/emailNotifications';
import { SenderWorkerTaskType } from '../types/userNotifications';
import ProjectToWorkspace from '../models/projectToWorkspace';
import { Validator } from '../utils/validator';
import Validator from '../utils/validator';
import { dateFromObjectId } from '../utils/dates';

const { ApolloError, UserInputError, ForbiddenError } = require('apollo-server-express');
const crypto = require('crypto');
Expand Down Expand Up @@ -386,6 +387,17 @@ module.exports = {
workspace: () => ({}),
},
Workspace: {
/**
* Returns workspace creation date
*
* @param {WorkspaceDBScheme} workspace - result of parent resolver
*
* @returns {Date}
*/
creationDate(workspace) {
return dateFromObjectId(workspace._id);
},

/**
* Returns workspace invite hash
* If workspace has not hash this resolver generates it
Expand Down
5 changes: 5 additions & 0 deletions src/typeDefs/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ type Project {
"""
description: String
"""
Date of creating project
"""
creationDate: DateTime!
"""
Project domain
"""
Expand Down
5 changes: 5 additions & 0 deletions src/typeDefs/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default gql`
"""
name: String
"""
Date of registration
"""
registrationDate: DateTime!
"""
User's image
"""
Expand Down
5 changes: 5 additions & 0 deletions src/typeDefs/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export default gql`
"""
description: String
"""
Date of creating workspace
"""
creationDate: DateTime!
"""
Workspace logo image
"""
Expand Down
13 changes: 12 additions & 1 deletion src/utils/dates.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ObjectId } from 'mongodb';

/**
* Return timestamp for UTC midnight of the passed date
*
Expand Down Expand Up @@ -66,4 +68,13 @@ export function getMidnightWithTimezoneOffset(utcOccurrenceTime: number, utcMidn
const localMidnight = getUTCMidnight(localDate);

return localMidnight / milliseconds;
}
}

/**
* Returns date parsed from object id
*
* @param objectId - id of entity for getting date
*/
export function dateFromObjectId(objectId: ObjectId): Date {
return objectId.getTimestamp();
}
22 changes: 22 additions & 0 deletions test/utils/dateFromObjectId.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ObjectId } from 'mongodb';
import { dateFromObjectId } from '../../src/utils/dates';

describe('dateFromObjectId', () => {
it('should return correct Date object from Object ID', () => {
/**
* Arrange
*/
const objectId = new ObjectId('612102b24b7a2b00231131b6');
const expectedDate = new Date('2021-08-21T13:42:10.000Z');

/**
* Act
*/
const parsedDate = dateFromObjectId(objectId);

/**
* Assert
*/
expect(parsedDate).toStrictEqual(expectedDate);
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"resolveJsonModule": true, /* Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
Expand Down
Loading

0 comments on commit dd5d2e4

Please sign in to comment.