Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal rename lists to models #7845

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/great-nouns-fall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Changes list configuration naming from `lists` to `models`, as part of adding support for Singletons
4 changes: 2 additions & 2 deletions examples/assets-local/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
storage: {
my_images: {
kind: 'local',
Expand Down
2 changes: 1 addition & 1 deletion examples/assets-local/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { list } from '@keystone-6/core';
import { select, relationship, text, timestamp, image, file } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Post: list({
fields: {
title: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/assets-s3/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { config } from '@keystone-6/core';
import dotenv from 'dotenv';
import { lists } from './schema';
import { models } from './schema';

dotenv.config();

Expand All @@ -16,7 +16,7 @@ export default config({
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
storage: {
my_images: {
kind: 's3',
Expand Down
2 changes: 1 addition & 1 deletion examples/assets-s3/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { list } from '@keystone-6/core';
import { select, relationship, text, timestamp, image, file } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Post: list({
fields: {
title: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/auth/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import { createAuth } from '@keystone-6/auth';
import { lists } from './schema';
import { models } from './schema';

/**
* TODO: Implement validateItem. Would be invoked by the getItem() method in
Expand Down Expand Up @@ -63,7 +63,7 @@ export default withAuth(
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
ui: {},
session:
// Stateless sessions will store the listKey and itemId of the signed-in user in a cookie
Expand Down
2 changes: 1 addition & 1 deletion examples/auth/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { list } from '@keystone-6/core';
import { text, checkbox, password } from '@keystone-6/core/fields';

export const lists = {
export const models = {
User: list({
access: {
operation: {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import { createAuth } from '@keystone-6/auth';

import { lists, extendGraphqlSchema } from './schema';
import { models, extendGraphqlSchema } from './schema';

let sessionSecret = '-- DEV COOKIE SECRET; CHANGE ME --';
let sessionMaxAge = 60 * 60 * 24 * 30; // 30 days
Expand Down Expand Up @@ -54,7 +54,7 @@ export default auth.withAuth(
},
},
},
lists,
models,
extendGraphqlSchema,
session: statelessSessions({ maxAge: sessionMaxAge, secret: sessionSecret }),
// TODO -- Create a separate example for stored/redis sessions
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@keystone-6/core/fields';
import { document } from '@keystone-6/fields-document';
import { v4 } from 'uuid';
import { Context, Lists } from '.keystone/types';
import { Context, Models } from '.keystone/types';

type AccessArgs = {
session?: {
Expand All @@ -32,7 +32,7 @@ export const access = {

const randomNumber = () => Math.round(Math.random() * 10);

const User: Lists.User = list({
const User: Models.User = list({
ui: {
listView: {
initialColumns: ['name', 'posts', 'avatar'],
Expand Down Expand Up @@ -91,7 +91,7 @@ const User: Lists.User = list({
},
});

export const lists: Lists = {
export const models: Models = {
User,
PhoneNumber: list({
ui: {
Expand Down
4 changes: 2 additions & 2 deletions examples/blog/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';
import { insertSeedData } from './seed-data';
import { Context } from '.keystone/types';

Expand All @@ -13,5 +13,5 @@ export default config({
}
},
},
lists,
models,
});
2 changes: 1 addition & 1 deletion examples/blog/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { list } from '@keystone-6/core';
import { select, relationship, text, timestamp } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Post: list({
fields: {
title: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-logo/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
ui: {},
});
2 changes: 1 addition & 1 deletion examples/custom-admin-ui-logo/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { list } from '@keystone-6/core';
import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-navigation/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
});
2 changes: 1 addition & 1 deletion examples/custom-admin-ui-navigation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { list } from '@keystone-6/core';
import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-admin-ui-pages/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
});
2 changes: 1 addition & 1 deletion examples/custom-admin-ui-pages/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { list } from '@keystone-6/core';
import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-field-view/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
});
2 changes: 1 addition & 1 deletion examples/custom-field-view/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { list } from '@keystone-6/core';
import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields';
import { json, select } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-field/1-text-field/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
BaseListTypeInfo,
BaseModelTypeInfo,
fieldType,
FieldTypeFunc,
CommonFieldConfig,
Expand All @@ -8,15 +8,15 @@ import {
} from '@keystone-6/core/types';
import { graphql } from '@keystone-6/core';

export type TextFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
CommonFieldConfig<ListTypeInfo> & {
export type TextFieldConfig<ModelTypeInfo extends BaseModelTypeInfo> =
CommonFieldConfig<ModelTypeInfo> & {
isIndexed?: boolean | 'unique';
};

export function text<ListTypeInfo extends BaseListTypeInfo>({
export function text<ModelTypeInfo extends BaseModelTypeInfo>({
isIndexed,
...config
}: TextFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
}: TextFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> {
return meta =>
fieldType({
kind: 'scalar',
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-field/2-stars-field/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
BaseListTypeInfo,
BaseModelTypeInfo,
fieldType,
FieldTypeFunc,
CommonFieldConfig,
Expand All @@ -13,18 +13,18 @@ import { graphql } from '@keystone-6/core';
// and a different input in the Admin UI
// https://github.com/keystonejs/keystone/tree/main/packages/core/src/fields/types/integer

export type StarsFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
CommonFieldConfig<ListTypeInfo> & {
export type StarsFieldConfig<ModelTypeInfo extends BaseModelTypeInfo> =
CommonFieldConfig<ModelTypeInfo> & {
isIndexed?: boolean | 'unique';
maxStars?: number;
};

export const stars =
<ListTypeInfo extends BaseListTypeInfo>({
<ModelTypeInfo extends BaseModelTypeInfo>({
isIndexed,
maxStars = 5,
...config
}: StarsFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> =>
}: StarsFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> =>
meta =>
fieldType({
// this configures what data is stored in the database
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-field/3-pair-field/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
BaseListTypeInfo,
BaseModelTypeInfo,
fieldType,
FieldTypeFunc,
CommonFieldConfig,
} from '@keystone-6/core/types';
import { graphql } from '@keystone-6/core';

export type PairFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
CommonFieldConfig<ListTypeInfo> & {
export type PairFieldConfig<ModelTypeInfo extends BaseModelTypeInfo> =
CommonFieldConfig<ModelTypeInfo> & {
isIndexed?: boolean | 'unique';
};

export function pair<ListTypeInfo extends BaseListTypeInfo>({
export function pair<ModelTypeInfo extends BaseModelTypeInfo>({
isIndexed,
...config
}: PairFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
}: PairFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> {
function resolveInput(value: string | null | undefined) {
if (!value) return { left: value, right: value };
const [left = '', right = ''] = value.split(' ', 2);
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-field/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
});
4 changes: 2 additions & 2 deletions examples/custom-field/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { text } from './1-text-field';
import { stars } from './2-stars-field';
import { pair } from './3-pair-field';

import { Lists } from '.keystone/types';
import { Models } from '.keystone/types';

export const lists: Lists = {
export const models: Models = {
Post: list({
fields: {
content: text({
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-session-validation/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SessionStrategy } from '@keystone-6/core/src/types/session';
import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import { createAuth } from '@keystone-6/auth';
import { lists } from './schema';
import { models } from './schema';

// createAuth configures signin functionality based on the config below. Note this only implements
// authentication, i.e signing in as an item using identity and secret fields in a list. Session
Expand Down Expand Up @@ -93,7 +93,7 @@ export default myAuth(
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
// We add our session configuration to the system here.
session,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-session-validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { list } from '@keystone-6/core';
import { checkbox, password, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';

export const lists = {
export const models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
4 changes: 2 additions & 2 deletions examples/default-values/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config } from '@keystone-6/core';
import { lists } from './schema';
import { models } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
models,
});
4 changes: 2 additions & 2 deletions examples/default-values/schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { list } from '@keystone-6/core';
import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';
import { Lists } from '.keystone/types';
import { Models } from '.keystone/types';

export const lists: Lists = {
export const models: Models = {
Task: list({
fields: {
label: text({ validation: { isRequired: true } }),
Expand Down
Loading