Browse Source

feat: Better build

develop
Dale 2 weeks ago
parent
commit
4693f197bb
Signed by: Deiru GPG Key ID: AA250C0277B927E1
  1. 14
      codegen.yml
  2. 26
      default.nix
  3. 3
      next-env.d.ts
  4. 3
      next.config.js
  5. 18
      package.json
  6. 1
      result
  7. 35
      src/db/models/Sessions.ts
  8. 8
      src/db/types.ts
  9. 6
      src/graphql/mutations/users/index.ts
  10. 63
      src/pages/_app.tsx
  11. 41
      src/pages/index.tsx
  12. 0
      src/server/config/index.ts
  13. 0
      src/server/config/local.json
  14. 2
      src/server/db/acl/roles.ts
  15. 4
      src/server/db/generate-roles.ts
  16. 2
      src/server/db/index.ts
  17. 11
      src/server/db/models/Activities.ts
  18. 11
      src/server/db/models/Channels.ts
  19. 11
      src/server/db/models/Roles.ts
  20. 39
      src/server/db/models/Sessions.ts
  21. 8
      src/server/db/models/StreamKeys.ts
  22. 12
      src/server/db/models/Users.ts
  23. 0
      src/server/db/models/index.ts
  24. 2
      src/server/db/setup-db.ts
  25. 8
      src/server/db/types.ts
  26. 0
      src/server/graphql/errors/auth.ts
  27. 0
      src/server/graphql/errors/general.ts
  28. 0
      src/server/graphql/errors/users.ts
  29. 38
      src/server/graphql/index.ts
  30. 6
      src/server/graphql/mutations/activities/index.ts
  31. 10
      src/server/graphql/mutations/channels/index.ts
  32. 10
      src/server/graphql/mutations/stream-keys/index.ts
  33. 9
      src/server/graphql/mutations/users/auth.ts
  34. 10
      src/server/graphql/mutations/users/index.ts
  35. 7
      src/server/graphql/resolvers/activities/index.ts
  36. 7
      src/server/graphql/resolvers/channels/index.ts
  37. 6
      src/server/graphql/resolvers/roles/index.ts
  38. 8
      src/server/graphql/resolvers/stream-keys/index.ts
  39. 6
      src/server/graphql/resolvers/users/index.ts
  40. 0
      src/server/graphql/schema/Activities.graphql
  41. 0
      src/server/graphql/schema/Channels.graphql
  42. 0
      src/server/graphql/schema/Roles.graphql
  43. 0
      src/server/graphql/schema/Root.graphql
  44. 0
      src/server/graphql/schema/Scalars.graphql
  45. 0
      src/server/graphql/schema/StreamKeys.graphql
  46. 0
      src/server/graphql/schema/User.graphql
  47. 4
      src/server/server.ts
  48. 0
      src/server/types/graphql.ts
  49. 0
      src/server/types/resolver.ts
  50. 711
      src/shared/graphql.ts
  51. 44
      src/shared/hooks.ts
  52. 60
      tsconfig.json
  53. 2376
      yarn.lock

14
codegen.yml

@ -1,11 +1,19 @@
overwrite: true
schema: "http://localhost:4000/graphql"
documents: null
schema: "${API_URL}/graphql"
documents:
- 'src/**/*.{ts,tsx,graphql}'
generates:
src/types/graphql.ts:
src/shared/graphql.ts:
plugins:
- "typescript"
- "typescript-resolvers"
- "typescript-operations"
./graphql.schema.json:
plugins:
- "introspection"
src/shared/hooks.ts:
preset: import-types
presetConfig:
typesPath: 'shared/graphql'
plugins:
- typescript-react-apollo

26
default.nix

@ -13,22 +13,36 @@ in mkYarnPackage rec {
packageJSON = "${src}/package.json";
yarnLock = "${src}/yarn.lock";
configurePhase = ''
ln -s $node_modules ./node_modules
configurePhase = ''
rm -rf ./node_modules
mkdir ./node_modules
cp -R $node_modules/* ./node_modules
cp -R $node_modules/.bin ./node_modules
'';
buildPhase = ''
NODE_ENV=production $node_modules/.bin/ncc build src/server.ts -o ./dist/server
yarn build:server
yarn build:client
'';
installPhase = ''
mkdir -p $out/server/graphql
mkdir -p $out/server
cp -R ./dist/server/* $out/server/
cp -R src/graphql/schema/* $out/server/graphql/
makeWrapper ${nodePkg}/bin/node $out/bin/${name} \
mkdir -p $out/server/graphql
cp -R src/server/graphql/schema/* $out/server/graphql/
makeWrapper ${nodePkg}/bin/node $out/bin/server \
--add-flags "$out/server/index.js" \
--set node_modules $node_modules \
--set NODE_PATH $NODE_PATH:$node_modules
mkdir -p $out/client/dist
cp -R ./next-production.config.js $out/client/next.config.js
cp -R ./dist/client/* $out/client/dist
makeWrapper $node_modules/.bin/next $out/bin/client \
--add-flags "start" \
--add-flags "$out/client" \
--set node_modules $node_modules \
--set NODE_PATH $NODE_PATH:$node_modules
'';
distPhase = ''

3
next-env.d.ts

@ -0,0 +1,3 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

3
next.config.js

@ -0,0 +1,3 @@
module.exports = {
distDir: "/dist/client",
};

18
package.json

@ -8,30 +8,42 @@
"daemon:start": "NODE_ENV=production name=miracle-tv pm2 start yarn --name miracle-tv -- server",
"daemon:stop": "pm2 delete miracle-tv",
"daemon:restart": "name=miracle-tv pm2 restart miracle-tv --update-env",
"server": "NODE_ENV=production $node_modules/.bin/ts-node -r tsconfig-paths/register src/server.ts",
"client:dev": "next dev",
"server": "NODE_ENV=production $node_modules/.bin/ts-node -r tsconfig-paths/register src/server/server.ts",
"codegen": "graphql-codegen --config codegen.yml",
"dev": "nodemon -e ts,tsx,graphql --exec \"yarn run server\""
},
"dependencies": {
"@apollo/client": "^3.3.21",
"@chakra-ui/react": "^1.6.5",
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"apollo-server": "^2.24.0",
"apollo-server-express": "^2.24.0",
"async": "^3.2.0",
"express": "^4.17.1",
"express-graphql": "^0.12.0",
"framer-motion": "^4.1.17",
"glob": "^7.1.7",
"graphql": "^15.5.0",
"graphql": "^15.5.1",
"luxon": "^1.27.0",
"md5": "^2.3.0",
"module-alias": "^2.2.2",
"next": "^11.0.1",
"pm2": "^4.5.6",
"ramda": "^0.27.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rethinkdb": "^2.4.2",
"tsconfig-paths": "^3.9.0"
},
"devDependencies": {
"@graphql-codegen/cli": "1.21.4",
"@graphql-codegen/import-types-preset": "^1.18.6",
"@graphql-codegen/introspection": "1.18.2",
"@graphql-codegen/typescript": "1.22.0",
"@graphql-codegen/typescript-operations": "^1.18.4",
"@graphql-codegen/typescript-react-apollo": "^2.3.1",
"@graphql-codegen/typescript-resolvers": "1.19.1",
"@types/async": "^3.2.6",
"@types/express": "^4.17.11",
@ -41,6 +53,8 @@
"@types/md5": "^2.3.0",
"@types/module-alias": "^2.0.0",
"@types/ramda": "^0.27.40",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@types/rethinkdb": "^2.3.16",
"@vercel/ncc": "^0.28.6",
"file-loader": "^6.2.0",

1
result

@ -1 +0,0 @@
/nix/store/d4gc5hnnk1c1d7r503nfpxa3m5i2fhrh-miracle-tv

35
src/db/models/Sessions.ts

@ -1,35 +0,0 @@
import db from 'miracle-tv/db';
import { DbUser } from 'miracle-tv/db/types';
import { Model } from 'miracle-tv/db/models';
import { Session, SessionResponse } from 'miracle-tv/types/graphql';
import { DateTime } from 'luxon';
import { head } from 'ramda'
import { ServerError } from 'miracle-tv/graphql/errors/general';
export class SessionsModel extends Model {
table = db.table('sessions')
async createSession(userId: string): Promise<SessionResponse> {
return await this.table.insert({
user: userId,
expiresAt: DateTime.now().plus({ days: 30 }).toLocal().toISO(),
})
.run(this.conn)
.then(async (res) => {
const key = head(res.generated_keys)
const session = await this.getSessionById(key)
if (session) {
return { token: session.id, expiresAt: session.expiresAt }
}
throw new ServerError('Couldn\'t create session')
})
}
async getSessionById(id: string): Promise<Session> {
return await this.table.get(id).run(this.conn) as Session
}
async getUsers(filter?: Record<keyof DbUser, any>): Promise<Session[]> {
return await this.table.filter(filter).coerceTo('array').run(this.conn) as Session[]
}
}

8
src/db/types.ts

@ -1,8 +0,0 @@
import { Session, User } from "miracle-tv/types/graphql";
export type DbUser = Omit<User, 'emailHash'> & {
email: string
password: string
}
export type DbSession = Session

6
src/graphql/mutations/users/index.ts

@ -1,6 +0,0 @@
import { MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
export const signUpMutation: MutationResolvers<ResolverContext>['signUp'] = (_, { input }, { db: { users }}) => {
return users.createUserSafe(input)
};

63
src/pages/_app.tsx

@ -0,0 +1,63 @@
import { ChakraProvider } from "@chakra-ui/react";
import { Global, css } from "@emotion/react";
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
createHttpLink,
} from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
import Head from "next/head";
const httpLink = createHttpLink({
uri: process.env.NEXT_PUBLIC_API_URL
? process.env.NEXT_PUBLIC_API_URL
: "http://localhost:4000/graphql",
});
const authLink = setContext((_, { headers }) => {
// get the authentication token from local storage if it exists
const token = localStorage.getItem("token");
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
Authorization: token ? `${token}` : "",
},
};
});
const client = new ApolloClient({
cache: new InMemoryCache(),
link: authLink.concat(httpLink),
});
function MyApp({ Component, pageProps }: any) {
return (
<>
<Head>
<title>Кофейня - Учёт</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<Global
styles={css`
html,
body,
#__next {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
`}
/>
<ApolloProvider client={client}>
<ChakraProvider>
<Component {...pageProps} />
</ChakraProvider>
</ApolloProvider>
</>
);
}
export default MyApp;

41
src/pages/index.tsx

@ -0,0 +1,41 @@
import { gql } from "@apollo/client";
import { Box, Flex, Text } from "@chakra-ui/layout";
import { useHomeChannelsQuery } from "miracle-tv-shared/hooks";
gql`
query HomeChannels {
channels {
name
activity {
name
}
description
}
}
`;
const Home = () => {
const { data, loading } = useHomeChannelsQuery();
return (
<Flex w="100%" minH="100%" align="center" direction="column" p={6}>
{data &&
!loading &&
data?.channels?.map((channel: any) => (
<Box
p={3}
mb={3}
bgColor="lightgrey"
color="black"
borderRadius="15px"
key={channel.id}
w="30vw"
>
<Text mb={3}>Channel: {channel?.name}</Text>
<Text>Activity: {channel?.activity?.name}</Text>
</Box>
))}
</Flex>
);
};
export default Home;

0
src/config/index.ts → src/server/config/index.ts

0
src/config/local.json → src/server/config/local.json

2
src/db/acl/roles.ts → src/server/db/acl/roles.ts

@ -1,4 +1,4 @@
import { AccessUnit, Role } from "miracle-tv/types/graphql";
import { AccessUnit, Role } from "miracle-tv-server/types/graphql";
import { curry, pathOr, pick } from "ramda";
import { any, lensPath, view } from "ramda";

4
src/db/generate-roles.ts → src/server/db/generate-roles.ts

@ -1,8 +1,8 @@
import * as rdb from "rethinkdb";
import config from "miracle-tv/config";
import config from "miracle-tv-server/config";
import { AccessUnit, Role } from "miracle-tv/types/graphql";
import { AccessUnit, Role } from "miracle-tv-server/types/graphql";
const defaultAdminRole: Role = {
id: "admin",

2
src/db/index.ts → src/server/db/index.ts

@ -1,5 +1,5 @@
import rethinkdb from "rethinkdb";
import config from "miracle-tv/config";
import config from "miracle-tv-server/config";
const db = rethinkdb.db(config.database?.db || "miracle-tv");

11
src/db/models/Activities.ts → src/server/db/models/Activities.ts

@ -1,13 +1,16 @@
import db from "miracle-tv/db";
import { Model } from "miracle-tv/db/models";
import db from "miracle-tv-server/db";
import { Model } from "miracle-tv-server/db/models";
import {
Activity,
ActivityFilter,
CreateActivityInput,
UpdateActivityInput,
} from "miracle-tv/types/graphql";
} from "miracle-tv-server/types/graphql";
import { head } from "ramda";
import { NotFoundError, ServerError } from "miracle-tv/graphql/errors/general";
import {
NotFoundError,
ServerError,
} from "miracle-tv-server/graphql/errors/general";
export class ActivitiesModel extends Model {
table = db.table("activities");

11
src/db/models/Channels.ts → src/server/db/models/Channels.ts

@ -1,12 +1,15 @@
import db from "miracle-tv/db";
import { Model } from "miracle-tv/db/models";
import db from "miracle-tv-server/db";
import { Model } from "miracle-tv-server/db/models";
import {
Channel,
CreateChannelInput,
UpdateChannelInput,
} from "miracle-tv/types/graphql";
} from "miracle-tv-server/types/graphql";
import { head } from "ramda";
import { NotFoundError, ServerError } from "miracle-tv/graphql/errors/general";
import {
NotFoundError,
ServerError,
} from "miracle-tv-server/graphql/errors/general";
type ChanelsFilter = object;

11
src/db/models/Roles.ts → src/server/db/models/Roles.ts

@ -1,11 +1,14 @@
import db from "miracle-tv/db";
import { Model } from "miracle-tv/db/models";
import { NotFoundError, ServerError } from "miracle-tv/graphql/errors/general";
import db from "miracle-tv-server/db";
import { Model } from "miracle-tv-server/db/models";
import {
NotFoundError,
ServerError,
} from "miracle-tv-server/graphql/errors/general";
import {
CreateRoleInput,
Role,
UpdateRoleInput,
} from "miracle-tv/types/graphql";
} from "miracle-tv-server/types/graphql";
import { head } from "ramda";
import { Connection } from "rethinkdb";

39
src/server/db/models/Sessions.ts

@ -0,0 +1,39 @@
import db from "miracle-tv-server/db";
import { DbUser } from "miracle-tv-server/db/types";
import { Model } from "miracle-tv-server/db/models";
import { Session, SessionResponse } from "miracle-tv-server/types/graphql";
import { DateTime } from "luxon";
import { head } from "ramda";
import { ServerError } from "miracle-tv-server/graphql/errors/general";
export class SessionsModel extends Model {
table = db.table("sessions");
async createSession(userId: string): Promise<SessionResponse> {
return await this.table
.insert({
user: userId,
expiresAt: DateTime.now().plus({ days: 30 }).toLocal().toISO(),
})
.run(this.conn)
.then(async (res) => {
const key = head(res.generated_keys);
const session = await this.getSessionById(key);
if (session) {
return { token: session.id, expiresAt: session.expiresAt };
}
throw new ServerError("Couldn't create session");
});
}
async getSessionById(id: string): Promise<Session> {
return (await this.table.get(id).run(this.conn)) as Session;
}
async getUsers(filter?: Record<keyof DbUser, any>): Promise<Session[]> {
return (await this.table
.filter(filter)
.coerceTo("array")
.run(this.conn)) as Session[];
}
}

8
src/db/models/StreamKeys.ts → src/server/db/models/StreamKeys.ts

@ -1,8 +1,8 @@
import db from "miracle-tv/db";
import { Model } from "miracle-tv/db/models";
import { StreamKey } from "miracle-tv/types/graphql";
import db from "miracle-tv-server/db";
import { Model } from "miracle-tv-server/db/models";
import { StreamKey } from "miracle-tv-server/types/graphql";
import { head } from "ramda";
import { ServerError } from "miracle-tv/graphql/errors/general";
import { ServerError } from "miracle-tv-server/graphql/errors/general";
type StreamKeyFilter = {
userId?: string;

12
src/db/models/Users.ts → src/server/db/models/Users.ts

@ -1,13 +1,13 @@
import db from "miracle-tv/db";
import { DbUser } from "miracle-tv/db/types";
import { Model } from "miracle-tv/db/models";
import { CreateUserInput, User } from "miracle-tv/types/graphql";
import db from "miracle-tv-server/db";
import { DbUser } from "miracle-tv-server/db/types";
import { Model } from "miracle-tv-server/db/models";
import { CreateUserInput, User } from "miracle-tv-server/types/graphql";
import { head, map, omit } from "ramda";
import {
EmailExistsError,
UserExistsError,
} from "miracle-tv/graphql/errors/users";
import { NotFoundError } from "miracle-tv/graphql/errors/general";
} from "miracle-tv-server/graphql/errors/users";
import { NotFoundError } from "miracle-tv-server/graphql/errors/general";
type UsersFilter = Partial<Record<keyof DbUser, any>>;

0
src/db/models/index.ts → src/server/db/models/index.ts

2
src/db/setup-db.ts → src/server/db/setup-db.ts

@ -1,5 +1,5 @@
import * as rdb from "rethinkdb";
import config from "miracle-tv/config";
import config from "miracle-tv-server/config";
import { generateRoles } from "./generate-roles";
const tables: string[] = [

8
src/server/db/types.ts

@ -0,0 +1,8 @@
import { Session, User } from "miracle-tv-server/types/graphql";
export type DbUser = Omit<User, "emailHash"> & {
email: string;
password: string;
};
export type DbSession = Session;

0
src/graphql/errors/auth.ts → src/server/graphql/errors/auth.ts

0
src/graphql/errors/general.ts → src/server/graphql/errors/general.ts

0
src/graphql/errors/users.ts → src/server/graphql/errors/users.ts

38
src/graphql/index.ts → src/server/graphql/index.ts

@ -1,25 +1,25 @@
import { Resolvers } from "miracle-tv/types/graphql";
import { connection } from "miracle-tv/db/setup-db";
import { ResolverContext } from "miracle-tv/types/resolver";
import { Resolvers } from "miracle-tv-server/types/graphql";
import { connection } from "miracle-tv-server/db/setup-db";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import {
userQueryResolver,
userResolver,
usersQueryResolver,
userSelfQueryResolver,
userTestQueryResolver,
} from "./resolvers/users";
import { signUpMutation } from "./mutations/users";
} from "miracle-tv-server/graphql/resolvers/users";
import { signUpMutation } from "miracle-tv-server/graphql/mutations/users";
import { ApolloServer } from "apollo-server-express";
import { gql } from "apollo-server";
import { signInMutation } from "./mutations/users/auth";
import { DbSession, DbUser } from "miracle-tv/db/types";
import { signInMutation } from "miracle-tv-server/graphql/mutations/users/auth";
import { DbSession, DbUser } from "miracle-tv-server/db/types";
import { DateTime } from "luxon";
import { SessionsModel } from "miracle-tv/db/models/Sessions";
import { UsersModel } from "miracle-tv/db/models/Users";
import { SessionsModel } from "miracle-tv-server/db/models/Sessions";
import { UsersModel } from "miracle-tv-server/db/models/Users";
import glob from "glob";
import path from "path";
import { readFileSync } from "fs";
import { ChanelsModel } from "miracle-tv/db/models/Channels";
import { ChanelsModel } from "miracle-tv-server/db/models/Channels";
import {
channelQueryResolver,
channelResolver,
@ -29,7 +29,7 @@ import {
createChannelMutation,
updateChannelMutation,
} from "./mutations/channels";
import { ActivitiesModel } from "miracle-tv/db/models/Activities";
import { ActivitiesModel } from "miracle-tv-server/db/models/Activities";
import {
createActivityMutaiton,
updateActivityMutation,
@ -38,21 +38,21 @@ import {
activitiesQueryResolver,
activityQueryResolver,
activityResolver,
} from "./resolvers/activities";
import { RolesModel } from "miracle-tv/db/models/Roles";
import { getCompleteRights } from "miracle-tv/db/acl/roles";
import { roleResolvers } from "./resolvers/roles";
import config from "miracle-tv/config";
import { StreamKeysModel } from "miracle-tv/db/models/StreamKeys";
} from "miracle-tv-server/graphql/resolvers/activities";
import { RolesModel } from "miracle-tv-server/db/models/Roles";
import { getCompleteRights } from "miracle-tv-server/db/acl/roles";
import { roleResolvers } from "miracle-tv-server/graphql/resolvers/roles";
import config from "miracle-tv-server/config";
import { StreamKeysModel } from "miracle-tv-server/db/models/StreamKeys";
import {
selfStreamKeysQueryResolver,
streamKeysQueryResolver,
streamKeysResolver,
} from "./resolvers/stream-keys";
} from "miracle-tv-server/graphql/resolvers/stream-keys";
import {
createStreamKeyMutation,
revokeStreamKeyMutation,
} from "./mutations/stream-keys";
} from "miracle-tv-server/graphql/mutations/stream-keys";
const schemaString = glob
.sync(path.resolve(__dirname, "./**/*.graphql"))

6
src/graphql/mutations/activities/index.ts → src/server/graphql/mutations/activities/index.ts

@ -1,9 +1,9 @@
import {
AuthenticationError,
AuthorizationError,
} from "miracle-tv/graphql/errors/auth";
import { AccessUnit, MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
} from "miracle-tv-server/graphql/errors/auth";
import { AccessUnit, MutationResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import { any } from "ramda";
export const createActivityMutaiton: MutationResolvers<ResolverContext>["createActivity"] =

10
src/graphql/mutations/channels/index.ts → src/server/graphql/mutations/channels/index.ts

@ -1,11 +1,11 @@
import { checkRight } from "miracle-tv/db/acl/roles";
import { checkRight } from "miracle-tv-server/db/acl/roles";
import {
AuthenticationError,
AuthorizationError,
} from "miracle-tv/graphql/errors/auth";
import { NotFoundError } from "miracle-tv/graphql/errors/general";
import { AccessUnit, MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
} from "miracle-tv-server/graphql/errors/auth";
import { NotFoundError } from "miracle-tv-server/graphql/errors/general";
import { AccessUnit, MutationResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
export const createChannelMutation: MutationResolvers<ResolverContext>["createChannel"] =
async (_, { input }, { user, db: { channels } }) => {

10
src/graphql/mutations/stream-keys/index.ts → src/server/graphql/mutations/stream-keys/index.ts

@ -1,8 +1,8 @@
import { checkRight } from "miracle-tv/db/acl/roles";
import { AuthorizationError } from "miracle-tv/graphql/errors/auth";
import { IncorrectUserError } from "miracle-tv/graphql/errors/users";
import { AccessUnit, MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import { checkRight } from "miracle-tv-server/db/acl/roles";
import { AuthorizationError } from "miracle-tv-server/graphql/errors/auth";
import { IncorrectUserError } from "miracle-tv-server/graphql/errors/users";
import { AccessUnit, MutationResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import { prop } from "ramda";
export const createStreamKeyMutation: MutationResolvers<ResolverContext>["createStreamKey"] =

9
src/graphql/mutations/users/auth.ts → src/server/graphql/mutations/users/auth.ts

@ -1,12 +1,13 @@
import { MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import { MutationResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import { head } from "ramda";
import { InputErrorLogin } from "miracle-tv/graphql/errors/auth";
import { InputErrorLogin } from "miracle-tv-server/graphql/errors/auth";
import { DbUser } from "miracle-tv-server/db/types";
export const signInMutation: MutationResolvers<ResolverContext>["signIn"] =
async (_, { input: { username, password } }, { db: { users, sessions } }) => {
const userList = await users.getUsers({ username });
const user = head(userList);
const user: DbUser = head<DbUser>(userList);
if (user?.password === `salted+${password}`) {
return await sessions.createSession(user?.id!);
}

10
src/server/graphql/mutations/users/index.ts

@ -0,0 +1,10 @@
import { MutationResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
export const signUpMutation: MutationResolvers<ResolverContext>["signUp"] = (
_,
{ input },
{ db: { users } }
) => {
return users.createUserSafe(input);
};

7
src/graphql/resolvers/activities/index.ts → src/server/graphql/resolvers/activities/index.ts

@ -1,5 +1,8 @@
import { ActivityResolvers, QueryResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import {
ActivityResolvers,
QueryResolvers,
} from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import { propOr } from "ramda";
export const activityQueryResolver: QueryResolvers<ResolverContext>["activity"] =

7
src/graphql/resolvers/channels/index.ts → src/server/graphql/resolvers/channels/index.ts

@ -1,5 +1,8 @@
import { ChannelResolvers, QueryResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import {
ChannelResolvers,
QueryResolvers,
} from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
export const channelsQueryResolver: QueryResolvers<ResolverContext>["channels"] =
async (_, { filter }, { db: { channels } }) => {

6
src/graphql/resolvers/roles/index.ts → src/server/graphql/resolvers/roles/index.ts

@ -1,6 +1,6 @@
import { getCompleteRights } from "miracle-tv/db/acl/roles";
import { QueryResolvers, RoleResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import { getCompleteRights } from "miracle-tv-server/db/acl/roles";
import { QueryResolvers, RoleResolvers } from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
export const rolesQueryResolver: QueryResolvers<ResolverContext>["roles"] =
async (_, { filter }, { db: { roles } }) => {

8
src/graphql/resolvers/stream-keys/index.ts → src/server/graphql/resolvers/stream-keys/index.ts

@ -1,11 +1,11 @@
import { checkRight } from "miracle-tv/db/acl/roles";
import { AuthorizationError } from "miracle-tv/graphql/errors/auth";
import { checkRight } from "miracle-tv-server/db/acl/roles";
import { AuthorizationError } from "miracle-tv-server/graphql/errors/auth";
import {
AccessUnit,
QueryResolvers,
StreamKeyResolvers,
} from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
} from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
export const streamKeysQueryResolver: QueryResolvers<ResolverContext>["streamKeys"] =
async (_, _args, { user, userRoles, db: { streamKeys } }) => {

6
src/graphql/resolvers/users/index.ts → src/server/graphql/resolvers/users/index.ts

@ -1,12 +1,12 @@
import md5 from "md5";
import { AuthenticationError } from "miracle-tv/graphql/errors/auth";
import { AuthenticationError } from "miracle-tv-server/graphql/errors/auth";
import {
QueryResolvers,
Role,
User,
UserResolvers,
} from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
} from "miracle-tv-server/types/graphql";
import { ResolverContext } from "miracle-tv-server/types/resolver";
import { pick } from "ramda";
export const usersQueryResolver: QueryResolvers<ResolverContext>["users"] = (

0
src/graphql/schema/Activities.graphql → src/server/graphql/schema/Activities.graphql

0
src/graphql/schema/Channels.graphql → src/server/graphql/schema/Channels.graphql

0
src/graphql/schema/Roles.graphql → src/server/graphql/schema/Roles.graphql

0
src/graphql/schema/Root.graphql → src/server/graphql/schema/Root.graphql

0
src/graphql/schema/Scalars.graphql → src/server/graphql/schema/Scalars.graphql

0
src/graphql/schema/StreamKeys.graphql → src/server/graphql/schema/StreamKeys.graphql

0
src/graphql/schema/User.graphql → src/server/graphql/schema/User.graphql

4
src/server.ts → src/server/server.ts

@ -1,6 +1,6 @@
import Express from "express";
import { graphqlEndpoint } from "miracle-tv/graphql";
import { setupDB } from "miracle-tv/db/setup-db";
import { graphqlEndpoint } from "miracle-tv-server/graphql";
import { setupDB } from "miracle-tv-server/db/setup-db";
import config from "./config";
const app = Express();

0
src/types/graphql.ts → src/server/types/graphql.ts

0
src/types/resolver.ts → src/server/types/resolver.ts

711
src/shared/graphql.ts

@ -0,0 +1,711 @@
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } & { [P in K]-?: NonNullable<T[P]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
DateTime: any;
/** The `Upload` scalar type represents a file upload. */
Upload: any;
};
export type AccessRights = {
__typename?: 'AccessRights';
channels?: Maybe<AccessUnit>;
streamKeys?: Maybe<AccessUnit>;
users?: Maybe<AccessUnit>;
activities?: Maybe<AccessUnit>;
};
export type AccessTargets = {
__typename?: 'AccessTargets';
rights: AccessRights;
actions: Actions;
};
export type AccessTargetsInput = {
channels?: Maybe<AccessUnit>;
users?: Maybe<AccessUnit>;
activities?: Maybe<AccessUnit>;
actions: ActionsInput;
};
export enum AccessUnit {
Deny = 'DENY',
Read = 'READ',
Write = 'WRITE',
Self = 'SELF',
Inherit = 'INHERIT'
}
export type Actions = {
__typename?: 'Actions';
user?: Maybe<UserActions>;
};
export type ActionsInput = {
user?: Maybe<UserActionsInput>;
};
export type Activity = {
__typename?: 'Activity';
id: Scalars['ID'];
icon?: Maybe<Scalars['String']>;
image?: Maybe<Scalars['String']>;
name: Scalars['String'];
verb?: Maybe<Scalars['String']>;
};
export type ActivityFilter = {
id?: Maybe<Scalars['ID']>;
icon?: Maybe<Scalars['String']>;
image?: Maybe<Scalars['String']>;
name?: Maybe<Scalars['String']>;
verb?: Maybe<Scalars['String']>;
};
export enum CacheControlScope {
Public = 'PUBLIC',
Private = 'PRIVATE'
}
export type Channel = {
__typename?: 'Channel';
id: Scalars['ID'];
user?: Maybe<User>;
activity?: Maybe<Activity>;
slug?: Maybe<Scalars['String']>;
name: Scalars['String'];
description?: Maybe<Scalars['String']>;
};
export type ChannelsQueryFilter = {
id?: Maybe<Scalars['ID']>;
user?: Maybe<Scalars['ID']>;
activity?: Maybe<Scalars['ID']>;
slug?: Maybe<Scalars['String']>;
name?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type CreateActivityInput = {
icon?: Maybe<Scalars['String']>;
image?: Maybe<Scalars['String']>;
name: Scalars['String'];
verb?: Maybe<Scalars['String']>;
};
export type CreateChannelInput = {
userId?: Maybe<Scalars['ID']>;
activityId?: Maybe<Scalars['ID']>;
name: Scalars['String'];
slug?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type CreateRoleInput = {
id: Scalars['ID'];
name: Scalars['String'];
access: AccessTargetsInput;
parentId: Scalars['ID'];
};
export type CreateStreamKeyInput = {
userId: Scalars['ID'];
channelId: Scalars['ID'];
};
export type CreateUserInput = {
username: Scalars['String'];
password: Scalars['String'];
email: Scalars['String'];
};
export type InfoResponse = {
__typename?: 'InfoResponse';
name: Scalars['String'];
version: Scalars['String'];
packageName: Scalars['String'];
};
export type Mutation = {
__typename?: 'Mutation';
ping: Scalars['String'];
createActivity: Activity;
updateActivity: Activity;
createChannel: Channel;
updateChannel: Channel;
createRole: Role;
updateRole: Role;
deleteRole: Scalars['Boolean'];
createStreamKey: StreamKey;
revokeStreamKey: Scalars['Boolean'];
signUp: User;
signIn?: Maybe<SessionResponse>;
};
export type MutationCreateActivityArgs = {
input?: Maybe<CreateActivityInput>;
};
export type MutationUpdateActivityArgs = {
input?: Maybe<UpdateActivityInput>;
};
export type MutationCreateChannelArgs = {
input?: Maybe<CreateChannelInput>;
};
export type MutationUpdateChannelArgs = {
input?: Maybe<UpdateChannelInput>;
};
export type MutationCreateRoleArgs = {
input?: Maybe<CreateRoleInput>;
};
export type MutationUpdateRoleArgs = {
input?: Maybe<UpdateRoleInput>;
};
export type MutationDeleteRoleArgs = {
id: Scalars['ID'];
};
export type MutationCreateStreamKeyArgs = {
input?: Maybe<CreateStreamKeyInput>;
};
export type MutationRevokeStreamKeyArgs = {
input?: Maybe<CreateStreamKeyInput>;
};
export type MutationSignUpArgs = {
input: CreateUserInput;
};
export type MutationSignInArgs = {
input?: Maybe<SignInInput>;
};
export type Query = {
__typename?: 'Query';
info: InfoResponse;
test: TestResponse;
activity?: Maybe<Activity>;
activities: Array<Maybe<Activity>>;
channel?: Maybe<Channel>;
channels: Array<Maybe<Channel>>;
role?: Maybe<Role>;
roles: Array<Maybe<Role>>;
streamKeys: Array<Maybe<StreamKey>>;
selfStreamKeys: Array<Maybe<StreamKey>>;
users: Array<Maybe<User>>;
self: User;
user?: Maybe<User>;
};
export type QueryActivityArgs = {
id: Scalars['ID'];
};
export type QueryActivitiesArgs = {
filter?: Maybe<ActivityFilter>;
};
export type QueryChannelArgs = {
id: Scalars['ID'];
};
export type QueryChannelsArgs = {
filter?: Maybe<ChannelsQueryFilter>;
};
export type QueryRoleArgs = {
id: Scalars['ID'];
};
export type QueryRolesArgs = {
filter?: Maybe<UpdateRoleInput>;
};
export type QueryUserArgs = {
id: Scalars['ID'];
};
export type Role = {
__typename?: 'Role';
id: Scalars['ID'];
name: Scalars['String'];
access: AccessTargets;
parentId?: Maybe<Scalars['ID']>;
};
export type Session = {
__typename?: 'Session';
id: Scalars['ID'];
user: Scalars['ID'];
expiresAt: Scalars['DateTime'];
};
export type SessionResponse = {
__typename?: 'SessionResponse';
token: Scalars['ID'];
expiresAt: Scalars['DateTime'];
};
export type SignInInput = {
username: Scalars['String'];
password: Scalars['String'];
};
export type StreamKey = {
__typename?: 'StreamKey';
id: Scalars['ID'];
user: User;
channel: Channel;
};
export type TestResponse = {
__typename?: 'TestResponse';
secret: Scalars['String'];
};
export type UpdateActivityInput = {
id: Scalars['ID'];
icon?: Maybe<Scalars['String']>;
image?: Maybe<Scalars['String']>;
name: Scalars['String'];
verb?: Maybe<Scalars['String']>;
};
export type UpdateChannelInput = {
id: Scalars['ID'];
activityId?: Maybe<Scalars['ID']>;
name?: Maybe<Scalars['String']>;
slug?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type UpdateRoleInput = {
id?: Maybe<Scalars['ID']>;
name?: Maybe<Scalars['String']>;
access?: Maybe<AccessTargetsInput>;
parentId?: Maybe<Scalars['ID']>;
};
export type User = {
__typename?: 'User';
id?: Maybe<Scalars['ID']>;
username: Scalars['String'];
displayName?: Maybe<Scalars['String']>;
bio?: Maybe<Scalars['String']>;
singleUserMode: Scalars['Boolean'];
emailHash?: Maybe<Scalars['String']>;
roles: Array<Maybe<Role>>;
channels: Array<Maybe<Channel>>;
};
export type UserActions = {
__typename?: 'UserActions';
silence?: Maybe<Scalars['Boolean']>;
ban?: Maybe<Scalars['Boolean']>;
warn?: Maybe<Scalars['Boolean']>;
};
export type UserActionsInput = {
silence?: Maybe<Scalars['Boolean']>;
ban?: Maybe<Scalars['Boolean']>;
warn?: Maybe<Scalars['Boolean']>;
};
export type UserSettings = {
__typename?: 'UserSettings';
id?: Maybe<Scalars['ID']>;
useGravatar?: Maybe<Scalars['Boolean']>;
};
export type ResolverTypeWrapper<T> = Promise<T> | T;
export type LegacyStitchingResolver<TResult, TParent, TContext, TArgs> = {
fragment: string;
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type NewStitchingResolver<TResult, TParent, TContext, TArgs> = {
selectionSet: string;
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type StitchingResolver<TResult, TParent, TContext, TArgs> = LegacyStitchingResolver<TResult, TParent, TContext, TArgs> | NewStitchingResolver<TResult, TParent, TContext, TArgs>;
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
| ResolverFn<TResult, TParent, TContext, TArgs>
| StitchingResolver<TResult, TParent, TContext, TArgs>;
export type ResolverFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => Promise<TResult> | TResult;
export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;
export interface SubscriptionSubscriberObject<TResult, TKey extends string, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>;
resolve?: SubscriptionResolveFn<TResult, { [key in TKey]: TResult }, TContext, TArgs>;
}
export interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<any, TParent, TContext, TArgs>;
resolve: SubscriptionResolveFn<TResult, any, TContext, TArgs>;
}
export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>;
export type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TContext = {}, TArgs = {}> =
| ((...args: any[]) => SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>)
| SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>;
export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
parent: TParent,
context: TContext,
info: GraphQLResolveInfo
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;
export type IsTypeOfResolverFn<T = {}, TContext = {}> = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
export type NextResolverFn<T> = () => Promise<T>;
export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs = {}> = (
next: NextResolverFn<TResult>,
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;
/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
AccessRights: ResolverTypeWrapper<AccessRights>;
AccessTargets: ResolverTypeWrapper<AccessTargets>;
AccessTargetsInput: AccessTargetsInput;
AccessUnit: AccessUnit;
Actions: ResolverTypeWrapper<Actions>;
ActionsInput: ActionsInput;
Activity: ResolverTypeWrapper<Activity>;
ID: ResolverTypeWrapper<Scalars['ID']>;
String: ResolverTypeWrapper<Scalars['String']>;
ActivityFilter: ActivityFilter;
CacheControlScope: CacheControlScope;
Channel: ResolverTypeWrapper<Channel>;
ChannelsQueryFilter: ChannelsQueryFilter;
CreateActivityInput: CreateActivityInput;
CreateChannelInput: CreateChannelInput;
CreateRoleInput: CreateRoleInput;
CreateStreamKeyInput: CreateStreamKeyInput;
CreateUserInput: CreateUserInput;
DateTime: ResolverTypeWrapper<Scalars['DateTime']>;
InfoResponse: ResolverTypeWrapper<InfoResponse>;
Mutation: ResolverTypeWrapper<{}>;
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
Query: ResolverTypeWrapper<{}>;
Role: ResolverTypeWrapper<Role>;
Session: ResolverTypeWrapper<Session>;
SessionResponse: ResolverTypeWrapper<SessionResponse>;
SignInInput: SignInInput;
StreamKey: ResolverTypeWrapper<StreamKey>;
TestResponse: ResolverTypeWrapper<TestResponse>;
UpdateActivityInput: UpdateActivityInput;
UpdateChannelInput: UpdateChannelInput;
UpdateRoleInput: UpdateRoleInput;
Upload: ResolverTypeWrapper<Scalars['Upload']>;
User: ResolverTypeWrapper<User>;
UserActions: ResolverTypeWrapper<UserActions>;
UserActionsInput: UserActionsInput;
UserSettings: ResolverTypeWrapper<UserSettings>;
Int: ResolverTypeWrapper<Scalars['Int']>;
};
/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
AccessRights: AccessRights;
AccessTargets: AccessTargets;
AccessTargetsInput: AccessTargetsInput;
Actions: Actions;
ActionsInput: ActionsInput;
Activity: Activity;
ID: Scalars['ID'];
String: Scalars['String'];
ActivityFilter: ActivityFilter;
Channel: Channel;
ChannelsQueryFilter: ChannelsQueryFilter;
CreateActivityInput: CreateActivityInput;
CreateChannelInput: CreateChannelInput;
CreateRoleInput: CreateRoleInput;
CreateStreamKeyInput: CreateStreamKeyInput;
CreateUserInput: CreateUserInput;
DateTime: Scalars['DateTime'];
InfoResponse: InfoResponse;
Mutation: {};
Boolean: Scalars['Boolean'];
Query: {};
Role: Role;
Session: Session;
SessionResponse: SessionResponse;
SignInInput: SignInInput;
StreamKey: StreamKey;
TestResponse: TestResponse;
UpdateActivityInput: UpdateActivityInput;
UpdateChannelInput: UpdateChannelInput;
UpdateRoleInput: UpdateRoleInput;
Upload: Scalars['Upload'];
User: User;
UserActions: UserActions;
UserActionsInput: UserActionsInput;
UserSettings: UserSettings;
Int: Scalars['Int'];
};
export type CacheControlDirectiveArgs = { maxAge?: Maybe<Scalars['Int']>;
scope?: Maybe<CacheControlScope>; };
export type CacheControlDirectiveResolver<Result, Parent, ContextType = any, Args = CacheControlDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;
export type AccessRightsResolvers<ContextType = any, ParentType extends ResolversParentTypes['AccessRights'] = ResolversParentTypes['AccessRights']> = {
channels?: Resolver<Maybe<ResolversTypes['AccessUnit']>, ParentType, ContextType>;
streamKeys?: Resolver<Maybe<ResolversTypes['AccessUnit']>, ParentType, ContextType>;
users?: Resolver<Maybe<ResolversTypes['AccessUnit']>, ParentType, ContextType>;
activities?: Resolver<Maybe<ResolversTypes['AccessUnit']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AccessTargetsResolvers<ContextType = any, ParentType extends ResolversParentTypes['AccessTargets'] = ResolversParentTypes['AccessTargets']> = {
rights?: Resolver<ResolversTypes['AccessRights'], ParentType, ContextType>;
actions?: Resolver<ResolversTypes['Actions'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type ActionsResolvers<ContextType = any, ParentType extends ResolversParentTypes['Actions'] = ResolversParentTypes['Actions']> = {
user?: Resolver<Maybe<ResolversTypes['UserActions']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type ActivityResolvers<ContextType = any, ParentType extends ResolversParentTypes['Activity'] = ResolversParentTypes['Activity']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
icon?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
image?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
verb?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type ChannelResolvers<ContextType = any, ParentType extends ResolversParentTypes['Channel'] = ResolversParentTypes['Channel']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
user?: Resolver<Maybe<ResolversTypes['User']>, ParentType, ContextType>;
activity?: Resolver<Maybe<ResolversTypes['Activity']>, ParentType, ContextType>;
slug?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['DateTime'], any> {
name: 'DateTime';
}
export type InfoResponseResolvers<ContextType = any, ParentType extends ResolversParentTypes['InfoResponse'] = ResolversParentTypes['InfoResponse']> = {
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
version?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
packageName?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type MutationResolvers<ContextType = any, ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation']> = {
ping?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
createActivity?: Resolver<ResolversTypes['Activity'], ParentType, ContextType, RequireFields<MutationCreateActivityArgs, never>>;
updateActivity?: Resolver<ResolversTypes['Activity'], ParentType, ContextType, RequireFields<MutationUpdateActivityArgs, never>>;
createChannel?: Resolver<ResolversTypes['Channel'], ParentType, ContextType, RequireFields<MutationCreateChannelArgs, never>>;
updateChannel?: Resolver<ResolversTypes['Channel'], ParentType, ContextType, RequireFields<MutationUpdateChannelArgs, never>>;
createRole?: Resolver<ResolversTypes['Role'], ParentType, ContextType, RequireFields<MutationCreateRoleArgs, never>>;
updateRole?: Resolver<ResolversTypes['Role'], ParentType, ContextType, RequireFields<MutationUpdateRoleArgs, never>>;
deleteRole?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteRoleArgs, 'id'>>;
createStreamKey?: Resolver<ResolversTypes['StreamKey'], ParentType, ContextType, RequireFields<MutationCreateStreamKeyArgs, never>>;
revokeStreamKey?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationRevokeStreamKeyArgs, never>>;
signUp?: Resolver<ResolversTypes['User'], ParentType, ContextType, RequireFields<MutationSignUpArgs, 'input'>>;
signIn?: Resolver<Maybe<ResolversTypes['SessionResponse']>, ParentType, ContextType, RequireFields<MutationSignInArgs, never>>;
};
export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
info?: Resolver<ResolversTypes['InfoResponse'], ParentType, ContextType>;
test?: Resolver<ResolversTypes['TestResponse'], ParentType, ContextType>;
activity?: Resolver<Maybe<ResolversTypes['Activity']>, ParentType, ContextType, RequireFields<QueryActivityArgs, 'id'>>;
activities?: Resolver<Array<Maybe<ResolversTypes['Activity']>>, ParentType, ContextType, RequireFields<QueryActivitiesArgs, never>>;
channel?: Resolver<Maybe<ResolversTypes['Channel']>, ParentType, ContextType, RequireFields<QueryChannelArgs, 'id'>>;
channels?: Resolver<Array<Maybe<ResolversTypes['Channel']>>, ParentType, ContextType, RequireFields<QueryChannelsArgs, never>>;
role?: Resolver<Maybe<ResolversTypes['Role']>, ParentType, ContextType, RequireFields<QueryRoleArgs, 'id'>>;
roles?: Resolver<Array<Maybe<ResolversTypes['Role']>>, ParentType, ContextType, RequireFields<QueryRolesArgs, never>>;
streamKeys?: Resolver<Array<Maybe<ResolversTypes['StreamKey']>>, ParentType, ContextType>;
selfStreamKeys?: Resolver<Array<Maybe<ResolversTypes['StreamKey']>>, ParentType, ContextType>;
users?: Resolver<Array<Maybe<ResolversTypes['User']>>, ParentType, ContextType>;
self?: Resolver<ResolversTypes['User'], ParentType, ContextType>;
user?: Resolver<Maybe<ResolversTypes['User']>, ParentType, ContextType, RequireFields<QueryUserArgs, 'id'>>;
};
export type RoleResolvers<ContextType = any, ParentType extends ResolversParentTypes['Role'] = ResolversParentTypes['Role']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
access?: Resolver<ResolversTypes['AccessTargets'], ParentType, ContextType>;
parentId?: Resolver<Maybe<ResolversTypes['ID']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type SessionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Session'] = ResolversParentTypes['Session']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
user?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
expiresAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type SessionResponseResolvers<ContextType = any, ParentType extends ResolversParentTypes['SessionResponse'] = ResolversParentTypes['SessionResponse']> = {
token?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
expiresAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type StreamKeyResolvers<ContextType = any, ParentType extends ResolversParentTypes['StreamKey'] = ResolversParentTypes['StreamKey']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
user?: Resolver<ResolversTypes['User'], ParentType, ContextType>;
channel?: Resolver<ResolversTypes['Channel'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type TestResponseResolvers<ContextType = any, ParentType extends ResolversParentTypes['TestResponse'] = ResolversParentTypes['TestResponse']> = {
secret?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export interface UploadScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Upload'], any> {
name: 'Upload';
}
export type UserResolvers<ContextType = any, ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User']> = {
id?: Resolver<Maybe<ResolversTypes['ID']>, ParentType, ContextType>;
username?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
displayName?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
bio?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
singleUserMode?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
emailHash?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
roles?: Resolver<Array<Maybe<ResolversTypes['Role']>>, ParentType, ContextType>;
channels?: Resolver<Array<Maybe<ResolversTypes['Channel']>>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type UserActionsResolvers<ContextType = any, ParentType extends ResolversParentTypes['UserActions'] = ResolversParentTypes['UserActions']> = {
silence?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
ban?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
warn?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type UserSettingsResolvers<ContextType = any, ParentType extends ResolversParentTypes['UserSettings'] = ResolversParentTypes['UserSettings']> = {
id?: Resolver<Maybe<ResolversTypes['ID']>, ParentType, ContextType>;
useGravatar?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type Resolvers<ContextType = any> = {
AccessRights?: AccessRightsResolvers<ContextType>;
AccessTargets?: AccessTargetsResolvers<ContextType>;
Actions?: ActionsResolvers<ContextType>;
Activity?: ActivityResolvers<ContextType>;
Channel?: ChannelResolvers<ContextType>;
DateTime?: GraphQLScalarType;
InfoResponse?: InfoResponseResolvers<ContextType>;
Mutation?: MutationResolvers<ContextType>;