ifms-pti/server/src/typeDefs.js

327 lines
7.1 KiB
JavaScript
Raw Normal View History

2020-11-06 13:31:28 +00:00
import { gql } from 'apollo-server'
const typeDefs = gql`
type Query {
2020-12-21 19:27:24 +00:00
"Returns only a few fields of a user"
2021-11-17 16:17:56 +00:00
basicUser(sAMAccountName: String!): User! @cacheControl(maxAge: 10)
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"The authenticated user"
me: User! @auth
2020-12-21 19:27:24 +00:00
"All users matching the criteria"
2020-11-06 13:31:28 +00:00
users(
where: UserWhereInput!
2020-12-21 19:27:24 +00:00
"How many?"
2020-11-06 13:31:28 +00:00
limit: Int = 15
2020-12-21 19:27:24 +00:00
"Should return only students?"
2020-11-06 13:31:28 +00:00
onlyStudents: Boolean = false
2021-11-17 16:17:56 +00:00
): [User!] @auth(roles: ["servant"]) @cacheControl(maxAge: 10)
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"A single user"
2020-11-06 13:31:28 +00:00
user(sAMAccountName: String!): User!
@auth(roles: ["superAdmin"])
2021-11-17 16:17:56 +00:00
@cacheControl(maxAge: 10)
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"AD groups"
2020-11-06 13:31:28 +00:00
groups(where: GroupWhereInput!, limit: Int = 10): [Group!]!
@auth(roles: ["servant"])
2021-11-17 16:17:56 +00:00
@cacheControl(maxAge: 10)
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"Current stats. Differs from the historical statistics."
2021-11-17 16:17:56 +00:00
stats: Stats!
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"Users who has some device currently connected to Wi-Fi"
2020-11-27 19:01:55 +00:00
userPresence(search: String = ""): [UserPresence!] @auth(roles: ["watcher"])
2020-12-21 19:27:24 +00:00
"Devices that uses the Wi-Fi"
2020-11-06 13:31:28 +00:00
wifiDevices(
search: String = ""
identifiedOnly: Boolean = false
nonIdentifiedOnly: Boolean = false
2021-11-17 16:17:56 +00:00
): [WifiDevice]! @auth(roles: ["superAdmin"])
2020-11-06 13:31:28 +00:00
2020-12-21 19:27:24 +00:00
"Users that uses the Wi-Fi"
2021-11-17 16:17:56 +00:00
wifiUsers: [User]! @auth(roles: ["superAdmin"])
2020-12-18 14:53:04 +00:00
2020-12-21 19:27:24 +00:00
"Application Logs"
2020-12-23 21:30:34 +00:00
logs(
search: String = ""
2020-12-23 21:36:40 +00:00
dateIn: String
2020-12-23 21:30:34 +00:00
dateOut: String
limit: Int = 200
2021-11-17 16:17:56 +00:00
): [Log]! @auth(roles: ["superAdmin"])
2021-01-14 23:20:01 +00:00
pAHosts: [PAHost!]! @auth(roles: ["superAdmin"])
2020-11-06 13:31:28 +00:00
}
type Mutation {
2020-12-21 19:27:24 +00:00
"System login"
2020-11-06 13:31:28 +00:00
login(data: LoginInput!): AuthPayload!
2020-12-21 19:27:24 +00:00
"Update own password"
2020-11-06 13:31:28 +00:00
updatePassword(data: UpdatePasswordInput!): AuthPayload! @auth
2020-12-21 19:27:24 +00:00
"Update someone elses password"
2020-11-06 13:31:28 +00:00
replacePassword(data: ReplacePasswordInput!): String!
@auth(roles: ["superAdmin"])
2020-12-21 19:27:24 +00:00
"Create a Reset Token to reset a student password"
2020-11-06 13:31:28 +00:00
createResetToken(data: CreateResetTokenInput!): ResetToken!
@auth(roles: ["superAdmin", "tokenCreator"])
2020-12-21 19:27:24 +00:00
"Use a provided Reset Token to update a user password"
2020-11-06 13:31:28 +00:00
useResetToken(data: UseResetTokenInput!): Boolean!
2020-12-21 19:27:24 +00:00
2021-11-17 14:19:52 +00:00
"Delete all expired Tokens"
deleteExpiredTokens: String!
2020-12-21 19:27:24 +00:00
"Import all users from Active Directory"
2020-11-06 13:31:28 +00:00
importUsers: String! @auth(roles: ["superAdmin"])
2020-12-21 19:27:24 +00:00
"Force update devices connected to Wi-Fi"
2020-12-10 14:11:36 +00:00
updateWifiDevices: String! @auth(roles: ["superAdmin"])
2020-12-21 19:27:24 +00:00
"Force update user-id mapping on firewall"
2020-12-02 15:20:27 +00:00
updateUserIdMappings: String! @auth(roles: ["superAdmin"])
2021-01-14 17:04:41 +00:00
"Add a PA host"
addPAHost(data: AddPAHostInput!): PAHost! @auth(roles: ["superAdmin"])
2021-01-15 20:26:44 +00:00
"Remove a PA host"
delPAHost(id: Int!): PAHost! @auth(roles: ["superAdmin"])
2020-11-06 13:31:28 +00:00
}
2020-12-03 21:27:03 +00:00
type Subscription {
2020-12-21 19:27:24 +00:00
"The information about users who has some device currently connected to Wi-Fi was updated"
2020-12-03 21:27:03 +00:00
userPresenceUpdated: Int! @auth(roles: ["watcher"])
2020-12-21 19:27:24 +00:00
"Info about the logged user was updated"
2020-12-04 22:40:47 +00:00
authUpdated: User! @auth
2020-12-03 21:27:03 +00:00
}
2020-12-21 19:27:24 +00:00
"Needs authentication. Optionally, provide an array with roles to match."
2020-11-06 13:31:28 +00:00
directive @auth(roles: [String!]) on FIELD_DEFINITION
"A mix between the database User and the Active Directory User"
type User {
2020-11-06 13:31:28 +00:00
id: ID
wifiDevices: [WifiDevice!]
lastLogin: String
lastLoginPrior: String
roles: [String!]
groups: [Group!]
sharedFolders: [String!]
sharedPrinters: [String!]
2020-11-06 13:31:28 +00:00
firstName: String
isSuperAdmin: Boolean!
isTokenCreator: Boolean!
isServant: Boolean!
isStudent: Boolean!
isWatcher: Boolean!
createdAt: String!
updatedAt: String!
accountExpires: String
badPasswordTime: String
badPwdCount: String
cn: String
department: String
description: String
displayName: String
distinguishedName: String
dn: String
extensionAttribute1: String
extensionAttribute10: String
extensionAttribute2: String
extensionAttribute6: String
extensionAttribute7: String
givenName: String
homeDirectory: String
homeDrive: String
lastLogon: String
lastLogonTimestamp: String
lockoutTime: String
logonCount: String
mail: String
name: String
objectCategory: String
objectGUID: String
objectSid: String
primaryGroupID: String
pwdLastSet: String
sAMAccountName: String!
sAMAccountType: String
sn: String
thumbnailPhoto: String
title: String
userAccountControl: String
userPrincipalName: String
whenChanged: String
whenCreated: String
}
2020-12-21 19:27:24 +00:00
"Active Directory Groups"
2020-11-06 13:31:28 +00:00
type Group {
cn: String!
dn: String!
name: String
members: [User!]!
}
2020-12-21 19:27:24 +00:00
"Authentication payload"
2020-11-06 13:31:28 +00:00
type AuthPayload {
2020-12-21 19:27:24 +00:00
"The user who has logged in"
2020-11-06 13:31:28 +00:00
user: User!
2020-12-21 19:27:24 +00:00
"A Json Web Token used to authenticate with the API"
2020-11-06 13:31:28 +00:00
token: String!
2020-12-21 19:27:24 +00:00
"Time to invalidate the provided token"
2020-11-06 13:31:28 +00:00
expiresIn: String!
}
2020-12-21 19:27:24 +00:00
"A token to be used for passwords updates"
2020-11-06 13:31:28 +00:00
type ResetToken {
id: ID!
user: User!
creator: User!
token: String!
expiration: String!
createdAt: String!
updatedAt: String!
}
2020-12-21 19:27:24 +00:00
"Current stats"
2020-11-06 13:31:28 +00:00
type Stats {
tokenCountTotal: Int!
tokenCountUsed: Int!
tokenCountExpired: Int!
tokenCountNotUsed: Int!
2020-12-04 14:38:08 +00:00
onlineUsers: Int!
offlineUsers: Int!
totalUsers: Int!
2020-12-07 18:13:11 +00:00
totalWifiDevices: Int!
2020-12-10 14:11:36 +00:00
onlineWifiDevices: Int!
2020-11-06 13:31:28 +00:00
}
2020-12-21 19:27:24 +00:00
"A device connected to the Wi-Fi"
2020-11-06 13:31:28 +00:00
type WifiDevice {
user: User
2020-11-19 15:23:31 +00:00
id: ID!
2020-11-06 13:31:28 +00:00
oui: String
2020-11-19 15:23:31 +00:00
mac: String!
controller: String!
2020-11-06 13:31:28 +00:00
hostname: String
firstSeen: String
lastSeen: String
essid: String
ip: String
uptime: String
apName: String
status: Status
}
2020-12-21 19:27:24 +00:00
"A user that is on the Wi-Fi network reach"
2020-11-06 13:31:28 +00:00
type UserPresence {
2020-12-17 21:45:12 +00:00
id: ID!
displayName: String!
thumbnailPhoto: String
lastSeen: String!
status: Status!
apName: String!
2020-11-06 13:31:28 +00:00
}
2020-12-21 19:27:24 +00:00
"The status of a Device"
2020-11-06 13:31:28 +00:00
enum Status {
ONLINE
2020-12-17 20:28:09 +00:00
RECENT
2020-11-06 13:31:28 +00:00
OFFLINE
}
2020-12-21 19:27:24 +00:00
"A log message"
2020-12-18 14:53:04 +00:00
type Log {
id: ID!
timestamp: String!
level: LogLevel!
2020-12-19 13:06:40 +00:00
tags: [String]!
2020-12-18 14:53:04 +00:00
message: String
data: String
}
2020-12-21 19:27:24 +00:00
"The severity of a log entry"
2020-12-18 14:53:04 +00:00
enum LogLevel {
LOW
INFO
SUCCESS
WARNING
ERROR
}
2021-01-14 23:20:01 +00:00
"A Palo Alto firewall host"
2021-01-14 17:04:41 +00:00
type PAHost {
id: ID!
2021-01-14 23:20:01 +00:00
"Short description"
description: String!
"IP address in CIDR format"
cidr: String!
"First 5 characters from the key"
key: String!
"OptionalNote"
2021-01-14 17:04:41 +00:00
note: String
2021-01-15 14:50:56 +00:00
"The API key owner"
user: String
2021-01-18 20:03:08 +00:00
"The user who added the host"
owner: User!
2021-01-14 23:20:01 +00:00
2021-01-14 17:04:41 +00:00
createdAt: String
updatedAt: String
}
2020-11-06 13:31:28 +00:00
input LoginInput {
username: String!
password: String!
}
input UpdatePasswordInput {
oldPassword: String!
newPassword: String!
}
input ReplacePasswordInput {
username: String!
newPassword: String!
}
input UserWhereInput {
cn: String
displayName: String
sAMAccountName: String
}
input GroupWhereInput {
cn: String
dn: String
name: String
}
input CreateResetTokenInput {
username: String!
}
input UseResetTokenInput {
token: String!
newPassword: String!
}
2021-01-14 17:04:41 +00:00
input AddPAHostInput {
2021-01-14 19:12:37 +00:00
cidr: String!
2021-01-14 17:04:41 +00:00
user: String!
password: String!
description: String!
note: String
}
2020-11-06 13:31:28 +00:00
`
export { typeDefs }