Skip to content

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
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
749 changes: 691 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.25.2",
"graphql-editor-cli": "^0.8.6",
"graphql-editor-cli": "^0.9.0",
"jest": "^27.5.1",
"prettier": "^2.8.8",
"ts-jest": "^27.1.3",
Expand Down
18 changes: 18 additions & 0 deletions packages/integrations/gei-notifications/.eslintrc.json
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
}
}
4 changes: 4 additions & 0 deletions packages/integrations/gei-notifications/.gitignore
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 packages/integrations/gei-notifications/.graphql-editor.json
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": "./"
}
8 changes: 8 additions & 0 deletions packages/integrations/gei-notifications/.prettierrc.json
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 packages/integrations/gei-notifications/package-lock.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions packages/integrations/gei-notifications/package.json
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"
}
}
271 changes: 271 additions & 0 deletions packages/integrations/gei-notifications/schema.graphql
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!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
generatePushNotificationToken: GeneratePushNotificationTokenResult!
generatePushNotificationToken: GeneratePushNotificationTokenResult!

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.

}

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
}
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',
});
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);
Loading