diff --git a/.changeset/add-get-session.md b/.changeset/add-get-session.md new file mode 100644 index 00000000000..990d359ae6c --- /dev/null +++ b/.changeset/add-get-session.md @@ -0,0 +1,6 @@ +--- +'@keystone-6/auth': major +'@keystone-6/core': major +--- + +Remove `config.session`, replaced with `config.getSession` diff --git a/.changeset/bump-prisma-now.md b/.changeset/bump-prisma-now.md new file mode 100644 index 00000000000..44ac43239a3 --- /dev/null +++ b/.changeset/bump-prisma-now.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': major +--- + +Upgrade `prisma` to `5.1.0` diff --git a/.changeset/fix-frozen-prisma.md b/.changeset/fix-frozen-prisma.md new file mode 100644 index 00000000000..f3052478527 --- /dev/null +++ b/.changeset/fix-frozen-prisma.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': major +--- + +Changes `keystone prisma` behaviour to not generate Typescript types and prisma schema when using `--frozen` diff --git a/.changeset/more-errors-please.md b/.changeset/more-errors-please.md new file mode 100644 index 00000000000..7e4ed38c483 --- /dev/null +++ b/.changeset/more-errors-please.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': minor +--- + +`KS_PRISMA_ERRORS` are now logged with `console.error` on the server diff --git a/.changeset/move-session-strategies.md b/.changeset/move-session-strategies.md new file mode 100644 index 00000000000..8552cddffbe --- /dev/null +++ b/.changeset/move-session-strategies.md @@ -0,0 +1,6 @@ +--- +'@keystone-6/auth': minor +'@keystone-6/core': major +--- + +Moves `statelessSessions` and `storedSessions` to the `@keystone-6/auth` package diff --git a/.changeset/no-extend-type.md b/.changeset/no-extend-type.md new file mode 100644 index 00000000000..6a9eac494b5 --- /dev/null +++ b/.changeset/no-extend-type.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': major +--- + +Removes `ExtendGraphqlSchema` type alias, use `(schema: GraphQLSchema) => GraphQLSchema` instead (with `import type { GraphQLSchema } from 'graphql'`). diff --git a/.github/actions/ci-setup/action.yml b/.github/actions/ci-setup/action.yml index b79bca774c1..877a58ef01f 100644 --- a/.github/actions/ci-setup/action.yml +++ b/.github/actions/ci-setup/action.yml @@ -8,7 +8,7 @@ runs: - uses: actions/setup-node@main with: # preferably lts/*, but we hit API limits when querying that - node-version: 18 + node-version: 20 registry-url: 'https://registry.npmjs.org' cache: pnpm diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 3c032078a4a..00000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18 diff --git a/docs/pages/docs/config/auth.md b/docs/pages/docs/config/auth.md index ddd01245534..776c0d38766 100644 --- a/docs/pages/docs/config/auth.md +++ b/docs/pages/docs/config/auth.md @@ -18,9 +18,15 @@ const { withAuth } = createAuth({ listKey: 'User', identityField: 'email', secretField: 'password', +{% if $nextRelease %} + sessionStrategy: {/*.. Session Config ...*/} +{% /if %} // Additional options +{% if $nextRelease %} +{% else /%} sessionData: 'id name email', +{% /if %} initFirstItem: { fields: ['email', 'password'], itemData: { isAdmin: true }, @@ -46,7 +52,10 @@ export default withAuth( isAdmin: checkbox(), }, }), +{% if $nextRelease %} +{% else /%} session: { /* ... */ }, +{% /if %} }, }) ); @@ -54,8 +63,10 @@ export default withAuth( The function `createAuth` returns a function `withAuth` which should be used to wrap your `config()`. This wrapper function will modify the config object to inject extra fields, extra GraphQL queries and mutations, and custom Admin UI functionality into the system. +{% if $nextRelease %} +{% else /%} The `createAuth` function must be used in conjunction with a [session](./session) configuration. - +{% /if %} ## Required options The core functionality of the authentication system provides a GraphQL mutation to authenticate a user and then start a session, and a sign in page in the Admin UI. @@ -145,6 +156,11 @@ This page uses the `authenticateUserWithPassword` mutation to let users sign in The following options add extra functionality to your Keystone authentication system. By default they are disabled. +{% if $nextRelease %} + +Some info on Session + +{% else / %} ### sessionData This option adds support for setting a custom `session.data` value based on the authenticated user. @@ -165,6 +181,7 @@ const { withAuth } = createAuth({ sessionData: 'id name isAdmin', }); ``` +{% /if %} ### initFirstItem diff --git a/docs/pages/docs/config/config.md b/docs/pages/docs/config/config.md index 4f123ab1d73..67fb6dd7cff 100644 --- a/docs/pages/docs/config/config.md +++ b/docs/pages/docs/config/config.md @@ -19,7 +19,11 @@ export default config({ db: { /* ... */ }, ui: { /* ... */ }, server: { /* ... */ }, +{% if $nextRelease %} + getSession: { /* ... */ }, +{% else /%} session: { /* ... */ }, +{% /if %} graphql: { /* ... */ }, extendGraphqlSchema: { /* ... */ }, storage: { /* ... */ }, @@ -35,12 +39,10 @@ This type definition should be considered the source of truth for the available ## lists The `lists` config option is where you define the data model, or schema, of the Keystone system. -It has a TypeScript type of `ListSchemaConfig`. This is where you define and configure the `lists` and their `fields` of the data model. See the [Lists API](./lists) docs for details on how to use this function. ```typescript -import type { ListSchemaConfig } from '@keystone-6/core/types'; import { config } from '@keystone-6/core'; export default config({ @@ -51,12 +53,7 @@ export default config({ ## db -``` -import type { DatabaseConfig } from '@keystone-6/core/types'; -``` - The `db` config option configures the database used to store data in your Keystone system. -It has a TypeScript type of `DatabaseConfig`. Keystone supports the database types **PostgreSQL**, **MySQL** and **SQLite**. These database types are powered by their corresponding Prisma database providers; `postgresql`, `mysql` and `sqlite`. @@ -133,12 +130,7 @@ The `sqlite` provider is not intended to be used in production systems, and has ## ui -```ts -import type { AdminUIConfig } from '@keystone-6/core/types'; -``` - The `ui` config option configures the Admin UI which is provided by Keystone. -It has a TypeScript type of `AdminUIConfig`. This config option is for top level configuration of the Admin UI. Fine grained configuration of how lists and fields behave in the Admin UI is handled in the `lists` definition (see the [Lists API](./lists) for more details). @@ -194,10 +186,6 @@ export default config({ ## server -``` -import type { ServerConfig } from '@keystone-6/core/types'; -``` - The `dev` and `start` commands from the Keystone [command line](../guides/cli) will start an Express web-server for you. This server is configured via the `server` configuration option. @@ -314,20 +302,37 @@ export default config({ _Note_: when using `keystone dev`, `extendHttpServer` is only called once on startup - you will need to restart your process for any updates -## session +{% if $nextRelease %} +## getSession +The `getSession` config option allows you to configure how Keystone retieves a `session` based on a given `context`. `getSession` will generally check the original request `req` on the `context` to validate and return a `session` that is then added to the `context` for that request. + +```typescript +export default config({ + getSession: async ({ context }) => { + if (!context.req) return + return await getValidSession(context); + } + }, + /* ... */ +}); ``` -import type { SessionStrategy } from '@keystone-6/core/types'; -``` + +Whatever you return here will what is available in `context.session`, returning `undefined` here will make the `session` undefined, making the request essentially `unauthenticated` depending on your access-control. + +If using `getSession` with `@keystone-6/auth`, `getSession` is called *after* the authentication package has validated the session and added it to `context` that is passed in. + +See the [Session Docs](./session) for more details on how to configure session management using `@keystone-6/auth` in Keystone. +{% else /%} +## session The `session` config option allows you to configure session management of your Keystone system. -It has a TypeScript type of `SessionStrategy`. -In general you will use `SessionStrategy` objects from the `@keystone-6/core/session` package, rather than writing this yourself. +In general you will use `SessionStrategy` objects from the `@keystone-6/auth/session` package, rather than writing this yourself. ```typescript -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; export default config({ session: statelessSessions({ /* ... */ }), @@ -336,15 +341,10 @@ export default config({ ``` See the [Session API](./session) for more details on how to configure session management in Keystone. - +{% /if %} ## graphql -```ts -import type { GraphQLConfig } from '@keystone-6/core/types'; -``` - The `graphql` config option allows you to configure certain aspects of your GraphQL API. -It has a TypeScript type of `GraphQLConfig`. Options: @@ -374,12 +374,8 @@ export default config({ ## extendGraphqlSchema -```ts -import type { ExtendGraphqlSchema } from '@keystone-6/core/types'; -``` - The `extendGraphqlSchema` config option allows you to extend the GraphQL API which is generated by Keystone based on your schema definition. -It has a TypeScript type of `ExtendGraphqlSchema`. +It has a TypeScript type of `(schema: import("graphql").GraphQLSchema) => import("graphql").GraphQLSchema`. `extendGraphqlSchema` expects a function that takes the GraphQL Schema generated by Keystone and returns a valid GraphQL Schema @@ -399,10 +395,6 @@ See the [schema extension guide](../guides/schema-extension) for more details an ## storage (images and files) -```ts -import type { StorageConfig } from '@keystone-6/core/types' -``` - The `storage` config option provides configuration which is used by the [`file`](../fields/file) field type or the [`image`](../fields/image) field type. You provide an object whose property is a `StorageConfig` object, fields then reference this `storage` by the key. Each storage is configured separately using the options below. diff --git a/docs/pages/docs/config/session.md b/docs/pages/docs/config/session.md index db2bdea9ddc..85d091eab08 100644 --- a/docs/pages/docs/config/session.md +++ b/docs/pages/docs/config/session.md @@ -3,13 +3,36 @@ title: "Session" description: "Reference docs for the session property of Keystone’s system configuration object." --- +{% if $nextRelease %} +The `getSession` config option allows you to configure how Keystone retrieves a ` session`` based on a given `context`. `getSession`will generally check the original request`req`on the`context`to validate and return a`session`that is then added to the`context` for that request. + +```typescript +export default config({ + getSession: async ({ context }) => { + if (!context.req) return + return await getValidSession(context); + } + }, + /* ... */ +}); +``` + +Whatever you return here is what is available in `context.session`, returning `undefined` here will make the `session` undefined, making the request essentially `unauthenticated` depending on your access-control. + +## SessionStrategy in Auth + +The `sessionStrategy` property of the [auth configuration](./auth) object allows you to configure session management of your Keystone system when using `@keystone-6/auth`. It has a TypeScript type of `SessionStrategy`. +In general, you will use `SessionStrategy` objects from the `@keystone-6/auth/session` package, rather than writing this yourself. + +{% else /%} The `session` property of the [system configuration](./config) object allows you to configure session management of your Keystone system. It has a TypeScript type of `SessionStrategy`. -In general you will use `SessionStrategy` objects from the `@keystone-6/core/session` package, rather than writing this yourself. +In general, you will use `SessionStrategy` objects from the `@keystone-6/auth/session` package, rather than writing this yourself. +{% /if %} ```typescript import { config } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; export default config({ session: statelessSessions({ @@ -20,11 +43,24 @@ export default config({ path: '/', domain: 'localhost', sameSite: 'lax', +{% if $nextRelease %} + data: 'id name email' +{% /if %} }), /* ... */ }); ``` +{% if $nextRelease %} + +## Overriding session using `getSession` + +You can use this auth `sessionStrategy` in combination with `getSession` to customise your session configuration. `getSession` is called after the Auth package validates the session, this is passed through to `getSession` as `context.session`. + +See the [Custom Session Example](https://github.com/keystonejs/keystone/tree/main/examples/custom-session-validation) which demonstrates invalidating a session after a password change. + +{% /if %} + ## Stateless vs stored sessions Keystone supports both stateless and stored sessions. @@ -37,7 +73,11 @@ Both `statelessSessions()` and `storedSessions()` accept a common set of argumen ```typescript import { config } from '@keystone-6/core'; -import { statelessSessions, storedSessions } from '@keystone-6/core/session'; +{% if $nextRelease %} +import { statelessSessions, storedSessions } from '@keystone-6/auth/session'; +{% else /%} +import { statelessSessions, storedSessions } from '@keystone-6/auth/session'; +{% /if %} export default config({ // Stateless @@ -51,6 +91,10 @@ export default config({ Options +{% if $nextRelease %} + +- `data` (default: `'id'`): Graphql Query to populate the default `context.session.data` object. + {% /if %} - `secret` (required): The secret used by `@hapi/iron` for encrypting the cookie data. Must be at least 32 characters long. - `ironOptions`: Additional options to be passed to `Iron.seal()` and `Iron.unseal()` when encrypting and decrypting the cookies. See the [`@hapi/iron` docs](https://hapi.dev/module/iron/api/?v=6.0.0#options) for details. @@ -67,6 +111,20 @@ Options - `sameSite` (default: `'lax'`): Controls whether the cookie is sent with cross-origin requests. Can be one of `true`, `false`, `'strict'`, `'lax'` or `'none'`. See [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes) for more details on the `sameSite` cookie attribute. **Note**: The `secure` attribute must also be set when `sameSite` is set to `none`! +{% if $nextRelease %} + +### Session `data` + +This option adds support for setting a custom `session.data` value based on the authenticated user. + +The authentication mutations will set the values `{ listKey, itemId }` on the `context.session` object. +You will often need to know more than just the `itemId` of the authenticated user, such as when performing [access-control](../guides/auth-and-access-control) or using [hooks](../guides/hooks). +Configuring `data` will add an `session.data` based on the `itemId`, populated by the fields given in `sessionData.query`. + +The value is a GraphQL query string which indicates which fields should be populated on the `session.data` object + +{% /if %} + ### Session stores When using `storedSessions` you need to pass in a session store as the `store` option. @@ -96,7 +154,7 @@ Interface: If you configure your Keystone session with session management then the [`KeystoneContext`](../context/overview) type will include the following session related properties. - `session`: An object representing the session data. The value will depend on the value passed into `context.sessionStrategy.start()`. -- `sessionStrategy`: an object that, when using `statelessSessions` or `storedSessions` from `@keystone-6/core/session` includes the following functions: +- `sessionStrategy`: an object that, when using `statelessSessions` or `storedSessions` from `@keystone-6/auth/session` includes the following functions: - `get({context})`: a function that returns a `session` object based on `context` - this needs to be a `context` with a valid `req` (using `context.withRequest`). This function is called by Keystone to get the value of `context.session` - `start({context, data})`: a function that, given a valid `context.res` starts a new session containing what is passed into `data`. - `end({context})`: a function that, given a valid `context.res` ends a session. diff --git a/docs/pages/docs/guides/auth-and-access-control.md b/docs/pages/docs/guides/auth-and-access-control.md index e5d3d326d7d..c41919c50cf 100644 --- a/docs/pages/docs/guides/auth-and-access-control.md +++ b/docs/pages/docs/guides/auth-and-access-control.md @@ -84,7 +84,7 @@ Your entire Keystone config should now look like this: ```ts import { config, list } from '@keystone-6/core'; import { checkbox, password, text } from '@keystone-6/core/fields'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; const db = { diff --git a/docs/pages/docs/walkthroughs/lesson-4.md b/docs/pages/docs/walkthroughs/lesson-4.md index 745583969b8..aadc5587900 100644 --- a/docs/pages/docs/walkthroughs/lesson-4.md +++ b/docs/pages/docs/walkthroughs/lesson-4.md @@ -142,7 +142,7 @@ Having added an authentication method, we need to add a 'session', so that authe ```ts{3,12-500}[4-11] // auth.ts import { createAuth } from '@keystone-6/auth'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; const { withAuth } = createAuth({ listKey: 'User', @@ -227,7 +227,7 @@ feature in the `auth` package: ```ts{10-12} // auth.ts import { createAuth } from '@keystone-6/auth'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; const { withAuth } = createAuth({ listKey: 'User', @@ -259,7 +259,7 @@ Now, if you open Admin UI, you can check out the sign in flow. If you have no us ```ts // auth.ts import { createAuth } from '@keystone-6/auth'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; const { withAuth } = createAuth({ listKey: 'User', diff --git a/examples/assets-local/package.json b/examples/assets-local/package.json index 9baf2e050f8..e4a5f5202c2 100644 --- a/examples/assets-local/package.json +++ b/examples/assets-local/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/assets-local" diff --git a/examples/assets-s3/package.json b/examples/assets-s3/package.json index 8e8d64463bf..2d525d0260b 100644 --- a/examples/assets-s3/package.json +++ b/examples/assets-s3/package.json @@ -11,11 +11,11 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "dotenv": "^16.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/assets-s3" diff --git a/examples/auth/keystone.ts b/examples/auth/keystone.ts index febcac36353..7ad6b9abe41 100644 --- a/examples/auth/keystone.ts +++ b/examples/auth/keystone.ts @@ -1,5 +1,5 @@ import { config } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { fixPrismaPath } from '../example-utils'; import { lists } from './schema'; @@ -42,9 +42,15 @@ const { withAuth } = createAuth({ isAdmin: true, }, }, - - // add isAdmin to the session data - sessionData: 'isAdmin', + // you can find out more at https://keystonejs.com/docs/apis/session#session-api + sessionStrategy: statelessSessions({ + // the maxAge option controls how long session cookies are valid for before they expire + maxAge: sessionMaxAge, + // the session secret is used to encrypt cookie data + secret: sessionSecret, + // add isAdmin to the session data + data: 'isAdmin', + }), }); export default withAuth( @@ -63,12 +69,5 @@ export default withAuth( return session?.data?.isAdmin ?? false; }, }, - // you can find out more at https://keystonejs.com/docs/apis/session#session-api - session: statelessSessions({ - // the maxAge option controls how long session cookies are valid for before they expire - maxAge: sessionMaxAge, - // the session secret is used to encrypt cookie data - secret: sessionSecret, - }), }) ); diff --git a/examples/auth/package.json b/examples/auth/package.json index 0aba9f5d24b..67dcaa67f0e 100644 --- a/examples/auth/package.json +++ b/examples/auth/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/auth" diff --git a/examples/auth/schema.graphql b/examples/auth/schema.graphql index 3bbe083ed5c..35c02b4bc6f 100644 --- a/examples/auth/schema.graphql +++ b/examples/auth/schema.graphql @@ -81,7 +81,6 @@ type Mutation { deleteUsers(where: [UserWhereUniqueInput!]!): [User] endSession: Boolean! authenticateUserWithPassword(name: String!, password: String!): UserAuthenticationWithPasswordResult - createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure @@ -95,11 +94,6 @@ type UserAuthenticationWithPasswordFailure { message: String! } -input CreateInitialUserInput { - name: String - password: String -} - type Query { users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!] user(where: UserWhereUniqueInput!): User diff --git a/examples/custom-admin-ui-logo/package.json b/examples/custom-admin-ui-logo/package.json index 06640afd937..7d96080c5b4 100644 --- a/examples/custom-admin-ui-logo/package.json +++ b/examples/custom-admin-ui-logo/package.json @@ -12,13 +12,13 @@ "dependencies": { "@keystone-6/core": "^5.0.0", "@keystone-ui/core": "^5.0.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "next": "^13.3.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-admin-ui-logo" diff --git a/examples/custom-admin-ui-navigation/package.json b/examples/custom-admin-ui-navigation/package.json index 2506420fe77..028af5f5282 100644 --- a/examples/custom-admin-ui-navigation/package.json +++ b/examples/custom-admin-ui-navigation/package.json @@ -11,11 +11,11 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "react": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-admin-ui-navigation" diff --git a/examples/custom-admin-ui-pages/package.json b/examples/custom-admin-ui-pages/package.json index b373d338c00..b91a78e1029 100644 --- a/examples/custom-admin-ui-pages/package.json +++ b/examples/custom-admin-ui-pages/package.json @@ -12,13 +12,13 @@ "dependencies": { "@keystone-6/core": "^5.0.0", "@keystone-ui/core": "^5.0.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "next": "^13.3.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-admin-ui-pages" diff --git a/examples/custom-field-view/package.json b/examples/custom-field-view/package.json index cc8614021d3..88500c62779 100644 --- a/examples/custom-field-view/package.json +++ b/examples/custom-field-view/package.json @@ -16,13 +16,13 @@ "@keystone-ui/core": "^5.0.1", "@keystone-ui/fields": "^7.1.1", "@keystone-ui/icons": "^6.0.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "next": "^13.3.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-field-view" diff --git a/examples/custom-field/package.json b/examples/custom-field/package.json index 973a1b144b9..c215545e69c 100644 --- a/examples/custom-field/package.json +++ b/examples/custom-field/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/core": "^5.0.0", "@keystone-ui/fields": "^7.1.1", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-field" diff --git a/examples/custom-id/package.json b/examples/custom-id/package.json index 22399359377..d2309bc0208 100644 --- a/examples/custom-id/package.json +++ b/examples/custom-id/package.json @@ -13,10 +13,10 @@ "dependencies": { "@keystone-6/core": "^5.0.0", "@paralleldrive/cuid2": "^2.2.1", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" } diff --git a/examples/custom-output-paths/package.json b/examples/custom-output-paths/package.json index 3b770f33292..d695a6819f3 100644 --- a/examples/custom-output-paths/package.json +++ b/examples/custom-output-paths/package.json @@ -11,13 +11,13 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "next": "^13.3.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/custom-output-paths" diff --git a/examples/custom-session-invalidation/README.md b/examples/custom-session-invalidation/README.md index c1f5b9face7..4f85339800d 100644 --- a/examples/custom-session-invalidation/README.md +++ b/examples/custom-session-invalidation/README.md @@ -73,7 +73,7 @@ const { withAuth } = createAuth({ We can then change the default `statelessSessions` by passing in a new `start` and `get` functions. In the `start` function, we add the `startTime` to the session and start the session using keystone's `start` session function. we can then customize the `get` function to check this `startTime` on the session and compare it to the `passwordChangedAt` time stored in the `Person` table. ```typescript -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; const maxSessionAge = 60 * 60 * 8; // 8 hours, in seconds const withTimeData = ( diff --git a/examples/custom-session-invalidation/keystone.ts b/examples/custom-session-invalidation/keystone.ts index 7958521d277..7d2276a2de7 100644 --- a/examples/custom-session-invalidation/keystone.ts +++ b/examples/custom-session-invalidation/keystone.ts @@ -1,15 +1,43 @@ import { config } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { fixPrismaPath } from '../example-utils'; import { lists, Session } from './schema'; -import type { Config, Context, TypeInfo } from '.keystone/types'; +import type { Context, TypeInfo } from '.keystone/types'; // WARNING: this example is for demonstration purposes only // as with each of our examples, it has not been vetted // or tested for any particular usage -// withAuth is a function we can use to wrap our base configuration +function withSessionInvalidation() { + const sessionStrategy = statelessSessions({}); + return { + ...sessionStrategy, + async get({ context }: { context: Context }): Promise { + const session = await sessionStrategy.get({ context }); + if (!session) return; + + // has the password changed since the session started? + if (new Date(session.data.passwordChangedAt) > new Date(session.startedAt)) { + // invalidate the session if password changed + await sessionStrategy.end({ context }); + return; + } + + return session; + }, + async start({ context, data }: { context: Context; data: Session }) { + return await sessionStrategy.start({ + context, + data: { + ...data, + startedAt: Date.now(), + }, + }); + }, + }; +} + const { withAuth } = createAuth({ // this is the list that contains our users listKey: 'User', @@ -29,56 +57,19 @@ const { withAuth } = createAuth({ // the following fields are used by the "Create First User" form fields: ['name', 'password'], }, - - sessionData: 'passwordChangedAt', + sessionStrategy: withSessionInvalidation(), }); -function withSessionInvalidation(config: Config) { - const existingSessionStrategy = config.session!; - - return { - ...config, - session: { - ...config.session, - async get({ context }: { context: Context }): Promise { - const session = await existingSessionStrategy.get({ context }); - if (!session) return; - - // has the password changed since the session started? - if (new Date(session.data.passwordChangedAt) > new Date(session.startedAt)) { - // invalidate the session if password changed - await existingSessionStrategy.end({ context }); - return; - } +export default withAuth( + config({ + db: { + provider: 'sqlite', + url: process.env.DATABASE_URL || 'file:./keystone-example.db', - return session; - }, - async start({ context, data }: { context: Context; data: Session }) { - return await existingSessionStrategy.start({ - context, - data: { - ...data, - startedAt: Date.now(), - }, - }); - }, + // WARNING: this is only needed for our monorepo examples, dont do this + ...fixPrismaPath, }, - }; -} - -export default withSessionInvalidation( - withAuth( - config({ - db: { - provider: 'sqlite', - url: process.env.DATABASE_URL || 'file:./keystone-example.db', - - // WARNING: this is only needed for our monorepo examples, dont do this - ...fixPrismaPath, - }, - lists, - // you can find out more at https://keystonejs.com/docs/apis/session#session-api - session: statelessSessions(), - }) - ) + lists, + // you can find out more at https://keystonejs.com/docs/apis/session#session-api + }) ); diff --git a/examples/custom-session-invalidation/package.json b/examples/custom-session-invalidation/package.json index 1d60c22455d..bb47eb69f17 100644 --- a/examples/custom-session-invalidation/package.json +++ b/examples/custom-session-invalidation/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/custom-session-invalidation/schema.graphql b/examples/custom-session-invalidation/schema.graphql index 0d14c689015..b6e55b0e389 100644 --- a/examples/custom-session-invalidation/schema.graphql +++ b/examples/custom-session-invalidation/schema.graphql @@ -77,7 +77,6 @@ type Mutation { deleteUsers(where: [UserWhereUniqueInput!]!): [User] endSession: Boolean! authenticateUserWithPassword(name: String!, password: String!): UserAuthenticationWithPasswordResult - createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure @@ -91,11 +90,6 @@ type UserAuthenticationWithPasswordFailure { message: String! } -input CreateInitialUserInput { - name: String - password: String -} - type Query { users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!] user(where: UserWhereUniqueInput!): User diff --git a/examples/custom-session-jwt/keystone.ts b/examples/custom-session-jwt/keystone.ts index da9fb813076..32fabe0f760 100644 --- a/examples/custom-session-jwt/keystone.ts +++ b/examples/custom-session-jwt/keystone.ts @@ -49,32 +49,27 @@ async function jwtVerify(token: string): Promise { }); } -const jwtSessionStrategy = { - async get({ context }: { context: Context }): Promise { - if (!context.req) return; +const jwtSessionStrategy = async ({ + context, +}: { + context: Context; +}): Promise => { + if (!context.req) return; - const { cookie = '' } = context.req.headers; - const [cookieName, jwt] = cookie.split('='); - if (cookieName !== 'user') return; + const { cookie = '' } = context.req.headers; + const [cookieName, jwt] = cookie.split('='); + if (cookieName !== 'user') return; - const jwtResult = await jwtVerify(jwt); - if (!jwtResult) return; + const jwtResult = await jwtVerify(jwt); + if (!jwtResult) return; - const { id } = jwtResult; - const who = await context.sudo().db.User.findOne({ where: { id } }); - if (!who) return; - return { - id, - admin: who.admin, - }; - }, - - // we don't need these unless we want to support the functions - // context.sessionStrategy.start - // context.sessionStrategy.end - // - async start() {}, - async end() {}, + const { id } = jwtResult; + const who = await context.sudo().db.User.findOne({ where: { id } }); + if (!who) return; + return { + id, + admin: who.admin, + }; }; export default config({ @@ -98,5 +93,5 @@ export default config({ }, }, lists, - session: jwtSessionStrategy, + getSession: jwtSessionStrategy, }); diff --git a/examples/custom-session-jwt/package.json b/examples/custom-session-jwt/package.json index 894d968f9b8..b6242f7ab1f 100644 --- a/examples/custom-session-jwt/package.json +++ b/examples/custom-session-jwt/package.json @@ -12,12 +12,12 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "jsonwebtoken": "^9.0.0" }, "devDependencies": { "@types/jsonwebtoken": "^9.0.2", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/custom-session-jwt/schema.graphql b/examples/custom-session-jwt/schema.graphql index 70a5505dc80..251eedd1723 100644 --- a/examples/custom-session-jwt/schema.graphql +++ b/examples/custom-session-jwt/schema.graphql @@ -148,7 +148,6 @@ type Mutation { updateUsers(data: [UserUpdateArgs!]!): [User] deleteUser(where: UserWhereUniqueInput!): User deleteUsers(where: [UserWhereUniqueInput!]!): [User] - endSession: Boolean! } type Query { diff --git a/examples/custom-session-next-auth/keystone.ts b/examples/custom-session-next-auth/keystone.ts index acf5915ea10..ae8e12322a9 100644 --- a/examples/custom-session-next-auth/keystone.ts +++ b/examples/custom-session-next-auth/keystone.ts @@ -44,5 +44,5 @@ export default config>({ }, lists, // you can find out more at https://keystonejs.com/docs/apis/session#session-api - session: nextAuthSessionStrategy, + getSession: nextAuthSessionStrategy, }); diff --git a/examples/custom-session-next-auth/package.json b/examples/custom-session-next-auth/package.json index 0de5b3ecc73..415f95c04bf 100644 --- a/examples/custom-session-next-auth/package.json +++ b/examples/custom-session-next-auth/package.json @@ -11,11 +11,11 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.14.0", + "@prisma/client": "^5.0.0", "next-auth": "^4.22.1" }, "devDependencies": { - "prisma": "^4.14.0", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/custom-session-next-auth/schema.graphql b/examples/custom-session-next-auth/schema.graphql index 48ffae3a67b..a92d13881ea 100644 --- a/examples/custom-session-next-auth/schema.graphql +++ b/examples/custom-session-next-auth/schema.graphql @@ -182,7 +182,6 @@ type Mutation { updateAuthors(data: [AuthorUpdateArgs!]!): [Author] deleteAuthor(where: AuthorWhereUniqueInput!): Author deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author] - endSession: Boolean! } type Query { diff --git a/examples/custom-session-next-auth/session.ts b/examples/custom-session-next-auth/session.ts index 2351fc13fca..ef2c72941bc 100644 --- a/examples/custom-session-next-auth/session.ts +++ b/examples/custom-session-next-auth/session.ts @@ -86,38 +86,28 @@ export type Session = { id: string; }; -export const nextAuthSessionStrategy = { - async get({ context }: { context: Context }) { - const { req, res } = context; - const { headers } = req ?? {}; - if (!headers?.cookie || !res) return; - - // next-auth needs a different cookies structure - const cookies: Record = {}; - for (const part of headers.cookie.split(';')) { - const [key, value] = part.trim().split('='); - cookies[key] = decodeURIComponent(value); - } - - const nextAuthSession = await getServerSession( - { headers, cookies } as any, - res, - nextAuthOptions - ); - if (!nextAuthSession) return; - - const { authId } = nextAuthSession.keystone; - if (!authId) return; - - const author = await context.sudo().db.Author.findOne({ - where: { authId }, - }); - if (!author) return; - - return { id: author.id }; - }, +export const nextAuthSessionStrategy = async ({ context }: { context: Context }) => { + const { req, res } = context; + const { headers } = req ?? {}; + if (!headers?.cookie || !res) return; + + // next-auth needs a different cookies structure + const cookies: Record = {}; + for (const part of headers.cookie.split(';')) { + const [key, value] = part.trim().split('='); + cookies[key] = decodeURIComponent(value); + } + + const nextAuthSession = await getServerSession({ headers, cookies } as any, res, nextAuthOptions); + if (!nextAuthSession) return; + + const { authId } = nextAuthSession.keystone; + if (!authId) return; + + const author = await context.sudo().db.Author.findOne({ + where: { authId }, + }); + if (!author) return; - // we don't need these as next-auth handle start and end for us - async start() {}, - async end() {}, + return { id: author.id }; }; diff --git a/examples/custom-session-redis/keystone.ts b/examples/custom-session-redis/keystone.ts index c10d1bae2d1..f261138d863 100644 --- a/examples/custom-session-redis/keystone.ts +++ b/examples/custom-session-redis/keystone.ts @@ -1,5 +1,5 @@ import { config } from '@keystone-6/core'; -import { storedSessions } from '@keystone-6/core/session'; +import { storedSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { createClient } from '@redis/client'; import { fixPrismaPath } from '../example-utils'; @@ -30,6 +30,8 @@ const { withAuth } = createAuth({ // the following fields are used by the "Create First User" form fields: ['name', 'password'], }, + + sessionStrategy: redisSessionStrategy(), }); const redis = createClient(); @@ -70,6 +72,5 @@ export default withAuth( ...fixPrismaPath, }, lists, - session: redisSessionStrategy(), }) ); diff --git a/examples/custom-session-redis/package.json b/examples/custom-session-redis/package.json index 27df0d75dc9..3140b6b81f3 100644 --- a/examples/custom-session-redis/package.json +++ b/examples/custom-session-redis/package.json @@ -12,11 +12,11 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "@redis/client": "^1.3.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/custom-session-redis/schema.graphql b/examples/custom-session-redis/schema.graphql index c2b13378f9c..f2ae9b750d9 100644 --- a/examples/custom-session-redis/schema.graphql +++ b/examples/custom-session-redis/schema.graphql @@ -71,7 +71,6 @@ type Mutation { deleteUsers(where: [UserWhereUniqueInput!]!): [User] endSession: Boolean! authenticateUserWithPassword(name: String!, password: String!): UserAuthenticationWithPasswordResult - createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure @@ -85,11 +84,6 @@ type UserAuthenticationWithPasswordFailure { message: String! } -input CreateInitialUserInput { - name: String - password: String -} - type Query { users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!] user(where: UserWhereUniqueInput!): User diff --git a/examples/custom-session/keystone.ts b/examples/custom-session/keystone.ts index 832e1ba5fe7..3a160db95c9 100644 --- a/examples/custom-session/keystone.ts +++ b/examples/custom-session/keystone.ts @@ -3,33 +3,28 @@ import { fixPrismaPath } from '../example-utils'; import { lists, Session } from './schema'; import type { Context, TypeInfo } from '.keystone/types'; -const sillySessionStrategy = { - async get({ context }: { context: Context }): Promise { - if (!context.req) return; +const sillySessionStrategy = async ({ + context, +}: { + context: Context; +}): Promise => { + if (!context.req) return; - // WARNING: for demonstrative purposes only, this has no authentication - // use `Cookie:user=clh9v6pcn0000sbhm9u0j6in0` for Alice (admin) - // use `Cookie:user=clh9v762w0002sbhmhhyc0340` for Bob - // - // in practice, you should use authentication for your sessions, such as OAuth or JWT - const { cookie = '' } = context.req.headers; - const [cookieName, id] = cookie.split('='); - if (cookieName !== 'user') return; - - const who = await context.sudo().db.User.findOne({ where: { id } }); - if (!who) return; - return { - id, - admin: who.admin, - }; - }, - - // we don't need these unless we want to support the functions - // context.sessionStrategy.start - // context.sessionStrategy.end + // WARNING: for demonstrative purposes only, this has no authentication + // use `Cookie:user=clh9v6pcn0000sbhm9u0j6in0` for Alice (admin) + // use `Cookie:user=clh9v762w0002sbhmhhyc0340` for Bob // - async start() {}, - async end() {}, + // in practice, you should use authentication for your sessions, such as OAuth or JWT + const { cookie = '' } = context.req.headers; + const [cookieName, id] = cookie.split('='); + if (cookieName !== 'user') return; + + const who = await context.sudo().db.User.findOne({ where: { id } }); + if (!who) return; + return { + id, + admin: who.admin, + }; }; export default config({ @@ -41,5 +36,5 @@ export default config({ ...fixPrismaPath, }, lists, - session: sillySessionStrategy, + getSession: sillySessionStrategy, }); diff --git a/examples/custom-session/package.json b/examples/custom-session/package.json index fc8d42e4e59..24e1fc1469d 100644 --- a/examples/custom-session/package.json +++ b/examples/custom-session/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/custom-session/schema.graphql b/examples/custom-session/schema.graphql index 70a5505dc80..251eedd1723 100644 --- a/examples/custom-session/schema.graphql +++ b/examples/custom-session/schema.graphql @@ -148,7 +148,6 @@ type Mutation { updateUsers(data: [UserUpdateArgs!]!): [User] deleteUser(where: UserWhereUniqueInput!): User deleteUsers(where: [UserWhereUniqueInput!]!): [User] - endSession: Boolean! } type Query { diff --git a/examples/default-values/package.json b/examples/default-values/package.json index eba9bd4adfc..0660c2ce481 100644 --- a/examples/default-values/package.json +++ b/examples/default-values/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/default-values" diff --git a/examples/document-field-customisation/keystone-server/package.json b/examples/document-field-customisation/keystone-server/package.json index fefe508b302..9ac327acfa3 100644 --- a/examples/document-field-customisation/keystone-server/package.json +++ b/examples/document-field-customisation/keystone-server/package.json @@ -19,11 +19,11 @@ "@keystone-ui/fields": "^7.2.0", "@keystone-ui/icons": "^6.0.1", "@keystone-ui/tooltip": "^6.0.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "react": "^18.2.0", "typescript": "~5.0.0" }, "devDependencies": { - "prisma": "^4.16.2" + "prisma": "^5.0.0" } } diff --git a/examples/document-field/package.json b/examples/document-field/package.json index a7c67b6090a..1b45e3a4844 100644 --- a/examples/document-field/package.json +++ b/examples/document-field/package.json @@ -15,13 +15,13 @@ "@keystone-6/document-renderer": "^1.1.1", "@keystone-6/fields-document": "^8.0.0", "@preconstruct/next": "^4.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "next": "^13.3.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/document-field" diff --git a/examples/extend-express-app/package.json b/examples/extend-express-app/package.json index 6df05c62678..c639b7016c8 100644 --- a/examples/extend-express-app/package.json +++ b/examples/extend-express-app/package.json @@ -12,12 +12,12 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "@types/express": "^4.17.14", "express": "^4.17.1" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" }, diff --git a/examples/extend-graphql-schema-graphql-tools/package.json b/examples/extend-graphql-schema-graphql-tools/package.json index 1f718503ac4..65cf83efabe 100644 --- a/examples/extend-graphql-schema-graphql-tools/package.json +++ b/examples/extend-graphql-schema-graphql-tools/package.json @@ -13,11 +13,11 @@ "dependencies": { "@graphql-tools/schema": "^9.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "graphql": "^16.6.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/extend-graphql-schema-graphql-ts/package.json b/examples/extend-graphql-schema-graphql-ts/package.json index 77af0001e98..a7ba42eeef6 100644 --- a/examples/extend-graphql-schema-graphql-ts/package.json +++ b/examples/extend-graphql-schema-graphql-ts/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/extend-graphql-schema-graphql-ts" diff --git a/examples/extend-graphql-schema-nexus/package.json b/examples/extend-graphql-schema-nexus/package.json index d2b04397db0..934f2a8f91f 100644 --- a/examples/extend-graphql-schema-nexus/package.json +++ b/examples/extend-graphql-schema-nexus/package.json @@ -12,12 +12,12 @@ "dependencies": { "@graphql-tools/schema": "^9.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "graphql": "^16.6.0", "nexus": "^1.3.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/extend-graphql-schema-nexus", "devDependencies": { - "prisma": "^4.16.2" + "prisma": "^5.0.0" } } diff --git a/examples/extend-graphql-subscriptions/package.json b/examples/extend-graphql-subscriptions/package.json index 457956bfb4a..8a142fd6ce2 100644 --- a/examples/extend-graphql-subscriptions/package.json +++ b/examples/extend-graphql-subscriptions/package.json @@ -18,7 +18,7 @@ "@keystone-ui/button": "^7.0.1", "@keystone-ui/core": "^5.0.1", "@keystone-ui/fields": "^7.1.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "graphql": "^16.6.0", "graphql-subscriptions": "^2.0.0", "graphql-ws": "^5.9.1", @@ -27,7 +27,7 @@ }, "devDependencies": { "@types/ws": "^8.5.3", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/extend-prisma-schema/package.json b/examples/extend-prisma-schema/package.json index ce4d3d2a7d1..3b0f2fe0a17 100644 --- a/examples/extend-prisma-schema/package.json +++ b/examples/extend-prisma-schema/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/core": "^5.2.0", "@keystone-6/fields-document": "^8.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/extend-prisma-schema" diff --git a/examples/field-groups/package.json b/examples/field-groups/package.json index 6038916bde2..ce2440fee23 100644 --- a/examples/field-groups/package.json +++ b/examples/field-groups/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/framework-astro/package.json b/examples/framework-astro/package.json index 5fdf724bc2a..53eb7bf4429 100644 --- a/examples/framework-astro/package.json +++ b/examples/framework-astro/package.json @@ -14,14 +14,14 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "astro": "^2.2.1" }, "devDependencies": { "@types/node": "^18.11.14", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.4", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/framework-nextjs-app-directory/package.json b/examples/framework-nextjs-app-directory/package.json index 2e2baa79e88..458fdb23615 100644 --- a/examples/framework-nextjs-app-directory/package.json +++ b/examples/framework-nextjs-app-directory/package.json @@ -19,7 +19,7 @@ "@keystone-6/document-renderer": "^1.0.0", "@keystone-6/fields-document": "^8.0.0", "@preconstruct/next": "^4.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "graphql": "^16.6.0", "graphql-request": "^5.0.0", "graphql-yoga": "^3.1.0", @@ -31,7 +31,7 @@ "@types/node": "^18.11.14", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.4", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/framework-nextjs-app-directory" diff --git a/examples/framework-nextjs-pages-directory/package.json b/examples/framework-nextjs-pages-directory/package.json index f181c1d0963..3c996609c19 100644 --- a/examples/framework-nextjs-pages-directory/package.json +++ b/examples/framework-nextjs-pages-directory/package.json @@ -18,7 +18,7 @@ "@keystone-6/core": "^5.2.0", "@keystone-6/fields-document": "^8.0.0", "@preconstruct/next": "^4.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "graphql": "^16.6.0", "graphql-request": "^5.0.0", "graphql-yoga": "^3.1.0", @@ -30,7 +30,7 @@ "@types/node": "^18.11.14", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.4", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/framework-nextjs-pages-directory" diff --git a/examples/framework-nextjs-two-servers/keystone-server/package.json b/examples/framework-nextjs-two-servers/keystone-server/package.json index 8362db27c37..2768be24aa9 100644 --- a/examples/framework-nextjs-two-servers/keystone-server/package.json +++ b/examples/framework-nextjs-two-servers/keystone-server/package.json @@ -14,10 +14,10 @@ "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.2.0", "@keystone-6/fields-document": "^8.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/framework-remix/package.json b/examples/framework-remix/package.json index 443f2a538e4..7302b18b3df 100644 --- a/examples/framework-remix/package.json +++ b/examples/framework-remix/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@keystone-6/core": "^5.1.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "@remix-run/node": "^1.15.0", "@remix-run/react": "^1.15.0", "@remix-run/serve": "^1.15.0", @@ -22,7 +22,7 @@ "@remix-run/dev": "^1.15.0", "@types/react": "^18.0.25", "@types/react-dom": "^18.0.8", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/graphql-ts-gql/package.json b/examples/graphql-ts-gql/package.json index 32537dfd901..ca1a9872142 100644 --- a/examples/graphql-ts-gql/package.json +++ b/examples/graphql-ts-gql/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "@ts-gql/compiler": "^0.15.3", "@ts-gql/eslint-plugin": "^0.9.0", "@ts-gql/tag": "^0.7.0", @@ -21,7 +21,7 @@ "graphql": "^16.6.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "ts-gql": { diff --git a/examples/hooks/package.json b/examples/hooks/package.json index 7886eaa656c..17637d45389 100644 --- a/examples/hooks/package.json +++ b/examples/hooks/package.json @@ -10,10 +10,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/limits/package.json b/examples/limits/package.json index 684e4eb2ca4..27cc544e262 100644 --- a/examples/limits/package.json +++ b/examples/limits/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" }, diff --git a/examples/nextjs-keystone-two-servers/nextjs-frontend/next-env.d.ts b/examples/nextjs-keystone-two-servers/nextjs-frontend/next-env.d.ts deleted file mode 100644 index 4f11a03dc6c..00000000000 --- a/examples/nextjs-keystone-two-servers/nextjs-frontend/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/omit/package.json b/examples/omit/package.json index 52523303a10..e71087e6fc2 100644 --- a/examples/omit/package.json +++ b/examples/omit/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/omit" diff --git a/examples/script/package.json b/examples/script/package.json index c99b160026c..a1c0144a46f 100644 --- a/examples/script/package.json +++ b/examples/script/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" }, diff --git a/examples/singleton/package.json b/examples/singleton/package.json index 5b865f573e8..62fe4f73a1f 100644 --- a/examples/singleton/package.json +++ b/examples/singleton/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" } diff --git a/examples/testing/keystone.ts b/examples/testing/keystone.ts index 348b5b3d3bb..09d74b4c4ce 100644 --- a/examples/testing/keystone.ts +++ b/examples/testing/keystone.ts @@ -1,5 +1,5 @@ import { config } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { fixPrismaPath } from '../example-utils'; import { lists } from './schema'; @@ -30,6 +30,8 @@ const { withAuth } = createAuth({ // the following fields are used by the "Create First User" form fields: ['name', 'password'], }, + // you can find out more at https://keystonejs.com/docs/apis/session#session-api + sessionStrategy: statelessSessions({}), }); export default withAuth( @@ -42,7 +44,5 @@ export default withAuth( ...fixPrismaPath, }, lists, - // you can find out more at https://keystonejs.com/docs/apis/session#session-api - session: statelessSessions(), }) ); diff --git a/examples/testing/package.json b/examples/testing/package.json index d2d44863045..fbf42bb263d 100644 --- a/examples/testing/package.json +++ b/examples/testing/package.json @@ -16,13 +16,13 @@ "@babel/preset-typescript": "^7.21.0", "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { "@types/node": "^18.11.14", "babel-jest": "^29.0.1", "jest": "^29.0.0", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/testing" diff --git a/examples/testing/schema.graphql b/examples/testing/schema.graphql index 3f6eac5c130..0da5755056b 100644 --- a/examples/testing/schema.graphql +++ b/examples/testing/schema.graphql @@ -227,7 +227,6 @@ type Mutation { deleteUsers(where: [UserWhereUniqueInput!]!): [User] endSession: Boolean! authenticateUserWithPassword(name: String!, password: String!): UserAuthenticationWithPasswordResult - createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure @@ -241,11 +240,6 @@ type UserAuthenticationWithPasswordFailure { message: String! } -input CreateInitialUserInput { - name: String - password: String -} - type Query { tasks(where: TaskWhereInput! = {}, orderBy: [TaskOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TaskWhereUniqueInput): [Task!] task(where: TaskWhereUniqueInput!): Task diff --git a/examples/usecase-blog-moderated/keystone-example.db b/examples/usecase-blog-moderated/keystone-example.db index 2a5a95ba5dc..415e9d24b09 100644 Binary files a/examples/usecase-blog-moderated/keystone-example.db and b/examples/usecase-blog-moderated/keystone-example.db differ diff --git a/examples/usecase-blog-moderated/keystone.ts b/examples/usecase-blog-moderated/keystone.ts index bc878158111..43d283328f5 100644 --- a/examples/usecase-blog-moderated/keystone.ts +++ b/examples/usecase-blog-moderated/keystone.ts @@ -3,36 +3,31 @@ import { fixPrismaPath } from '../example-utils'; import { lists, Session } from './schema'; import type { Context, TypeInfo } from '.keystone/types'; -const sillySessionStrategy = { - async get({ context }: { context: Context }): Promise { - if (!context.req) return; +const sillySessionStrategy = async ({ + context, +}: { + context: Context; +}): Promise => { + if (!context.req) return; - // WARNING: for demonstrative purposes only, this has no authentication - // use `Cookie:user=clh9v6pcn0000sbhm9u0j6in0` for Alice (admin) - // use `Cookie:user=clh9v762w0002sbhmhhyc0340` for Bob (moderator) - // use `Cookie:user=clh9v7ahs0004sbhmpx30w85n` for Eve (contributor) - // - // in practice, you should use authentication for your sessions, such as OAuth or JWT - const { cookie = '' } = context.req.headers; - const [cookieName, id] = cookie.split('='); - if (cookieName !== 'user') return; - - const who = await context.sudo().db.User.findOne({ where: { id } }); - if (!who) return; - return { - id, - admin: who.admin, - moderator: who.moderatorId ? { id: who.moderatorId } : null, - contributor: who.contributorId ? { id: who.contributorId } : null, - }; - }, - - // we don't need these unless we want to support the functions - // context.sessionStrategy.start - // context.sessionStrategy.end + // WARNING: for demonstrative purposes only, this has no authentication + // use `Cookie:user=clh9v6pcn0000sbhm9u0j6in0` for Alice (admin) + // use `Cookie:user=clh9v762w0002sbhmhhyc0340` for Bob (moderator) + // use `Cookie:user=clh9v7ahs0004sbhmpx30w85n` for Eve (contributor) // - async start() {}, - async end() {}, + // in practice, you should use authentication for your sessions, such as OAuth or JWT + const { cookie = '' } = context.req.headers; + const [cookieName, id] = cookie.split('='); + if (cookieName !== 'user') return; + + const who = await context.sudo().db.User.findOne({ where: { id } }); + if (!who) return; + return { + id, + admin: who.admin, + moderator: who.moderatorId ? { id: who.moderatorId } : null, + contributor: who.contributorId ? { id: who.contributorId } : null, + }; }; export default config({ @@ -44,5 +39,5 @@ export default config({ ...fixPrismaPath, }, lists, - session: sillySessionStrategy, + getSession: sillySessionStrategy, }); diff --git a/examples/usecase-blog-moderated/package.json b/examples/usecase-blog-moderated/package.json index 4718db3b393..94f3d6a5337 100644 --- a/examples/usecase-blog-moderated/package.json +++ b/examples/usecase-blog-moderated/package.json @@ -11,10 +11,10 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/usecase-blog-moderated/schema.graphql b/examples/usecase-blog-moderated/schema.graphql index 31b1086239d..1ab9d3a9557 100644 --- a/examples/usecase-blog-moderated/schema.graphql +++ b/examples/usecase-blog-moderated/schema.graphql @@ -324,7 +324,6 @@ type Mutation { updateUsers(data: [UserUpdateArgs!]!): [User] deleteUser(where: UserWhereUniqueInput!): User deleteUsers(where: [UserWhereUniqueInput!]!): [User] - endSession: Boolean! } type Query { diff --git a/examples/usecase-blog/package.json b/examples/usecase-blog/package.json index 3e157851959..15c6c13a25d 100644 --- a/examples/usecase-blog/package.json +++ b/examples/usecase-blog/package.json @@ -13,10 +13,10 @@ "dependencies": { "@keystone-6/core": "^5.2.0", "@keystone-6/fields-document": "^8.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" } diff --git a/examples/usecase-roles/keystone.ts b/examples/usecase-roles/keystone.ts index c331d7d70c3..a9b5a95c5ba 100644 --- a/examples/usecase-roles/keystone.ts +++ b/examples/usecase-roles/keystone.ts @@ -1,5 +1,5 @@ import { config } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { fixPrismaPath } from '../example-utils'; import { lists } from './schema'; @@ -49,19 +49,22 @@ const { withAuth } = createAuth({ }, }, - sessionData: ` - name - role { - id + // you can find out more at https://keystonejs.com/docs/apis/session#session-api + sessionStrategy: statelessSessions({ + data: ` name - canCreateTodos - canManageAllTodos - canSeeOtherPeople - canEditOtherPeople - canManagePeople - canManageRoles - canUseAdminUI - }`, + role { + id + name + canCreateTodos + canManageAllTodos + canSeeOtherPeople + canEditOtherPeople + canManagePeople + canManageRoles + canUseAdminUI + }`, + }), }); export default withAuth( @@ -79,7 +82,5 @@ export default withAuth( return session?.data.role?.canUseAdminUI ?? false; }, }, - // you can find out more at https://keystonejs.com/docs/apis/session#session-api - session: statelessSessions(), }) ); diff --git a/examples/usecase-roles/package.json b/examples/usecase-roles/package.json index 3dfd6494b64..d84e10c6b7d 100644 --- a/examples/usecase-roles/package.json +++ b/examples/usecase-roles/package.json @@ -12,10 +12,10 @@ "dependencies": { "@keystone-6/auth": "^7.0.0", "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/examples/usecase-roles/schema.graphql b/examples/usecase-roles/schema.graphql index fd2f1122126..52b7da27e7e 100644 --- a/examples/usecase-roles/schema.graphql +++ b/examples/usecase-roles/schema.graphql @@ -307,7 +307,6 @@ type Mutation { deleteRoles(where: [RoleWhereUniqueInput!]!): [Role] endSession: Boolean! authenticateUserWithPassword(name: String!, password: String!): UserAuthenticationWithPasswordResult - createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure @@ -321,11 +320,6 @@ type UserAuthenticationWithPasswordFailure { message: String! } -input CreateInitialUserInput { - name: String - password: String -} - type Query { todos(where: TodoWhereInput! = {}, orderBy: [TodoOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TodoWhereUniqueInput): [Todo!] todo(where: TodoWhereUniqueInput!): Todo diff --git a/examples/usecase-todo/package.json b/examples/usecase-todo/package.json index b38eb5d9f69..ae208440269 100644 --- a/examples/usecase-todo/package.json +++ b/examples/usecase-todo/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" }, diff --git a/examples/usecase-versioning/package.json b/examples/usecase-versioning/package.json index 70fd19ff16e..1330817e8f2 100644 --- a/examples/usecase-versioning/package.json +++ b/examples/usecase-versioning/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "tsx": "^3.9.0", "typescript": "~5.0.0" }, diff --git a/examples/virtual-field/package.json b/examples/virtual-field/package.json index 40958f4b164..2b128d57377 100644 --- a/examples/virtual-field/package.json +++ b/examples/virtual-field/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/examples/virtual-field" diff --git a/packages/auth/package.json b/packages/auth/package.json index 0b22609d5a8..7f57bc79b62 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -9,6 +9,10 @@ "module": "./dist/keystone-6-auth.esm.js", "default": "./dist/keystone-6-auth.cjs.js" }, + "./session": { + "module": "./session/dist/keystone-6-auth-session.esm.js", + "default": "./session/dist/keystone-6-auth-session.cjs.js" + }, "./pages/InitPage": { "module": "./pages/InitPage/dist/keystone-6-auth-pages-InitPage.esm.js", "default": "./pages/InitPage/dist/keystone-6-auth-pages-InitPage.cjs.js" @@ -21,17 +25,20 @@ }, "dependencies": { "@babel/runtime": "^7.16.3", + "@hapi/iron": "^7.0.0", "@keystone-ui/button": "^7.0.2", "@keystone-ui/core": "^5.0.2", "@keystone-ui/fields": "^7.1.2", "@keystone-ui/loading": "^6.0.2", "@keystone-ui/notice": "^6.0.2", + "cookie": "^0.5.0", "cross-fetch": "^4.0.0", "fast-deep-equal": "^3.1.3", "graphql": "^16.6.0" }, "devDependencies": { "@keystone-6/core": "^5.4.0", + "@types/cookie": "^0.5.0", "react": "^18.2.0" }, "peerDependencies": { @@ -40,6 +47,7 @@ }, "preconstruct": { "entrypoints": [ + "session/index.ts", "index.ts", "pages/*.tsx" ] diff --git a/packages/auth/session/package.json b/packages/auth/session/package.json new file mode 100644 index 00000000000..a38b1eafc22 --- /dev/null +++ b/packages/auth/session/package.json @@ -0,0 +1,4 @@ +{ + "main": "dist/keystone-6-auth-session.cjs.js", + "module": "dist/keystone-6-auth-session.esm.js" +} diff --git a/packages/auth/src/gql/getBaseAuthSchema.ts b/packages/auth/src/gql/getBaseAuthSchema.ts index 33c53cee69c..f36dc38c69d 100644 --- a/packages/auth/src/gql/getBaseAuthSchema.ts +++ b/packages/auth/src/gql/getBaseAuthSchema.ts @@ -1,6 +1,6 @@ import type { BaseItem } from '@keystone-6/core/types'; import { graphql } from '@keystone-6/core'; -import { AuthGqlNames, SecretFieldImpl } from '../types'; +import { AuthGqlNames, SecretFieldImpl, SessionStrategy } from '../types'; import { validateSecret } from '../lib/validateSecret'; @@ -11,6 +11,7 @@ export function getBaseAuthSchema({ gqlNames, secretFieldImpl, base, + sessionStrategy, }: { listKey: string; identityField: I; @@ -18,6 +19,7 @@ export function getBaseAuthSchema({ gqlNames: AuthGqlNames; secretFieldImpl: SecretFieldImpl; base: graphql.BaseSchemaMeta; + sessionStrategy: SessionStrategy; // TODO: return type required by pnpm :( }): { @@ -46,8 +48,8 @@ export function getBaseAuthSchema({ const AuthenticationResult = graphql.union({ name: gqlNames.ItemAuthenticationWithPasswordResult, types: [ItemAuthenticationWithPasswordSuccess, ItemAuthenticationWithPasswordFailure], - resolveType(val) { - if ('sessionToken' in val) { + resolveType(value) { + if ('sessionToken' in value) { return gqlNames.ItemAuthenticationWithPasswordSuccess; } return gqlNames.ItemAuthenticationWithPasswordFailure; @@ -77,17 +79,31 @@ export function getBaseAuthSchema({ }), }, mutation: { + endSession: graphql.field({ + type: graphql.nonNull(graphql.Boolean), + async resolve(root, args, context) { + if (sessionStrategy) { + await sessionStrategy.end({ context }); + } + return true; + }, + }), [gqlNames.authenticateItemWithPassword]: graphql.field({ type: AuthenticationResult, args: { [identityField]: graphql.arg({ type: graphql.nonNull(graphql.String) }), [secretField]: graphql.arg({ type: graphql.nonNull(graphql.String) }), }, - async resolve(root, { [identityField]: identity, [secretField]: secret }, context) { - if (!context.sessionStrategy) { + async resolve(root, args, context) { + if (!context.res) { throw new Error('No session implementation available on context'); } + const { + [identityField]: identity, + [secretField]: secret + } = args; + const dbItemAPI = context.sudo().db[listKey]; const result = await validateSecret( secretFieldImpl, @@ -103,7 +119,8 @@ export function getBaseAuthSchema({ } // Update system state - const sessionToken = await context.sessionStrategy.start({ + + const sessionToken = await sessionStrategy.start({ data: { listKey, itemId: result.item.id, diff --git a/packages/auth/src/index.ts b/packages/auth/src/index.ts index 31d66c8d8b0..801948e0084 100644 --- a/packages/auth/src/index.ts +++ b/packages/auth/src/index.ts @@ -3,12 +3,11 @@ import type { BaseListTypeInfo, KeystoneConfig, KeystoneContext, - SessionStrategy, BaseKeystoneTypeInfo, } from '@keystone-6/core/types'; import { password, timestamp } from '@keystone-6/core/fields'; -import type { AuthConfig, AuthGqlNames } from './types'; +import type { AuthConfig, AuthGqlNames, SessionStrategy } from './types'; import { getSchemaExtension } from './schema'; import { signinTemplate } from './templates/signin'; import { initTemplate } from './templates/init'; @@ -32,7 +31,7 @@ export function createAuth({ identityField, magicAuthLink, passwordResetLink, - sessionData = 'id', + sessionStrategy, }: AuthConfig) { const gqlNames: AuthGqlNames = { // Core @@ -130,7 +129,7 @@ export function createAuth({ initFirstItem, passwordResetLink, magicAuthLink, - sessionData, + sessionStrategy, }); function throwIfInvalidConfig( @@ -153,43 +152,50 @@ export function createAuth({ for (const fieldKey of initFirstItem?.fields || []) { if (fieldKey in list.fields) continue; - - throw new Error(`initFirstItem.fields has unknown field "${listKey}.${fieldKey}"`); } } - - // this strategy wraps the existing session strategy, - // and injects the requested session.data before returning - function authSessionStrategy( - _sessionStrategy: SessionStrategy - ): SessionStrategy { - const { get, ...sessionStrategy } = _sessionStrategy; - return { - ...sessionStrategy, - get: async ({ context }) => { - const session = await get({ context }); - const sudoContext = context.sudo(); - if (!session) return; - if (!session.itemId) return; - if (session.listKey !== listKey) return; - - try { - const data = await sudoContext.query[listKey].findOne({ - where: { id: session.itemId }, - query: sessionData, - }); - if (!data) return; - + /** + * withItemData + * + * Automatically injects a session.data value with the authenticated item + */ + const withItemData = ( + sessionStrategy: SessionStrategy>, + getSession: KeystoneConfig['getSession'] + ): ((args: { context: KeystoneContext }) => Promise) => { + const { get } = sessionStrategy; + return async ({ context }) => { + const session = await get({ context }); + const sudoContext = context.sudo(); + if ( + !session || + !session.listKey || + session.listKey !== listKey || + !session.itemId || + !sudoContext.query[session.listKey] + ) { + return; + } + + try { + const data = await sudoContext.query[listKey].findOne({ + where: { id: session.itemId }, + query: sessionStrategy.data, + }); + if (!data) return; + if (getSession) { + return getSession({ context: { ...context, session: { ...session, data } } }); + } else { return { ...session, itemId: session.itemId, listKey, data }; - } catch (e) { - console.error(e); - // TODO: the assumption is this could only be from an invalid sessionData configuration - // it could be something else though, either way, result is a bad session - return; } - }, + } catch (e) { + console.error(e); + // TODO: the assumption is this could only be from an invalid sessionData configuration + // it could be something else though, either way, result is a bad session + return; + } }; - } + }; async function hasInitFirstItemConditions( context: KeystoneContext @@ -233,7 +239,7 @@ export function createAuth({ return { kind: 'redirect', to: `${basePath}/signin` }; } - function defaultIsAccessAllowed({ session, sessionStrategy }: KeystoneContext) { + function defaultIsAccessAllowed({ session }: KeystoneContext) { return session !== undefined; } @@ -277,7 +283,7 @@ export function createAuth({ }; } - if (!config.session) throw new TypeError('Missing .session configuration'); + const getSession = withItemData(sessionStrategy, config.getSession); const { extendGraphqlSchema = defaultExtendGraphqlSchema } = config; const authListConfig = config.lists[listKey]; @@ -285,7 +291,7 @@ export function createAuth({ return { ...config, ui, - session: authSessionStrategy(config.session), + getSession, lists: { ...config.lists, [listKey]: { diff --git a/packages/auth/src/schema.ts b/packages/auth/src/schema.ts index dc2ebd021b4..bd2636cd083 100644 --- a/packages/auth/src/schema.ts +++ b/packages/auth/src/schema.ts @@ -1,4 +1,4 @@ -import { getGqlNames } from '@keystone-6/core/types'; +import { ExtendGraphqlSchema, getGqlNames } from '@keystone-6/core/types'; import { assertObjectType, @@ -15,11 +15,9 @@ import type { AuthTokenTypeConfig, InitFirstItemConfig, SecretFieldImpl, + SessionStrategy, } from './types'; import { getBaseAuthSchema } from './gql/getBaseAuthSchema'; -import { getInitFirstItemSchema } from './gql/getInitFirstItemSchema'; -import { getPasswordResetSchema } from './gql/getPasswordResetSchema'; -import { getMagicAuthLinkSchema } from './gql/getMagicAuthLinkSchema'; function assertSecretFieldImpl( impl: any, @@ -53,7 +51,7 @@ export const getSchemaExtension = ({ initFirstItem, passwordResetLink, magicAuthLink, - sessionData, + sessionStrategy, }: { identityField: string; listKey: string; @@ -62,8 +60,8 @@ export const getSchemaExtension = ({ initFirstItem?: InitFirstItemConfig; passwordResetLink?: AuthTokenTypeConfig; magicAuthLink?: AuthTokenTypeConfig; - sessionData: string; -}) => + sessionStrategy: SessionStrategy; +}): ExtendGraphqlSchema => graphql.extend(base => { const uniqueWhereInputType = assertInputObjectType( base.schema.getType(`${listKey}WhereUniqueInput`) @@ -89,6 +87,7 @@ export const getSchemaExtension = ({ gqlNames, secretFieldImpl: getSecretFieldImpl(base.schema, listKey, secretField), base, + sessionStrategy, }); // technically this will incorrectly error if someone has a schema extension that adds a field to the list output type @@ -96,7 +95,7 @@ export const getSchemaExtension = ({ // they want to add a GraphQL field, they'll probably use a virtual field const query = `query($id: ID!) { ${ getGqlNames({ listKey, pluralGraphQLName: '' }).itemQueryName - }(where: { id: $id }) { ${sessionData} } }`; + }(where: { id: $id }) { ${sessionStrategy.data} } }`; let ast; try { @@ -116,38 +115,5 @@ export const getSchemaExtension = ({ ); } - return [ - baseSchema.extension, - initFirstItem && - getInitFirstItemSchema({ - listKey, - fields: initFirstItem.fields, - itemData: initFirstItem.itemData, - gqlNames, - graphQLSchema: base.schema, - ItemAuthenticationWithPasswordSuccess: baseSchema.ItemAuthenticationWithPasswordSuccess, - }), - passwordResetLink && - getPasswordResetSchema({ - identityField, - listKey, - secretField, - passwordResetLink, - gqlNames, - passwordResetTokenSecretFieldImpl: getSecretFieldImpl( - base.schema, - listKey, - 'passwordResetToken' - ), - }), - magicAuthLink && - getMagicAuthLinkSchema({ - identityField, - listKey, - magicAuthLink, - gqlNames, - magicAuthTokenSecretFieldImpl: getSecretFieldImpl(base.schema, listKey, 'magicAuthToken'), - base, - }), - ].filter((x): x is Exclude => x !== undefined); + return [baseSchema.extension].filter((x): x is Exclude => x !== undefined); }); diff --git a/packages/core/src/session/index.ts b/packages/auth/src/session/index.ts similarity index 96% rename from packages/core/src/session/index.ts rename to packages/auth/src/session/index.ts index 8f394c635ac..bbd09e7b17d 100644 --- a/packages/core/src/session/index.ts +++ b/packages/auth/src/session/index.ts @@ -68,8 +68,7 @@ export function statelessSessions({ ironOptions = Iron.defaults, domain, sameSite = 'lax', -}: StatelessSessionsOptions = {}): SessionStrategy { - // atleast 192-bit in base64 +}: StatelessSessionsOptions): SessionStrategy { if (secret.length < 32) { throw new Error('The session secret must be at least 32 characters long'); } @@ -129,9 +128,9 @@ export function storedSessions({ store: storeFn, maxAge = 60 * 60 * 8, // 8 hours ...statelessSessionsOptions -}: { +}: StatelessSessionsOptions & { store: SessionStoreFunction; -} & StatelessSessionsOptions): SessionStrategy { +}): SessionStrategy { const stateless = statelessSessions({ ...statelessSessionsOptions, maxAge }); const store = storeFn({ maxAge }); diff --git a/packages/auth/src/types.ts b/packages/auth/src/types.ts index fa31c7e6420..d7f76c35008 100644 --- a/packages/auth/src/types.ts +++ b/packages/auth/src/types.ts @@ -1,4 +1,4 @@ -import { BaseListTypeInfo, KeystoneContext } from '@keystone-6/core/types'; +import type { BaseListTypeInfo, KeystoneContext } from '@keystone-6/core/types'; export type AuthGqlNames = { CreateInitialInput: string; @@ -35,6 +35,43 @@ export type AuthTokenTypeConfig = { tokensValidForMins?: number; }; +export type JSONValue = + | string + | number + | boolean + | null + | readonly JSONValue[] + | { [key: string]: JSONValue }; + +export type SessionStrategy = { + data: string; + // creates token from data, sets the cookie with token via res, returns token + start: (args: { + data: StoredSessionData | StartSessionData; + context: KeystoneContext; + }) => Promise; + // resets the cookie via res + end: (args: { context: KeystoneContext }) => Promise; + // -- this one is invoked at the start of every request + // reads the token, gets the data, returns it + get: (args: { context: KeystoneContext }) => Promise; +}; + +export type SessionStore = { + get(key: string): undefined | JSONValue | Promise; + // 😞 using any here rather than void to be compatible with Map. note that `| Promise` doesn't actually do anything type wise because it just turns into any, it's just to show intent here + set(key: string, value: JSONValue): any | Promise; + // 😞 | boolean is for compatibility with Map + delete(key: string): void | boolean | Promise; +}; + +export type SessionStoreFunction = (args: { + /** + * The number of seconds that a cookie session be valid for + */ + maxAge: number; +}) => SessionStore; + export type AuthConfig = { /** The key of the list to authenticate users with */ listKey: ListTypeInfo['key']; @@ -49,7 +86,7 @@ export type AuthConfig = { /** "Magic link" functionality */ magicAuthLink?: AuthTokenTypeConfig; /** Session data population */ - sessionData?: string; + sessionStrategy: SessionStrategy; }; export type InitFirstItemConfig = { diff --git a/packages/auth/types/package.json b/packages/auth/types/package.json new file mode 100644 index 00000000000..337875520a6 --- /dev/null +++ b/packages/auth/types/package.json @@ -0,0 +1,4 @@ +{ + "main": "dist/keystone-6-auth-types.cjs.js", + "module": "dist/keystone-6-auth-types.esm.js" +} diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 432dfed7600..118293c1997 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -354,7 +354,7 @@ - [#7888](https://github.com/keystonejs/keystone/pull/7888) [`ed3d97874`](https://github.com/keystonejs/keystone/commit/ed3d97874e93470cccac67ac2e43dbd268e7e929) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Changes default Apollo Server configuration to use `cache: "bounded"` and `persistedQueries: false` -- [#7912](https://github.com/keystonejs/keystone/pull/7912) [`c3a3789c6`](https://github.com/keystonejs/keystone/commit/c3a3789c6e4a1761a24cd02904b7549a62113363) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Removes `createSessionContext` export from `@keystone-6/core/session` +- [#7912](https://github.com/keystonejs/keystone/pull/7912) [`c3a3789c6`](https://github.com/keystonejs/keystone/commit/c3a3789c6e4a1761a24cd02904b7549a62113363) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Removes `createSessionContext` export from `@keystone-6/auth/session` - [#7972](https://github.com/keystonejs/keystone/pull/7972) [`81f33eed3`](https://github.com/keystonejs/keystone/commit/81f33eed3570057be9bc8df1f29de12886dfceea) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Removes `@keystone-6/core/artifacts` from our exports diff --git a/packages/core/package.json b/packages/core/package.json index 7e99d6b9ff1..00f9975cd0e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -42,10 +42,6 @@ "module": "./scripts/dist/keystone-6-core-scripts.esm.js", "default": "./scripts/dist/keystone-6-core-scripts.cjs.js" }, - "./session": { - "module": "./session/dist/keystone-6-core-session.esm.js", - "default": "./session/dist/keystone-6-core-session.cjs.js" - }, "./admin-ui/image": { "module": "./admin-ui/image/dist/keystone-6-core-admin-ui-image.esm.js", "default": "./admin-ui/image/dist/keystone-6-core-admin-ui-image.cjs.js" @@ -208,9 +204,10 @@ "@keystone-ui/toast": "^6.0.2", "@keystone-ui/tooltip": "^6.0.2", "@nodelib/fs.walk": "^2.0.0", - "@prisma/client": "4.16.2", - "@prisma/internals": "4.16.2", - "@prisma/migrate": "4.16.2", + "@prisma/client": "5.1.1", + "@prisma/internals": "5.1.1", + "@prisma/migrate": "5.1.1", + "@sindresorhus/slugify": "^1.1.2", "apollo-upload-client": "^17.0.0", "bcryptjs": "^2.4.3", "body-parser": "^1.20.1", @@ -240,7 +237,7 @@ "node-fetch": "^2.6.7", "p-limit": "^2.3.0", "pluralize": "^8.0.0", - "prisma": "4.16.2", + "prisma": "5.1.1", "prompts": "^2.4.2", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -274,7 +271,6 @@ "___internal-do-not-use-will-break-in-patch/admin-ui/id-field-view.tsx", "context.ts", "testing.ts", - "session/index.ts", "scripts/index.ts", "scripts/cli.ts", "admin-ui/components/index.ts", diff --git a/packages/core/session/package.json b/packages/core/session/package.json deleted file mode 100644 index a5b8d27f9f1..00000000000 --- a/packages/core/session/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "main": "dist/keystone-6-core-session.cjs.js", - "module": "dist/keystone-6-core-session.esm.js" -} diff --git a/packages/core/src/admin-ui/templates/index.ts b/packages/core/src/admin-ui/templates/index.ts index 05bfa8e9ff5..0813a5931dd 100644 --- a/packages/core/src/admin-ui/templates/index.ts +++ b/packages/core/src/admin-ui/templates/index.ts @@ -29,7 +29,7 @@ export const writeAdminFiles = ( inputPath: Path.join(pkgDir, 'static', 'favicon.ico'), outputPath: 'public/favicon.ico', }, - { mode: 'write', src: noAccessTemplate(config.session), outputPath: 'pages/no-access.js' }, + { mode: 'write', src: noAccessTemplate(config.getSession), outputPath: 'pages/no-access.js' }, { mode: 'write', src: appTemplate( diff --git a/packages/core/src/admin-ui/templates/no-access.ts b/packages/core/src/admin-ui/templates/no-access.ts index 38302a0f00b..26bccb9ccfb 100644 --- a/packages/core/src/admin-ui/templates/no-access.ts +++ b/packages/core/src/admin-ui/templates/no-access.ts @@ -1,6 +1,6 @@ import type { KeystoneConfig } from '../../types'; -export const noAccessTemplate = (session: KeystoneConfig['session']) => +export const noAccessTemplate = (session: KeystoneConfig['getSession']) => `import { getNoAccessPage } from '@keystone-6/core/___internal-do-not-use-will-break-in-patch/admin-ui/pages/NoAccessPage'; export default getNoAccessPage(${JSON.stringify({ sessionsEnabled: !!session })}) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 1a04e0e0f5e..c341bd54ad2 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,3 +1,3 @@ export { list, config, group } from './schema'; -export type { ListSchemaConfig, ListConfig, ExtendGraphqlSchema, BaseFields } from './types'; +export type { ListConfig, BaseFields } from './types'; export { graphql } from './types/schema'; diff --git a/packages/core/src/lib/context/createContext.ts b/packages/core/src/lib/context/createContext.ts index ae5936966b7..58885e7c372 100644 --- a/packages/core/src/lib/context/createContext.ts +++ b/packages/core/src/lib/context/createContext.ts @@ -80,8 +80,9 @@ export function createContext({ req: newReq, res: newRes, }); + return newContext.withSession( - config.session ? await config.session.get({ context: newContext }) : undefined + config.getSession ? await config.getSession({ context: newContext }) : undefined ); } @@ -96,8 +97,9 @@ export function createContext({ req, res, - sessionStrategy: config.session, + ...(session ? { session } : {}), + getSession: config.getSession, withRequest, withSession: session => { diff --git a/packages/core/src/lib/core/graphql-errors.ts b/packages/core/src/lib/core/graphql-errors.ts index bc29b8ed1dc..57439132828 100644 --- a/packages/core/src/lib/core/graphql-errors.ts +++ b/packages/core/src/lib/core/graphql-errors.ts @@ -6,7 +6,9 @@ export const userInputError = (msg: string) => export const accessDeniedError = (msg: string) => new GraphQLError(`Access denied: ${msg}`, { extensions: { code: 'KS_ACCESS_DENIED' } }); -export const prismaError = (err: Error) => { +export function prismaError(err: Error) { + console.error(err); + if ((err as any).code === undefined) { return new GraphQLError(`Prisma error`, { extensions: { @@ -23,7 +25,7 @@ export const prismaError = (err: Error) => { prisma: { ...err }, }, }); -}; +} export const validationFailureError = (messages: string[]) => { const s = messages.map(m => ` - ${m}`).join('\n'); diff --git a/packages/core/src/lib/createGraphQLSchema.ts b/packages/core/src/lib/createGraphQLSchema.ts index 685fae60af9..6d525c9472c 100644 --- a/packages/core/src/lib/createGraphQLSchema.ts +++ b/packages/core/src/lib/createGraphQLSchema.ts @@ -97,25 +97,13 @@ function collectTypes( export function createGraphQLSchema( config: KeystoneConfig, lists: Record, - adminMeta: AdminMetaRootVal | null, + adminMeta: AdminMetaRootVal, sudo: boolean ) { const graphQLSchema = getGraphQLSchema( lists, { - mutation: config.session - ? { - endSession: graphql.field({ - type: graphql.nonNull(graphql.Boolean), - async resolve(rootVal, args, context) { - if (context.sessionStrategy) { - await context.sessionStrategy.end({ context }); - } - return true; - }, - }), - } - : {}, + mutation: {}, query: adminMeta ? { keystone: graphql.field({ diff --git a/packages/core/src/lib/server/createAdminUIMiddleware.ts b/packages/core/src/lib/server/createAdminUIMiddleware.ts index ef7c0347522..52b8b1221d0 100644 --- a/packages/core/src/lib/server/createAdminUIMiddleware.ts +++ b/packages/core/src/lib/server/createAdminUIMiddleware.ts @@ -7,8 +7,8 @@ import { pkgDir } from '../../pkg-dir'; const adminErrorHTMLFilepath = path.join(pkgDir, 'static', 'admin-error.html'); -function defaultIsAccessAllowed({ session, sessionStrategy }: KeystoneContext) { - if (!sessionStrategy) return true; +function defaultIsAccessAllowed({ session, getSession }: KeystoneContext) { + if (!getSession) return true; return session !== undefined; } diff --git a/packages/core/src/scripts/prisma.ts b/packages/core/src/scripts/prisma.ts index 04cb722f3ad..9416ea38ae6 100644 --- a/packages/core/src/scripts/prisma.ts +++ b/packages/core/src/scripts/prisma.ts @@ -4,7 +4,8 @@ import { createSystem } from '../lib/createSystem'; import { getBuiltKeystoneConfiguration, generateTypescriptTypesAndPrisma, - validatePrismaAndGraphQLSchemas, + generatePrismaAndGraphQLSchemas, + validatePrismaAndGraphQLSchemas } from '../artifacts'; import { getEsbuildConfig } from '../lib/esbuild'; import { ExitError } from './utils'; @@ -19,8 +20,15 @@ export async function prisma(cwd: string, args: string[], frozen: boolean) { // TODO: this cannot be changed for now, circular dependency with getSystemPaths, getEsbuildConfig const config = getBuiltKeystoneConfiguration(cwd); const { graphQLSchema } = createSystem(config); - await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema); - await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema); + + if (frozen) { + await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema); + console.log('✨ GraphQL and Prisma schemas are up to date'); + } else { + await generatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema); // TODO: rename to generateSchemas (or similar) + console.log('✨ Generated GraphQL and Prisma schemas'); + await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema); // TODO: rename to generatePrismaClientAndTypes (or similar) + } return new Promise((resolve, reject) => { const p = execFile( diff --git a/packages/core/src/types/config/index.ts b/packages/core/src/types/config/index.ts index 31cc9c71e3f..8ea075b6f76 100644 --- a/packages/core/src/types/config/index.ts +++ b/packages/core/src/types/config/index.ts @@ -8,7 +8,6 @@ import type { Options as BodyParserOptions } from 'body-parser'; import type { AssetMode, BaseKeystoneTypeInfo, KeystoneContext, DatabaseProvider } from '..'; -import type { SessionStrategy } from '../session'; import type { MaybePromise } from '../utils'; import type { ListSchemaConfig, @@ -99,13 +98,15 @@ export type KeystoneConfig; ui?: AdminUIConfig; server?: ServerConfig; - session?: SessionStrategy; + getSession?: (args: { + context: KeystoneContext; + }) => Promise; types?: { path?: string; }; // TODO: why isn't this within .graphql? - extendGraphqlSchema?: ExtendGraphqlSchema; + extendGraphqlSchema?: (schema: GraphQLSchema) => GraphQLSchema; /** An object containing configuration about keystone's various external storages. * * Each entry should be of either `kind: 'local'` or `kind: 's3'`, and follow the configuration of each. @@ -292,10 +293,6 @@ export type GraphQLConfig GraphQLSchema; - export type FilesConfig = { upload: AssetMode; transformFilename?: (str: string) => string; diff --git a/packages/core/src/types/context.ts b/packages/core/src/types/context.ts index 6d283a931c2..40e332ddfcc 100644 --- a/packages/core/src/types/context.ts +++ b/packages/core/src/types/context.ts @@ -3,7 +3,6 @@ import type { Readable } from 'stream'; import type { GraphQLSchema, ExecutionResult, DocumentNode } from 'graphql'; import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; import type { InitialisedList } from '../lib/core/initialise-lists'; -import type { SessionStrategy } from './session'; import type { BaseListTypeInfo, BaseKeystoneTypeInfo } from './type-info'; export type KeystoneContext = { @@ -27,7 +26,7 @@ export type KeystoneContext; }; - sessionStrategy?: SessionStrategy; + getSession?: (args: { context: KeystoneContext }) => Promise; session?: TypeInfo['session']; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f2f3ab93ca5..b575724dc1d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -636,12 +636,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -652,15 +652,15 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) dotenv: specifier: ^16.0.0 version: 16.0.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -674,12 +674,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -693,8 +693,8 @@ importers: specifier: ^5.0.1 version: link:../../design-system/packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next: specifier: ^13.3.0 version: 13.3.0(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0) @@ -706,8 +706,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -718,15 +718,15 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) react: specifier: ^18.2.0 version: 18.2.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -740,8 +740,8 @@ importers: specifier: ^5.0.1 version: link:../../design-system/packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next: specifier: ^13.3.0 version: 13.3.0(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0) @@ -753,8 +753,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -768,12 +768,12 @@ importers: specifier: ^7.1.1 version: link:../../design-system/packages/fields '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -799,8 +799,8 @@ importers: specifier: ^6.0.1 version: link:../../design-system/packages/icons '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next: specifier: ^13.3.0 version: 13.3.0(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0) @@ -812,8 +812,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -827,12 +827,12 @@ importers: specifier: ^2.2.1 version: 2.2.1 '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -846,8 +846,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next: specifier: ^13.3.0 version: 13.3.0(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0) @@ -859,8 +859,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -874,12 +874,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -893,12 +893,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -912,8 +912,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) jsonwebtoken: specifier: ^9.0.0 version: 9.0.0 @@ -922,8 +922,8 @@ importers: specifier: ^9.0.2 version: 9.0.2 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -934,15 +934,15 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.14.0 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next-auth: specifier: ^4.22.1 version: 4.22.1(next@13.4.19)(react-dom@18.2.0)(react@18.2.0) devDependencies: prisma: - specifier: ^4.14.0 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -956,15 +956,15 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@redis/client': specifier: ^1.3.0 version: 1.3.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -975,12 +975,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1000,8 +1000,8 @@ importers: specifier: ^4.0.0 version: 4.0.0 '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) next: specifier: ^13.3.0 version: 13.3.0(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0) @@ -1013,8 +1013,8 @@ importers: version: 18.2.0(react@18.2.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1052,8 +1052,8 @@ importers: specifier: ^6.0.1 version: link:../../../design-system/packages/tooltip '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) react: specifier: ^18.2.0 version: 18.2.0 @@ -1062,8 +1062,8 @@ importers: version: 5.0.2 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 examples/document-field-customisation/nextjs-frontend: dependencies: @@ -1105,8 +1105,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@types/express': specifier: ^4.17.14 version: 4.17.14 @@ -1115,8 +1115,8 @@ importers: version: 4.17.1 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1133,15 +1133,15 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) graphql: specifier: ^16.6.0 version: 16.6.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1152,12 +1152,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1171,8 +1171,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) graphql: specifier: ^16.6.0 version: 16.6.0 @@ -1181,8 +1181,8 @@ importers: version: 1.3.0(graphql@16.6.0) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 examples/extend-graphql-subscriptions: dependencies: @@ -1208,8 +1208,8 @@ importers: specifier: ^7.1.1 version: link:../../design-system/packages/fields '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) graphql: specifier: ^16.6.0 version: 16.6.0 @@ -1230,8 +1230,8 @@ importers: specifier: ^8.5.3 version: 8.5.3 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1245,12 +1245,12 @@ importers: specifier: ^8.0.0 version: link:../../packages/fields-document '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1261,12 +1261,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1277,8 +1277,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) astro: specifier: ^2.2.1 version: 2.2.1(@types/node@18.11.14) @@ -1293,8 +1293,8 @@ importers: specifier: ^18.0.4 version: 18.0.8 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1317,8 +1317,8 @@ importers: specifier: ^4.0.0 version: 4.0.0 '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) graphql: specifier: ^16.6.0 version: 16.6.0 @@ -1348,8 +1348,8 @@ importers: specifier: ^18.0.4 version: 18.0.8 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1369,8 +1369,8 @@ importers: specifier: ^4.0.0 version: 4.0.0 '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) graphql: specifier: ^16.6.0 version: 16.6.0 @@ -1400,8 +1400,8 @@ importers: specifier: ^18.0.4 version: 18.0.8 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1424,12 +1424,12 @@ importers: specifier: ^8.0.0 version: link:../../../packages/fields-document '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1474,8 +1474,8 @@ importers: specifier: ^5.1.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@remix-run/node': specifier: ^1.15.0 version: 1.15.0 @@ -1505,8 +1505,8 @@ importers: specifier: ^18.0.8 version: 18.0.8 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1517,8 +1517,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@ts-gql/compiler': specifier: ^0.15.3 version: 0.15.3(graphql@16.6.0) @@ -1536,8 +1536,8 @@ importers: version: 16.6.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1548,12 +1548,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1564,12 +1564,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1583,12 +1583,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1599,12 +1599,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1618,12 +1618,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1649,8 +1649,8 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: '@types/node': specifier: ^18.11.14 @@ -1662,8 +1662,8 @@ importers: specifier: ^29.0.0 version: 29.0.0(@types/node@18.11.14) prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1677,12 +1677,12 @@ importers: specifier: ^8.0.0 version: link:../../packages/fields-document '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1699,12 +1699,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1718,12 +1718,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1734,12 +1734,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1753,12 +1753,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tsx: specifier: ^3.9.0 version: 3.9.0 @@ -1772,12 +1772,12 @@ importers: specifier: ^5.0.0 version: link:../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -1949,14 +1949,17 @@ importers: specifier: ^2.0.0 version: 2.0.0 '@prisma/client': - specifier: 4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: 5.1.1 + version: 5.1.1(prisma@5.1.1) '@prisma/internals': - specifier: 4.16.2 - version: 4.16.2 + specifier: 5.1.1 + version: 5.1.1 '@prisma/migrate': - specifier: 4.16.2 - version: 4.16.2(@prisma/generator-helper@4.16.2)(@prisma/internals@4.16.2) + specifier: 5.1.1 + version: 5.1.1(@prisma/generator-helper@5.2.0)(@prisma/internals@5.1.1) + '@sindresorhus/slugify': + specifier: ^1.1.2 + version: 1.1.2 apollo-upload-client: specifier: ^17.0.0 version: 17.0.0(@apollo/client@3.7.0)(graphql@16.6.0) @@ -2045,8 +2048,8 @@ importers: specifier: ^8.0.0 version: 8.0.0 prisma: - specifier: 4.16.2 - version: 4.16.2 + specifier: 5.1.1 + version: 5.1.1 prompts: specifier: ^2.4.2 version: 2.4.2 @@ -2239,11 +2242,11 @@ importers: prisma-utils: dependencies: '@prisma/generator-helper': - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.2.0 '@prisma/internals': - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 fs-extra: specifier: ^11.0.0 version: 11.0.0 @@ -2344,11 +2347,11 @@ importers: specifier: '*' version: link:../../packages/fields-document '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@prisma/internals': - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 '@types/express': specifier: ^4.17.14 version: 4.17.14 @@ -2374,8 +2377,8 @@ importers: specifier: ^2.6.7 version: 2.6.7 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 supertest: specifier: ^6.1.6 version: 6.1.6 @@ -2423,11 +2426,11 @@ importers: specifier: '*' version: link:../../packages/fields-document '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) '@prisma/internals': - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 chalk: specifier: ^4.1.2 version: 4.1.2 @@ -2447,8 +2450,8 @@ importers: specifier: ^2.6.7 version: 2.6.7 prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 tests/examples-smoke-tests: dependencies: @@ -2501,15 +2504,15 @@ importers: specifier: ^6.0.1 version: link:../../design-system/packages/tooltip '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) react: specifier: ^18.2.0 version: 18.2.0 devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -2520,12 +2523,12 @@ importers: specifier: ^5.0.0 version: link:../../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -2536,12 +2539,12 @@ importers: specifier: ^5.0.0 version: link:../../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -2552,12 +2555,12 @@ importers: specifier: ^5.0.0 version: link:../../../packages/core '@prisma/client': - specifier: ^4.16.2 - version: 4.16.2(prisma@4.16.2) + specifier: ^5.0.0 + version: 5.1.1(prisma@5.1.1) devDependencies: prisma: - specifier: ^4.16.2 - version: 4.16.2 + specifier: ^5.0.0 + version: 5.1.1 typescript: specifier: ~5.0.0 version: 5.0.2 @@ -2575,8 +2578,8 @@ packages: '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.19 - /@antfu/ni@0.21.4: - resolution: {integrity: sha512-O0Uv9LbLDSoEg26fnMDdDRiPwFJnQSoD4WnrflDwKCJm8Cx/0mV4cGxwBLXan5mGIrpK4Dd7vizf4rQm0QCEAA==} + /@antfu/ni@0.21.5: + resolution: {integrity: sha512-rFmuqZMFa1OTRbxdu3vmfytsy1CtsIUFH0bO85rZ1xdu2uLoioSaEi6iOULDVTQUrnes50jMs+UW355Ndj7Oxg==} hasBin: true /@apollo/cache-control-types@1.0.2(graphql@16.6.0): @@ -8390,7 +8393,7 @@ packages: graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: graphql: 16.6.0 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /@graphql-tools/relay-operation-optimizer@6.5.18(graphql@16.6.0): @@ -8401,7 +8404,7 @@ packages: '@ardatan/relay-compiler': 12.0.0(graphql@16.6.0) '@graphql-tools/utils': 9.2.1(graphql@16.6.0) graphql: 16.6.0 - tslib: 2.6.2 + tslib: 2.4.1 transitivePeerDependencies: - encoding - supports-color @@ -8437,7 +8440,7 @@ packages: graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: graphql: 16.6.0 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /@graphql-tools/utils@8.9.1(graphql@16.6.0): @@ -8626,14 +8629,14 @@ packages: '@jest/test-result': 29.6.4 '@jest/transform': 29.6.4 '@jest/types': 29.6.3 - '@types/node': 18.17.11 + '@types/node': 18.11.14 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.6.3 - jest-config: 29.6.4(@types/node@18.17.11) + jest-config: 29.6.4(@types/node@18.11.14) jest-haste-map: 29.6.4 jest-message-util: 29.6.3 jest-regex-util: 29.6.3 @@ -8661,7 +8664,7 @@ packages: dependencies: '@jest/fake-timers': 29.6.4 '@jest/types': 29.6.3 - '@types/node': 18.17.11 + '@types/node': 18.11.14 jest-mock: 29.6.3 dev: true @@ -8688,7 +8691,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 18.17.11 + '@types/node': 18.11.14 jest-message-util: 29.6.3 jest-mock: 29.6.3 jest-util: 29.6.3 @@ -8831,7 +8834,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.17.11 + '@types/node': 18.11.14 '@types/yargs': 15.0.15 chalk: 4.1.2 dev: true @@ -8843,7 +8846,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.17.11 + '@types/node': 18.11.14 '@types/yargs': 17.0.24 chalk: 4.1.2 dev: true @@ -9323,9 +9326,9 @@ packages: resolution: {integrity: sha512-vSrc8wFQgBErU7dKTKSQtr/DLWPHcN9jMoiWOAQodB1+B4Kpqqry6QhGYoRm0DQU5gNL+Rcp+Xb350O1E/gjsg==} dev: false - /@prisma/client@4.16.2(prisma@4.16.2): - resolution: {integrity: sha512-qCoEyxv1ZrQ4bKy39GnylE8Zq31IRmm8bNhNbZx7bF2cU5aiCCnSa93J2imF88MBjn7J9eUQneNxUQVJdl/rPQ==} - engines: {node: '>=14.17'} + /@prisma/client@5.1.1(prisma@5.1.1): + resolution: {integrity: sha512-fxcCeK5pMQGcgCqCrWsi+I2rpIbk0rAhdrN+ke7f34tIrgPwA68ensrpin+9+fZvuV2OtzHmuipwduSY6HswdA==} + engines: {node: '>=16.13'} requiresBuild: true peerDependencies: prisma: '*' @@ -9333,11 +9336,11 @@ packages: prisma: optional: true dependencies: - '@prisma/engines-version': 4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 - prisma: 4.16.2 + '@prisma/engines-version': 5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e + prisma: 5.1.1 - /@prisma/debug@4.16.2: - resolution: {integrity: sha512-7L7WbG0qNNZYgLpsVB8rCHCXEyHFyIycRlRDNwkVfjQmACC2OW6AWCYCbfdjQhkF/t7+S3njj8wAWAocSs+Brw==} + /@prisma/debug@5.1.1: + resolution: {integrity: sha512-R9e2Tn8f+ujVjwn6ne1YkXY35BXzUmxJbGsmD1c8RAZ/NXgbYktEFAwIkOZn5H5zRfY2VDSBvGI6TFpnOu50cg==} dependencies: '@types/debug': 4.1.8 debug: 4.3.4 @@ -9345,26 +9348,36 @@ packages: transitivePeerDependencies: - supports-color - /@prisma/engines-version@4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81: - resolution: {integrity: sha512-q617EUWfRIDTriWADZ4YiWRZXCa/WuhNgLTVd+HqWLffjMSPzyM5uOWoauX91wvQClSKZU4pzI4JJLQ9Kl62Qg==} + /@prisma/debug@5.2.0: + resolution: {integrity: sha512-dOrNOA8B65l3dCp2r3gn5A5dbMXNbEixO3JAaMWiS2q03qMU3/R9oNv86H2c1i3GSwQglH5gjwpkA9olp/+h1A==} + dependencies: + '@types/debug': 4.1.8 + debug: 4.3.4 + strip-ansi: 6.0.1 + transitivePeerDependencies: + - supports-color + dev: false + + /@prisma/engines-version@5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e: + resolution: {integrity: sha512-owZqbY/wucbr65bXJ/ljrHPgQU5xXTSkmcE/JcbqE1kusuAXV/TLN3/exmz21SZ5rJ7WDkyk70J2G/n68iogbQ==} - /@prisma/engines@4.16.2: - resolution: {integrity: sha512-vx1nxVvN4QeT/cepQce68deh/Turxy5Mr+4L4zClFuK1GlxN3+ivxfuv+ej/gvidWn1cE1uAhW7ALLNlYbRUAw==} + /@prisma/engines@5.1.1: + resolution: {integrity: sha512-NV/4nVNWFZSJCCIA3HIFJbbDKO/NARc9ej0tX5S9k2EVbkrFJC4Xt9b0u4rNZWL4V+F5LAjvta8vzEUw0rw+HA==} requiresBuild: true - /@prisma/fetch-engine@4.16.2: - resolution: {integrity: sha512-lnCnHcOaNn0kw8qTJbVcNhyfIf5Lus2GFXbj3qpkdKEIB9xLgqkkuTP+35q1xFaqwQ0vy4HFpdRUpFP7njE15g==} + /@prisma/fetch-engine@5.1.1: + resolution: {integrity: sha512-75aKd1QAk0ChoKcpq8J3UeFCL6MfE4ETpnrqjS6x/IoscEWDhS4xoLP8+cctROUG46YExwV5ptuBUawVhGi/Jw==} dependencies: - '@prisma/debug': 4.16.2 - '@prisma/get-platform': 4.16.2 + '@prisma/debug': 5.1.1 + '@prisma/get-platform': 5.1.1 execa: 5.1.1 find-cache-dir: 3.3.2 fs-extra: 11.1.1 hasha: 5.2.2 http-proxy-agent: 7.0.0 - https-proxy-agent: 7.0.0 + https-proxy-agent: 7.0.1 kleur: 4.1.5 - node-fetch: 2.6.11 + node-fetch: 2.6.12 p-filter: 2.1.0 p-map: 4.0.0 p-retry: 4.6.2 @@ -9376,20 +9389,31 @@ packages: - encoding - supports-color - /@prisma/generator-helper@4.16.2: - resolution: {integrity: sha512-bMOH7y73Ui7gpQrioFeavMQA+Tf8ksaVf8Nhs9rQNzuSg8SSV6E9baczob0L5KGZTSgYoqnrRxuo03kVJYrnIg==} + /@prisma/generator-helper@5.1.1: + resolution: {integrity: sha512-Qk9iiVk4JZQYZrYsc1Wx9fXFFnS1AH4T7WyLxCIFnX/end0K5tOK75Qxv6mjZAHE0XUGrzoTlZUkbSDVYz/CvQ==} dependencies: - '@prisma/debug': 4.16.2 + '@prisma/debug': 5.1.1 '@types/cross-spawn': 6.0.2 cross-spawn: 7.0.3 kleur: 4.1.5 transitivePeerDependencies: - supports-color - /@prisma/get-platform@4.16.2: - resolution: {integrity: sha512-fnDey1/iSefHJRMB+w243BhWENf+paRouPMdCqIVqu8dYkR1NqhldblsSUC4Zr2sKS7Ta2sK4OLdt9IH+PZTfw==} + /@prisma/generator-helper@5.2.0: + resolution: {integrity: sha512-jju+nGe8IgwDhs412sx6PSk5efkuoBqHOJSqbRBb9Y/fMfeDRGLVdwia8Hj+PKmd/YXrqFgBd4NDeFxeCcVVqw==} dependencies: - '@prisma/debug': 4.16.2 + '@prisma/debug': 5.2.0 + '@types/cross-spawn': 6.0.2 + cross-spawn: 7.0.3 + kleur: 4.1.5 + transitivePeerDependencies: + - supports-color + dev: false + + /@prisma/get-platform@5.1.1: + resolution: {integrity: sha512-AH3rafdGQ0WWZMGCrGXPg49Ebd7G/ZT8HL+WR9cqr+i5/g+95dPpMNZjuPt6doAM6EdbrlFj4M08a0x4Fazm4g==} + dependencies: + '@prisma/debug': 5.1.1 escape-string-regexp: 4.0.0 execa: 5.1.1 fs-jetpack: 5.1.0 @@ -9402,20 +9426,20 @@ packages: transitivePeerDependencies: - supports-color - /@prisma/internals@4.16.2: - resolution: {integrity: sha512-/3OiSADA3RRgsaeEE+MDsBgL6oAMwddSheXn6wtYGUnjERAV/BmF5bMMLnTykesQqwZ1s8HrISrJ0Vf6cjOxMg==} + /@prisma/internals@5.1.1: + resolution: {integrity: sha512-RIai3iR/MbliBZgU4UXtFwAAhhAudmh1UIfxG/9AtZWDQl7x1ENFD8Kf4XW+M/Fh3ZO27aWRgSuNwHBKHEHPtw==} dependencies: - '@antfu/ni': 0.21.4 + '@antfu/ni': 0.21.5 '@opentelemetry/api': 1.4.1 - '@prisma/debug': 4.16.2 - '@prisma/engines': 4.16.2 - '@prisma/fetch-engine': 4.16.2 - '@prisma/generator-helper': 4.16.2 - '@prisma/get-platform': 4.16.2 - '@prisma/prisma-fmt-wasm': 4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 + '@prisma/debug': 5.1.1 + '@prisma/engines': 5.1.1 + '@prisma/fetch-engine': 5.1.1 + '@prisma/generator-helper': 5.1.1 + '@prisma/get-platform': 5.1.1 + '@prisma/prisma-schema-wasm': 5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e archiver: 5.3.1 arg: 5.0.2 - checkpoint-client: 1.1.24 + checkpoint-client: 1.1.27 cli-truncate: 2.1.0 dotenv: 16.0.3 escape-string-regexp: 4.0.0 @@ -9431,7 +9455,7 @@ packages: is-wsl: 2.2.0 kleur: 4.1.5 new-github-issue-url: 0.2.1 - node-fetch: 2.6.11 + node-fetch: 2.6.12 npm-packlist: 5.1.3 open: 7.4.2 p-map: 4.0.0 @@ -9443,7 +9467,6 @@ packages: strip-ansi: 6.0.1 strip-indent: 3.0.0 temp-dir: 2.0.0 - temp-write: 4.0.0 tempy: 1.0.1 terminal-link: 2.1.1 tmp: 0.2.1 @@ -9452,16 +9475,16 @@ packages: - encoding - supports-color - /@prisma/migrate@4.16.2(@prisma/generator-helper@4.16.2)(@prisma/internals@4.16.2): - resolution: {integrity: sha512-Icnmg+qTE7K3SU37s3ik39fheEsRyrO2tBX+iI+SpoJ57ZVPFfkpl0oCda4CdLMPnskxKrD51u4Z2gQVsDC2wQ==} + /@prisma/migrate@5.1.1(@prisma/generator-helper@5.2.0)(@prisma/internals@5.1.1): + resolution: {integrity: sha512-SJUAF6xsY7iVgo6NjjZSwen2yV8J8rj2MGCA+dlWT4grVnBKlkGZZlbZcEq7D3VOdq9yD6tf52m3s5/ImcJ02A==} peerDependencies: '@prisma/generator-helper': '*' '@prisma/internals': '*' dependencies: - '@prisma/debug': 4.16.2 - '@prisma/generator-helper': 4.16.2 - '@prisma/get-platform': 4.16.2 - '@prisma/internals': 4.16.2 + '@prisma/debug': 5.1.1 + '@prisma/generator-helper': 5.2.0 + '@prisma/get-platform': 5.1.1 + '@prisma/internals': 5.1.1 '@sindresorhus/slugify': 1.1.2 arg: 5.0.2 execa: 5.1.1 @@ -9471,8 +9494,8 @@ packages: indent-string: 4.0.0 kleur: 4.1.5 log-update: 4.0.0 - mariadb: 3.1.2 - mongoose: 6.11.2 + mariadb: 3.2.0 + mongoose: 6.11.4 mssql: 9.1.1 ora: 5.4.1 pg: 8.10.0 @@ -9487,8 +9510,8 @@ packages: - supports-color dev: false - /@prisma/prisma-fmt-wasm@4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81: - resolution: {integrity: sha512-g090+dEH7wrdCw359+8J9+TGH84qK28V/dxwINjhhNCtju9lej99z9w/AVsJP9UhhcCPS4psYz4iu8d53uxVpA==} + /@prisma/prisma-schema-wasm@5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e: + resolution: {integrity: sha512-d1E8kp7DwfWG6R5Fy+06Jin/AJEHIXvROMGPvJ3SBoUUOv+w3n4EyFD6ouy2/U16CbPQkZtPlhsaJvEuaR9fkg==} /@protobufjs/aspromise@1.1.2: resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} @@ -10173,7 +10196,6 @@ packages: /@smithy/types@2.2.2: resolution: {integrity: sha512-4PS0y1VxDnELGHGgBWlDksB2LJK8TG8lcvlWxIsgR+8vROI7Ms8h1P4FQUx+ftAX2QZv5g1CJCdhdRmQKyonyw==} engines: {node: '>=14.0.0'} - requiresBuild: true dependencies: tslib: 2.6.2 dev: false @@ -10858,7 +10880,7 @@ packages: /@types/jsdom@20.0.1: resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} dependencies: - '@types/node': 18.17.11 + '@types/node': 18.11.14 '@types/tough-cookie': 4.0.2 parse5: 7.1.2 dev: true @@ -11048,7 +11070,7 @@ packages: /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 18.17.11 + '@types/node': 18.11.14 dev: true /@types/resolve@1.20.2: @@ -12705,7 +12727,7 @@ packages: resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==} dependencies: pascal-case: 3.1.2 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /camelcase-keys@6.2.2: @@ -12740,7 +12762,7 @@ packages: resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} dependencies: no-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 upper-case-first: 2.0.2 dev: false @@ -12831,7 +12853,7 @@ packages: path-case: 3.0.4 sentence-case: 3.0.4 snake-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /char-regex@1.0.2: @@ -12873,15 +12895,14 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /checkpoint-client@1.1.24: - resolution: {integrity: sha512-nIOlLhDS7MKs4tUzS3LCm+sE1NgTCVnVrXlD0RRxaoEkkLu8LIWSUNiNWai6a+LK5unLzTyZeTCYX1Smqy0YoA==} + /checkpoint-client@1.1.27: + resolution: {integrity: sha512-xstymfUalJOv6ZvTtmkwP4ORJN36ikT4PvrIoLe3wstbYf87XIXCcZrSmbFQOjyB0v1qbBnCsAscDpfdZlCkFA==} dependencies: ci-info: 3.8.0 env-paths: 2.2.1 - fast-write-atomic: 0.2.1 - make-dir: 3.1.0 + make-dir: 4.0.0 ms: 2.1.3 - node-fetch: 2.6.11 + node-fetch: 2.6.12 uuid: 9.0.0 transitivePeerDependencies: - encoding @@ -13194,7 +13215,7 @@ packages: resolution: {integrity: sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==} dependencies: no-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 upper-case: 2.0.2 dev: false @@ -15171,9 +15192,6 @@ packages: resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} dev: true - /fast-write-atomic@0.2.1: - resolution: {integrity: sha512-WvJe06IfNYlr+6cO3uQkdKdy3Cb1LlCJSF8zRs2eT8yuhdbSlR9nIt+TgQ92RUxiRrQm+/S7RARnMfCs5iuAjw==} - /fast-xml-parser@3.19.0: resolution: {integrity: sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg==} hasBin: true @@ -16165,7 +16183,7 @@ packages: resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==} dependencies: capital-case: 1.0.4 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /hoist-non-react-statics@3.3.2: @@ -16294,8 +16312,8 @@ packages: transitivePeerDependencies: - supports-color - /https-proxy-agent@7.0.0: - resolution: {integrity: sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw==} + /https-proxy-agent@7.0.1: + resolution: {integrity: sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 @@ -16785,7 +16803,7 @@ packages: /is-lower-case@2.0.2: resolution: {integrity: sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /is-map@2.0.2: @@ -16960,7 +16978,7 @@ packages: /is-upper-case@2.0.2: resolution: {integrity: sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /is-weakmap@2.0.1: @@ -17192,46 +17210,6 @@ packages: - supports-color dev: true - /jest-config@29.6.4(@types/node@18.17.11): - resolution: {integrity: sha512-JWohr3i9m2cVpBumQFv2akMEnFEPVOh+9L2xIBJhJ0zOaci2ZXuKJj0tgMKQCBZAKA09H049IR4HVS/43Qb19A==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true - dependencies: - '@babel/core': 7.21.0 - '@jest/test-sequencer': 29.6.4 - '@jest/types': 29.6.3 - '@types/node': 18.17.11 - babel-jest: 29.6.4(@babel/core@7.21.0) - chalk: 4.1.2 - ci-info: 3.8.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.6.4 - jest-environment-node: 29.6.4 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.6.4 - jest-runner: 29.6.4 - jest-util: 29.6.3 - jest-validate: 29.6.3 - micromatch: 4.0.5 - parse-json: 5.2.0 - pretty-format: 29.6.3 - slash: 3.0.0 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - dev: true - /jest-diff@29.0.0: resolution: {integrity: sha512-erkuYf1dQBHow3XJmS+bH6t9TZ0GwrSdQGauN8sTqyZlFByOjRadmHgTTcAHINeeSwxzGHN2ob3PXVvZphD7XQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -17386,7 +17364,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.17.11 + '@types/node': 18.11.14 jest-util: 29.6.3 dev: true @@ -17549,7 +17527,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.17.11 + '@types/node': 18.11.14 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -17586,7 +17564,7 @@ packages: resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.17.11 + '@types/node': 18.11.14 merge-stream: 2.0.0 supports-color: 7.2.0 dev: true @@ -18076,13 +18054,13 @@ packages: /lower-case-first@2.0.2: resolution: {integrity: sha512-EVm/rR94FJTZi3zefZ82fLWab+GX14LJN4HrWBcuo6Evmsl9hEfnqxgcHCKb9q+mNf6EVdsjx/qucYFIIB84pg==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /lower-case@2.0.2: resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 /lowercase-keys@1.0.1: resolution: {integrity: sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==} @@ -18152,7 +18130,6 @@ packages: engines: {node: '>=10'} dependencies: semver: 7.5.4 - dev: true /makeerror@1.0.12: resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} @@ -18183,8 +18160,8 @@ packages: object-visit: 1.0.1 dev: true - /mariadb@3.1.2: - resolution: {integrity: sha512-ILlC54fkXkvizTJZC1uP7f/REBxuu1k+OWzpiIITIEdS+dGIjFe/Ob3EW9KrdtBa38l3z+odz6elva0RG/y5og==} + /mariadb@3.2.0: + resolution: {integrity: sha512-IH2nidQat1IBMxP5gjuNxG6dADtz1PESEC6rKrcATen5v3ngFyZITjehyYiwNfz3zUNQupfYmVntz93M+Pz8pQ==} engines: {node: '>= 12'} dependencies: '@types/geojson': 7946.0.10 @@ -19120,8 +19097,8 @@ packages: - aws-crt dev: false - /mongoose@6.11.2: - resolution: {integrity: sha512-BJHQerozE+qIVdH8Hn9niMVMUzRNcjmwU7hFEzER1+aYtGmVJgGsXBd9wJ9GnrHrbCsYmKlRy8aTuxEdlEtfow==} + /mongoose@6.11.4: + resolution: {integrity: sha512-q9NaW9/BBYZofx80SqlR7uoSR09CS3g02y+KMj1lNLUxcFFsPshupY3WWisNFauYG9gyuDF4L/RgyIK3obSghg==} engines: {node: '>=12.0.0'} dependencies: bson: 4.7.2 @@ -19419,8 +19396,8 @@ packages: engines: {node: '>=10.5.0'} dev: false - /node-fetch@2.6.11: - resolution: {integrity: sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==} + /node-fetch@2.6.12: + resolution: {integrity: sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==} engines: {node: 4.x || >=6.0.0} peerDependencies: encoding: ^0.1.0 @@ -19939,7 +19916,7 @@ packages: resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==} dependencies: dot-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /parent-module@1.0.1: @@ -20037,7 +20014,7 @@ packages: resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} dependencies: no-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /pascalcase@0.1.1: @@ -20049,7 +20026,7 @@ packages: resolution: {integrity: sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==} dependencies: dot-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 dev: false /path-exists@3.0.0: @@ -20530,13 +20507,13 @@ packages: react: 18.2.0 dev: false - /prisma@4.16.2: - resolution: {integrity: sha512-SYCsBvDf0/7XSJyf2cHTLjLeTLVXYfqp7pG5eEVafFLeT0u/hLFz/9W196nDRGUOo1JfPatAEb+uEnTQImQC1g==} - engines: {node: '>=14.17'} + /prisma@5.1.1: + resolution: {integrity: sha512-WJFG/U7sMmcc6TjJTTifTfpI6Wjoh55xl4AzopVwAdyK68L9/ogNo8QQ2cxuUjJf/Wa82z/uhyh3wMzvRIBphg==} + engines: {node: '>=16.13'} hasBin: true requiresBuild: true dependencies: - '@prisma/engines': 4.16.2 + '@prisma/engines': 5.1.1 /prismjs@1.29.0: resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==} @@ -21716,7 +21693,7 @@ packages: resolution: {integrity: sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==} dependencies: no-case: 3.0.4 - tslib: 2.6.2 + tslib: 2.4.1 upper-case-first: 2.0.2 dev: false @@ -22124,7 +22101,7 @@ packages: /sponge-case@1.0.1: resolution: {integrity: sha512-dblb9Et4DAtiZ5YSUZHLl4XhH4uK80GhAZrVXdN4O2P4gQ40Wa5UIOPUHlA/nFd2PLblBZWUioLMMAVrgpoYcA==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /sprintf-js@1.0.3: @@ -22523,7 +22500,7 @@ packages: /swap-case@2.0.2: resolution: {integrity: sha512-kc6S2YS/2yXbtkSMunBtKdah4VFETZ8Oh6ONSmSd9bRxhqTrtARUCBUiWXH3xVPpvR7tz2CSnkuXVE42EcGnMw==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /symbol-observable@4.0.0: @@ -22602,24 +22579,10 @@ packages: - supports-color dev: false - /temp-dir@1.0.0: - resolution: {integrity: sha512-xZFXEGbG7SNC3itwBzI3RYjq/cEhBkx2hJuKGIUOcEULmkQExXiHat2z/qkISYsuR+IKumhEfKKbV5qXmhICFQ==} - engines: {node: '>=4'} - /temp-dir@2.0.0: resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} engines: {node: '>=8'} - /temp-write@4.0.0: - resolution: {integrity: sha512-HIeWmj77uOOHb0QX7siN3OtwV3CTntquin6TNVg6SHOqCP3hYKmox90eeFOGaY1MqJ9WYDDjkyZrW6qS5AWpbw==} - engines: {node: '>=8'} - dependencies: - graceful-fs: 4.2.11 - is-stream: 2.0.1 - make-dir: 3.1.0 - temp-dir: 1.0.0 - uuid: 3.4.0 - /tempy@1.0.1: resolution: {integrity: sha512-biM9brNqxSc04Ee71hzFbryD11nX7VPhQQY32AdDmjFvodsRFz/3ufeoTZ6uYkRFfGo188tENcASNs3vTdsM0w==} engines: {node: '>=10'} @@ -22710,7 +22673,7 @@ packages: /title-case@3.0.3: resolution: {integrity: sha512-e1zGYRvbffpcHIrnuqT0Dh+gEJtDaxDSoG4JAIpq4oDFyooziLBIiYQv0GBT4FUAnUop5uZ1hiIAj7oAF6sOCA==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /titleize@3.0.0: @@ -22916,7 +22879,6 @@ packages: /tslib@2.4.1: resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} - dev: false /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} @@ -23288,13 +23250,13 @@ packages: /upper-case-first@2.0.2: resolution: {integrity: sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /upper-case@2.0.2: resolution: {integrity: sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==} dependencies: - tslib: 2.6.2 + tslib: 2.4.1 dev: false /uri-js@4.4.1: @@ -23381,11 +23343,6 @@ packages: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} - /uuid@3.4.0: - resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} - deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. - hasBin: true - /uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true diff --git a/prisma-utils/package.json b/prisma-utils/package.json index e681dda508a..747b7996d9a 100644 --- a/prisma-utils/package.json +++ b/prisma-utils/package.json @@ -3,8 +3,8 @@ "version": "0.0.2", "private": true, "dependencies": { - "@prisma/generator-helper": "^4.16.2", - "@prisma/internals": "^4.16.2", + "@prisma/generator-helper": "^5.0.0", + "@prisma/internals": "^5.0.0", "fs-extra": "^11.0.0", "tsx": "^3.9.0", "prettier": "^2.5.0" diff --git a/tests/api-tests/access-control/utils.ts b/tests/api-tests/access-control/utils.ts index 6f7035047e5..45883b2450c 100644 --- a/tests/api-tests/access-control/utils.ts +++ b/tests/api-tests/access-control/utils.ts @@ -1,6 +1,6 @@ import { text, password } from '@keystone-6/core/fields'; import { list, ListSchemaConfig } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { allowAll } from '@keystone-6/core/access'; import { testConfig } from '../utils'; @@ -174,13 +174,12 @@ const auth = createAuth({ listKey: 'User', identityField: 'email', secretField: 'password', - sessionData: 'id', + sessionStrategy: statelessSessions({ secret: COOKIE_SECRET }), }); const config = auth.withAuth( testConfig({ lists, - session: statelessSessions({ secret: COOKIE_SECRET }), }) ); diff --git a/tests/api-tests/auth-header.test.ts b/tests/api-tests/auth-header.test.ts index 0cbdbe1092a..9207d70336c 100644 --- a/tests/api-tests/auth-header.test.ts +++ b/tests/api-tests/auth-header.test.ts @@ -1,6 +1,6 @@ import { text, timestamp, password } from '@keystone-6/core/fields'; import { list } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import type { KeystoneContext } from '@keystone-6/core/types'; import { setupTestRunner, setupTestEnv } from '@keystone-6/api-tests/test-runner'; @@ -23,7 +23,7 @@ function setup(options?: any) { listKey: 'User', identityField: 'email', secretField: 'password', - sessionData: 'id', + sessionStrategy: statelessSessions({ secret: COOKIE_SECRET }), ...options, }); @@ -48,7 +48,6 @@ function setup(options?: any) { }, }), }, - session: statelessSessions({ secret: COOKIE_SECRET }), }) ), }) @@ -103,7 +102,7 @@ describe('Auth testing', () => { listKey: 'User', identityField: 'email', secretField: 'password', - sessionData: 'id', + sessionStrategy: statelessSessions({ secret: COOKIE_SECRET }), }); await expect( setupTestEnv({ @@ -119,8 +118,6 @@ describe('Auth testing', () => { }, }), }, - - session: statelessSessions({ secret: COOKIE_SECRET }), }) ), }) diff --git a/tests/api-tests/auth.test.ts b/tests/api-tests/auth.test.ts index bd0aedbc4b9..29b01589f17 100644 --- a/tests/api-tests/auth.test.ts +++ b/tests/api-tests/auth.test.ts @@ -1,6 +1,6 @@ import { text, password } from '@keystone-6/core/fields'; import { list } from '@keystone-6/core'; -import { statelessSessions } from '@keystone-6/core/session'; +import { statelessSessions } from '@keystone-6/auth/session'; import { createAuth } from '@keystone-6/auth'; import { setupTestRunner } from '@keystone-6/api-tests/test-runner'; import { allowAll } from '@keystone-6/core/access'; @@ -23,7 +23,6 @@ const auth = createAuth({ listKey: 'User', identityField: 'email', secretField: 'password', - sessionData: 'id name', initFirstItem: { fields: ['email', 'password'], itemData: { name: 'First User' } }, magicAuthLink: { sendToken: async ({ identity, token }) => { @@ -43,6 +42,7 @@ const auth = createAuth({ }, tokensValidForMins: 60, }, + sessionStrategy: statelessSessions({ secret: COOKIE_SECRET, data: 'id name' }), }); const runner = withServer( @@ -59,7 +59,6 @@ const runner = withServer( }, }), }, - session: statelessSessions({ secret: COOKIE_SECRET }), }) ), }) diff --git a/tests/api-tests/hooks/hook-errors.test.ts b/tests/api-tests/hooks/hook-errors.test.ts index 5d9242f900c..e0025e4a152 100644 --- a/tests/api-tests/hooks/hook-errors.test.ts +++ b/tests/api-tests/hooks/hook-errors.test.ts @@ -619,7 +619,7 @@ test( code: 'KS_PRISMA_ERROR', debug: { message: expect.stringMatching( - /Unknown arg `blah` in data\.badResolveInput\.blah for type PostCreateNestedOneWithoutFrom_BadResolveInput_badResolveInputInput\./ + /Unknown argument `blah`. Available options are listed in green./ ), }, }, diff --git a/tests/api-tests/package.json b/tests/api-tests/package.json index 6793fc47393..447f053b8be 100644 --- a/tests/api-tests/package.json +++ b/tests/api-tests/package.json @@ -14,8 +14,8 @@ "@keystone-6/auth": "*", "@keystone-6/core": "*", "@keystone-6/fields-document": "*", - "@prisma/client": "^4.16.2", - "@prisma/internals": "^4.16.2", + "@prisma/client": "^5.0.0", + "@prisma/internals": "^5.0.0", "@types/express": "^4.17.14", "cookie-signature": "^1.1.0", "fs-extra": "^11.0.0", @@ -24,7 +24,7 @@ "graphql-upload": "^15.0.2", "mime": "^3.0.0", "node-fetch": "^2.6.7", - "prisma": "^4.16.2", + "prisma": "^5.0.0", "supertest": "^6.1.6", "testcheck": "^1.0.0-rc.2", "uuid": "^9.0.0" diff --git a/tests/api-tests/test-runner.ts b/tests/api-tests/test-runner.ts index 92d98b11f40..8e3f728f23b 100644 --- a/tests/api-tests/test-runner.ts +++ b/tests/api-tests/test-runner.ts @@ -40,6 +40,28 @@ const generatedPrismaModules = new Map(); // a modified version of https://github.com/prisma/prisma/blob/bbdf1c23653a77b0b5bf7d62efd243dcebea018b/packages/client/src/utils/getTestClient.ts // yes, it's totally relying on implementation details // we're okay with that because otherwise the performance of our tests is very bad +// TODO: we should find a better way to do this +function buildMapForRuntime( + list: T[] +): Record> { + const result: Record> = {}; + for (const { name, ...rest } of list) { + result[name] = rest; + } + return result; +} + +async function schemaToRuntimeDataModel(schema: string): Promise { + const { datamodel } = externalToInternalDmmf( + await getDMMF({ datamodel: schema, previewFeatures: [] }) + ); + return { + models: buildMapForRuntime(datamodel.models), + enums: buildMapForRuntime(datamodel.enums), + types: buildMapForRuntime(datamodel.types), + }; +} + const tmpdir = os.tmpdir(); const prismaSchemaDirectory = path.join(tmpdir, Math.random().toString(36).slice(2)); @@ -67,12 +89,9 @@ async function getTestPrismaModule(schema: string): Promise { const generator = config.generators.find(g => parseEnvValue(g.provider) === 'prisma-client-js'); - const document = externalToInternalDmmf( - await getDMMF({ datamodel: schema, previewFeatures: [] }) - ); const activeProvider = config.datasources[0].activeProvider; const options: Parameters[0] = { - document, + runtimeDataModel: await schemaToRuntimeDataModel(schema), generator, dirname: prismaSchemaDirectory, relativePath: '', diff --git a/tests/cli-tests/artifacts.test.ts b/tests/cli-tests/artifacts.test.ts index 7c4f92af97d..019552d1ec6 100644 --- a/tests/cli-tests/artifacts.test.ts +++ b/tests/cli-tests/artifacts.test.ts @@ -9,22 +9,38 @@ import { testdir, } from './utils'; -describe.each(['postinstall', ['build', '--frozen'], ['prisma', 'migrate', 'status']])( - '%s', - command => { - test('logs an error and exits with 1 when the schemas do not exist', async () => { - const tmp = await testdir({ - ...symlinkKeystoneDeps, - 'keystone.js': basicKeystoneConfig, - }); - const recording = recordConsole(); - await expect(runCommand(tmp, command)).rejects.toEqual(new ExitError(1)); - expect(recording()).toMatchInlineSnapshot( - `"Your Prisma and GraphQL schemas are not up to date"` - ); +describe.each(['postinstall', ['build', '--frozen']])('%s', command => { + test('logs an error and exits with 1 when the schemas do not exist', async () => { + const tmp = await testdir({ + ...symlinkKeystoneDeps, + 'keystone.js': basicKeystoneConfig, + }); + const recording = recordConsole(); + await expect(runCommand(tmp, command)).rejects.toEqual(new ExitError(1)); + expect(recording()).toMatchInlineSnapshot( + `"Your Prisma and GraphQL schemas are not up to date"` + ); + }); +}); + +describe('prisma migrate status', () => { + test('logs an error and exits with 1 when the schemas do not exist', async () => { + const tmp = await testdir({ + ...symlinkKeystoneDeps, + 'keystone.js': basicKeystoneConfig, }); - } -); + await expect(runCommand(tmp, ['build', '--no-ui', '--frozen'])).rejects.toEqual( + new ExitError(1) + ); + const recording = recordConsole(); + await expect(runCommand(tmp, ['prisma', '--frozen', 'migrate', 'status'])).rejects.toEqual( + new ExitError(1) + ); + expect(recording()).toMatchInlineSnapshot( + `"Your Prisma and GraphQL schemas are not up to date"` + ); + }); +}); const schemasMatch = ['schema.prisma', 'schema.graphql']; diff --git a/tests/cli-tests/migrations.test.ts b/tests/cli-tests/migrations.test.ts index 6609a6ec96a..b58e1952bf7 100644 --- a/tests/cli-tests/migrations.test.ts +++ b/tests/cli-tests/migrations.test.ts @@ -248,7 +248,8 @@ describe('useMigrations: false', () => { } expect(recording()).toMatchInlineSnapshot(` - "? Starting Keystone + "? Generated GraphQL and Prisma schemas + ? Starting Keystone ? Server listening on :3000 (http://localhost:3000/) ? GraphQL API available at /api/graphql ? Generating GraphQL and Prisma schemas diff --git a/tests/cli-tests/package.json b/tests/cli-tests/package.json index 304b7382a87..40d077e172c 100644 --- a/tests/cli-tests/package.json +++ b/tests/cli-tests/package.json @@ -13,15 +13,15 @@ "@keystone-6/auth": "*", "@keystone-6/core": "*", "@keystone-6/fields-document": "*", - "@prisma/client": "^4.16.2", - "@prisma/internals": "^4.16.2", + "@prisma/client": "^5.0.0", + "@prisma/internals": "^5.0.0", "chalk": "^4.1.2", "execa": "^5.1.1", "fast-glob": "^3.2.12", "fs-extra": "^11.0.0", "mime": "^3.0.0", "node-fetch": "^2.6.7", - "prisma": "^4.16.2" + "prisma": "^5.0.0" }, "dependencies": { "@types/fs-extra": "^11.0.0", diff --git a/tests/cli-tests/prisma.test.ts b/tests/cli-tests/prisma.test.ts index 564d3cd74e6..52c9612efe8 100644 --- a/tests/cli-tests/prisma.test.ts +++ b/tests/cli-tests/prisma.test.ts @@ -15,7 +15,8 @@ test('keystone prisma exits with the same code as the prisma child process exits cwd: tmp, }); expect(result.all!.replace(/[^ -~\n]/g, '?')).toMatchInlineSnapshot(` - " + "? Generated GraphQL and Prisma schemas + ! Unknown command "bad-thing" ? Prisma is a modern DB toolkit to query, migrate and model your database (https://prisma.io) @@ -79,8 +80,9 @@ test('keystone prisma uses the db url in the keystone config', async () => { all: true, cwd: tmp, }); - expect(result.all).toMatchInlineSnapshot(` - "Prisma schema loaded from schema.prisma + expect(result.all!.replace(/[^ -~\n]/g, '?')).toMatchInlineSnapshot(` + "? Generated GraphQL and Prisma schemas + Prisma schema loaded from schema.prisma Datasource "sqlite": SQLite database "app.db" at "file:./app.db" Error: P1003: Database app.db does not exist at ./app.db" `); diff --git a/tests/cli-tests/utils.ts b/tests/cli-tests/utils.ts index fd02c1e83e7..151ba90e90f 100644 --- a/tests/cli-tests/utils.ts +++ b/tests/cli-tests/utils.ts @@ -8,7 +8,7 @@ import fastGlob from 'fast-glob'; import chalk from 'chalk'; // @ts-ignore -import { MigrateEngine } from '@prisma/migrate'; +import { SchemaEngine } from '@prisma/migrate'; import { uriToCredentials } from '@prisma/internals'; import type { KeystoneConfig } from '@keystone-6/core/types'; import { cli } from '@keystone-6/core/scripts/cli'; @@ -172,7 +172,7 @@ export async function getFiles( } export async function introspectDb(cwd: string, url: string) { - const engine = new MigrateEngine({ projectDir: cwd }); + const engine = new SchemaEngine({ projectDir: cwd }); try { const { datamodel } = await engine.introspect({ schema: `datasource db { diff --git a/tests/sandbox/package.json b/tests/sandbox/package.json index 1190f32b8c4..673ab945106 100644 --- a/tests/sandbox/package.json +++ b/tests/sandbox/package.json @@ -17,12 +17,12 @@ "@keystone-ui/fields": "^7.2.0", "@keystone-ui/icons": "^6.0.1", "@keystone-ui/tooltip": "^6.0.1", - "@prisma/client": "^4.16.2", + "@prisma/client": "^5.0.0", "react": "^18.2.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/tests/sandbox", "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" } } diff --git a/tests/test-projects/basic/package.json b/tests/test-projects/basic/package.json index bf00cf4ed0f..bd65fe7d74e 100644 --- a/tests/test-projects/basic/package.json +++ b/tests/test-projects/basic/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/tests/test-projects/basic" diff --git a/tests/test-projects/crud-notifications/package.json b/tests/test-projects/crud-notifications/package.json index 41eedb95047..9f0f3556abe 100644 --- a/tests/test-projects/crud-notifications/package.json +++ b/tests/test-projects/crud-notifications/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/tests/test-projects/crud-notifications" diff --git a/tests/test-projects/live-reloading/package.json b/tests/test-projects/live-reloading/package.json index e0228035181..499f4fe1de4 100644 --- a/tests/test-projects/live-reloading/package.json +++ b/tests/test-projects/live-reloading/package.json @@ -11,10 +11,10 @@ }, "dependencies": { "@keystone-6/core": "^5.0.0", - "@prisma/client": "^4.16.2" + "@prisma/client": "^5.0.0" }, "devDependencies": { - "prisma": "^4.16.2", + "prisma": "^5.0.0", "typescript": "~5.0.0" }, "repository": "https://github.com/keystonejs/keystone/tree/main/tests/test-projects/live-reloading"