Skip to content

Commit

Permalink
Revert "Minimal rename lists to models (#7845)" (#7864)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
  • Loading branch information
dcousens and dcousens committed Aug 30, 2022
1 parent 4980a56 commit ed736e3
Show file tree
Hide file tree
Showing 174 changed files with 428 additions and 434 deletions.
5 changes: 0 additions & 5 deletions .changeset/great-nouns-fall.md

This file was deleted.

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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

dotenv.config();

Expand All @@ -16,7 +16,7 @@ export default config({
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } 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',
},
models,
lists,
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 models = {
export const lists = {
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 { models, extendGraphqlSchema } from './schema';
import { lists, 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(
},
},
},
models,
lists,
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, Models } from '.keystone/types';
import { Context, Lists } from '.keystone/types';

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

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

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

export const models: Models = {
export const lists: Lists = {
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 { models } from './schema';
import { lists } from './schema';
import { insertSeedData } from './seed-data';
import { Context } from '.keystone/types';

Expand All @@ -13,5 +13,5 @@ export default config({
}
},
},
models,
lists,
});
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
});
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
});
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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
});
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 models = {
export const lists = {
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 {
BaseModelTypeInfo,
BaseListTypeInfo,
fieldType,
FieldTypeFunc,
CommonFieldConfig,
Expand All @@ -8,15 +8,15 @@ import {
} from '@keystone-6/core/types';
import { graphql } from '@keystone-6/core';

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

export function text<ModelTypeInfo extends BaseModelTypeInfo>({
export function text<ListTypeInfo extends BaseListTypeInfo>({
isIndexed,
...config
}: TextFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> {
}: TextFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
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 {
BaseModelTypeInfo,
BaseListTypeInfo,
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<ModelTypeInfo extends BaseModelTypeInfo> =
CommonFieldConfig<ModelTypeInfo> & {
export type StarsFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
CommonFieldConfig<ListTypeInfo> & {
isIndexed?: boolean | 'unique';
maxStars?: number;
};

export const stars =
<ModelTypeInfo extends BaseModelTypeInfo>({
<ListTypeInfo extends BaseListTypeInfo>({
isIndexed,
maxStars = 5,
...config
}: StarsFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> =>
}: StarsFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> =>
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 {
BaseModelTypeInfo,
BaseListTypeInfo,
fieldType,
FieldTypeFunc,
CommonFieldConfig,
} from '@keystone-6/core/types';
import { graphql } from '@keystone-6/core';

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

export function pair<ModelTypeInfo extends BaseModelTypeInfo>({
export function pair<ListTypeInfo extends BaseListTypeInfo>({
isIndexed,
...config
}: PairFieldConfig<ModelTypeInfo> = {}): FieldTypeFunc<ModelTypeInfo> {
}: PairFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
});
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 { Models } from '.keystone/types';
import { Lists } from '.keystone/types';

export const models: Models = {
export const lists: Lists = {
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 { models } from './schema';
import { lists } 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',
},
models,
lists,
// 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 models = {
export const lists = {
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 { models } from './schema';
import { lists } from './schema';

export default config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
models,
lists,
});
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 { Models } from '.keystone/types';
import { Lists } from '.keystone/types';

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

0 comments on commit ed736e3

Please sign in to comment.