Skip to content

Commit

Permalink
Rename listKey on FieldData to modelKey
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed Aug 29, 2022
1 parent 7ccfefb commit b472b95
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/fields/non-null-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export function assertReadIsNonNullAllowed<ModelTypeInfo extends BaseModelTypeIn
if (config.graphql?.read?.isNonNull) {
if (resolvedIsNullable) {
throw new Error(
`The field at ${meta.listKey}.${meta.fieldKey} sets graphql.read.isNonNull: true but not validation.isRequired: true or db.isNullable: false.\n` +
`The field at ${meta.modelKey}.${meta.fieldKey} sets graphql.read.isNonNull: true but not validation.isRequired: true or db.isNullable: false.\n` +
`Set validation.isRequired: true or db.isNullable: false or disable graphql.read.isNonNull`
);
}
if (hasReadAccessControl(config.access)) {
throw new Error(
`The field at ${meta.listKey}.${meta.fieldKey} sets graphql.read.isNonNull: true and has read access control, this is not allowed.\n` +
`The field at ${meta.modelKey}.${meta.fieldKey} sets graphql.read.isNonNull: true and has read access control, this is not allowed.\n` +
'Either disable graphql.read.isNonNull or read access control.'
);
}
Expand All @@ -64,7 +64,7 @@ export function assertCreateIsNonNullAllowed<ModelTypeInfo extends BaseModelType
) {
if (config.graphql?.create?.isNonNull && hasCreateAccessControl(config.access)) {
throw new Error(
`The field at ${meta.listKey}.${meta.fieldKey} sets graphql.create.isNonNull: true and has create access control, this is not allowed.\n` +
`The field at ${meta.modelKey}.${meta.fieldKey} sets graphql.create.isNonNull: true and has create access control, this is not allowed.\n` +
'Either disable graphql.create.isNonNull or create access control.'
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/fields/types/bigInt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const bigInt =
if (hasAutoIncDefault) {
if (meta.provider === 'sqlite' || meta.provider === 'mysql') {
throw new Error(
`The bigInt field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, this is not supported on ${meta.provider}`
`The bigInt field at ${meta.modelKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, this is not supported on ${meta.provider}`
);
}
if (isNullable !== false) {
throw new Error(
`The bigInt field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' } but doesn't specify db.isNullable: false.\n` +
`The bigInt field at ${meta.modelKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' } but doesn't specify db.isNullable: false.\n` +
`Having nullable autoincrements on Prisma currently incorrectly creates a non-nullable column so it is not allowed.\n` +
`https://github.com/prisma/prisma/issues/8663`
);
Expand All @@ -81,13 +81,13 @@ export const bigInt =
for (const type of ['min', 'max'] as const) {
if (validation[type] > MAX_INT || validation[type] < MIN_INT) {
throw new Error(
`The bigInt field at ${meta.listKey}.${meta.fieldKey} specifies validation.${type}: ${validation[type]} which is outside of the range of a 64bit signed integer(${MIN_INT}n - ${MAX_INT}n) which is not allowed`
`The bigInt field at ${meta.modelKey}.${meta.fieldKey} specifies validation.${type}: ${validation[type]} which is outside of the range of a 64bit signed integer(${MIN_INT}n - ${MAX_INT}n) which is not allowed`
);
}
}
if (validation.min > validation.max) {
throw new Error(
`The bigInt field at ${meta.listKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
`The bigInt field at ${meta.modelKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/calendarDay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const calendarDay =
graphql.CalendarDay.graphQLType.parseValue(defaultValue);
} catch (err) {
throw new Error(
`The calendarDay field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: ${defaultValue} but values must be provided as a full-date ISO8601 string such as 1970-01-01`
`The calendarDay field at ${meta.modelKey}.${meta.fieldKey} specifies defaultValue: ${defaultValue} but values must be provided as a full-date ISO8601 string such as 1970-01-01`
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/fields/types/decimal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ function parseDecimalValueOption(meta: FieldData, value: string, name: string) {
decimal = new Decimal(value);
} catch (err) {
throw new Error(
`The decimal field at ${meta.listKey}.${meta.fieldKey} specifies ${name}: ${value}, this is not valid decimal value.`
`The decimal field at ${meta.modelKey}.${meta.fieldKey} specifies ${name}: ${value}, this is not valid decimal value.`
);
}
if (!decimal.isFinite()) {
throw new Error(
`The decimal field at ${meta.listKey}.${meta.fieldKey} specifies ${name}: ${value} which is not finite but ${name} must be finite.`
`The decimal field at ${meta.modelKey}.${meta.fieldKey} specifies ${name}: ${value} which is not finite but ${name} must be finite.`
);
}
return decimal;
Expand All @@ -64,19 +64,19 @@ export const decimal =

if (!Number.isInteger(scale)) {
throw new Error(
`The scale for decimal fields must be an integer but the scale for the decimal field at ${meta.listKey}.${meta.fieldKey} is not an integer`
`The scale for decimal fields must be an integer but the scale for the decimal field at ${meta.modelKey}.${meta.fieldKey} is not an integer`
);
}

if (!Number.isInteger(precision)) {
throw new Error(
`The precision for decimal fields must be an integer but the precision for the decimal field at ${meta.listKey}.${meta.fieldKey} is not an integer`
`The precision for decimal fields must be an integer but the precision for the decimal field at ${meta.modelKey}.${meta.fieldKey} is not an integer`
);
}

if (scale > precision) {
throw new Error(
`The scale configured for decimal field at ${meta.listKey}.${meta.fieldKey} (${scale}) ` +
`The scale configured for decimal field at ${meta.modelKey}.${meta.fieldKey} (${scale}) ` +
`must not be larger than the field's precision (${precision})`
);
}
Expand All @@ -94,7 +94,7 @@ export const decimal =

if (min !== undefined && max !== undefined && max.lessThan(min)) {
throw new Error(
`The decimal field at ${meta.listKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
`The decimal field at ${meta.modelKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const file =

if (!storage) {
throw new Error(
`${meta.listKey}.${meta.fieldKey} has storage set to ${config.storage}, but no storage configuration was found for that key`
`${meta.modelKey}.${meta.fieldKey} has storage set to ${config.storage}, but no storage configuration was found for that key`
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/fields/types/float/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const float =
(typeof defaultValue !== 'number' || !Number.isFinite(defaultValue))
) {
throw new Error(
`The float field at ${meta.listKey}.${meta.fieldKey} specifies a default value of: ${defaultValue} but it must be a valid finite number`
`The float field at ${meta.modelKey}.${meta.fieldKey} specifies a default value of: ${defaultValue} but it must be a valid finite number`
);
}

Expand All @@ -60,7 +60,7 @@ export const float =
(typeof validation.min !== 'number' || !Number.isFinite(validation.min))
) {
throw new Error(
`The float field at ${meta.listKey}.${meta.fieldKey} specifies validation.min: ${validation.min} but it must be a valid finite number`
`The float field at ${meta.modelKey}.${meta.fieldKey} specifies validation.min: ${validation.min} but it must be a valid finite number`
);
}

Expand All @@ -69,7 +69,7 @@ export const float =
(typeof validation.max !== 'number' || !Number.isFinite(validation.max))
) {
throw new Error(
`The float field at ${meta.listKey}.${meta.fieldKey} specifies validation.max: ${validation.max} but it must be a valid finite number`
`The float field at ${meta.modelKey}.${meta.fieldKey} specifies validation.max: ${validation.max} but it must be a valid finite number`
);
}

Expand All @@ -79,7 +79,7 @@ export const float =
validation.min > validation.max
) {
throw new Error(
`The float field at ${meta.listKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
`The float field at ${meta.modelKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const image =

if (!storage) {
throw new Error(
`${meta.listKey}.${meta.fieldKey} has storage set to ${config.storage}, but no storage configuration was found for that key`
`${meta.modelKey}.${meta.fieldKey} has storage set to ${config.storage}, but no storage configuration was found for that key`
);
}

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/fields/types/integer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const integer =
if (hasAutoIncDefault) {
if (meta.provider === 'sqlite' || meta.provider === 'mysql') {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, this is not supported on ${meta.provider}`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' }, this is not supported on ${meta.provider}`
);
}
if (isNullable !== false) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' } but doesn't specify db.isNullable: false.\n` +
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies defaultValue: { kind: 'autoincrement' } but doesn't specify db.isNullable: false.\n` +
`Having nullable autoincrements on Prisma currently incorrectly creates a non-nullable column so it is not allowed.\n` +
`https://github.com/prisma/prisma/issues/8663`
);
Expand All @@ -74,23 +74,23 @@ export const integer =

if (validation?.min !== undefined && !Number.isInteger(validation.min)) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies validation.min: ${validation.min} but it must be an integer`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies validation.min: ${validation.min} but it must be an integer`
);
}
if (validation?.max !== undefined && !Number.isInteger(validation.max)) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies validation.max: ${validation.max} but it must be an integer`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies validation.max: ${validation.max} but it must be an integer`
);
}

if (validation?.min !== undefined && (validation?.min > MAX_INT || validation?.min < MIN_INT)) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies validation.min: ${validation.min} which is outside of the range of a 32bit signed integer(${MIN_INT} - ${MAX_INT}) which is not allowed`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies validation.min: ${validation.min} which is outside of the range of a 32bit signed integer(${MIN_INT} - ${MAX_INT}) which is not allowed`
);
}
if (validation?.max !== undefined && (validation?.max > MAX_INT || validation?.max < MIN_INT)) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies validation.max: ${validation.max} which is outside of the range of a 32bit signed integer(${MIN_INT} - ${MAX_INT}) which is not allowed`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies validation.max: ${validation.max} which is outside of the range of a 32bit signed integer(${MIN_INT} - ${MAX_INT}) which is not allowed`
);
}

Expand All @@ -100,7 +100,7 @@ export const integer =
validation.min > validation.max
) {
throw new Error(
`The integer field at ${meta.listKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
`The integer field at ${meta.modelKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`
);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/fields/types/multiselect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const multiselect =
const possibleValues = new Set(transformedConfig.options.map(x => x.value));
if (possibleValues.size !== transformedConfig.options.length) {
throw new Error(
`The multiselect field at ${meta.listKey}.${meta.fieldKey} has duplicate options, this is not allowed`
`The multiselect field at ${meta.modelKey}.${meta.fieldKey} has duplicate options, this is not allowed`
);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ function configToOptionsAndGraphQLType(
)
) {
throw new Error(
`The multiselect field at ${meta.listKey}.${meta.fieldKey} specifies integer values that are outside the range of a 32 bit signed integer`
`The multiselect field at ${meta.modelKey}.${meta.fieldKey} specifies integer values that are outside the range of a 32 bit signed integer`
);
}
return {
Expand All @@ -187,7 +187,7 @@ function configToOptionsAndGraphQLType(
});

if (config.type === 'enum') {
const enumName = `${meta.listKey}${inflection.classify(meta.fieldKey)}Type`;
const enumName = `${meta.modelKey}${inflection.classify(meta.fieldKey)}Type`;
const graphqlType = graphql.enum({
name: enumName,
values: graphql.enumValues(options.map(x => x.value)),
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/fields/types/password/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ export const password =
const val = validation.length[type];
if (val !== null && (!Number.isInteger(val) || val < 1)) {
throw new Error(
`The password field at ${meta.listKey}.${meta.fieldKey} specifies validation.length.${type}: ${val} but it must be a positive integer >= 1`
`The password field at ${meta.modelKey}.${meta.fieldKey} specifies validation.length.${type}: ${val} but it must be a positive integer >= 1`
);
}
}

if (validation.length.max !== null && validation.length.min > validation.length.max) {
throw new Error(
`The password field at ${meta.listKey}.${meta.fieldKey} specifies a validation.length.max that is less than the validation.length.min, and therefore has no valid options`
`The password field at ${meta.modelKey}.${meta.fieldKey} specifies a validation.length.max that is less than the validation.length.min, and therefore has no valid options`
);
}

if (workFactor < 6 || workFactor > 31 || !Number.isInteger(workFactor)) {
throw new Error(
`The password field at ${meta.listKey}.${meta.fieldKey} specifies workFactor: ${workFactor} but it must be an integer between 6 and 31`
`The password field at ${meta.modelKey}.${meta.fieldKey} specifies workFactor: ${workFactor} but it must be an integer between 6 and 31`
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/fields/types/relationship/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export const relationship =
): Parameters<typeof import('./views').controller>[0]['fieldMeta'] => {
if (!meta.lists[foreignListKey]) {
throw new Error(
`The ref [${ref}] on relationship [${meta.listKey}.${meta.fieldKey}] is invalid`
`The ref [${ref}] on relationship [${meta.modelKey}.${meta.fieldKey}] is invalid`
);
}
if (config.ui?.displayMode === 'cards') {
// we're checking whether the field which will be in the admin meta at the time that getAdminMeta is called.
// in newer versions of keystone, it will be there and it will not be there for older versions of keystone.
// this is so that relationship fields doesn't break in confusing ways
// if people are using a slightly older version of keystone
const currentField = adminMetaRoot.listsByKey[meta.listKey].fields.find(
const currentField = adminMetaRoot.listsByKey[meta.modelKey].fields.find(
x => x.path === meta.fieldKey
);
if (currentField) {
Expand All @@ -114,7 +114,7 @@ export const relationship =
for (const foreignField of foreignFields) {
if (!allForeignFields.has(foreignField)) {
throw new Error(
`The ${configOption} option on the relationship field at ${meta.listKey}.${meta.fieldKey} includes the "${foreignField}" field but that field does not exist on the "${foreignListKey}" list`
`The ${configOption} option on the relationship field at ${meta.modelKey}.${meta.fieldKey} includes the "${foreignField}" field but that field does not exist on the "${foreignListKey}" list`
);
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ export const relationship =
};
if (!meta.lists[foreignListKey]) {
throw new Error(
`Unable to resolve related list '${foreignListKey}' from ${meta.listKey}.${meta.fieldKey}`
`Unable to resolve related list '${foreignListKey}' from ${meta.modelKey}.${meta.fieldKey}`
);
}
const listTypes = meta.lists[foreignListKey].types;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/fields/types/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const select =
const values = new Set(options.map(x => x.value));
if (values.size !== options.length) {
throw new Error(
`The select field at ${meta.listKey}.${meta.fieldKey} has duplicate options, this is not allowed`
`The select field at ${meta.modelKey}.${meta.fieldKey} has duplicate options, this is not allowed`
);
}
return {
Expand Down Expand Up @@ -156,7 +156,7 @@ export const select =
)
) {
throw new Error(
`The select field at ${meta.listKey}.${meta.fieldKey} specifies integer values that are outside the range of a 32 bit signed integer`
`The select field at ${meta.modelKey}.${meta.fieldKey} specifies integer values that are outside the range of a 32 bit signed integer`
);
}
return fieldType({
Expand Down Expand Up @@ -190,7 +190,7 @@ export const select =
});

if (config.type === 'enum') {
const enumName = `${meta.listKey}${inflection.classify(meta.fieldKey)}Type`;
const enumName = `${meta.modelKey}${inflection.classify(meta.fieldKey)}Type`;
const graphQLType = graphql.enum({
name: enumName,
values: graphql.enumValues(options.map(x => x.value)),
Expand Down
Loading

0 comments on commit b472b95

Please sign in to comment.