@payloadcms/graphql 3.0.0-beta.53 → 3.0.0-beta.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/bin/generateSchema.js.map +1 -1
  2. package/dist/bin/index.js.map +1 -1
  3. package/dist/exports/types.d.ts +2 -0
  4. package/dist/exports/types.d.ts.map +1 -1
  5. package/dist/exports/types.js +2 -0
  6. package/dist/exports/types.js.map +1 -1
  7. package/dist/exports/utilities.js.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/packages/graphql-query-complexity/QueryComplexity.js.map +1 -1
  10. package/dist/packages/graphql-query-complexity/createComplexityRule.js.map +1 -1
  11. package/dist/packages/graphql-query-complexity/estimators/fieldExtensions/index.js.map +1 -1
  12. package/dist/packages/graphql-query-complexity/estimators/simple/index.js.map +1 -1
  13. package/dist/packages/graphql-query-complexity/index.js.map +1 -1
  14. package/dist/packages/graphql-type-json/index.js.map +1 -1
  15. package/dist/resolvers/auth/access.js.map +1 -1
  16. package/dist/resolvers/auth/forgotPassword.js.map +1 -1
  17. package/dist/resolvers/auth/init.js.map +1 -1
  18. package/dist/resolvers/auth/login.js.map +1 -1
  19. package/dist/resolvers/auth/logout.js.map +1 -1
  20. package/dist/resolvers/auth/me.js.map +1 -1
  21. package/dist/resolvers/auth/refresh.js.map +1 -1
  22. package/dist/resolvers/auth/resetPassword.js.map +1 -1
  23. package/dist/resolvers/auth/unlock.js.map +1 -1
  24. package/dist/resolvers/auth/verifyEmail.js.map +1 -1
  25. package/dist/resolvers/collections/count.js.map +1 -1
  26. package/dist/resolvers/collections/create.d.ts +5 -6
  27. package/dist/resolvers/collections/create.d.ts.map +1 -1
  28. package/dist/resolvers/collections/create.js.map +1 -1
  29. package/dist/resolvers/collections/delete.d.ts +4 -4
  30. package/dist/resolvers/collections/delete.d.ts.map +1 -1
  31. package/dist/resolvers/collections/delete.js.map +1 -1
  32. package/dist/resolvers/collections/docAccess.js.map +1 -1
  33. package/dist/resolvers/collections/duplicate.d.ts +4 -4
  34. package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
  35. package/dist/resolvers/collections/duplicate.js.map +1 -1
  36. package/dist/resolvers/collections/find.js.map +1 -1
  37. package/dist/resolvers/collections/findByID.d.ts +4 -4
  38. package/dist/resolvers/collections/findByID.d.ts.map +1 -1
  39. package/dist/resolvers/collections/findByID.js.map +1 -1
  40. package/dist/resolvers/collections/findVersionByID.js.map +1 -1
  41. package/dist/resolvers/collections/findVersions.js.map +1 -1
  42. package/dist/resolvers/collections/restoreVersion.js.map +1 -1
  43. package/dist/resolvers/collections/update.d.ts +5 -5
  44. package/dist/resolvers/collections/update.d.ts.map +1 -1
  45. package/dist/resolvers/collections/update.js.map +1 -1
  46. package/dist/resolvers/globals/docAccess.js.map +1 -1
  47. package/dist/resolvers/globals/findOne.js.map +1 -1
  48. package/dist/resolvers/globals/findVersionByID.js.map +1 -1
  49. package/dist/resolvers/globals/findVersions.js.map +1 -1
  50. package/dist/resolvers/globals/index.js.map +1 -1
  51. package/dist/resolvers/globals/restoreVersion.js.map +1 -1
  52. package/dist/resolvers/globals/update.d.ts +5 -5
  53. package/dist/resolvers/globals/update.d.ts.map +1 -1
  54. package/dist/resolvers/globals/update.js.map +1 -1
  55. package/dist/resolvers/types.js.map +1 -1
  56. package/dist/schema/buildFallbackLocaleInputType.js.map +1 -1
  57. package/dist/schema/buildLocaleInputType.js.map +1 -1
  58. package/dist/schema/buildMutationInputType.d.ts.map +1 -1
  59. package/dist/schema/buildMutationInputType.js.map +1 -1
  60. package/dist/schema/buildObjectType.js.map +1 -1
  61. package/dist/schema/buildPaginatedListType.d.ts +1 -2
  62. package/dist/schema/buildPaginatedListType.d.ts.map +1 -1
  63. package/dist/schema/buildPaginatedListType.js +1 -2
  64. package/dist/schema/buildPaginatedListType.js.map +1 -1
  65. package/dist/schema/buildPoliciesType.js.map +1 -1
  66. package/dist/schema/buildWhereInputType.js.map +1 -1
  67. package/dist/schema/fieldToWhereInputSchemaMap.js.map +1 -1
  68. package/dist/schema/initCollections.js +1 -1
  69. package/dist/schema/initCollections.js.map +1 -1
  70. package/dist/schema/initGlobals.js +1 -1
  71. package/dist/schema/initGlobals.js.map +1 -1
  72. package/dist/schema/isFieldNullable.js.map +1 -1
  73. package/dist/schema/operators.js.map +1 -1
  74. package/dist/schema/recursivelyBuildNestedPaths.js.map +1 -1
  75. package/dist/schema/withNullableType.js.map +1 -1
  76. package/dist/schema/withOperators.js.map +1 -1
  77. package/dist/utilities/combineParentName.js.map +1 -1
  78. package/dist/utilities/formatName.js.map +1 -1
  79. package/dist/utilities/formatName.spec.js.map +1 -1
  80. package/dist/utilities/formatOptions.js.map +1 -1
  81. package/dist/utilities/getCheckIfLocaleObject.js.map +1 -1
  82. package/dist/utilities/groupOrTabHasRequiredSubfield.js.map +1 -1
  83. package/dist/utilities/uppercase.js.map +1 -1
  84. package/dist/utilities/wrapCustomResolver.js.map +1 -1
  85. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLObjectType } from 'graphql';
2
- const buildPaginatedListType = (name, docType)=>new GraphQLObjectType({
2
+ export const buildPaginatedListType = (name, docType)=>new GraphQLObjectType({
3
3
  name,
4
4
  fields: {
5
5
  docs: {
@@ -37,6 +37,5 @@ const buildPaginatedListType = (name, docType)=>new GraphQLObjectType({
37
37
  }
38
38
  }
39
39
  });
40
- export default buildPaginatedListType;
41
40
 
42
41
  //# sourceMappingURL=buildPaginatedListType.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildPaginatedListType.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLObjectType } from 'graphql'\n\nconst buildPaginatedListType = (name, docType) =>\n new GraphQLObjectType({\n name,\n fields: {\n docs: {\n type: new GraphQLList(docType),\n },\n hasNextPage: { type: GraphQLBoolean },\n hasPrevPage: { type: GraphQLBoolean },\n limit: { type: GraphQLInt },\n nextPage: { type: GraphQLInt },\n offset: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagingCounter: { type: GraphQLInt },\n prevPage: { type: GraphQLInt },\n totalDocs: { type: GraphQLInt },\n totalPages: { type: GraphQLInt },\n },\n })\n\nexport default buildPaginatedListType\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLList","GraphQLObjectType","buildPaginatedListType","name","docType","fields","docs","type","hasNextPage","hasPrevPage","limit","nextPage","offset","page","pagingCounter","prevPage","totalDocs","totalPages"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,UAAS;AAEpF,MAAMC,yBAAyB,CAACC,MAAMC,UACpC,IAAIH,kBAAkB;QACpBE;QACAE,QAAQ;YACNC,MAAM;gBACJC,MAAM,IAAIP,YAAYI;YACxB;YACAI,aAAa;gBAAED,MAAMT;YAAe;YACpCW,aAAa;gBAAEF,MAAMT;YAAe;YACpCY,OAAO;gBAAEH,MAAMR;YAAW;YAC1BY,UAAU;gBAAEJ,MAAMR;YAAW;YAC7Ba,QAAQ;gBAAEL,MAAMR;YAAW;YAC3Bc,MAAM;gBAAEN,MAAMR;YAAW;YACzBe,eAAe;gBAAEP,MAAMR;YAAW;YAClCgB,UAAU;gBAAER,MAAMR;YAAW;YAC7BiB,WAAW;gBAAET,MAAMR;YAAW;YAC9BkB,YAAY;gBAAEV,MAAMR;YAAW;QACjC;IACF;AAEF,eAAeG,uBAAsB"}
1
+ {"version":3,"sources":["../../src/schema/buildPaginatedListType.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLObjectType } from 'graphql'\n\nexport const buildPaginatedListType = (name, docType) =>\n new GraphQLObjectType({\n name,\n fields: {\n docs: {\n type: new GraphQLList(docType),\n },\n hasNextPage: { type: GraphQLBoolean },\n hasPrevPage: { type: GraphQLBoolean },\n limit: { type: GraphQLInt },\n nextPage: { type: GraphQLInt },\n offset: { type: GraphQLInt },\n page: { type: GraphQLInt },\n pagingCounter: { type: GraphQLInt },\n prevPage: { type: GraphQLInt },\n totalDocs: { type: GraphQLInt },\n totalPages: { type: GraphQLInt },\n },\n })\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLList","GraphQLObjectType","buildPaginatedListType","name","docType","fields","docs","type","hasNextPage","hasPrevPage","limit","nextPage","offset","page","pagingCounter","prevPage","totalDocs","totalPages"],"mappings":"AAAA,SAASA,cAAc,EAAEC,UAAU,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,UAAS;AAEpF,OAAO,MAAMC,yBAAyB,CAACC,MAAMC,UAC3C,IAAIH,kBAAkB;QACpBE;QACAE,QAAQ;YACNC,MAAM;gBACJC,MAAM,IAAIP,YAAYI;YACxB;YACAI,aAAa;gBAAED,MAAMT;YAAe;YACpCW,aAAa;gBAAEF,MAAMT;YAAe;YACpCY,OAAO;gBAAEH,MAAMR;YAAW;YAC1BY,UAAU;gBAAEJ,MAAMR;YAAW;YAC7Ba,QAAQ;gBAAEL,MAAMR;YAAW;YAC3Bc,MAAM;gBAAEN,MAAMR;YAAW;YACzBe,eAAe;gBAAEP,MAAMR;YAAW;YAClCgB,UAAU;gBAAER,MAAMR;YAAW;YAC7BiB,WAAW;gBAAET,MAAMR;YAAW;YAC9BkB,YAAY;gBAAEV,MAAMR;YAAW;QACjC;IACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport formatName from '../utilities/formatName.js'\n\ntype OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = ['create', 'read', 'update', 'delete'].reduce(\n (operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n },\n {},\n )\n\n if (field.fields) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: buildFields(`${label}_${fieldName}`, field.fields),\n }),\n }\n }\n\n return {\n ...builtFields,\n [field.name]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const fields = {\n fields: {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: buildFields(fieldsTypeName, entityFields),\n }),\n },\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) return null\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport default function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","subFields","tabs","fieldsWithTabFields","tab","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","Object","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,gBAAgB,6BAA4B;AAUnD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM,IAAIF,MAAMG,IAAI,KAAK;QACrD,IAAIF,cAAc;YACh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I,EAAE,GAAG;YACpC3B,MAAM2C;QACR;IACF;IAEAJ,OAAOC,MAAM,CAACH,OAAOO,OAAO,EAAEvB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMiB,mBAAmBrB,gBAAgB;YACvCxB,MAAM;YACNyB,QAAQU;YACRT,YAAY;QACd;QAEAhB,MAAM,CAACnB,WAAW4C,QAAOR,IAAI,EAAE,GAAG;YAChC3B,MAAM6C;QACR;IACF;IAEA,OAAO,IAAIzD,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport formatName from '../utilities/formatName.js'\n\ntype OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = ['create', 'read', 'update', 'delete'].reduce(\n (operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n },\n {},\n )\n\n if (field.fields) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: buildFields(`${label}_${fieldName}`, field.fields),\n }),\n }\n }\n\n return {\n ...builtFields,\n [field.name]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields) {\n const subFields = buildFields(label, field.fields)\n\n return {\n ...builtFields,\n ...subFields,\n }\n }\n\n if (field.type === 'tabs') {\n return field.tabs.reduce(\n (fieldsWithTabFields, tab) => {\n return {\n ...fieldsWithTabFields,\n ...buildFields(label, tab.fields),\n }\n },\n { ...builtFields },\n )\n }\n }\n return builtFields\n }, {})\n\ntype BuildEntityPolicy = {\n entityFields: Field[]\n name: string\n operations: OperationType[]\n scope: AccessScopes\n}\nexport const buildEntityPolicy = (args: BuildEntityPolicy) => {\n const { name, entityFields, operations, scope } = args\n\n const fieldsTypeName = toWords(`${name}-${scope || ''}-Fields`, true)\n const fields = {\n fields: {\n type: new GraphQLObjectType({\n name: fieldsTypeName,\n fields: buildFields(fieldsTypeName, entityFields),\n }),\n },\n }\n\n operations.forEach((operation) => {\n const operationTypeName = toWords(`${name}-${operation}-${scope || 'Access'}`, true)\n\n fields[operation] = {\n type: new GraphQLObjectType({\n name: operationTypeName,\n fields: {\n permission: { type: new GraphQLNonNull(GraphQLBoolean) },\n where: { type: GraphQLJSONObject },\n },\n }),\n }\n })\n\n return fields\n}\n\ntype BuildPolicyType = {\n scope?: AccessScopes\n typeSuffix?: string\n} & (\n | {\n entity: CollectionConfig\n type: 'collection'\n }\n | {\n entity: GlobalConfig\n type: 'global'\n }\n)\nexport function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {\n const { type, entity, scope, typeSuffix } = args\n const { slug, fields, graphQL, versions } = entity\n\n let operations = []\n\n if (graphQL === false) return null\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete']\n\n if (\n entity.auth &&\n typeof entity.auth === 'object' &&\n typeof entity.auth.maxLoginAttempts !== 'undefined' &&\n entity.auth.maxLoginAttempts !== 0\n ) {\n operations.push('unlock')\n }\n\n if (versions) {\n operations.push('readVersions')\n }\n\n const collectionTypeName = formatName(`${slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: collectionTypeName,\n fields: buildEntityPolicy({\n name: slug,\n entityFields: fields,\n operations,\n scope,\n }),\n })\n }\n\n // else create global type\n operations = ['read', 'update']\n\n if (entity.versions) {\n operations.push('readVersions')\n }\n\n const globalTypeName = formatName(`${global?.graphQL?.name || slug}${typeSuffix || ''}`)\n\n return new GraphQLObjectType({\n name: globalTypeName,\n fields: buildEntityPolicy({\n name: entity.graphQL ? entity?.graphQL?.name || slug : slug,\n entityFields: entity.fields,\n operations,\n scope,\n }),\n })\n}\n\nexport default function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {\n const fields = {\n canAccessAdmin: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n }\n\n Object.values(config.collections).forEach((collection: SanitizedCollectionConfig) => {\n if (collection.graphQL === false) {\n return\n }\n const collectionPolicyType = buildPolicyType({\n type: 'collection',\n entity: collection,\n typeSuffix: 'Access',\n })\n\n fields[formatName(collection.slug)] = {\n type: collectionPolicyType,\n }\n })\n\n Object.values(config.globals).forEach((global: SanitizedGlobalConfig) => {\n if (global.graphQL === false) {\n return\n }\n const globalPolicyType = buildPolicyType({\n type: 'global',\n entity: global,\n typeSuffix: 'Access',\n })\n\n fields[formatName(global.slug)] = {\n type: globalPolicyType,\n }\n })\n\n return new GraphQLObjectType({\n name: 'Access',\n fields,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLNonNull","GraphQLObjectType","toWords","GraphQLJSONObject","formatName","buildFields","label","fieldsToBuild","reduce","builtFields","field","includeField","hidden","type","name","fieldName","objectTypeFields","operations","operation","capitalizedOperation","charAt","toUpperCase","slice","fields","permission","subFields","tabs","fieldsWithTabFields","tab","buildEntityPolicy","args","entityFields","scope","fieldsTypeName","forEach","operationTypeName","where","buildPolicyType","entity","typeSuffix","slug","graphQL","versions","auth","maxLoginAttempts","push","collectionTypeName","globalTypeName","global","buildPoliciesType","config","canAccessAdmin","Object","values","collections","collection","collectionPolicyType","globals","globalPolicyType"],"mappings":"AASA,SAASA,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,UAAS;AAC3E,SAASC,OAAO,QAAQ,UAAS;AAEjC,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,gBAAgB,6BAA4B;AAUnD,MAAMC,cAAc,CAACC,OAAOC,gBAC1BA,cAAcC,MAAM,CAAC,CAACC,aAAaC;QACjC,MAAMC,eAAe,CAACD,MAAME,MAAM,IAAIF,MAAMG,IAAI,KAAK;QACrD,IAAIF,cAAc;YAChB,IAAID,MAAMI,IAAI,EAAE;gBACd,MAAMC,YAAYX,WAAWM,MAAMI,IAAI;gBAEvC,MAAME,mBAAqC;oBAAC;oBAAU;oBAAQ;oBAAU;iBAAS,CAACR,MAAM,CACtF,CAACS,YAAYC;oBACX,MAAMC,uBAAuBD,UAAUE,MAAM,CAAC,GAAGC,WAAW,KAAKH,UAAUI,KAAK,CAAC;oBAEjF,OAAO;wBACL,GAAGL,UAAU;wBACb,CAACC,UAAU,EAAE;4BACXL,MAAM,IAAIZ,kBAAkB;gCAC1Ba,MAAM,CAAC,EAAER,MAAM,CAAC,EAAES,UAAU,CAAC,EAAEI,qBAAqB,CAAC;gCACrDI,QAAQ;oCACNC,YAAY;wCACVX,MAAM,IAAIb,eAAeD;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF,GACA,CAAC;gBAGH,IAAIW,MAAMa,MAAM,EAAE;oBAChBP,iBAAiBO,MAAM,GAAG;wBACxBV,MAAM,IAAIZ,kBAAkB;4BAC1Ba,MAAM,CAAC,EAAER,MAAM,CAAC,EAAES,UAAU,OAAO,CAAC;4BACpCQ,QAAQlB,YAAY,CAAC,EAAEC,MAAM,CAAC,EAAES,UAAU,CAAC,EAAEL,MAAMa,MAAM;wBAC3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OAAOG,OAAO,GAAGH,QAAQG,SAAS3B,QAAQ0B,OAAOA;YACvDT,cAAcO,OAAOf,MAAM;YAC3BN;YACAe;QACF;IACF;AACF;AAEA,eAAe,SAASiB,kBAAkBC,MAAuB;IAC/D,MAAM3B,SAAS;QACb4B,gBAAgB;YACdtC,MAAM,IAAIb,eAAeD;QAC3B;IACF;IAEAqD,OAAOC,MAAM,CAACH,OAAOI,WAAW,EAAEpB,OAAO,CAAC,CAACqB;QACzC,IAAIA,WAAWd,OAAO,KAAK,OAAO;YAChC;QACF;QACA,MAAMe,uBAAuBnB,gBAAgB;YAC3CxB,MAAM;YACNyB,QAAQiB;YACRhB,YAAY;QACd;QAEAhB,MAAM,CAACnB,WAAWmD,WAAWf,IAAI,EAAE,GAAG;YACpC3B,MAAM2C;QACR;IACF;IAEAJ,OAAOC,MAAM,CAACH,OAAOO,OAAO,EAAEvB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMiB,mBAAmBrB,gBAAgB;YACvCxB,MAAM;YACNyB,QAAQU;YACRT,YAAY;QACd;QAEAhB,MAAM,CAACnB,WAAW4C,QAAOR,IAAI,EAAE,GAAG;YAChC3B,MAAM6C;QACR;IACF;IAEA,OAAO,IAAIzD,kBAAkB;QAC3Ba,MAAM;QACNS;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport formatName from '../utilities/formatName.js'\nimport fieldToSchemaMap from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nconst buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' } as FieldAffectingData, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n\nexport default buildWhereInputType\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0DAA0D,GAG1D,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,OAAOC,gBAAgB,6BAA4B;AACnD,OAAOC,sBAAsB,kCAAiC;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,MAAMC,sBAAsB,CAAC,EAAEC,IAAI,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IAC7D,wDAAwD;IACxD,iCAAiC;IAEjC,MAAMC,UAAUX,sBAAsBS,QAAQG,IAAI,CAChD,CAACC,QAAUZ,iBAAiBY,UAAUA,MAAML,IAAI,KAAK;IAGvD,MAAMM,aAAaL,OAAOM,MAAM,CAAC,CAACC,QAAQH;QACxC,IAAI,CAACV,0BAA0BU,UAAU,CAACA,MAAMI,MAAM,EAAE;YACtD,MAAMC,iBAAiBb,iBAAiB;gBACtCK;YACF,EAAE,CAACG,MAAMM,IAAI,CAAC;YAEd,IAAID,gBAAgB;gBAClB,MAAME,cAAcF,eAAeL;gBAEnC,IAAIX,kBAAkBW,UAAUA,MAAMM,IAAI,KAAK,QAAQ;oBACrD,OAAO;wBACL,GAAGH,MAAM;wBACT,GAAGI,YAAYL,MAAM,CACnB,CAACM,WAAWC,WAAc,CAAA;gCACxB,GAAGD,SAAS;gCACZ,CAACjB,WAAWkB,SAASC,GAAG,EAAE,EAAED,SAASH,IAAI;4BAC3C,CAAA,GACA,CAAC,EACF;oBACH;gBACF;gBAEA,OAAO;oBACL,GAAGH,MAAM;oBACT,CAACZ,WAAWS,MAAML,IAAI,EAAE,EAAEY;gBAC5B;YACF;QACF;QAEA,OAAOJ;IACT,GAAG,CAAC;IAEJ,IAAI,CAACL,SAAS;QACZG,WAAWU,EAAE,GAAG;YACdL,MAAMb,cAAc;gBAAEE,MAAM;gBAAMW,MAAM;YAAO,GAAyBT;QAC1E;IACF;IAEA,MAAMe,YAAYrB,WAAWI;IAE7B,MAAMkB,kBAAkB;QACtBC,KAAK;YACHR,MAAM,IAAIpB,YACR,IAAID,uBAAuB;gBACzBU,MAAM,CAAC,EAAEiB,UAAU,UAAU,CAAC;gBAC9BhB,QAAQ,IAAO,CAAA;wBACb,GAAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;QACAE,IAAI;YACFT,MAAM,IAAIpB,YACR,IAAID,uBAAuB;gBACzBU,MAAM,CAAC,EAAEiB,UAAU,SAAS,CAAC;gBAC7BhB,QAAQ,IAAO,CAAA;wBACb,GAAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;IACF;IAEA,OAAO,IAAI5B,uBAAuB;QAChCU,MAAM,CAAC,EAAEiB,UAAU,MAAM,CAAC;QAC1BhB,QAAQ;YACN,GAAGK,UAAU;YACb,GAAGY,eAAe;QACpB;IACF;AACF;AAEA,eAAenB,oBAAmB"}
1
+ {"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type { Field, FieldAffectingData } from 'payload'\n\nimport { GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport formatName from '../utilities/formatName.js'\nimport fieldToSchemaMap from './fieldToWhereInputSchemaMap.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n fields: Field[]\n name: string\n parentName: string\n}\n\n/** This does as the function name suggests. It builds a where GraphQL input type\n * for all the fields which are passed to the function.\n * Each field has different operators which may be valid for a where input type.\n * For example, a text field may have a \"contains\" operator, but a number field\n * may not.\n *\n * buildWhereInputType is similar to buildObjectType and operates\n * on a field basis with a few distinct differences.\n *\n * 1. Everything needs to be a GraphQLInputObjectType or scalar / enum\n * 2. Relationships, groups, repeaters and flex content are not\n * directly searchable. Instead, we need to build a chained pathname\n * using dot notation so MongoDB can properly search nested paths.\n */\nconst buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {\n // This is the function that builds nested paths for all\n // field types with nested paths.\n\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n const fieldTypes = fields.reduce((schema, field) => {\n if (!fieldIsPresentationalOnly(field) && !field.hidden) {\n const getFieldSchema = fieldToSchemaMap({\n parentName,\n })[field.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema(field)\n\n if (fieldHasSubFields(field) || field.type === 'tabs') {\n return {\n ...schema,\n ...fieldSchema.reduce(\n (subFields, subField) => ({\n ...subFields,\n [formatName(subField.key)]: subField.type,\n }),\n {},\n ),\n }\n }\n\n return {\n ...schema,\n [formatName(field.name)]: fieldSchema,\n }\n }\n }\n\n return schema\n }, {})\n\n if (!idField) {\n fieldTypes.id = {\n type: withOperators({ name: 'id', type: 'text' } as FieldAffectingData, parentName),\n }\n }\n\n const fieldName = formatName(name)\n\n const recursiveFields = {\n AND: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_and`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n OR: {\n type: new GraphQLList(\n new GraphQLInputObjectType({\n name: `${fieldName}_where_or`,\n fields: () => ({\n ...fieldTypes,\n ...recursiveFields,\n }),\n }),\n ),\n },\n }\n\n return new GraphQLInputObjectType({\n name: `${fieldName}_where`,\n fields: {\n ...fieldTypes,\n ...recursiveFields,\n },\n })\n}\n\nexport default buildWhereInputType\n"],"names":["GraphQLInputObjectType","GraphQLList","flattenTopLevelFields","fieldAffectsData","fieldHasSubFields","fieldIsPresentationalOnly","formatName","fieldToSchemaMap","withOperators","buildWhereInputType","name","fields","parentName","idField","find","field","fieldTypes","reduce","schema","hidden","getFieldSchema","type","fieldSchema","subFields","subField","key","id","fieldName","recursiveFields","AND","OR"],"mappings":"AAAA,0DAA0D,GAG1D,SAASA,sBAAsB,EAAEC,WAAW,QAAQ,UAAS;AAC7D,SAASC,qBAAqB,QAAQ,UAAS;AAC/C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE/F,OAAOC,gBAAgB,6BAA4B;AACnD,OAAOC,sBAAsB,kCAAiC;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAQlD;;;;;;;;;;;;;CAaC,GACD,MAAMC,sBAAsB,CAAC,EAAEC,IAAI,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IAC7D,wDAAwD;IACxD,iCAAiC;IAEjC,MAAMC,UAAUX,sBAAsBS,QAAQG,IAAI,CAChD,CAACC,QAAUZ,iBAAiBY,UAAUA,MAAML,IAAI,KAAK;IAGvD,MAAMM,aAAaL,OAAOM,MAAM,CAAC,CAACC,QAAQH;QACxC,IAAI,CAACV,0BAA0BU,UAAU,CAACA,MAAMI,MAAM,EAAE;YACtD,MAAMC,iBAAiBb,iBAAiB;gBACtCK;YACF,EAAE,CAACG,MAAMM,IAAI,CAAC;YAEd,IAAID,gBAAgB;gBAClB,MAAME,cAAcF,eAAeL;gBAEnC,IAAIX,kBAAkBW,UAAUA,MAAMM,IAAI,KAAK,QAAQ;oBACrD,OAAO;wBACL,GAAGH,MAAM;wBACT,GAAGI,YAAYL,MAAM,CACnB,CAACM,WAAWC,WAAc,CAAA;gCACxB,GAAGD,SAAS;gCACZ,CAACjB,WAAWkB,SAASC,GAAG,EAAE,EAAED,SAASH,IAAI;4BAC3C,CAAA,GACA,CAAC,EACF;oBACH;gBACF;gBAEA,OAAO;oBACL,GAAGH,MAAM;oBACT,CAACZ,WAAWS,MAAML,IAAI,EAAE,EAAEY;gBAC5B;YACF;QACF;QAEA,OAAOJ;IACT,GAAG,CAAC;IAEJ,IAAI,CAACL,SAAS;QACZG,WAAWU,EAAE,GAAG;YACdL,MAAMb,cAAc;gBAAEE,MAAM;gBAAMW,MAAM;YAAO,GAAyBT;QAC1E;IACF;IAEA,MAAMe,YAAYrB,WAAWI;IAE7B,MAAMkB,kBAAkB;QACtBC,KAAK;YACHR,MAAM,IAAIpB,YACR,IAAID,uBAAuB;gBACzBU,MAAM,CAAC,EAAEiB,UAAU,UAAU,CAAC;gBAC9BhB,QAAQ,IAAO,CAAA;wBACb,GAAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;QACAE,IAAI;YACFT,MAAM,IAAIpB,YACR,IAAID,uBAAuB;gBACzBU,MAAM,CAAC,EAAEiB,UAAU,SAAS,CAAC;gBAC7BhB,QAAQ,IAAO,CAAA;wBACb,GAAGK,UAAU;wBACb,GAAGY,eAAe;oBACpB,CAAA;YACF;QAEJ;IACF;IAEA,OAAO,IAAI5B,uBAAuB;QAChCU,MAAM,CAAC,EAAEiB,UAAU,MAAM,CAAC;QAC1BhB,QAAQ;YACN,GAAGK,UAAU;YACb,GAAGY,eAAe;QACpB;IACF;AACF;AAEA,eAAenB,oBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/fieldToWhereInputSchemaMap.ts"],"sourcesContent":["import type {\n ArrayField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SelectField,\n TabsField,\n TextField,\n TextareaField,\n UploadField,\n} from 'payload'\n\nimport { GraphQLEnumType, GraphQLInputObjectType } from 'graphql'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport combineParentName from '../utilities/combineParentName.js'\nimport formatName from '../utilities/formatName.js'\nimport recursivelyBuildNestedPaths from './recursivelyBuildNestedPaths.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n nestedFieldName?: string\n parentName: string\n}\n\nconst fieldToSchemaMap = ({ nestedFieldName, parentName }: Args): any => ({\n array: (field: ArrayField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n checkbox: (field: CheckboxField) => ({\n type: withOperators(field, parentName),\n }),\n code: (field: CodeField) => ({\n type: withOperators(field, parentName),\n }),\n collapsible: (field: CollapsibleField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n date: (field: DateField) => ({\n type: withOperators(field, parentName),\n }),\n email: (field: EmailField) => ({\n type: withOperators(field, parentName),\n }),\n group: (field: GroupField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n json: (field: JSONField) => ({\n type: withOperators(field, parentName),\n }),\n number: (field: NumberField) => ({\n type: withOperators(field, parentName),\n }),\n point: (field: PointField) => ({\n type: withOperators(field, parentName),\n }),\n radio: (field: RadioField) => ({\n type: withOperators(field, parentName),\n }),\n relationship: (field: RelationshipField) => {\n if (Array.isArray(field.relationTo)) {\n return {\n type: new GraphQLInputObjectType({\n name: `${combineParentName(parentName, field.name)}_Relation`,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Relation_RelationTo`,\n values: field.relationTo.reduce(\n (values, relation) => ({\n ...values,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n }),\n }\n }\n\n return {\n type: withOperators(field, parentName),\n }\n },\n richText: (field: RichTextField) => ({\n type: withOperators(field, parentName),\n }),\n row: (field: RowField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n select: (field: SelectField) => ({\n type: withOperators(field, parentName),\n }),\n tabs: (field: TabsField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n text: (field: TextField) => ({\n type: withOperators(field, parentName),\n }),\n textarea: (field: TextareaField) => ({\n type: withOperators(field, parentName),\n }),\n upload: (field: UploadField) => ({\n type: withOperators(field, parentName),\n }),\n})\n\nexport default fieldToSchemaMap\n"],"names":["GraphQLEnumType","GraphQLInputObjectType","GraphQLJSON","combineParentName","formatName","recursivelyBuildNestedPaths","withOperators","fieldToSchemaMap","nestedFieldName","parentName","array","field","nestedFieldName2","checkbox","type","code","collapsible","date","email","group","json","number","point","radio","relationship","Array","isArray","relationTo","name","fields","values","reduce","relation","value","richText","row","select","tabs","text","textarea","upload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAsBA,SAASA,eAAe,EAAEC,sBAAsB,QAAQ,UAAS;AAEjE,SAASC,WAAW,QAAQ,yCAAwC;AACpE,OAAOC,uBAAuB,oCAAmC;AACjE,OAAOC,gBAAgB,6BAA4B;AACnD,OAAOC,iCAAiC,mCAAkC;AAC1E,SAASC,aAAa,QAAQ,qBAAoB;AAOlD,MAAMC,mBAAmB,CAAC,EAAEC,eAAe,EAAEC,UAAU,EAAQ,GAAW,CAAA;QACxEC,OAAO,CAACC,QACNN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACFI,UAAU,CAACF,QAA0B,CAAA;gBACnCG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAM,MAAM,CAACJ,QAAsB,CAAA;gBAC3BG,MAAMR,cAAcK,OAAOF;YAC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,OAAOF;YAC7B;QACF;QACAyB,UAAU,CAACvB,QAA0B,CAAA;gBACnCG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACA0B,KAAK,CAACxB,QACJN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACF2B,QAAQ,CAACzB,QAAwB,CAAA;gBAC/BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACA4B,MAAM,CAAC1B,QACLN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACF6B,MAAM,CAAC3B,QAAsB,CAAA;gBAC3BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACA8B,UAAU,CAAC5B,QAA0B,CAAA;gBACnCG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACA+B,QAAQ,CAAC7B,QAAwB,CAAA;gBAC/BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;IACF,CAAA;AAEA,eAAeF,iBAAgB"}
1
+ {"version":3,"sources":["../../src/schema/fieldToWhereInputSchemaMap.ts"],"sourcesContent":["import type {\n ArrayField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SelectField,\n TabsField,\n TextField,\n TextareaField,\n UploadField,\n} from 'payload'\n\nimport { GraphQLEnumType, GraphQLInputObjectType } from 'graphql'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport combineParentName from '../utilities/combineParentName.js'\nimport formatName from '../utilities/formatName.js'\nimport recursivelyBuildNestedPaths from './recursivelyBuildNestedPaths.js'\nimport { withOperators } from './withOperators.js'\n\ntype Args = {\n nestedFieldName?: string\n parentName: string\n}\n\nconst fieldToSchemaMap = ({ nestedFieldName, parentName }: Args): any => ({\n array: (field: ArrayField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n checkbox: (field: CheckboxField) => ({\n type: withOperators(field, parentName),\n }),\n code: (field: CodeField) => ({\n type: withOperators(field, parentName),\n }),\n collapsible: (field: CollapsibleField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n date: (field: DateField) => ({\n type: withOperators(field, parentName),\n }),\n email: (field: EmailField) => ({\n type: withOperators(field, parentName),\n }),\n group: (field: GroupField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n json: (field: JSONField) => ({\n type: withOperators(field, parentName),\n }),\n number: (field: NumberField) => ({\n type: withOperators(field, parentName),\n }),\n point: (field: PointField) => ({\n type: withOperators(field, parentName),\n }),\n radio: (field: RadioField) => ({\n type: withOperators(field, parentName),\n }),\n relationship: (field: RelationshipField) => {\n if (Array.isArray(field.relationTo)) {\n return {\n type: new GraphQLInputObjectType({\n name: `${combineParentName(parentName, field.name)}_Relation`,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Relation_RelationTo`,\n values: field.relationTo.reduce(\n (values, relation) => ({\n ...values,\n [formatName(relation)]: {\n value: relation,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n }),\n }\n }\n\n return {\n type: withOperators(field, parentName),\n }\n },\n richText: (field: RichTextField) => ({\n type: withOperators(field, parentName),\n }),\n row: (field: RowField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n select: (field: SelectField) => ({\n type: withOperators(field, parentName),\n }),\n tabs: (field: TabsField) =>\n recursivelyBuildNestedPaths({\n field,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n text: (field: TextField) => ({\n type: withOperators(field, parentName),\n }),\n textarea: (field: TextareaField) => ({\n type: withOperators(field, parentName),\n }),\n upload: (field: UploadField) => ({\n type: withOperators(field, parentName),\n }),\n})\n\nexport default fieldToSchemaMap\n"],"names":["GraphQLEnumType","GraphQLInputObjectType","GraphQLJSON","combineParentName","formatName","recursivelyBuildNestedPaths","withOperators","fieldToSchemaMap","nestedFieldName","parentName","array","field","nestedFieldName2","checkbox","type","code","collapsible","date","email","group","json","number","point","radio","relationship","Array","isArray","relationTo","name","fields","values","reduce","relation","value","richText","row","select","tabs","text","textarea","upload"],"mappings":"AAsBA,SAASA,eAAe,EAAEC,sBAAsB,QAAQ,UAAS;AAEjE,SAASC,WAAW,QAAQ,yCAAwC;AACpE,OAAOC,uBAAuB,oCAAmC;AACjE,OAAOC,gBAAgB,6BAA4B;AACnD,OAAOC,iCAAiC,mCAAkC;AAC1E,SAASC,aAAa,QAAQ,qBAAoB;AAOlD,MAAMC,mBAAmB,CAAC,EAAEC,eAAe,EAAEC,UAAU,EAAQ,GAAW,CAAA;QACxEC,OAAO,CAACC,QACNN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACFI,UAAU,CAACF,QAA0B,CAAA;gBACnCG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAM,MAAM,CAACJ,QAAsB,CAAA;gBAC3BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAO,aAAa,CAACL,QACZN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACFQ,MAAM,CAACN,QAAsB,CAAA;gBAC3BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAS,OAAO,CAACP,QAAuB,CAAA;gBAC7BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAU,OAAO,CAACR,QACNN,4BAA4B;gBAC1BM;gBACAC,kBAAkBJ;gBAClBC;YACF;QACFW,MAAM,CAACT,QAAsB,CAAA;gBAC3BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAY,QAAQ,CAACV,QAAwB,CAAA;gBAC/BG,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;QACAa,OAAO,CAACX,QAAuB,CAAA;gBAC7BG,MAAMR,cAAcK,OAAOF;YAC7B,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,MAAMR,cAAcK,OAAOF;YAC7B,CAAA;IACF,CAAA;AAEA,eAAeF,iBAAgB"}
@@ -24,7 +24,7 @@ import { updateResolver } from '../resolvers/collections/update.js';
24
24
  import formatName from '../utilities/formatName.js';
25
25
  import { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js';
26
26
  import { buildObjectType } from './buildObjectType.js';
27
- import buildPaginatedListType from './buildPaginatedListType.js';
27
+ import { buildPaginatedListType } from './buildPaginatedListType.js';
28
28
  import { buildPolicyType } from './buildPoliciesType.js';
29
29
  import buildWhereInputType from './buildWhereInputType.js';
30
30
  function initCollectionsGraphQL({ config, graphqlResult }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { GraphQLInfo } from 'payload'\nimport type { Collection, Field, SanitizedCollectionConfig, SanitizedConfig } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport forgotPassword from '../resolvers/auth/forgotPassword.js'\nimport init from '../resolvers/auth/init.js'\nimport login from '../resolvers/auth/login.js'\nimport logout from '../resolvers/auth/logout.js'\nimport me from '../resolvers/auth/me.js'\nimport refresh from '../resolvers/auth/refresh.js'\nimport resetPassword from '../resolvers/auth/resetPassword.js'\nimport unlock from '../resolvers/auth/unlock.js'\nimport verifyEmail from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport createResolver from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport duplicateResolver from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport restoreVersionResolver from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport formatName from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport buildPaginatedListType from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport buildWhereInputType from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nfunction initCollectionsGraphQL({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) return\n\n let singularName\n let pluralName\n const fromSlug = formatNames(collection.config.slug)\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: idType }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n fields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: true,\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields,\n graphqlResult,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: fields.filter((field) => !(fieldAffectsData(field) && field.name === 'id')),\n forceNullable: true,\n graphqlResult,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: docAccessResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: duplicateResolver(collection),\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] = collectionConfig.auth.disableLocalStrategy\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n args: {\n token: { type: GraphQLString },\n },\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n email: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n email: { type: GraphQLString },\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n disableEmail: { type: GraphQLBoolean },\n email: { type: new GraphQLNonNull(GraphQLString) },\n expiration: { type: GraphQLInt },\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n })\n}\n\nexport default initCollectionsGraphQL\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollectionsGraphQL","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","forceNullable","parentName","paginatedType","whereInputType","auth","disableLocalStrategy","label","required","createMutationInputType","mutationInputType","updateMutationInputType","filter","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","versionType","authFields","JWT","saveToJWT","exp","token","user","refreshedToken","maxLoginAttempts","email","password","disableEmail","expiration"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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c;wBAChC2G,OAAO;4BAAE9C,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAAS3E,cAAc6B;gBACzB;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,WAAW,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC5De,MAAMjE;oBACNmF,MAAM;wBACJ4B,OAAO;4BAAE9C,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAASzE,YAAY2B;gBACvB;YACF;QACF;IACF;AACF;AAEA,eAAeR,uBAAsB"}
1
+ {"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { GraphQLInfo } from 'payload'\nimport type { Collection, Field, SanitizedCollectionConfig, SanitizedConfig } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ObjectTypeConfig } from './buildObjectType.js'\n\nimport forgotPassword from '../resolvers/auth/forgotPassword.js'\nimport init from '../resolvers/auth/init.js'\nimport login from '../resolvers/auth/login.js'\nimport logout from '../resolvers/auth/logout.js'\nimport me from '../resolvers/auth/me.js'\nimport refresh from '../resolvers/auth/refresh.js'\nimport resetPassword from '../resolvers/auth/resetPassword.js'\nimport unlock from '../resolvers/auth/unlock.js'\nimport verifyEmail from '../resolvers/auth/verifyEmail.js'\nimport { countResolver } from '../resolvers/collections/count.js'\nimport createResolver from '../resolvers/collections/create.js'\nimport { getDeleteResolver } from '../resolvers/collections/delete.js'\nimport { docAccessResolver } from '../resolvers/collections/docAccess.js'\nimport duplicateResolver from '../resolvers/collections/duplicate.js'\nimport { findResolver } from '../resolvers/collections/find.js'\nimport { findByIDResolver } from '../resolvers/collections/findByID.js'\nimport { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'\nimport { findVersionsResolver } from '../resolvers/collections/findVersions.js'\nimport restoreVersionResolver from '../resolvers/collections/restoreVersion.js'\nimport { updateResolver } from '../resolvers/collections/update.js'\nimport formatName from '../utilities/formatName.js'\nimport { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport buildWhereInputType from './buildWhereInputType.js'\n\ntype InitCollectionsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nfunction initCollectionsGraphQL({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {\n Object.keys(graphqlResult.collections).forEach((slug) => {\n const collection: Collection = graphqlResult.collections[slug]\n const {\n config: collectionConfig,\n config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },\n } = collection\n\n if (!graphQL) return\n\n let singularName\n let pluralName\n const fromSlug = formatNames(collection.config.slug)\n if (graphQL.singularName) {\n singularName = toWords(graphQL.singularName, true)\n } else {\n singularName = fromSlug.singular\n }\n if (graphQL.pluralName) {\n pluralName = toWords(graphQL.pluralName, true)\n } else {\n pluralName = fromSlug.plural\n }\n\n // For collections named 'Media' or similar,\n // there is a possibility that the singular name\n // will equal the plural name. Append `all` to the beginning\n // of potential conflicts\n if (singularName === pluralName) {\n pluralName = `all${singularName}`\n }\n\n collection.graphQL = {} as Collection['graphQL']\n\n const hasIDField =\n flattenTopLevelFields(fields).findIndex(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) > -1\n\n const idType = getCollectionIDType(config.db.defaultIDType, collectionConfig)\n\n const baseFields: ObjectTypeConfig = {}\n\n const whereInputFields = [...fields]\n\n if (!hasIDField) {\n baseFields.id = { type: idType }\n whereInputFields.push({\n name: 'id',\n type: config.db.defaultIDType as 'text',\n })\n }\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n collection.graphQL.type = buildObjectType({\n name: singularName,\n baseFields,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: singularName,\n })\n\n collection.graphQL.paginatedType = buildPaginatedListType(pluralName, collection.graphQL.type)\n\n collection.graphQL.whereInputType = buildWhereInputType({\n name: singularName,\n fields: whereInputFields,\n parentName: singularName,\n })\n\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n fields.push({\n name: 'password',\n type: 'text',\n label: 'Password',\n required: true,\n })\n }\n\n const createMutationInputType = buildMutationInputType({\n name: singularName,\n config,\n fields,\n graphqlResult,\n parentName: singularName,\n })\n if (createMutationInputType) {\n collection.graphQL.mutationInputType = new GraphQLNonNull(createMutationInputType)\n }\n\n const updateMutationInputType = buildMutationInputType({\n name: `${singularName}Update`,\n config,\n fields: fields.filter((field) => !(fieldAffectsData(field) && field.name === 'id')),\n forceNullable: true,\n graphqlResult,\n parentName: `${singularName}Update`,\n })\n if (updateMutationInputType) {\n collection.graphQL.updateMutationInputType = new GraphQLNonNull(updateMutationInputType)\n }\n\n graphqlResult.Query.fields[singularName] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findByIDResolver(collection),\n }\n\n graphqlResult.Query.fields[pluralName] = {\n type: buildPaginatedListType(pluralName, collection.graphQL.type),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findResolver(collection),\n }\n\n graphqlResult.Query.fields[`count${pluralName}`] = {\n type: new GraphQLObjectType({\n name: `count${pluralName}`,\n fields: {\n totalDocs: { type: GraphQLInt },\n },\n }),\n args: {\n draft: { type: GraphQLBoolean },\n where: { type: collection.graphQL.whereInputType },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: countResolver(collection),\n }\n\n graphqlResult.Query.fields[`docAccess${singularName}`] = {\n type: buildPolicyType({\n type: 'collection',\n entity: collectionConfig,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: docAccessResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`create${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n ...(createMutationInputType\n ? { data: { type: collection.graphQL.mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: createResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`update${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n autosave: { type: GraphQLBoolean },\n ...(updateMutationInputType\n ? { data: { type: collection.graphQL.updateMutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: updateResolver(collection),\n }\n\n graphqlResult.Mutation.fields[`delete${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: getDeleteResolver(collection),\n }\n\n if (collectionConfig.disableDuplicate !== true) {\n graphqlResult.Mutation.fields[`duplicate${singularName}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: new GraphQLNonNull(idType) },\n },\n resolve: duplicateResolver(collection),\n }\n }\n\n if (collectionConfig.versions) {\n const versionIDType = config.db.defaultIDType === 'text' ? GraphQLString : GraphQLInt\n const versionCollectionFields: Field[] = [\n ...buildVersionCollectionFields(collectionConfig),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n collection.graphQL.versionType = buildObjectType({\n name: `${singularName}Version`,\n config,\n fields: versionCollectionFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${singularName}Version`,\n })\n\n graphqlResult.Query.fields[`version${formatName(singularName)}`] = {\n type: collection.graphQL.versionType,\n args: {\n id: { type: versionIDType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(collection),\n }\n graphqlResult.Query.fields[`versions${pluralName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(pluralName)}`,\n collection.graphQL.versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${singularName}`,\n fields: versionCollectionFields,\n parentName: `versions${singularName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(collection),\n }\n graphqlResult.Mutation.fields[`restoreVersion${formatName(singularName)}`] = {\n type: collection.graphQL.type,\n args: {\n id: { type: versionIDType },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] = collectionConfig.auth.disableLocalStrategy\n ? []\n : [\n {\n name: 'email',\n type: 'email',\n required: true,\n },\n ]\n collection.graphQL.JWT = buildObjectType({\n name: formatName(`${slug}JWT`),\n config,\n fields: [\n ...collectionConfig.fields.filter((field) => fieldAffectsData(field) && field.saveToJWT),\n ...authFields,\n {\n name: 'collection',\n type: 'text',\n required: true,\n },\n ],\n graphqlResult,\n parentName: formatName(`${slug}JWT`),\n })\n\n graphqlResult.Query.fields[`me${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Me`),\n fields: {\n collection: {\n type: GraphQLString,\n },\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n resolve: me(collection),\n }\n\n graphqlResult.Query.fields[`initialized${singularName}`] = {\n type: GraphQLBoolean,\n resolve: init(collection.config.slug),\n }\n\n graphqlResult.Mutation.fields[`refreshToken${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}Refreshed${singularName}`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n refreshedToken: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\n }),\n args: {\n token: { type: GraphQLString },\n },\n resolve: refresh(collection),\n }\n\n graphqlResult.Mutation.fields[`logout${singularName}`] = {\n type: GraphQLString,\n resolve: logout(collection),\n }\n\n if (!collectionConfig.auth.disableLocalStrategy) {\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n email: { type: new GraphQLNonNull(GraphQLString) },\n },\n resolve: unlock(collection),\n }\n }\n\n graphqlResult.Mutation.fields[`login${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}LoginResult`),\n fields: {\n exp: {\n type: GraphQLInt,\n },\n token: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.type,\n },\n },\n }),\n args: {\n email: { type: GraphQLString },\n password: { type: GraphQLString },\n },\n resolve: login(collection),\n }\n\n graphqlResult.Mutation.fields[`forgotPassword${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: {\n disableEmail: { type: GraphQLBoolean },\n email: { type: new GraphQLNonNull(GraphQLString) },\n expiration: { type: GraphQLInt },\n },\n resolve: forgotPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`resetPassword${singularName}`] = {\n type: new GraphQLObjectType({\n name: formatName(`${slug}ResetPassword`),\n fields: {\n token: { type: GraphQLString },\n user: { type: collection.graphQL.type },\n },\n }),\n args: {\n password: { type: GraphQLString },\n token: { type: GraphQLString },\n },\n resolve: resetPassword(collection),\n }\n\n graphqlResult.Mutation.fields[`verifyEmail${singularName}`] = {\n type: GraphQLBoolean,\n args: {\n token: { type: GraphQLString },\n },\n resolve: verifyEmail(collection),\n }\n }\n }\n })\n}\n\nexport default initCollectionsGraphQL\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLObjectType","GraphQLString","buildVersionCollectionFields","flattenTopLevelFields","formatNames","toWords","fieldAffectsData","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","countResolver","createResolver","getDeleteResolver","docAccessResolver","duplicateResolver","findResolver","findByIDResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","getCollectionIDType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initCollectionsGraphQL","config","graphqlResult","Object","keys","collections","forEach","slug","collection","collectionConfig","fields","graphQL","versions","singularName","pluralName","fromSlug","singular","plural","hasIDField","findIndex","field","name","idType","db","defaultIDType","baseFields","whereInputFields","id","type","push","forceNullableObjectType","Boolean","drafts","forceNullable","parentName","paginatedType","whereInputType","auth","disableLocalStrategy","label","required","createMutationInputType","mutationInputType","updateMutationInputType","filter","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","where","limit","page","sort","totalDocs","entity","scope","typeSuffix","Mutation","data","autosave","disableDuplicate","versionIDType","versionCollectionFields","versionType","authFields","JWT","saveToJWT","exp","token","user","refreshedToken","maxLoginAttempts","email","password","disableEmail","expiration"],"mappings":"AAAA,oCAAoC,GAIpC,SACEA,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,aAAa,QACR,UAAS;AAChB,SAASC,4BAA4B,EAAEC,qBAAqB,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAS;AACnG,SAASC,gBAAgB,QAAQ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C,cAAc;4BAAEpD,MAAMjE;wBAAe;wBACrCmH,OAAO;4BAAElD,MAAM,IAAI/D,eAAeE;wBAAe;wBACjDkH,YAAY;4BAAErD,MAAMhE;wBAAW;oBACjC;oBACA0F,SAASjF,eAAemC;gBAC1B;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,aAAa,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC9De,MAAM,IAAI9D,kBAAkB;wBAC1BuD,MAAM5B,WAAW,CAAC,EAAEc,KAAK,aAAa,CAAC;wBACvCG,QAAQ;4BACNgE,OAAO;gCAAE9C,MAAM7D;4BAAc;4BAC7B4G,MAAM;gCAAE/C,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;4BAAC;wBACxC;oBACF;oBACAkB,MAAM;wBACJiC,UAAU;4BAAEnD,MAAM7D;wBAAc;wBAChC2G,OAAO;4BAAE9C,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAAS3E,cAAc6B;gBACzB;gBAEAN,cAAc6D,QAAQ,CAACrD,MAAM,CAAC,CAAC,WAAW,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC5De,MAAMjE;oBACNmF,MAAM;wBACJ4B,OAAO;4BAAE9C,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAASzE,YAAY2B;gBACvB;YACF;QACF;IACF;AACF;AAEA,eAAeR,uBAAsB"}
@@ -11,7 +11,7 @@ import updateResolver from '../resolvers/globals/update.js';
11
11
  import formatName from '../utilities/formatName.js';
12
12
  import { buildMutationInputType } from './buildMutationInputType.js';
13
13
  import { buildObjectType } from './buildObjectType.js';
14
- import buildPaginatedListType from './buildPaginatedListType.js';
14
+ import { buildPaginatedListType } from './buildPaginatedListType.js';
15
15
  import { buildPolicyType } from './buildPoliciesType.js';
16
16
  import buildWhereInputType from './buildWhereInputType.js';
17
17
  function initGlobalsGraphQL({ config, graphqlResult }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/initGlobals.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport findOneResolver from '../resolvers/globals/findOne.js'\nimport findVersionByIDResolver from '../resolvers/globals/findVersionByID.js'\nimport findVersionsResolver from '../resolvers/globals/findVersions.js'\nimport restoreVersionResolver from '../resolvers/globals/restoreVersion.js'\nimport updateResolver from '../resolvers/globals/update.js'\nimport formatName from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport buildPaginatedListType from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport buildWhereInputType from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nfunction initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL, versions } = global\n\n if (graphQL === false) {\n return\n }\n\n const formattedName = graphQL?.name ? graphQL.name : singular(toWords(global.slug, true))\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n if (!graphqlResult.globals.graphQL) graphqlResult.globals.graphQL = {}\n\n const updateMutationInputType = buildMutationInputType({\n name: formattedName,\n config,\n fields,\n graphqlResult,\n parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findOneResolver(global),\n }\n\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: updateResolver(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(global),\n }\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n },\n resolve: restoreVersionResolver(global),\n }\n }\n })\n}\n\nexport default initGlobalsGraphQL\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","docAccessResolver","findOneResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobalsGraphQL","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","versions","formattedName","name","forceNullableObjectType","Boolean","drafts","updateMutationInputType","parentName","type","forceNullable","mutationInputType","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","Mutation","data","entity","scope","typeSuffix","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","sort"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GACpC,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,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CAAC;4BAChCH,QAAQ+B;4BACRtB,YAAY,CAAC,QAAQ,EAAEN,cAAc,CAAC;wBACxC;oBACF;oBACA,GAAIX,OAAOwB,YAAY,GACnB;wBACEC,gBAAgB;4BAAEP,MAAMjB,cAAcyB,KAAK,CAACC,uBAAuB;wBAAC;wBACpEC,QAAQ;4BAAEV,MAAMjB,cAAcyB,KAAK,CAACG,eAAe;wBAAC;oBACtD,IACA,CAAC,CAAC;oBACNe,OAAO;wBAAE1B,MAAMtC;oBAAW;oBAC1BiE,MAAM;wBAAE3B,MAAMtC;oBAAW;oBACzBkE,MAAM;wBAAE5B,MAAMpC;oBAAc;gBAC9B;gBACAgD,SAASxC,qBAAqBiB;YAChC;YACAN,cAAc8B,QAAQ,CAACvB,MAAM,CAAC,CAAC,cAAc,EAAEf,WAAWkB,eAAe,CAAC,CAAC,GAAG;gBAC5EO,MAAMjB,cAAcG,OAAO,CAACK,OAAO,CAACH,KAAK,CAACY,IAAI;gBAC9CI,MAAM;oBACJoB,IAAI;wBAAExB,MAAMkB;oBAAO;gBACrB;gBACAN,SAASvC,uBAAuBgB;YAClC;QACF;IACF;AACF;AAEA,eAAeR,mBAAkB"}
1
+ {"version":3,"sources":["../../src/schema/initGlobals.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql'\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { buildVersionGlobalFields, toWords } from 'payload'\n\nimport { docAccessResolver } from '../resolvers/globals/docAccess.js'\nimport findOneResolver from '../resolvers/globals/findOne.js'\nimport findVersionByIDResolver from '../resolvers/globals/findVersionByID.js'\nimport findVersionsResolver from '../resolvers/globals/findVersions.js'\nimport restoreVersionResolver from '../resolvers/globals/restoreVersion.js'\nimport updateResolver from '../resolvers/globals/update.js'\nimport formatName from '../utilities/formatName.js'\nimport { buildMutationInputType } from './buildMutationInputType.js'\nimport { buildObjectType } from './buildObjectType.js'\nimport { buildPaginatedListType } from './buildPaginatedListType.js'\nimport { buildPolicyType } from './buildPoliciesType.js'\nimport buildWhereInputType from './buildWhereInputType.js'\n\ntype InitGlobalsGraphQLArgs = {\n config: SanitizedConfig\n graphqlResult: GraphQLInfo\n}\nfunction initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {\n Object.keys(graphqlResult.globals.config).forEach((slug) => {\n const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]\n const { fields, graphQL, versions } = global\n\n if (graphQL === false) {\n return\n }\n\n const formattedName = graphQL?.name ? graphQL.name : singular(toWords(global.slug, true))\n\n const forceNullableObjectType = Boolean(versions?.drafts)\n\n if (!graphqlResult.globals.graphQL) graphqlResult.globals.graphQL = {}\n\n const updateMutationInputType = buildMutationInputType({\n name: formattedName,\n config,\n fields,\n graphqlResult,\n parentName: formattedName,\n })\n graphqlResult.globals.graphQL[slug] = {\n type: buildObjectType({\n name: formattedName,\n config,\n fields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: formattedName,\n }),\n mutationInputType: updateMutationInputType\n ? new GraphQLNonNull(updateMutationInputType)\n : null,\n }\n\n graphqlResult.Query.fields[formattedName] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findOneResolver(global),\n }\n\n graphqlResult.Mutation.fields[`update${formattedName}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n ...(updateMutationInputType\n ? { data: { type: graphqlResult.globals.graphQL[slug].mutationInputType } }\n : {}),\n draft: { type: GraphQLBoolean },\n ...(config.localization\n ? {\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: updateResolver(global),\n }\n\n graphqlResult.Query.fields[`docAccess${formattedName}`] = {\n type: buildPolicyType({\n type: 'global',\n entity: global,\n scope: 'docAccess',\n typeSuffix: 'DocAccess',\n }),\n resolve: docAccessResolver(global),\n }\n\n if (global.versions) {\n const idType = config.db.defaultIDType === 'number' ? GraphQLInt : GraphQLString\n\n const versionGlobalFields: Field[] = [\n ...buildVersionGlobalFields(global),\n {\n name: 'id',\n type: config.db.defaultIDType as 'text',\n },\n {\n name: 'createdAt',\n type: 'date',\n label: 'Created At',\n },\n {\n name: 'updatedAt',\n type: 'date',\n label: 'Updated At',\n },\n ]\n\n graphqlResult.globals.graphQL[slug].versionType = buildObjectType({\n name: `${formattedName}Version`,\n config,\n fields: versionGlobalFields,\n forceNullable: forceNullableObjectType,\n graphqlResult,\n parentName: `${formattedName}Version`,\n })\n\n graphqlResult.Query.fields[`version${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].versionType,\n args: {\n id: { type: idType },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n },\n resolve: findVersionByIDResolver(global),\n }\n graphqlResult.Query.fields[`versions${formattedName}`] = {\n type: buildPaginatedListType(\n `versions${formatName(formattedName)}`,\n graphqlResult.globals.graphQL[slug].versionType,\n ),\n args: {\n where: {\n type: buildWhereInputType({\n name: `versions${formattedName}`,\n fields: versionGlobalFields,\n parentName: `versions${formattedName}`,\n }),\n },\n ...(config.localization\n ? {\n fallbackLocale: { type: graphqlResult.types.fallbackLocaleInputType },\n locale: { type: graphqlResult.types.localeInputType },\n }\n : {}),\n limit: { type: GraphQLInt },\n page: { type: GraphQLInt },\n sort: { type: GraphQLString },\n },\n resolve: findVersionsResolver(global),\n }\n graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {\n type: graphqlResult.globals.graphQL[slug].type,\n args: {\n id: { type: idType },\n },\n resolve: restoreVersionResolver(global),\n }\n }\n })\n}\n\nexport default initGlobalsGraphQL\n"],"names":["GraphQLBoolean","GraphQLInt","GraphQLNonNull","GraphQLString","pluralize","singular","buildVersionGlobalFields","toWords","docAccessResolver","findOneResolver","findVersionByIDResolver","findVersionsResolver","restoreVersionResolver","updateResolver","formatName","buildMutationInputType","buildObjectType","buildPaginatedListType","buildPolicyType","buildWhereInputType","initGlobalsGraphQL","config","graphqlResult","Object","keys","globals","forEach","slug","global","fields","graphQL","versions","formattedName","name","forceNullableObjectType","Boolean","drafts","updateMutationInputType","parentName","type","forceNullable","mutationInputType","Query","args","draft","localization","fallbackLocale","types","fallbackLocaleInputType","locale","localeInputType","resolve","Mutation","data","entity","scope","typeSuffix","idType","db","defaultIDType","versionGlobalFields","label","versionType","id","where","limit","page","sort"],"mappings":"AAAA,oCAAoC,GACpC,SAASA,cAAc,EAAEC,UAAU,EAAEC,cAAc,EAAEC,aAAa,QAAQ,UAAS;AACnF,OAAOC,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAIrB,SAASE,wBAAwB,EAAEC,OAAO,QAAQ,UAAS;AAE3D,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,OAAOC,qBAAqB,kCAAiC;AAC7D,OAAOC,6BAA6B,0CAAyC;AAC7E,OAAOC,0BAA0B,uCAAsC;AACvE,OAAOC,4BAA4B,yCAAwC;AAC3E,OAAOC,oBAAoB,iCAAgC;AAC3D,OAAOC,gBAAgB,6BAA4B;AACnD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,OAAOC,yBAAyB,2BAA0B;AAM1D,SAASC,mBAAmB,EAAEC,MAAM,EAAEC,aAAa,EAA0B;IAC3EC,OAAOC,IAAI,CAACF,cAAcG,OAAO,CAACJ,MAAM,EAAEK,OAAO,CAAC,CAACC;QACjD,MAAMC,SAAgCN,cAAcG,OAAO,CAACJ,MAA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,SAASvC,uBAAuBgB;YAClC;QACF;IACF;AACF;AAEA,eAAeR,mBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/isFieldNullable.ts"],"sourcesContent":["import type { FieldAffectingData } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nconst isFieldNullable = (field: FieldAffectingData, force: boolean): boolean => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n return !(\n force &&\n fieldAffectsData(field) &&\n 'required' in field &&\n field.required &&\n !field.localized &&\n !condition &&\n !hasReadAccessControl\n )\n}\n\nexport default isFieldNullable\n"],"names":["fieldAffectsData","isFieldNullable","field","force","hasReadAccessControl","access","read","condition","admin","required","localized"],"rangeMappings":";;;;;;","mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,MAAMC,kBAAkB,CAACC,OAA2BC;IAClD,MAAMC,uBAAuBF,MAAMG,MAAM,IAAIH,MAAMG,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYL,MAAMM,KAAK,IAAIN,MAAMM,KAAK,CAACD,SAAS;IACtD,OAAO,CACLJ,CAAAA,SACAH,iBAAiBE,UACjB,cAAcA,SACdA,MAAMO,QAAQ,IACd,CAACP,MAAMQ,SAAS,IAChB,CAACH,aACD,CAACH,oBAAmB;AAExB;AAEA,eAAeH,gBAAe"}
1
+ {"version":3,"sources":["../../src/schema/isFieldNullable.ts"],"sourcesContent":["import type { FieldAffectingData } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nconst isFieldNullable = (field: FieldAffectingData, force: boolean): boolean => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n return !(\n force &&\n fieldAffectsData(field) &&\n 'required' in field &&\n field.required &&\n !field.localized &&\n !condition &&\n !hasReadAccessControl\n )\n}\n\nexport default isFieldNullable\n"],"names":["fieldAffectsData","isFieldNullable","field","force","hasReadAccessControl","access","read","condition","admin","required","localized"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,MAAMC,kBAAkB,CAACC,OAA2BC;IAClD,MAAMC,uBAAuBF,MAAMG,MAAM,IAAIH,MAAMG,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYL,MAAMM,KAAK,IAAIN,MAAMM,KAAK,CAACD,SAAS;IACtD,OAAO,CACLJ,CAAAA,SACAH,iBAAiBE,UACjB,cAAcA,SACdA,MAAMO,QAAQ,IACd,CAACP,MAAMQ,SAAS,IAChB,CAACH,aACD,CAACH,oBAAmB;AAExB;AAEA,eAAeH,gBAAe"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/operators.ts"],"sourcesContent":["const operators = {\n comparison: ['greater_than_equal', 'greater_than', 'less_than_equal', 'less_than'],\n contains: ['in', 'not_in', 'all'],\n equality: ['equals', 'not_equals'],\n geo: ['near'],\n geojson: ['within', 'intersects'],\n partial: ['like', 'contains'],\n}\n\nexport default operators\n"],"names":["operators","comparison","contains","equality","geo","geojson","partial"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,YAAY;IAChBC,YAAY;QAAC;QAAsB;QAAgB;QAAmB;KAAY;IAClFC,UAAU;QAAC;QAAM;QAAU;KAAM;IACjCC,UAAU;QAAC;QAAU;KAAa;IAClCC,KAAK;QAAC;KAAO;IACbC,SAAS;QAAC;QAAU;KAAa;IACjCC,SAAS;QAAC;QAAQ;KAAW;AAC/B;AAEA,eAAeN,UAAS"}
1
+ {"version":3,"sources":["../../src/schema/operators.ts"],"sourcesContent":["const operators = {\n comparison: ['greater_than_equal', 'greater_than', 'less_than_equal', 'less_than'],\n contains: ['in', 'not_in', 'all'],\n equality: ['equals', 'not_equals'],\n geo: ['near'],\n geojson: ['within', 'intersects'],\n partial: ['like', 'contains'],\n}\n\nexport default operators\n"],"names":["operators","comparison","contains","equality","geo","geojson","partial"],"mappings":"AAAA,MAAMA,YAAY;IAChBC,YAAY;QAAC;QAAsB;QAAgB;QAAmB;KAAY;IAClFC,UAAU;QAAC;QAAM;QAAU;KAAM;IACjCC,UAAU;QAAC;QAAU;KAAa;IAClCC,KAAK;QAAC;KAAO;IACbC,SAAS;QAAC;QAAU;KAAa;IACjCC,SAAS;QAAC;QAAQ;KAAW;AAC/B;AAEA,eAAeN,UAAS"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/recursivelyBuildNestedPaths.ts"],"sourcesContent":["import type { FieldWithSubFields, TabsField } from 'payload'\n\nimport { fieldAffectsData, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport fieldToSchemaMap from './fieldToWhereInputSchemaMap.js'\n\ntype Args = {\n field: FieldWithSubFields | TabsField\n nestedFieldName2: string\n parentName: string\n}\n\nconst recursivelyBuildNestedPaths = ({ field, nestedFieldName2, parentName }: Args) => {\n const fieldName = fieldAffectsData(field) ? field.name : undefined\n const nestedFieldName = fieldName || nestedFieldName2\n\n if (field.type === 'tabs') {\n // if the tab has a name, treat it as a group\n // otherwise, treat it as a row\n return field.tabs.reduce((tabSchema, tab: any) => {\n tabSchema.push(\n ...recursivelyBuildNestedPaths({\n field: {\n ...tab,\n type: 'name' in tab ? 'group' : 'row',\n },\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n )\n return tabSchema\n }, [])\n }\n\n const nestedPaths = field.fields.reduce((nestedFields, nestedField) => {\n if (!fieldIsPresentationalOnly(nestedField)) {\n if (!fieldAffectsData(nestedField)) {\n return [\n ...nestedFields,\n ...recursivelyBuildNestedPaths({\n field: nestedField,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n ]\n }\n\n const nestedPathName = fieldAffectsData(nestedField)\n ? `${nestedFieldName ? `${nestedFieldName}__` : ''}${nestedField.name}`\n : undefined\n const getFieldSchema = fieldToSchemaMap({\n nestedFieldName,\n parentName,\n })[nestedField.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema({\n ...nestedField,\n name: nestedPathName,\n })\n\n if (Array.isArray(fieldSchema)) {\n return [...nestedFields, ...fieldSchema]\n }\n\n return [\n ...nestedFields,\n {\n type: fieldSchema,\n key: nestedPathName,\n },\n ]\n }\n }\n\n return nestedFields\n }, [])\n\n return nestedPaths\n}\n\nexport default recursivelyBuildNestedPaths\n"],"names":["fieldAffectsData","fieldIsPresentationalOnly","fieldToSchemaMap","recursivelyBuildNestedPaths","field","nestedFieldName2","parentName","fieldName","name","undefined","nestedFieldName","type","tabs","reduce","tabSchema","tab","push","nestedPaths","fields","nestedFields","nestedField","nestedPathName","getFieldSchema","fieldSchema","Array","isArray","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,gBAAgB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE5E,OAAOC,sBAAsB,kCAAiC;AAQ9D,MAAMC,8BAA8B,CAAC,EAAEC,KAAK,EAAEC,gBAAgB,EAAEC,UAAU,EAAQ;IAChF,MAAMC,YAAYP,iBAAiBI,SAASA,MAAMI,IAAI,GAAGC;IACzD,MAAMC,kBAAkBH,aAAaF;IAErC,IAAID,MAAMO,IAAI,KAAK,QAAQ;QACzB,6CAA6C;QAC7C,+BAA+B;QAC/B,OAAOP,MAAMQ,IAAI,CAACC,MAAM,CAAC,CAACC,WAAWC;YACnCD,UAAUE,IAAI,IACTb,4BAA4B;gBAC7BC,OAAO;oBACL,GAAGW,GAAG;oBACNJ,MAAM,UAAUI,MAAM,UAAU;gBAClC;gBACAV,kBAAkBK;gBAClBJ;YACF;YAEF,OAAOQ;QACT,GAAG,EAAE;IACP;IAEA,MAAMG,cAAcb,MAAMc,MAAM,CAACL,MAAM,CAAC,CAACM,cAAcC;QACrD,IAAI,CAACnB,0BAA0BmB,cAAc;YAC3C,IAAI,CAACpB,iBAAiBoB,cAAc;gBAClC,OAAO;uBACFD;uBACAhB,4BAA4B;wBAC7BC,OAAOgB;wBACPf,kBAAkBK;wBAClBJ;oBACF;iBACD;YACH;YAEA,MAAMe,iBAAiBrB,iBAAiBoB,eACpC,CAAC,EAAEV,kBAAkB,CAAC,EAAEA,gBAAgB,EAAE,CAAC,GAAG,GAAG,EAAEU,YAAYZ,IAAI,CAAC,CAAC,GACrEC;YACJ,MAAMa,iBAAiBpB,iBAAiB;gBACtCQ;gBACAJ;YACF,EAAE,CAACc,YAAYT,IAAI,CAAC;YAEpB,IAAIW,gBAAgB;gBAClB,MAAMC,cAAcD,eAAe;oBACjC,GAAGF,WAAW;oBACdZ,MAAMa;gBACR;gBAEA,IAAIG,MAAMC,OAAO,CAACF,cAAc;oBAC9B,OAAO;2BAAIJ;2BAAiBI;qBAAY;gBAC1C;gBAEA,OAAO;uBACFJ;oBACH;wBACER,MAAMY;wBACNG,KAAKL;oBACP;iBACD;YACH;QACF;QAEA,OAAOF;IACT,GAAG,EAAE;IAEL,OAAOF;AACT;AAEA,eAAed,4BAA2B"}
1
+ {"version":3,"sources":["../../src/schema/recursivelyBuildNestedPaths.ts"],"sourcesContent":["import type { FieldWithSubFields, TabsField } from 'payload'\n\nimport { fieldAffectsData, fieldIsPresentationalOnly } from 'payload/shared'\n\nimport fieldToSchemaMap from './fieldToWhereInputSchemaMap.js'\n\ntype Args = {\n field: FieldWithSubFields | TabsField\n nestedFieldName2: string\n parentName: string\n}\n\nconst recursivelyBuildNestedPaths = ({ field, nestedFieldName2, parentName }: Args) => {\n const fieldName = fieldAffectsData(field) ? field.name : undefined\n const nestedFieldName = fieldName || nestedFieldName2\n\n if (field.type === 'tabs') {\n // if the tab has a name, treat it as a group\n // otherwise, treat it as a row\n return field.tabs.reduce((tabSchema, tab: any) => {\n tabSchema.push(\n ...recursivelyBuildNestedPaths({\n field: {\n ...tab,\n type: 'name' in tab ? 'group' : 'row',\n },\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n )\n return tabSchema\n }, [])\n }\n\n const nestedPaths = field.fields.reduce((nestedFields, nestedField) => {\n if (!fieldIsPresentationalOnly(nestedField)) {\n if (!fieldAffectsData(nestedField)) {\n return [\n ...nestedFields,\n ...recursivelyBuildNestedPaths({\n field: nestedField,\n nestedFieldName2: nestedFieldName,\n parentName,\n }),\n ]\n }\n\n const nestedPathName = fieldAffectsData(nestedField)\n ? `${nestedFieldName ? `${nestedFieldName}__` : ''}${nestedField.name}`\n : undefined\n const getFieldSchema = fieldToSchemaMap({\n nestedFieldName,\n parentName,\n })[nestedField.type]\n\n if (getFieldSchema) {\n const fieldSchema = getFieldSchema({\n ...nestedField,\n name: nestedPathName,\n })\n\n if (Array.isArray(fieldSchema)) {\n return [...nestedFields, ...fieldSchema]\n }\n\n return [\n ...nestedFields,\n {\n type: fieldSchema,\n key: nestedPathName,\n },\n ]\n }\n }\n\n return nestedFields\n }, [])\n\n return nestedPaths\n}\n\nexport default recursivelyBuildNestedPaths\n"],"names":["fieldAffectsData","fieldIsPresentationalOnly","fieldToSchemaMap","recursivelyBuildNestedPaths","field","nestedFieldName2","parentName","fieldName","name","undefined","nestedFieldName","type","tabs","reduce","tabSchema","tab","push","nestedPaths","fields","nestedFields","nestedField","nestedPathName","getFieldSchema","fieldSchema","Array","isArray","key"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAE5E,OAAOC,sBAAsB,kCAAiC;AAQ9D,MAAMC,8BAA8B,CAAC,EAAEC,KAAK,EAAEC,gBAAgB,EAAEC,UAAU,EAAQ;IAChF,MAAMC,YAAYP,iBAAiBI,SAASA,MAAMI,IAAI,GAAGC;IACzD,MAAMC,kBAAkBH,aAAaF;IAErC,IAAID,MAAMO,IAAI,KAAK,QAAQ;QACzB,6CAA6C;QAC7C,+BAA+B;QAC/B,OAAOP,MAAMQ,IAAI,CAACC,MAAM,CAAC,CAACC,WAAWC;YACnCD,UAAUE,IAAI,IACTb,4BAA4B;gBAC7BC,OAAO;oBACL,GAAGW,GAAG;oBACNJ,MAAM,UAAUI,MAAM,UAAU;gBAClC;gBACAV,kBAAkBK;gBAClBJ;YACF;YAEF,OAAOQ;QACT,GAAG,EAAE;IACP;IAEA,MAAMG,cAAcb,MAAMc,MAAM,CAACL,MAAM,CAAC,CAACM,cAAcC;QACrD,IAAI,CAACnB,0BAA0BmB,cAAc;YAC3C,IAAI,CAACpB,iBAAiBoB,cAAc;gBAClC,OAAO;uBACFD;uBACAhB,4BAA4B;wBAC7BC,OAAOgB;wBACPf,kBAAkBK;wBAClBJ;oBACF;iBACD;YACH;YAEA,MAAMe,iBAAiBrB,iBAAiBoB,eACpC,CAAC,EAAEV,kBAAkB,CAAC,EAAEA,gBAAgB,EAAE,CAAC,GAAG,GAAG,EAAEU,YAAYZ,IAAI,CAAC,CAAC,GACrEC;YACJ,MAAMa,iBAAiBpB,iBAAiB;gBACtCQ;gBACAJ;YACF,EAAE,CAACc,YAAYT,IAAI,CAAC;YAEpB,IAAIW,gBAAgB;gBAClB,MAAMC,cAAcD,eAAe;oBACjC,GAAGF,WAAW;oBACdZ,MAAMa;gBACR;gBAEA,IAAIG,MAAMC,OAAO,CAACF,cAAc;oBAC9B,OAAO;2BAAIJ;2BAAiBI;qBAAY;gBAC1C;gBAEA,OAAO;uBACFJ;oBACH;wBACER,MAAMY;wBACNG,KAAKL;oBACP;iBACD;YACH;QACF;QAEA,OAAOF;IACT,GAAG,EAAE;IAEL,OAAOF;AACT;AAEA,eAAed,4BAA2B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nconst withNullableType = (\n field: FieldAffectingData,\n type: GraphQLType,\n forceNullable = false,\n): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n !field.localized &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n\nexport default withNullableType\n"],"names":["GraphQLNonNull","withNullableType","field","type","forceNullable","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","required","localized"],"rangeMappings":";;;;;;;;;;","mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAExC,MAAMC,mBAAmB,CACvBC,OACAC,MACAC,gBAAgB,KAAK;IAErB,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,MAAME,cAAcR,MAAMS,IAAI,KAAK,eAAeT,MAAMS,IAAI,KAAK;IAEjE,IACE,CAACP,iBACD,cAAcF,SACdA,MAAMU,QAAQ,IACd,CAACV,MAAMW,SAAS,IAChB,CAACL,aACD,CAACH,wBACD,CAACK,aACD;QACA,OAAO,IAAIV,eAAeG;IAC5B;IAEA,OAAOA;AACT;AAEA,eAAeF,iBAAgB"}
1
+ {"version":3,"sources":["../../src/schema/withNullableType.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData } from 'payload'\n\nimport { GraphQLNonNull } from 'graphql'\n\nconst withNullableType = (\n field: FieldAffectingData,\n type: GraphQLType,\n forceNullable = false,\n): GraphQLType => {\n const hasReadAccessControl = field.access && field.access.read\n const condition = field.admin && field.admin.condition\n const isTimestamp = field.name === 'createdAt' || field.name === 'updatedAt'\n\n if (\n !forceNullable &&\n 'required' in field &&\n field.required &&\n !field.localized &&\n !condition &&\n !hasReadAccessControl &&\n !isTimestamp\n ) {\n return new GraphQLNonNull(type)\n }\n\n return type\n}\n\nexport default withNullableType\n"],"names":["GraphQLNonNull","withNullableType","field","type","forceNullable","hasReadAccessControl","access","read","condition","admin","isTimestamp","name","required","localized"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAExC,MAAMC,mBAAmB,CACvBC,OACAC,MACAC,gBAAgB,KAAK;IAErB,MAAMC,uBAAuBH,MAAMI,MAAM,IAAIJ,MAAMI,MAAM,CAACC,IAAI;IAC9D,MAAMC,YAAYN,MAAMO,KAAK,IAAIP,MAAMO,KAAK,CAACD,SAAS;IACtD,MAAME,cAAcR,MAAMS,IAAI,KAAK,eAAeT,MAAMS,IAAI,KAAK;IAEjE,IACE,CAACP,iBACD,cAAcF,SACdA,MAAMU,QAAQ,IACd,CAACV,MAAMW,SAAS,IAChB,CAACL,aACD,CAACH,wBACD,CAACK,aACD;QACA,OAAO,IAAIV,eAAeG;IAC5B;IAEA,OAAOA;AACT;AAEA,eAAeF,iBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/withOperators.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData, NumberField, RadioField, SelectField } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLString,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { optionIsObject } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport combineParentName from '../utilities/combineParentName.js'\nimport formatName from '../utilities/formatName.js'\nimport operators from './operators.js'\n\ntype staticTypes =\n | 'checkbox'\n | 'code'\n | 'date'\n | 'email'\n | 'json'\n | 'number'\n | 'point'\n | 'relationship'\n | 'richText'\n | 'text'\n | 'textarea'\n | 'upload'\n\ntype dynamicTypes = 'radio' | 'select'\n\nconst GeoJSONObject = new GraphQLInputObjectType({\n name: 'GeoJSONObject',\n fields: {\n type: { type: GraphQLString },\n coordinates: {\n type: GraphQLJSON,\n },\n },\n})\n\ntype DefaultsType = {\n [key in staticTypes]: {\n operators: {\n name: string\n type: ((field: FieldAffectingData, parentName: string) => GraphQLType) | GraphQLType\n }[]\n }\n} & {\n [key in dynamicTypes]: {\n operators: {\n name: string\n type: (field: FieldAffectingData, parentName: string) => GraphQLType\n }[]\n }\n}\n\nconst defaults: DefaultsType = {\n checkbox: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLBoolean,\n })),\n ],\n },\n code: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n date: {\n operators: [\n ...[...operators.equality, ...operators.comparison, 'like'].map((operator) => ({\n name: operator,\n type: DateTimeResolver,\n })),\n ],\n },\n email: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: EmailAddressResolver,\n })),\n ],\n },\n json: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.geojson].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n number: {\n operators: [\n ...[...operators.equality, ...operators.comparison].map((operator) => ({\n name: operator,\n type: (field: NumberField): GraphQLType => {\n return field?.name === 'id' ? GraphQLInt : GraphQLFloat\n },\n })),\n ],\n },\n point: {\n operators: [\n ...[...operators.equality, ...operators.comparison, ...operators.geo].map((operator) => ({\n name: operator,\n type: new GraphQLList(GraphQLFloat),\n })),\n ...operators.geojson.map((operator) => ({\n name: operator,\n /**\n * @example:\n * within: {\n * type: \"Polygon\",\n * coordinates: [[\n * [0.0, 0.0],\n * [1.0, 1.0],\n * [1.0, 0.0],\n * [0.0, 0.0],\n * ]],\n * }\n * @example\n * intersects: {\n * type: \"Point\",\n * coordinates: [ 0.5, 0.5 ]\n * }\n */\n type: GeoJSONObject,\n })),\n ],\n },\n radio: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: (field: RadioField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n relationship: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n richText: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n select: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: (field: SelectField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n text: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n textarea: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n upload: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n // array: n/a\n // group: n/a\n // row: n/a\n // collapsible: n/a\n // tabs: n/a\n}\n\nconst listOperators = ['in', 'not_in', 'all']\n\nconst gqlTypeCache: Record<string, GraphQLType> = {}\n\n/**\n * In GraphQL, you can use \"where\" as an argument to filter a collection. Example:\n * { Posts(where: { title: { equals: \"Hello\" } }) { text } }\n * This function defines the operators for a field's condition in the \"where\" argument of the collection (it thus gets called for every field).\n * For example, in the example above, it would control that\n * - \"equals\" is a valid operator for the \"title\" field\n * - the accepted type of the \"equals\" argument has to be a string.\n *\n * @param field the field for which their valid operators inside a \"where\" argument is being defined\n * @param parentName the name of the parent field (if any)\n * @returns all the operators (including their types) which can be used as a condition for a given field inside a where\n */\nexport const withOperators = (\n field: FieldAffectingData,\n parentName: string,\n): GraphQLInputObjectType => {\n if (!defaults?.[field.type]) throw new Error(`Error: ${field.type} has no defaults configured.`)\n\n const name = `${combineParentName(parentName, field.name)}_operator`\n\n // Get the default operators for the field type which are hard-coded above\n const fieldOperators = [...defaults[field.type].operators]\n\n if (!('required' in field) || !field.required) {\n fieldOperators.push({\n name: 'exists',\n type: fieldOperators[0].type,\n })\n }\n\n return new GraphQLInputObjectType({\n name,\n fields: fieldOperators.reduce((objectTypeFields, operator) => {\n // Get the type of the operator. It can be either static, or dynamic (=> a function)\n let gqlType: GraphQLType =\n typeof operator.type === 'function' ? operator.type(field, parentName) : operator.type\n\n // GraphQL does not allow types with duplicate names, so we use this cache to avoid that.\n // Without this, select and radio fields would have the same name, and GraphQL would throw an error\n // This usually only happens if a custom type is returned from the operator.type function\n if (typeof operator.type === 'function' && 'name' in gqlType) {\n if (gqlTypeCache[gqlType.name]) {\n gqlType = gqlTypeCache[gqlType.name]\n } else {\n gqlTypeCache[gqlType.name] = gqlType\n }\n }\n\n if (listOperators.includes(operator.name)) {\n gqlType = new GraphQLList(gqlType)\n } else if (operator.name === 'exists') {\n gqlType = GraphQLBoolean\n }\n\n return {\n ...objectTypeFields,\n [operator.name]: {\n type: gqlType,\n },\n }\n }, {}),\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLString","DateTimeResolver","EmailAddressResolver","optionIsObject","GraphQLJSON","combineParentName","formatName","operators","GeoJSONObject","name","fields","type","coordinates","defaults","checkbox","equality","map","operator","code","partial","date","comparison","email","contains","json","geojson","number","field","point","geo","radio","parentName","values","options","reduce","option","value","relationship","richText","select","text","textarea","upload","listOperators","gqlTypeCache","withOperators","Error","fieldOperators","required","push","objectTypeFields","gqlType","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CY;QACAC,QAAQqC,eAAeb,MAAM,CAAC,CAACgB,kBAAkBjC;YAC/C,oFAAoF;YACpF,IAAIkC,UACF,OAAOlC,SAASN,IAAI,KAAK,aAAaM,SAASN,IAAI,CAACgB,OAAOI,cAAcd,SAASN,IAAI;YAExF,yFAAyF;YACzF,mGAAmG;YACnG,yFAAyF;YACzF,IAAI,OAAOM,SAASN,IAAI,KAAK,cAAc,UAAUwC,SAAS;gBAC5D,IAAIP,YAAY,CAACO,QAAQ1C,IAAI,CAAC,EAAE;oBAC9B0C,UAAUP,YAAY,CAACO,QAAQ1C,IAAI,CAAC;gBACtC,OAAO;oBACLmC,YAAY,CAACO,QAAQ1C,IAAI,CAAC,GAAG0C;gBAC/B;YACF;YAEA,IAAIR,cAAcS,QAAQ,CAACnC,SAASR,IAAI,GAAG;gBACzC0C,UAAU,IAAIpD,YAAYoD;YAC5B,OAAO,IAAIlC,SAASR,IAAI,KAAK,UAAU;gBACrC0C,UAAUzD;YACZ;YAEA,OAAO;gBACL,GAAGwD,gBAAgB;gBACnB,CAACjC,SAASR,IAAI,CAAC,EAAE;oBACfE,MAAMwC;gBACR;YACF;QACF,GAAG,CAAC;IACN;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/withOperators.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData, NumberField, RadioField, SelectField } from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLString,\n} from 'graphql'\nimport { DateTimeResolver, EmailAddressResolver } from 'graphql-scalars'\nimport { optionIsObject } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport combineParentName from '../utilities/combineParentName.js'\nimport formatName from '../utilities/formatName.js'\nimport operators from './operators.js'\n\ntype staticTypes =\n | 'checkbox'\n | 'code'\n | 'date'\n | 'email'\n | 'json'\n | 'number'\n | 'point'\n | 'relationship'\n | 'richText'\n | 'text'\n | 'textarea'\n | 'upload'\n\ntype dynamicTypes = 'radio' | 'select'\n\nconst GeoJSONObject = new GraphQLInputObjectType({\n name: 'GeoJSONObject',\n fields: {\n type: { type: GraphQLString },\n coordinates: {\n type: GraphQLJSON,\n },\n },\n})\n\ntype DefaultsType = {\n [key in staticTypes]: {\n operators: {\n name: string\n type: ((field: FieldAffectingData, parentName: string) => GraphQLType) | GraphQLType\n }[]\n }\n} & {\n [key in dynamicTypes]: {\n operators: {\n name: string\n type: (field: FieldAffectingData, parentName: string) => GraphQLType\n }[]\n }\n}\n\nconst defaults: DefaultsType = {\n checkbox: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLBoolean,\n })),\n ],\n },\n code: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n date: {\n operators: [\n ...[...operators.equality, ...operators.comparison, 'like'].map((operator) => ({\n name: operator,\n type: DateTimeResolver,\n })),\n ],\n },\n email: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: EmailAddressResolver,\n })),\n ],\n },\n json: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.geojson].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n number: {\n operators: [\n ...[...operators.equality, ...operators.comparison].map((operator) => ({\n name: operator,\n type: (field: NumberField): GraphQLType => {\n return field?.name === 'id' ? GraphQLInt : GraphQLFloat\n },\n })),\n ],\n },\n point: {\n operators: [\n ...[...operators.equality, ...operators.comparison, ...operators.geo].map((operator) => ({\n name: operator,\n type: new GraphQLList(GraphQLFloat),\n })),\n ...operators.geojson.map((operator) => ({\n name: operator,\n /**\n * @example:\n * within: {\n * type: \"Polygon\",\n * coordinates: [[\n * [0.0, 0.0],\n * [1.0, 1.0],\n * [1.0, 0.0],\n * [0.0, 0.0],\n * ]],\n * }\n * @example\n * intersects: {\n * type: \"Point\",\n * coordinates: [ 0.5, 0.5 ]\n * }\n */\n type: GeoJSONObject,\n })),\n ],\n },\n radio: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: (field: RadioField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n relationship: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n richText: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLJSON,\n })),\n ],\n },\n select: {\n operators: [\n ...[...operators.equality, ...operators.contains].map((operator) => ({\n name: operator,\n type: (field: SelectField, parentName): GraphQLType =>\n new GraphQLEnumType({\n name: `${combineParentName(parentName, field.name)}_Input`,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n }),\n })),\n ],\n },\n text: {\n operators: [\n ...[...operators.equality, ...operators.partial, ...operators.contains].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n textarea: {\n operators: [\n ...[...operators.equality, ...operators.partial].map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n upload: {\n operators: [\n ...operators.equality.map((operator) => ({\n name: operator,\n type: GraphQLString,\n })),\n ],\n },\n // array: n/a\n // group: n/a\n // row: n/a\n // collapsible: n/a\n // tabs: n/a\n}\n\nconst listOperators = ['in', 'not_in', 'all']\n\nconst gqlTypeCache: Record<string, GraphQLType> = {}\n\n/**\n * In GraphQL, you can use \"where\" as an argument to filter a collection. Example:\n * { Posts(where: { title: { equals: \"Hello\" } }) { text } }\n * This function defines the operators for a field's condition in the \"where\" argument of the collection (it thus gets called for every field).\n * For example, in the example above, it would control that\n * - \"equals\" is a valid operator for the \"title\" field\n * - the accepted type of the \"equals\" argument has to be a string.\n *\n * @param field the field for which their valid operators inside a \"where\" argument is being defined\n * @param parentName the name of the parent field (if any)\n * @returns all the operators (including their types) which can be used as a condition for a given field inside a where\n */\nexport const withOperators = (\n field: FieldAffectingData,\n parentName: string,\n): GraphQLInputObjectType => {\n if (!defaults?.[field.type]) throw new Error(`Error: ${field.type} has no defaults configured.`)\n\n const name = `${combineParentName(parentName, field.name)}_operator`\n\n // Get the default operators for the field type which are hard-coded above\n const fieldOperators = [...defaults[field.type].operators]\n\n if (!('required' in field) || !field.required) {\n fieldOperators.push({\n name: 'exists',\n type: fieldOperators[0].type,\n })\n }\n\n return new GraphQLInputObjectType({\n name,\n fields: fieldOperators.reduce((objectTypeFields, operator) => {\n // Get the type of the operator. It can be either static, or dynamic (=> a function)\n let gqlType: GraphQLType =\n typeof operator.type === 'function' ? operator.type(field, parentName) : operator.type\n\n // GraphQL does not allow types with duplicate names, so we use this cache to avoid that.\n // Without this, select and radio fields would have the same name, and GraphQL would throw an error\n // This usually only happens if a custom type is returned from the operator.type function\n if (typeof operator.type === 'function' && 'name' in gqlType) {\n if (gqlTypeCache[gqlType.name]) {\n gqlType = gqlTypeCache[gqlType.name]\n } else {\n gqlTypeCache[gqlType.name] = gqlType\n }\n }\n\n if (listOperators.includes(operator.name)) {\n gqlType = new GraphQLList(gqlType)\n } else if (operator.name === 'exists') {\n gqlType = GraphQLBoolean\n }\n\n return {\n ...objectTypeFields,\n [operator.name]: {\n type: gqlType,\n },\n }\n }, {}),\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLString","DateTimeResolver","EmailAddressResolver","optionIsObject","GraphQLJSON","combineParentName","formatName","operators","GeoJSONObject","name","fields","type","coordinates","defaults","checkbox","equality","map","operator","code","partial","date","comparison","email","contains","json","geojson","number","field","point","geo","radio","parentName","values","options","reduce","option","value","relationship","richText","select","text","textarea","upload","listOperators","gqlTypeCache","withOperators","Error","fieldOperators","required","push","objectTypeFields","gqlType","includes"],"mappings":"AAGA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,aAAa,QACR,UAAS;AAChB,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,kBAAiB;AACxE,SAASC,cAAc,QAAQ,iBAAgB;AAE/C,SAASC,WAAW,QAAQ,yCAAwC;AACpE,OAAOC,uBAAuB,oCAAmC;AACjE,OAAOC,gBAAgB,6BAA4B;AACnD,OAAOC,eAAe,iBAAgB;AAkBtC,MAAMC,gBAAgB,IAAIX,uBAAuB;IAC/CY,MAAM;IACNC,QAAQ;QACNC,MAAM;YAAEA,MAAMX;QAAc;QAC5BY,aAAa;YACXD,MAAMP;QACR;IACF;AACF;AAkBA,MAAMS,WAAyB;IAC7BC,UAAU;QACRP,WAAW;eACNA,UAAUQ,QAAQ,CAACC,GAAG,CAAC,CAACC,WAAc,CAAA;oBACvCR,MAAMQ;oBACNN,MAAMjB;gBACR,CAAA;SACD;IACH;IACAwB,MAAM;QACJX,WAAW;eACN;mBAAIA,UAAUQ,QAAQ;mBAAKR,UAAUY,OAAO;aAAC,CAACH,GAAG,CAAC,CAACC,WAAc,CAAA;oBAClER,MAAMQ;oBACNN,MAAMX;gBACR,CAAA;SACD;IACH;IACAoB,MAAM;QACJb,WAAW;eACN;mBAAIA,UAAUQ,QAAQ;mBAAKR,UAAUc,UAAU;gBAAE;aAAO,CAACL,GAAG,CAAC,CAACC,WAAc,CAAA;oBAC7ER,MAAMQ;oBACNN,MAAMV;gBACR,CAAA;SACD;IACH;IACAqB,OAAO;QACLf,WAAW;eACN;mBAAIA,UAAUQ,QAAQ;mBAAKR,UAAUY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AAQqC,eAAeb,MAAM,CAAC,CAACgB,kBAAkBjC;YAC/C,oFAAoF;YACpF,IAAIkC,UACF,OAAOlC,SAASN,IAAI,KAAK,aAAaM,SAASN,IAAI,CAACgB,OAAOI,cAAcd,SAASN,IAAI;YAExF,yFAAyF;YACzF,mGAAmG;YACnG,yFAAyF;YACzF,IAAI,OAAOM,SAASN,IAAI,KAAK,cAAc,UAAUwC,SAAS;gBAC5D,IAAIP,YAAY,CAACO,QAAQ1C,IAAI,CAAC,EAAE;oBAC9B0C,UAAUP,YAAY,CAACO,QAAQ1C,IAAI,CAAC;gBACtC,OAAO;oBACLmC,YAAY,CAACO,QAAQ1C,IAAI,CAAC,GAAG0C;gBAC/B;YACF;YAEA,IAAIR,cAAcS,QAAQ,CAACnC,SAASR,IAAI,GAAG;gBACzC0C,UAAU,IAAIpD,YAAYoD;YAC5B,OAAO,IAAIlC,SAASR,IAAI,KAAK,UAAU;gBACrC0C,UAAUzD;YACZ;YAEA,OAAO;gBACL,GAAGwD,gBAAgB;gBACnB,CAACjC,SAASR,IAAI,CAAC,EAAE;oBACfE,MAAMwC;gBACR;YACF;QACF,GAAG,CAAC;IACN;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/combineParentName.ts"],"sourcesContent":["import formatName from './formatName.js'\n\nconst combineParentName = (parent: string, name: string): string =>\n formatName(`${parent ? `${parent}_` : ''}${name}`)\n\nexport default combineParentName\n"],"names":["formatName","combineParentName","parent","name"],"rangeMappings":";;","mappings":"AAAA,OAAOA,gBAAgB,kBAAiB;AAExC,MAAMC,oBAAoB,CAACC,QAAgBC,OACzCH,WAAW,CAAC,EAAEE,SAAS,CAAC,EAAEA,OAAO,CAAC,CAAC,GAAG,GAAG,EAAEC,KAAK,CAAC;AAEnD,eAAeF,kBAAiB"}
1
+ {"version":3,"sources":["../../src/utilities/combineParentName.ts"],"sourcesContent":["import formatName from './formatName.js'\n\nconst combineParentName = (parent: string, name: string): string =>\n formatName(`${parent ? `${parent}_` : ''}${name}`)\n\nexport default combineParentName\n"],"names":["formatName","combineParentName","parent","name"],"mappings":"AAAA,OAAOA,gBAAgB,kBAAiB;AAExC,MAAMC,oBAAoB,CAACC,QAAgBC,OACzCH,WAAW,CAAC,EAAEE,SAAS,CAAC,EAAEA,OAAO,CAAC,CAAC,GAAG,GAAG,EAAEC,KAAK,CAAC;AAEnD,eAAeF,kBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/formatName.ts"],"sourcesContent":["const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n\nconst formatName = (string: string): string => {\n let sanitizedString = String(string)\n\n const firstLetter = sanitizedString.substring(0, 1)\n\n if (numbers.indexOf(firstLetter) > -1) {\n sanitizedString = `_${sanitizedString}`\n }\n\n const formatted = sanitizedString\n // Convert accented characters\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n\n .replace(/\\./g, '_')\n .replace(/-|\\//g, '_')\n .replace(/\\+/g, '_')\n .replace(/,/g, '_')\n .replace(/\\(/g, '_')\n .replace(/\\)/g, '_')\n .replace(/'/g, '_')\n .replace(/ /g, '')\n\n return formatted || '_'\n}\n\nexport default formatName\n"],"names":["numbers","formatName","string","sanitizedString","String","firstLetter","substring","indexOf","formatted","normalize","replace"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,UAAU;IAAC;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;CAAI;AAElE,MAAMC,aAAa,CAACC;IAClB,IAAIC,kBAAkBC,OAAOF;IAE7B,MAAMG,cAAcF,gBAAgBG,SAAS,CAAC,GAAG;IAEjD,IAAIN,QAAQO,OAAO,CAACF,eAAe,CAAC,GAAG;QACrCF,kBAAkB,CAAC,CAAC,EAAEA,gBAAgB,CAAC;IACzC;IAEA,MAAMK,YAAYL,eAChB,8BAA8B;KAC7BM,SAAS,CAAC,QACVC,OAAO,CAAC,oBAAoB,IAE5BA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,SAAS,KACjBA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,MAAM;IAEjB,OAAOF,aAAa;AACtB;AAEA,eAAeP,WAAU"}
1
+ {"version":3,"sources":["../../src/utilities/formatName.ts"],"sourcesContent":["const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n\nconst formatName = (string: string): string => {\n let sanitizedString = String(string)\n\n const firstLetter = sanitizedString.substring(0, 1)\n\n if (numbers.indexOf(firstLetter) > -1) {\n sanitizedString = `_${sanitizedString}`\n }\n\n const formatted = sanitizedString\n // Convert accented characters\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n\n .replace(/\\./g, '_')\n .replace(/-|\\//g, '_')\n .replace(/\\+/g, '_')\n .replace(/,/g, '_')\n .replace(/\\(/g, '_')\n .replace(/\\)/g, '_')\n .replace(/'/g, '_')\n .replace(/ /g, '')\n\n return formatted || '_'\n}\n\nexport default formatName\n"],"names":["numbers","formatName","string","sanitizedString","String","firstLetter","substring","indexOf","formatted","normalize","replace"],"mappings":"AAAA,MAAMA,UAAU;IAAC;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;IAAK;CAAI;AAElE,MAAMC,aAAa,CAACC;IAClB,IAAIC,kBAAkBC,OAAOF;IAE7B,MAAMG,cAAcF,gBAAgBG,SAAS,CAAC,GAAG;IAEjD,IAAIN,QAAQO,OAAO,CAACF,eAAe,CAAC,GAAG;QACrCF,kBAAkB,CAAC,CAAC,EAAEA,gBAAgB,CAAC;IACzC;IAEA,MAAMK,YAAYL,eAChB,8BAA8B;KAC7BM,SAAS,CAAC,QACVC,OAAO,CAAC,oBAAoB,IAE5BA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,SAAS,KACjBA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,MAAM;IAEjB,OAAOF,aAAa;AACtB;AAEA,eAAeP,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/formatName.spec.ts"],"sourcesContent":["/* eslint-disable indent */\n/* eslint-disable jest/prefer-strict-equal */\nimport formatName from './formatName'\n\ndescribe('formatName', () => {\n it.each`\n char | expected\n ${'á'} | ${'a'}\n ${'è'} | ${'e'}\n ${'í'} | ${'i'}\n ${'ó'} | ${'o'}\n ${'ú'} | ${'u'}\n ${'ñ'} | ${'n'}\n ${'ü'} | ${'u'}\n `('should convert accented character: $char', ({ char, expected }) => {\n expect(formatName(char)).toEqual(expected)\n })\n})\n"],"names":["formatName","describe","it","each","char","expected","expect","toEqual"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,yBAAyB,GACzB,2CAA2C,GAC3C,OAAOA,gBAAgB,eAAc;AAErCC,SAAS,cAAc;IACrBC,GAAGC,IAAI,CAAC;;IAEN,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;EACjB,CAAC,CAAC,4CAA4C,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAE;QAC/DC,OAAON,WAAWI,OAAOG,OAAO,CAACF;IACnC;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/formatName.spec.ts"],"sourcesContent":["/* eslint-disable indent */\n/* eslint-disable jest/prefer-strict-equal */\nimport formatName from './formatName'\n\ndescribe('formatName', () => {\n it.each`\n char | expected\n ${'á'} | ${'a'}\n ${'è'} | ${'e'}\n ${'í'} | ${'i'}\n ${'ó'} | ${'o'}\n ${'ú'} | ${'u'}\n ${'ñ'} | ${'n'}\n ${'ü'} | ${'u'}\n `('should convert accented character: $char', ({ char, expected }) => {\n expect(formatName(char)).toEqual(expected)\n })\n})\n"],"names":["formatName","describe","it","each","char","expected","expect","toEqual"],"mappings":"AAAA,yBAAyB,GACzB,2CAA2C,GAC3C,OAAOA,gBAAgB,eAAc;AAErCC,SAAS,cAAc;IACrBC,GAAGC,IAAI,CAAC;;IAEN,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;IACf,EAAE,IAAI,GAAG,EAAE,IAAI;EACjB,CAAC,CAAC,4CAA4C,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAE;QAC/DC,OAAON,WAAWI,OAAOG,OAAO,CAACF;IACnC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/formatOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from 'payload'\n\nimport formatName from './formatName.js'\n\nconst formatOptions = (field: RadioField | SelectField) => {\n return field.options.reduce((values, option) => {\n if (typeof option === 'object') {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {})\n}\n\nexport default formatOptions\n"],"names":["formatName","formatOptions","field","options","reduce","values","option","value"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,kBAAiB;AAExC,MAAMC,gBAAgB,CAACC;IACrB,OAAOA,MAAMC,OAAO,CAACC,MAAM,CAAC,CAACC,QAAQC;QACnC,IAAI,OAAOA,WAAW,UAAU;YAC9B,OAAO;gBACL,GAAGD,MAAM;gBACT,CAACL,WAAWM,OAAOC,KAAK,EAAE,EAAE;oBAC1BA,OAAOD,OAAOC,KAAK;gBACrB;YACF;QACF;QAEA,OAAO;YACL,GAAGF,MAAM;YACT,CAACL,WAAWM,QAAQ,EAAE;gBACpBC,OAAOD;YACT;QACF;IACF,GAAG,CAAC;AACN;AAEA,eAAeL,cAAa"}
1
+ {"version":3,"sources":["../../src/utilities/formatOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from 'payload'\n\nimport formatName from './formatName.js'\n\nconst formatOptions = (field: RadioField | SelectField) => {\n return field.options.reduce((values, option) => {\n if (typeof option === 'object') {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {})\n}\n\nexport default formatOptions\n"],"names":["formatName","formatOptions","field","options","reduce","values","option","value"],"mappings":"AAEA,OAAOA,gBAAgB,kBAAiB;AAExC,MAAMC,gBAAgB,CAACC;IACrB,OAAOA,MAAMC,OAAO,CAACC,MAAM,CAAC,CAACC,QAAQC;QACnC,IAAI,OAAOA,WAAW,UAAU;YAC9B,OAAO;gBACL,GAAGD,MAAM;gBACT,CAACL,WAAWM,OAAOC,KAAK,EAAE,EAAE;oBAC1BA,OAAOD,OAAOC,KAAK;gBACrB;YACF;QACF;QAEA,OAAO;YACL,GAAGF,MAAM;YACT,CAACL,WAAWM,QAAQ,EAAE;gBACpBC,OAAOD;YACT;QACF;IACF,GAAG,CAAC;AACN;AAEA,eAAeL,cAAa"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getCheckIfLocaleObject.ts"],"sourcesContent":["export default (localization: { locales: string[] }) =>\n (value: unknown): boolean =>\n typeof value === 'object' &&\n Object.keys(value).some((key) => localization.locales.indexOf(key) > -1)\n"],"names":["localization","value","Object","keys","some","key","locales","indexOf"],"rangeMappings":"","mappings":"AAAA,eAAe,CAAA,CAACA,eACd,CAACC,QACC,OAAOA,UAAU,YACjBC,OAAOC,IAAI,CAACF,OAAOG,IAAI,CAAC,CAACC,MAAQL,aAAaM,OAAO,CAACC,OAAO,CAACF,OAAO,CAAC,EAAC,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getCheckIfLocaleObject.ts"],"sourcesContent":["export default (localization: { locales: string[] }) =>\n (value: unknown): boolean =>\n typeof value === 'object' &&\n Object.keys(value).some((key) => localization.locales.indexOf(key) > -1)\n"],"names":["localization","value","Object","keys","some","key","locales","indexOf"],"mappings":"AAAA,eAAe,CAAA,CAACA,eACd,CAACC,QACC,OAAOA,UAAU,YACjBC,OAAOC,IAAI,CAACF,OAAOG,IAAI,CAAC,CAACC,MAAQL,aAAaM,OAAO,CAACC,OAAO,CAACF,OAAO,CAAC,EAAC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) && 'required' in subField && subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","type","fields","some","subField","required"],"rangeMappings":";;;;;;;;;;;","mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,UAAUA,UAAUA,OAAOC,IAAI,KAAK,SAAS;QAC/C,OAAOD,OAAOE,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACN,iBAAiBM,aAAa,cAAcA,YAAYA,SAASC,QAAQ,IAC1EN,8BAA8BK;QAElC;IACF;IAEA,IAAI,YAAYJ,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeE,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaL,8BAA8BK;IACjF;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nexport const groupOrTabHasRequiredSubfield = (entity: Field | Tab): boolean => {\n if ('type' in entity && entity.type === 'group') {\n return entity.fields.some((subField) => {\n return (\n (fieldAffectsData(subField) && 'required' in subField && subField.required) ||\n groupOrTabHasRequiredSubfield(subField)\n )\n })\n }\n\n if ('fields' in entity && 'name' in entity) {\n return (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField))\n }\n\n return false\n}\n"],"names":["fieldAffectsData","groupOrTabHasRequiredSubfield","entity","type","fields","some","subField","required"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAEjD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,IAAI,UAAUA,UAAUA,OAAOC,IAAI,KAAK,SAAS;QAC/C,OAAOD,OAAOE,MAAM,CAACC,IAAI,CAAC,CAACC;YACzB,OACE,AAACN,iBAAiBM,aAAa,cAAcA,YAAYA,SAASC,QAAQ,IAC1EN,8BAA8BK;QAElC;IACF;IAEA,IAAI,YAAYJ,UAAU,UAAUA,QAAQ;QAC1C,OAAO,AAACA,OAAeE,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaL,8BAA8BK;IACjF;IAEA,OAAO;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/uppercase.ts"],"sourcesContent":["function uppercase(str: string): string {\n const array1 = str.split(' ')\n const newarray1 = []\n\n for (let x = 0; x < array1.length; x += 1) {\n newarray1.push(array1[x].charAt(0).toUpperCase() + array1[x].slice(1))\n }\n return newarray1.join(' ')\n}\n\nexport default uppercase\n"],"names":["uppercase","str","array1","split","newarray1","x","length","push","charAt","toUpperCase","slice","join"],"rangeMappings":";;;;;;;;","mappings":"AAAA,SAASA,UAAUC,GAAW;IAC5B,MAAMC,SAASD,IAAIE,KAAK,CAAC;IACzB,MAAMC,YAAY,EAAE;IAEpB,IAAK,IAAIC,IAAI,GAAGA,IAAIH,OAAOI,MAAM,EAAED,KAAK,EAAG;QACzCD,UAAUG,IAAI,CAACL,MAAM,CAACG,EAAE,CAACG,MAAM,CAAC,GAAGC,WAAW,KAAKP,MAAM,CAACG,EAAE,CAACK,KAAK,CAAC;IACrE;IACA,OAAON,UAAUO,IAAI,CAAC;AACxB;AAEA,eAAeX,UAAS"}
1
+ {"version":3,"sources":["../../src/utilities/uppercase.ts"],"sourcesContent":["function uppercase(str: string): string {\n const array1 = str.split(' ')\n const newarray1 = []\n\n for (let x = 0; x < array1.length; x += 1) {\n newarray1.push(array1[x].charAt(0).toUpperCase() + array1[x].slice(1))\n }\n return newarray1.join(' ')\n}\n\nexport default uppercase\n"],"names":["uppercase","str","array1","split","newarray1","x","length","push","charAt","toUpperCase","slice","join"],"mappings":"AAAA,SAASA,UAAUC,GAAW;IAC5B,MAAMC,SAASD,IAAIE,KAAK,CAAC;IACzB,MAAMC,YAAY,EAAE;IAEpB,IAAK,IAAIC,IAAI,GAAGA,IAAIH,OAAOI,MAAM,EAAED,KAAK,EAAG;QACzCD,UAAUG,IAAI,CAACL,MAAM,CAACG,EAAE,CAACG,MAAM,CAAC,GAAGC,WAAW,KAAKP,MAAM,CAACG,EAAE,CAACK,KAAK,CAAC;IACrE;IACA,OAAON,UAAUO,IAAI,CAAC;AACxB;AAEA,eAAeX,UAAS"}