-
Notifications
You must be signed in to change notification settings - Fork 0
Gei notifications #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pavelbrui
wants to merge
7
commits into
master
Choose a base branch
from
gei-notifications
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
525c4c9
feat: Init gei notifications
TakSeBiegam 9bfd91a
addGetAuthorize
pavelbrui b321cb1
clean
pavelbrui 225d31f
addSendPushNotification
pavelbrui b66bb60
addSendPushNotificationToUserAndAuthorization
pavelbrui c2f2ff5
cleanAll
pavelbrui c4e778e
last
pavelbrui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"prettier" | ||
], | ||
"rules": { | ||
"@typescript-eslint/explicit-function-return-type": 0 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
/lib | ||
/node_modules | ||
.graphql-editor-auth.json |
11 changes: 11 additions & 0 deletions
11
packages/integrations/gei-notifications/.graphql-editor.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"namespace": "editor-integrations", | ||
"project": "gei-notifications", | ||
"projectVersion": "latest", | ||
"typingsEnv": "node", | ||
"typingsHost": "http://localhost:8080/", | ||
"typingsDir": "./src", | ||
"backendSrc": "./src", | ||
"backendLib": "./lib", | ||
"schemaDir": "./" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"arrowParens": "always", | ||
"semi": true, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} |
2,710 changes: 2,710 additions & 0 deletions
2,710
packages/integrations/gei-notifications/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "gei-notifications", | ||
"version": "0.0.0", | ||
"description": "Automatically generated by graphql-editor-cli", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"start": "gecli dev", | ||
"build": "tsc", | ||
"watch": "tsc --watch", | ||
"update": "gecli codegen models && gecli schema pull && gecli codegen typings" | ||
}, | ||
"author": "GraphQL Editor Centaur Generator", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/node": "^18.7.18", | ||
"@types/node-fetch": "^2.6.2", | ||
"@types/ws": "^8.5.4", | ||
"@typescript-eslint/eslint-plugin": "^5.38.0", | ||
"@typescript-eslint/parser": "^5.38.0", | ||
"eslint": "^8.23.1", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.7.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.3" | ||
}, | ||
"dependencies": { | ||
"@pusher/push-notifications-server": "^1.2.6", | ||
"node-fetch": "^3.2.10", | ||
"pusher": "^5.1.3", | ||
"stucco-js": "^0.10.17", | ||
"ws": "^8.12.0" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
type Query{ | ||
userQuery( | ||
userId: String! | ||
): UserQuery | ||
publicQuery: PublicQuery! | ||
} | ||
|
||
type UserQuery{ | ||
listNotifications( | ||
input: ListNotificationsInput | ||
): ListNotificationsResult! | ||
listChannels( | ||
input: ListChannelsInput | ||
): ListChannelsResult! | ||
generatePushNotificationToken: GeneratePushNotificationTokenResult! | ||
} | ||
|
||
type Mutation{ | ||
userMutation( | ||
userId: String! | ||
): UserMutation | ||
} | ||
|
||
type UserMutation{ | ||
markNotificationReaded( | ||
input: MarkNotificationReadedInput! | ||
): MarkNotificationReadedResult! | ||
sendStaticNotification( | ||
input: SendStaticNotificationInput! | ||
): SendStaticNotificationResult! | ||
getChannelAuthorization( | ||
input: GetChannelAuthorizationInput! | ||
): GetChannelAuthorizationResult! | ||
createNotificationGroup( | ||
input: CreateNotificationGroupInput! | ||
): CreateNotificationGroupResult! | ||
modifyNotifactionGroup( | ||
groupId: String! | ||
): NotificationGroupOps | ||
} | ||
|
||
type PublicQuery{ | ||
listNotificationGroups( | ||
input: ListNotificationGroupsInput | ||
): ListNotificationGroupsResult! | ||
} | ||
|
||
type NotificationGroupOps{ | ||
""" | ||
if we adding or removing users, duplicates will be reduced | ||
""" | ||
addUserToGroup( | ||
userIds: [String!] | ||
): AddUserToGroupResult! | ||
removeUserFromGroup( | ||
userIds: [String!] | ||
): RemoveUserToGroupResult! | ||
editNotificationGroup( | ||
input: EditNotificationGroupInput! | ||
): EditNotificationGroupResult | ||
deleteNotificationGroup: DeleteNotificationGroupResult! | ||
} | ||
|
||
type GeneratePushNotificationTokenResult{ | ||
error: GlobalError | ||
token: String! | ||
exp: Date | ||
} | ||
|
||
input GetChannelAuthorizationInput{ | ||
targetId: String! | ||
socketId: String! | ||
} | ||
|
||
type GetChannelAuthorizationResult{ | ||
error: GlobalError | ||
auth: String | ||
channel_data: String | ||
shared_secret: String | ||
} | ||
|
||
input ListChannelsInput{ | ||
page: PageOptionsInput | ||
} | ||
|
||
input ListNotificationGroupsInput{ | ||
page: PageOptionsInput | ||
filter: ListNotificationGroupsInputFilter | ||
} | ||
|
||
input ListNotificationGroupsInputFilter{ | ||
""" | ||
this is a regex searching | ||
""" | ||
name: String | ||
""" | ||
if targetId is filled, this filter will return Notification groups that contains inside specific target | ||
""" | ||
targetId: String | ||
sortDirection: SortDirection | ||
notificationType: NotificationType | ||
startDate: Date | ||
endDate: Date | ||
} | ||
|
||
input ListNotificationsInput{ | ||
filter: ListNotificationsInputFilter | ||
page: PageOptionsInput | ||
} | ||
|
||
input ListNotificationsInputFilter{ | ||
notificationType: NotificationType | ||
sortDirection: SortDirection | ||
isReaded: Boolean | ||
startDate: Date | ||
endDate: Date | ||
} | ||
|
||
input SendStaticNotificationInput{ | ||
channelsId: [String!]! | ||
message: String! | ||
event: String! | ||
} | ||
|
||
type ListChannelsResult{ | ||
error: GlobalError | ||
result: [Channel!] | ||
page: PageOptionsResult | ||
} | ||
|
||
type DeleteNotificationGroupResult{ | ||
error: GlobalError | ||
result: Boolean | ||
} | ||
|
||
type SendStaticNotificationResult{ | ||
error: GlobalError | ||
result: Boolean | ||
} | ||
|
||
type EditNotificationGroupResult{ | ||
error: GlobalError | ||
result: Boolean | ||
} | ||
|
||
input EditNotificationGroupInput{ | ||
name: String | ||
users: [String!] | ||
} | ||
|
||
type AddUserToGroupResult implements error{ | ||
result: Boolean | ||
error: GlobalError | ||
} | ||
|
||
type RemoveUserToGroupResult implements error{ | ||
result: Boolean | ||
error: GlobalError | ||
} | ||
|
||
type CreateNotificationGroupResult implements error{ | ||
error: GlobalError | ||
result: Boolean | ||
} | ||
|
||
input CreateNotificationGroupInput{ | ||
name: String! | ||
users: [String!]! | ||
notificationType: NotificationType! | ||
} | ||
|
||
type MarkNotificationReadedResult{ | ||
error: GlobalError | ||
result: Boolean | ||
} | ||
|
||
input MarkNotificationReadedInput{ | ||
state: Boolean! | ||
notificationId: String! | ||
} | ||
|
||
type ListNotificationGroupsResult implements error{ | ||
error: GlobalError | ||
notificationGroup: [NotificationGroup!] | ||
} | ||
|
||
type ListNotificationsResult implements error{ | ||
error: GlobalError | ||
notification: [Notification!] | ||
page: PageOptionsResult | ||
} | ||
|
||
type GlobalError{ | ||
message: String! | ||
path: String! | ||
} | ||
|
||
type Notification implements DbEssentials{ | ||
body: String! | ||
targetIds: [String!]! | ||
_id: String! | ||
createdAt: Date! | ||
isReaded: Boolean! | ||
notificationType: NotificationType! | ||
} | ||
|
||
type NotificationGroup implements DbEssentials{ | ||
targets: [String!]! | ||
notificationType: NotificationType! | ||
name: String! | ||
_id: String! | ||
createdAt: Date! | ||
} | ||
|
||
type NotificationReaded{ | ||
userId: String! | ||
notificationId: String! | ||
createdAt: Date! | ||
} | ||
|
||
type Channel{ | ||
channelId: String! | ||
createdAt: Date | ||
} | ||
|
||
input PageOptionsInput{ | ||
""" | ||
default limit is 10 | ||
""" | ||
limit: Int | ||
""" | ||
count stating from 0 | ||
""" | ||
page: Int | ||
} | ||
|
||
type PageOptionsResult{ | ||
count: Int | ||
hasNext: Boolean | ||
} | ||
|
||
interface DbEssentials{ | ||
_id: String! | ||
createdAt: Date! | ||
} | ||
|
||
interface error{ | ||
error: GlobalError | ||
} | ||
|
||
enum NotificationTargetType{ | ||
USER | ||
GROUP | ||
} | ||
|
||
enum SortDirection{ | ||
asc | ||
desc | ||
} | ||
|
||
enum NotificationType{ | ||
STATIC | ||
PUSH | ||
} | ||
|
||
scalar Date | ||
|
||
schema{ | ||
query: Query | ||
mutation: Mutation | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/integrations/gei-notifications/src/Mutation/userMutation.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FieldResolveInput } from 'stucco-js'; | ||
|
||
export const handler = async (input: FieldResolveInput) => ({ | ||
userId: 'root', | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/integrations/gei-notifications/src/PublicQuery/listNotificationGroups.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FieldResolveInput } from 'stucco-js'; | ||
import { resolverFor } from '../zeus/index.js'; | ||
import { orm, prepareDateOptions, preparePageOptions } from '../utils/db/orm.js'; | ||
|
||
export const isNotNullObject = (v: unknown): v is Record<string | number | symbol, unknown> => | ||
typeof v === 'object' && v !== null; | ||
|
||
export const handler = async (input: FieldResolveInput) => | ||
resolverFor('PublicQuery', 'listNotificationGroups', async (args, src) => { | ||
const { limit, skip } = preparePageOptions(args.input?.page); | ||
const o = await orm(); | ||
console.log('abc'); | ||
return await o('NotificationGroup') | ||
.collection.find({ | ||
...(args.input?.filter?.name && { name: { $regex: args.input.filter.name } }), | ||
...(args.input?.filter?.targetId && { targets: args.input.filter.targetId }), | ||
...prepareDateOptions(args.input?.filter?.startDate, args.input?.filter?.endDate), | ||
...(args.input?.filter?.notificationType && { notificationType: args.input.filter.notificationType }), | ||
}) | ||
.limit(limit) | ||
.skip(skip) | ||
.sort({ createdAt: args.input?.filter?.sortDirection ? args.input.filter.sortDirection : 'desc' }) | ||
.toArray(); | ||
})(input.arguments, input.source); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dlaczego to jest w query? Może aktualna implementacja nie ma żadynch side effectów, ale sama nazwa
generate
sugeruje, że kiedyś będą potrzebne.