@payloadcms/graphql 3.0.0-beta.9 → 3.0.0-beta.90
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.
- package/bin.js +54 -0
- package/dist/bin/generateSchema.d.ts +3 -0
- package/dist/bin/generateSchema.d.ts.map +1 -0
- package/dist/bin/generateSchema.js +10 -0
- package/dist/bin/generateSchema.js.map +1 -0
- package/dist/bin/index.d.ts +2 -0
- package/dist/bin/index.d.ts.map +1 -0
- package/dist/bin/index.js +17 -0
- package/dist/bin/index.js.map +1 -0
- package/dist/exports/types.d.ts +4 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +5 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/exports/utilities.d.ts +3 -0
- package/dist/exports/utilities.d.ts.map +1 -0
- package/dist/exports/utilities.js +4 -0
- package/dist/exports/utilities.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/packages/graphql-query-complexity/QueryComplexity.d.ts +51 -0
- package/dist/packages/graphql-query-complexity/QueryComplexity.d.ts.map +1 -0
- package/dist/packages/graphql-query-complexity/QueryComplexity.js +270 -0
- package/dist/packages/graphql-query-complexity/QueryComplexity.js.map +1 -0
- package/dist/packages/graphql-query-complexity/createComplexityRule.d.ts +5 -0
- package/dist/packages/graphql-query-complexity/createComplexityRule.d.ts.map +1 -0
- package/dist/packages/graphql-query-complexity/createComplexityRule.js +8 -0
- package/dist/packages/graphql-query-complexity/createComplexityRule.js.map +1 -0
- package/dist/packages/graphql-query-complexity/estimators/fieldExtensions/index.d.ts +3 -0
- package/dist/packages/graphql-query-complexity/estimators/fieldExtensions/index.d.ts.map +1 -0
- package/dist/packages/graphql-query-complexity/estimators/fieldExtensions/index.js +14 -0
- package/dist/packages/graphql-query-complexity/estimators/fieldExtensions/index.js.map +1 -0
- package/dist/packages/graphql-query-complexity/estimators/simple/index.d.ts +5 -0
- package/dist/packages/graphql-query-complexity/estimators/simple/index.d.ts.map +1 -0
- package/dist/packages/graphql-query-complexity/estimators/simple/index.js +8 -0
- package/dist/packages/graphql-query-complexity/estimators/simple/index.js.map +1 -0
- package/dist/packages/graphql-query-complexity/index.d.ts +4 -0
- package/dist/packages/graphql-query-complexity/index.d.ts.map +1 -0
- package/dist/packages/graphql-query-complexity/index.js +5 -0
- package/dist/packages/graphql-query-complexity/index.js.map +1 -0
- package/dist/packages/graphql-type-json/index.d.ts +4 -0
- package/dist/packages/graphql-type-json/index.d.ts.map +1 -0
- package/dist/packages/graphql-type-json/index.js +63 -0
- package/dist/packages/graphql-type-json/index.js.map +1 -0
- package/dist/resolvers/auth/access.d.ts +1 -1
- package/dist/resolvers/auth/access.d.ts.map +1 -1
- package/dist/resolvers/auth/access.js +1 -2
- package/dist/resolvers/auth/access.js.map +1 -1
- package/dist/resolvers/auth/forgotPassword.d.ts +1 -1
- package/dist/resolvers/auth/forgotPassword.d.ts.map +1 -1
- package/dist/resolvers/auth/forgotPassword.js +3 -3
- package/dist/resolvers/auth/forgotPassword.js.map +1 -1
- package/dist/resolvers/auth/init.d.ts.map +1 -1
- package/dist/resolvers/auth/init.js +1 -2
- package/dist/resolvers/auth/init.js.map +1 -1
- package/dist/resolvers/auth/login.d.ts +1 -1
- package/dist/resolvers/auth/login.d.ts.map +1 -1
- package/dist/resolvers/auth/login.js +3 -4
- package/dist/resolvers/auth/login.js.map +1 -1
- package/dist/resolvers/auth/logout.d.ts +1 -1
- package/dist/resolvers/auth/logout.d.ts.map +1 -1
- package/dist/resolvers/auth/logout.js +1 -3
- package/dist/resolvers/auth/logout.js.map +1 -1
- package/dist/resolvers/auth/me.d.ts +1 -1
- package/dist/resolvers/auth/me.d.ts.map +1 -1
- package/dist/resolvers/auth/me.js +3 -2
- package/dist/resolvers/auth/me.js.map +1 -1
- package/dist/resolvers/auth/refresh.d.ts +1 -1
- package/dist/resolvers/auth/refresh.d.ts.map +1 -1
- package/dist/resolvers/auth/refresh.js +3 -11
- package/dist/resolvers/auth/refresh.js.map +1 -1
- package/dist/resolvers/auth/resetPassword.d.ts +1 -1
- package/dist/resolvers/auth/resetPassword.d.ts.map +1 -1
- package/dist/resolvers/auth/resetPassword.js +1 -3
- package/dist/resolvers/auth/resetPassword.js.map +1 -1
- package/dist/resolvers/auth/unlock.d.ts +1 -1
- package/dist/resolvers/auth/unlock.d.ts.map +1 -1
- package/dist/resolvers/auth/unlock.js +3 -3
- package/dist/resolvers/auth/unlock.js.map +1 -1
- package/dist/resolvers/auth/verifyEmail.d.ts +1 -1
- package/dist/resolvers/auth/verifyEmail.d.ts.map +1 -1
- package/dist/resolvers/auth/verifyEmail.js +1 -2
- package/dist/resolvers/auth/verifyEmail.js.map +1 -1
- package/dist/resolvers/collections/count.d.ts +12 -0
- package/dist/resolvers/collections/count.d.ts.map +1 -0
- package/dist/resolvers/collections/count.js +22 -0
- package/dist/resolvers/collections/count.js.map +1 -0
- package/dist/resolvers/collections/create.d.ts +5 -8
- package/dist/resolvers/collections/create.d.ts.map +1 -1
- package/dist/resolvers/collections/create.js +1 -2
- package/dist/resolvers/collections/create.js.map +1 -1
- package/dist/resolvers/collections/delete.d.ts +6 -6
- package/dist/resolvers/collections/delete.d.ts.map +1 -1
- package/dist/resolvers/collections/delete.js +8 -6
- package/dist/resolvers/collections/delete.js.map +1 -1
- package/dist/resolvers/collections/docAccess.d.ts +1 -2
- package/dist/resolvers/collections/docAccess.d.ts.map +1 -1
- package/dist/resolvers/collections/docAccess.js +1 -2
- package/dist/resolvers/collections/docAccess.js.map +1 -1
- package/dist/resolvers/collections/duplicate.d.ts +4 -6
- package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
- package/dist/resolvers/collections/duplicate.js +2 -2
- package/dist/resolvers/collections/duplicate.js.map +1 -1
- package/dist/resolvers/collections/find.d.ts +2 -4
- package/dist/resolvers/collections/find.d.ts.map +1 -1
- package/dist/resolvers/collections/find.js +12 -6
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.d.ts +4 -6
- package/dist/resolvers/collections/findByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findByID.js +6 -3
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.d.ts +2 -5
- package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +3 -4
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.d.ts +3 -4
- package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersions.js +8 -6
- package/dist/resolvers/collections/findVersions.js.map +1 -1
- package/dist/resolvers/collections/restoreVersion.d.ts +2 -2
- package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/collections/restoreVersion.js +2 -2
- package/dist/resolvers/collections/restoreVersion.js.map +1 -1
- package/dist/resolvers/collections/update.d.ts +6 -7
- package/dist/resolvers/collections/update.d.ts.map +1 -1
- package/dist/resolvers/collections/update.js +8 -6
- package/dist/resolvers/collections/update.js.map +1 -1
- package/dist/resolvers/globals/docAccess.d.ts +1 -2
- package/dist/resolvers/globals/docAccess.d.ts.map +1 -1
- package/dist/resolvers/globals/docAccess.js +1 -2
- package/dist/resolvers/globals/docAccess.js.map +1 -1
- package/dist/resolvers/globals/findOne.d.ts +1 -1
- package/dist/resolvers/globals/findOne.d.ts.map +1 -1
- package/dist/resolvers/globals/findOne.js +1 -2
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +1 -2
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.d.ts +1 -1
- package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersions.js +1 -2
- package/dist/resolvers/globals/findVersions.js.map +1 -1
- package/dist/resolvers/globals/index.js.map +1 -1
- package/dist/resolvers/globals/restoreVersion.d.ts +2 -1
- package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/globals/restoreVersion.js +2 -2
- package/dist/resolvers/globals/restoreVersion.js.map +1 -1
- package/dist/resolvers/globals/update.d.ts +5 -6
- package/dist/resolvers/globals/update.d.ts.map +1 -1
- package/dist/resolvers/globals/update.js +1 -2
- package/dist/resolvers/globals/update.js.map +1 -1
- package/dist/resolvers/types.d.ts +1 -1
- package/dist/resolvers/types.d.ts.map +1 -1
- package/dist/resolvers/types.js.map +1 -1
- package/dist/schema/buildFallbackLocaleInputType.d.ts +1 -1
- package/dist/schema/buildFallbackLocaleInputType.d.ts.map +1 -1
- package/dist/schema/buildFallbackLocaleInputType.js.map +1 -1
- package/dist/schema/buildLocaleInputType.d.ts +1 -1
- package/dist/schema/buildLocaleInputType.d.ts.map +1 -1
- package/dist/schema/buildLocaleInputType.js.map +1 -1
- package/dist/schema/buildMutationInputType.d.ts +1 -2
- package/dist/schema/buildMutationInputType.d.ts.map +1 -1
- package/dist/schema/buildMutationInputType.js +35 -8
- package/dist/schema/buildMutationInputType.js.map +1 -1
- package/dist/schema/buildObjectType.d.ts +3 -4
- package/dist/schema/buildObjectType.d.ts.map +1 -1
- package/dist/schema/buildObjectType.js +183 -63
- package/dist/schema/buildObjectType.js.map +1 -1
- package/dist/schema/buildPaginatedListType.d.ts +1 -2
- package/dist/schema/buildPaginatedListType.d.ts.map +1 -1
- package/dist/schema/buildPaginatedListType.js +1 -2
- package/dist/schema/buildPaginatedListType.js.map +1 -1
- package/dist/schema/buildPoliciesType.d.ts +1 -1
- package/dist/schema/buildPoliciesType.d.ts.map +1 -1
- package/dist/schema/buildPoliciesType.js +2 -2
- package/dist/schema/buildPoliciesType.js.map +1 -1
- package/dist/schema/buildWhereInputType.d.ts +1 -1
- package/dist/schema/buildWhereInputType.d.ts.map +1 -1
- package/dist/schema/buildWhereInputType.js +3 -3
- package/dist/schema/buildWhereInputType.js.map +1 -1
- package/dist/schema/fieldToWhereInputSchemaMap.d.ts.map +1 -1
- package/dist/schema/fieldToWhereInputSchemaMap.js +28 -4
- package/dist/schema/fieldToWhereInputSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts +1 -2
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +63 -30
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts +1 -2
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +10 -5
- package/dist/schema/initGlobals.js.map +1 -1
- package/dist/schema/isFieldNullable.d.ts +1 -1
- package/dist/schema/isFieldNullable.d.ts.map +1 -1
- package/dist/schema/isFieldNullable.js +1 -1
- package/dist/schema/isFieldNullable.js.map +1 -1
- package/dist/schema/operators.js.map +1 -1
- package/dist/schema/recursivelyBuildNestedPaths.d.ts +1 -1
- package/dist/schema/recursivelyBuildNestedPaths.d.ts.map +1 -1
- package/dist/schema/recursivelyBuildNestedPaths.js +1 -1
- package/dist/schema/recursivelyBuildNestedPaths.js.map +1 -1
- package/dist/schema/withNullableType.d.ts +1 -1
- package/dist/schema/withNullableType.d.ts.map +1 -1
- package/dist/schema/withNullableType.js.map +1 -1
- package/dist/schema/withOperators.d.ts +1 -1
- package/dist/schema/withOperators.d.ts.map +1 -1
- package/dist/schema/withOperators.js +7 -4
- package/dist/schema/withOperators.js.map +1 -1
- package/dist/utilities/combineParentName.js.map +1 -1
- package/dist/utilities/formatName.js.map +1 -1
- package/dist/utilities/formatName.spec.js +1 -1
- package/dist/utilities/formatName.spec.js.map +1 -1
- package/dist/utilities/formatOptions.d.ts +1 -1
- package/dist/utilities/formatOptions.d.ts.map +1 -1
- package/dist/utilities/formatOptions.js.map +1 -1
- package/dist/utilities/getCheckIfLocaleObject.js.map +1 -1
- package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts +1 -1
- package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts.map +1 -1
- package/dist/utilities/groupOrTabHasRequiredSubfield.js +1 -1
- package/dist/utilities/groupOrTabHasRequiredSubfield.js.map +1 -1
- package/dist/utilities/uppercase.js.map +1 -1
- package/dist/utilities/wrapCustomResolver.d.ts +1 -1
- package/dist/utilities/wrapCustomResolver.d.ts.map +1 -1
- package/dist/utilities/wrapCustomResolver.js +1 -1
- package/dist/utilities/wrapCustomResolver.js.map +1 -1
- package/package.json +34 -23
- package/src/index.ts +0 -126
|
@@ -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/types'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { GraphQLJSONObject } from 'graphql-type-json'\nimport { toWords } from 'payload/utilities'\n\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","GraphQLJSONObject","toWords","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,iBAAiB,QAAQ,oBAAmB;AACrD,SAASC,OAAO,QAAQ,oBAAmB;AAE3C,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;oBA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nBzB,WAAW4B,IAAI,CAAC;IAClB;IAEA,MAAME,iBAAiB3C,WAAW,CAAC,EAAE4C,QAAQP,SAAS3B,QAAQ0B,KAAK,EAAED,cAAc,GAAG,CAAC;IAEvF,OAAO,IAAItC,kBAAkB;QAC3Ba,MAAMiC;QACNxB,QAAQM,kBAAkB;YACxBf,MAAMwB,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
|
+
{"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,m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AEvB,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,"file":"buildWhereInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildWhereInputType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildWhereInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildWhereInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,SAAS,CAAA;AAExD,OAAO,EAAE,sBAAsB,EAAe,MAAM,SAAS,CAAA;AAQ7D,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,mBAAmB,iCAAkC,IAAI,KAAG,sBAgFjE,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { GraphQLInputObjectType, GraphQLList } from 'graphql';
|
|
2
|
+
import { flattenTopLevelFields } from 'payload';
|
|
3
|
+
import { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared';
|
|
4
4
|
import formatName from '../utilities/formatName.js';
|
|
5
5
|
import fieldToSchemaMap from './fieldToWhereInputSchemaMap.js';
|
|
6
6
|
import { withOperators } from './withOperators.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/schema/buildWhereInputType.ts"],"sourcesContent":["import 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":"AAEA,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,MAA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AAenB,oBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldToWhereInputSchemaMap.d.ts","sourceRoot":"","sources":["../../src/schema/fieldToWhereInputSchemaMap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fieldToWhereInputSchemaMap.d.ts","sourceRoot":"","sources":["../../src/schema/fieldToWhereInputSchemaMap.ts"],"names":[],"mappings":"AA8BA,KAAK,IAAI,GAAG;IACV,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,QAAA,MAAM,gBAAgB,oCAAqC,IAAI,KAAG,GA+HhE,CAAA;AAEF,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { GraphQLEnumType, GraphQLInputObjectType } from 'graphql';
|
|
2
|
-
import
|
|
2
|
+
import { GraphQLJSON } from '../packages/graphql-type-json/index.js';
|
|
3
3
|
import combineParentName from '../utilities/combineParentName.js';
|
|
4
4
|
import formatName from '../utilities/formatName.js';
|
|
5
5
|
import recursivelyBuildNestedPaths from './recursivelyBuildNestedPaths.js';
|
|
6
6
|
import { withOperators } from './withOperators.js';
|
|
7
|
-
const GraphQLJSON = GraphQLJSONImport || GraphQLJSONImport.default;
|
|
8
7
|
const fieldToSchemaMap = ({ nestedFieldName, parentName })=>({
|
|
9
8
|
array: (field)=>recursivelyBuildNestedPaths({
|
|
10
9
|
field,
|
|
@@ -95,9 +94,34 @@ const fieldToSchemaMap = ({ nestedFieldName, parentName })=>({
|
|
|
95
94
|
textarea: (field)=>({
|
|
96
95
|
type: withOperators(field, parentName)
|
|
97
96
|
}),
|
|
98
|
-
upload: (field)=>
|
|
97
|
+
upload: (field)=>{
|
|
98
|
+
if (Array.isArray(field.relationTo)) {
|
|
99
|
+
return {
|
|
100
|
+
type: new GraphQLInputObjectType({
|
|
101
|
+
name: `${combineParentName(parentName, field.name)}_Relation`,
|
|
102
|
+
fields: {
|
|
103
|
+
relationTo: {
|
|
104
|
+
type: new GraphQLEnumType({
|
|
105
|
+
name: `${combineParentName(parentName, field.name)}_Relation_RelationTo`,
|
|
106
|
+
values: field.relationTo.reduce((values, relation)=>({
|
|
107
|
+
...values,
|
|
108
|
+
[formatName(relation)]: {
|
|
109
|
+
value: relation
|
|
110
|
+
}
|
|
111
|
+
}), {})
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
value: {
|
|
115
|
+
type: GraphQLJSON
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
99
122
|
type: withOperators(field, parentName)
|
|
100
|
-
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
101
125
|
});
|
|
102
126
|
export default fieldToSchemaMap;
|
|
103
127
|
|
|
@@ -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
|
|
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 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})\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;gBAC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,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;YACP,IAAIc,MAAMC,OAAO,CAACf,MAAMgB,UAAU,GAAG;gBACnC,OAAO;oBACLb,MAAM,IAAIb,uBAAuB;wBAC/B2B,MAAM,CAAC,EAAEzB,kBAAkBM,YAAYE,MAAMiB,IAAI,EAAE,SAAS,CAAC;wBAC7DC,QAAQ;4BACNF,YAAY;gCACVb,MAAM,IAAId,gBAAgB;oCACxB4B,MAAM,CAAC,EAAEzB,kBAAkBM,YAAYE,MAAMiB,IAAI,EAAE,oBAAoB,CAAC;oCACxEE,QAAQnB,MAAMgB,UAAU,CAACI,MAAM,CAC7B,CAACD,QAAQE,WAAc,CAAA;4CACrB,GAAGF,MAAM;4CACT,CAAC1B,WAAW4B,UAAU,EAAE;gDACtBC,OAAOD;4CACT;wCACF,CAAA,GACA,CAAC;gCAEL;4BACF;4BACAC,OAAO;gCAAEnB,MAAMZ;4BAAY;wBAC7B;oBACF;gBACF;YACF;YAEA,OAAO;gBACLY,MAAMR,cAAcK,OAAOF;YAC7B;QACF;IACF,CAAA;AAEA,eAAeF,iBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCollections.d.ts","sourceRoot":"","sources":["../../src/schema/initCollections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initCollections.d.ts","sourceRoot":"","sources":["../../src/schema/initCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EAEX,eAAe,EAChB,MAAM,SAAS,CAAA;AAyChB,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,iBAAS,sBAAsB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,0BAA0B,GAAG,IAAI,CAgd3F;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { buildVersionCollectionFields } from 'payload/versions';
|
|
1
|
+
import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql';
|
|
2
|
+
import { buildVersionCollectionFields, flattenTopLevelFields, formatNames, toWords } from 'payload';
|
|
3
|
+
import { fieldAffectsData } from 'payload/shared';
|
|
5
4
|
import forgotPassword from '../resolvers/auth/forgotPassword.js';
|
|
6
5
|
import init from '../resolvers/auth/init.js';
|
|
7
6
|
import login from '../resolvers/auth/login.js';
|
|
@@ -11,20 +10,21 @@ import refresh from '../resolvers/auth/refresh.js';
|
|
|
11
10
|
import resetPassword from '../resolvers/auth/resetPassword.js';
|
|
12
11
|
import unlock from '../resolvers/auth/unlock.js';
|
|
13
12
|
import verifyEmail from '../resolvers/auth/verifyEmail.js';
|
|
13
|
+
import { countResolver } from '../resolvers/collections/count.js';
|
|
14
14
|
import createResolver from '../resolvers/collections/create.js';
|
|
15
|
-
import getDeleteResolver from '../resolvers/collections/delete.js';
|
|
15
|
+
import { getDeleteResolver } from '../resolvers/collections/delete.js';
|
|
16
16
|
import { docAccessResolver } from '../resolvers/collections/docAccess.js';
|
|
17
17
|
import duplicateResolver from '../resolvers/collections/duplicate.js';
|
|
18
|
-
import findResolver from '../resolvers/collections/find.js';
|
|
19
|
-
import findByIDResolver from '../resolvers/collections/findByID.js';
|
|
20
|
-
import findVersionByIDResolver from '../resolvers/collections/findVersionByID.js';
|
|
21
|
-
import findVersionsResolver from '../resolvers/collections/findVersions.js';
|
|
18
|
+
import { findResolver } from '../resolvers/collections/find.js';
|
|
19
|
+
import { findByIDResolver } from '../resolvers/collections/findByID.js';
|
|
20
|
+
import { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js';
|
|
21
|
+
import { findVersionsResolver } from '../resolvers/collections/findVersions.js';
|
|
22
22
|
import restoreVersionResolver from '../resolvers/collections/restoreVersion.js';
|
|
23
|
-
import updateResolver from '../resolvers/collections/update.js';
|
|
23
|
+
import { updateResolver } from '../resolvers/collections/update.js';
|
|
24
24
|
import formatName from '../utilities/formatName.js';
|
|
25
25
|
import { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js';
|
|
26
|
-
import buildObjectType from './buildObjectType.js';
|
|
27
|
-
import buildPaginatedListType from './buildPaginatedListType.js';
|
|
26
|
+
import { buildObjectType } from './buildObjectType.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 }) {
|
|
@@ -162,6 +162,30 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
162
162
|
},
|
|
163
163
|
resolve: findResolver(collection)
|
|
164
164
|
};
|
|
165
|
+
graphqlResult.Query.fields[`count${pluralName}`] = {
|
|
166
|
+
type: new GraphQLObjectType({
|
|
167
|
+
name: `count${pluralName}`,
|
|
168
|
+
fields: {
|
|
169
|
+
totalDocs: {
|
|
170
|
+
type: GraphQLInt
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
args: {
|
|
175
|
+
draft: {
|
|
176
|
+
type: GraphQLBoolean
|
|
177
|
+
},
|
|
178
|
+
where: {
|
|
179
|
+
type: collection.graphQL.whereInputType
|
|
180
|
+
},
|
|
181
|
+
...config.localization ? {
|
|
182
|
+
locale: {
|
|
183
|
+
type: graphqlResult.types.localeInputType
|
|
184
|
+
}
|
|
185
|
+
} : {}
|
|
186
|
+
},
|
|
187
|
+
resolve: countResolver(collection)
|
|
188
|
+
};
|
|
165
189
|
graphqlResult.Query.fields[`docAccess${singularName}`] = {
|
|
166
190
|
type: buildPolicyType({
|
|
167
191
|
type: 'collection',
|
|
@@ -319,13 +343,16 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
319
343
|
args: {
|
|
320
344
|
id: {
|
|
321
345
|
type: versionIDType
|
|
346
|
+
},
|
|
347
|
+
draft: {
|
|
348
|
+
type: GraphQLBoolean
|
|
322
349
|
}
|
|
323
350
|
},
|
|
324
351
|
resolve: restoreVersionResolver(collection)
|
|
325
352
|
};
|
|
326
353
|
}
|
|
327
354
|
if (collectionConfig.auth) {
|
|
328
|
-
const authFields = collectionConfig.auth.disableLocalStrategy ? [] : [
|
|
355
|
+
const authFields = collectionConfig.auth.disableLocalStrategy || collectionConfig.auth.loginWithUsername && !collectionConfig.auth.loginWithUsername.allowEmailLogin && !collectionConfig.auth.loginWithUsername.requireEmail ? [] : [
|
|
329
356
|
{
|
|
330
357
|
name: 'email',
|
|
331
358
|
type: 'email',
|
|
@@ -357,6 +384,9 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
357
384
|
exp: {
|
|
358
385
|
type: GraphQLInt
|
|
359
386
|
},
|
|
387
|
+
strategy: {
|
|
388
|
+
type: GraphQLString
|
|
389
|
+
},
|
|
360
390
|
token: {
|
|
361
391
|
type: GraphQLString
|
|
362
392
|
},
|
|
@@ -381,16 +411,14 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
381
411
|
refreshedToken: {
|
|
382
412
|
type: GraphQLString
|
|
383
413
|
},
|
|
414
|
+
strategy: {
|
|
415
|
+
type: GraphQLString
|
|
416
|
+
},
|
|
384
417
|
user: {
|
|
385
418
|
type: collection.graphQL.JWT
|
|
386
419
|
}
|
|
387
420
|
}
|
|
388
421
|
}),
|
|
389
|
-
args: {
|
|
390
|
-
token: {
|
|
391
|
-
type: GraphQLString
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
422
|
resolve: refresh(collection)
|
|
395
423
|
};
|
|
396
424
|
graphqlResult.Mutation.fields[`logout${singularName}`] = {
|
|
@@ -398,14 +426,23 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
398
426
|
resolve: logout(collection)
|
|
399
427
|
};
|
|
400
428
|
if (!collectionConfig.auth.disableLocalStrategy) {
|
|
429
|
+
const authArgs = {};
|
|
430
|
+
const canLoginWithEmail = !collectionConfig.auth.loginWithUsername || collectionConfig.auth.loginWithUsername?.allowEmailLogin;
|
|
431
|
+
const canLoginWithUsername = collectionConfig.auth.loginWithUsername;
|
|
432
|
+
if (canLoginWithEmail) {
|
|
433
|
+
authArgs['email'] = {
|
|
434
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
if (canLoginWithUsername) {
|
|
438
|
+
authArgs['username'] = {
|
|
439
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
440
|
+
};
|
|
441
|
+
}
|
|
401
442
|
if (collectionConfig.auth.maxLoginAttempts > 0) {
|
|
402
443
|
graphqlResult.Mutation.fields[`unlock${singularName}`] = {
|
|
403
444
|
type: new GraphQLNonNull(GraphQLBoolean),
|
|
404
|
-
args:
|
|
405
|
-
email: {
|
|
406
|
-
type: new GraphQLNonNull(GraphQLString)
|
|
407
|
-
}
|
|
408
|
-
},
|
|
445
|
+
args: authArgs,
|
|
409
446
|
resolve: unlock(collection)
|
|
410
447
|
};
|
|
411
448
|
}
|
|
@@ -425,9 +462,7 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
425
462
|
}
|
|
426
463
|
}),
|
|
427
464
|
args: {
|
|
428
|
-
|
|
429
|
-
type: GraphQLString
|
|
430
|
-
},
|
|
465
|
+
...authArgs,
|
|
431
466
|
password: {
|
|
432
467
|
type: GraphQLString
|
|
433
468
|
}
|
|
@@ -440,12 +475,10 @@ function initCollectionsGraphQL({ config, graphqlResult }) {
|
|
|
440
475
|
disableEmail: {
|
|
441
476
|
type: GraphQLBoolean
|
|
442
477
|
},
|
|
443
|
-
email: {
|
|
444
|
-
type: new GraphQLNonNull(GraphQLString)
|
|
445
|
-
},
|
|
446
478
|
expiration: {
|
|
447
479
|
type: GraphQLInt
|
|
448
|
-
}
|
|
480
|
+
},
|
|
481
|
+
...authArgs
|
|
449
482
|
},
|
|
450
483
|
resolve: forgotPassword(collection)
|
|
451
484
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { GraphQLInfo } from 'payload/config'\nimport type { Collection, Field, SanitizedCollectionConfig, SanitizedConfig } from 'payload/types'\n\nimport {\n GraphQLBoolean,\n GraphQLInt,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLString,\n} from 'graphql'\nimport { fieldAffectsData } from 'payload/types'\nimport { flattenTopLevelFields, formatNames, toWords } from 'payload/utilities'\nimport { buildVersionCollectionFields } from 'payload/versions'\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 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[`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","fieldAffectsData","flattenTopLevelFields","formatNames","toWords","buildVersionCollectionFields","forgotPassword","init","login","logout","me","refresh","resetPassword","unlock","verifyEmail","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","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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jDgH,YAAY;4BAAEpD,MAAM/D;wBAAW;oBACjC;oBACAyF,SAAShF,eAAekC;gBAC1B;gBAEAN,cAAc4D,QAAQ,CAACpD,MAAM,CAAC,CAAC,aAAa,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC9De,MAAM,IAAI7D,kBAAkB;wBAC1BsD,MAAM5B,WAAW,CAAC,EAAEc,KAAK,aAAa,CAAC;wBACvCG,QAAQ;4BACN+D,OAAO;gCAAE7C,MAAM5D;4BAAc;4BAC7B0G,MAAM;gCAAE9C,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;4BAAC;wBACxC;oBACF;oBACAkB,MAAM;wBACJgC,UAAU;4BAAElD,MAAM5D;wBAAc;wBAChCyG,OAAO;4BAAE7C,MAAM5D;wBAAc;oBAC/B;oBACAsF,SAAS1E,cAAc4B;gBACzB;gBAEAN,cAAc4D,QAAQ,CAACpD,MAAM,CAAC,CAAC,WAAW,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC5De,MAAMhE;oBACNkF,MAAM;wBACJ2B,OAAO;4BAAE7C,MAAM5D;wBAAc;oBAC/B;oBACAsF,SAASxE,YAAY0B;gBACvB;YACF;QACF;IACF;AACF;AAEA,eAAeR,uBAAsB"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/initCollections.ts"],"sourcesContent":["import type {\n Collection,\n Field,\n GraphQLInfo,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} 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 draft: { type: GraphQLBoolean },\n },\n resolve: restoreVersionResolver(collection),\n }\n }\n\n if (collectionConfig.auth) {\n const authFields: Field[] =\n collectionConfig.auth.disableLocalStrategy ||\n (collectionConfig.auth.loginWithUsername &&\n !collectionConfig.auth.loginWithUsername.allowEmailLogin &&\n !collectionConfig.auth.loginWithUsername.requireEmail)\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 strategy: {\n type: GraphQLString,\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 strategy: {\n type: GraphQLString,\n },\n user: {\n type: collection.graphQL.JWT,\n },\n },\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 const authArgs = {}\n\n const canLoginWithEmail =\n !collectionConfig.auth.loginWithUsername ||\n collectionConfig.auth.loginWithUsername?.allowEmailLogin\n const canLoginWithUsername = collectionConfig.auth.loginWithUsername\n\n if (canLoginWithEmail) {\n authArgs['email'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n if (canLoginWithUsername) {\n authArgs['username'] = { type: new GraphQLNonNull(GraphQLString) }\n }\n\n if (collectionConfig.auth.maxLoginAttempts > 0) {\n graphqlResult.Mutation.fields[`unlock${singularName}`] = {\n type: new GraphQLNonNull(GraphQLBoolean),\n args: authArgs,\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 ...authArgs,\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 expiration: { type: GraphQLInt },\n ...authArgs,\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","loginWithUsername","allowEmailLogin","requireEmail","JWT","saveToJWT","exp","strategy","token","user","refreshedToken","authArgs","canLoginWithEmail","canLoginWithUsername","maxLoginAttempts","password","disableEmail","expiration"],"mappings":"AAQA,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,iBAAgB;AAIjD,OAAOC,oBAAoB,sCAAqC;AAChE,OAAOC,UAAU,4BAA2B;AAC5C,OAAOC,WAAW,6BAA4B;AAC9C,OAAOC,YAAY,8BAA6B;AAChD,OAAOC,QAAQ,0BAAyB;AACxC,OAAOC,aAAa,+BAA8B;AAClD,OAAOC,mBAAmB,qCAAoC;AAC9D,OAAOC,YAAY,8BAA6B;AAChD,OAAOC,iBAAiB,mCAAkC;AAC1D,SAASC,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,oBAAoB,qCAAoC;AAC/D,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,iBAAiB,QAAQ,wCAAuC;AACzE,O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AACrD,MAAM,CAAC,CAAC,cAAc,EAAEG,aAAa,CAAC,CAAC,GAAG;oBAC/De,MAAM,IAAI/D,eAAeF;oBACzBmF,MAAM;wBACJwC,cAAc;4BAAE1D,MAAMjE;wBAAe;wBACrC4H,YAAY;4BAAE3D,MAAMhE;wBAAW;wBAC/B,GAAGqH,QAAQ;oBACb;oBACA3B,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;4BACNoE,OAAO;gCAAElD,MAAM7D;4BAAc;4BAC7BgH,MAAM;gCAAEnD,MAAMpB,WAAWG,OAAO,CAACiB,IAAI;4BAAC;wBACxC;oBACF;oBACAkB,MAAM;wBACJuC,UAAU;4BAAEzD,MAAM7D;wBAAc;wBAChC+G,OAAO;4BAAElD,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;wBACJgC,OAAO;4BAAElD,MAAM7D;wBAAc;oBAC/B;oBACAuF,SAASzE,YAAY2B;gBACvB;YACF;QACF;IACF;AACF;AAEA,eAAeR,uBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initGlobals.d.ts","sourceRoot":"","sources":["../../src/schema/initGlobals.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,WAAW,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAiBzF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;CAC3B,CAAA;AACD,iBAAS,kBAAkB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,sBAAsB,GAAG,IAAI,CA2JnF;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql';
|
|
2
2
|
import pluralize from 'pluralize';
|
|
3
3
|
const { singular } = pluralize;
|
|
4
|
-
import { toWords } from 'payload
|
|
5
|
-
import { buildVersionGlobalFields } from 'payload/versions';
|
|
4
|
+
import { buildVersionGlobalFields, toWords } from 'payload';
|
|
6
5
|
import { docAccessResolver } from '../resolvers/globals/docAccess.js';
|
|
7
6
|
import findOneResolver from '../resolvers/globals/findOne.js';
|
|
8
7
|
import findVersionByIDResolver from '../resolvers/globals/findVersionByID.js';
|
|
@@ -11,8 +10,8 @@ import restoreVersionResolver from '../resolvers/globals/restoreVersion.js';
|
|
|
11
10
|
import updateResolver from '../resolvers/globals/update.js';
|
|
12
11
|
import formatName from '../utilities/formatName.js';
|
|
13
12
|
import { buildMutationInputType } from './buildMutationInputType.js';
|
|
14
|
-
import buildObjectType from './buildObjectType.js';
|
|
15
|
-
import buildPaginatedListType from './buildPaginatedListType.js';
|
|
13
|
+
import { buildObjectType } from './buildObjectType.js';
|
|
14
|
+
import { buildPaginatedListType } from './buildPaginatedListType.js';
|
|
16
15
|
import { buildPolicyType } from './buildPoliciesType.js';
|
|
17
16
|
import buildWhereInputType from './buildWhereInputType.js';
|
|
18
17
|
function initGlobalsGraphQL({ config, graphqlResult }) {
|
|
@@ -121,6 +120,9 @@ function initGlobalsGraphQL({ config, graphqlResult }) {
|
|
|
121
120
|
id: {
|
|
122
121
|
type: idType
|
|
123
122
|
},
|
|
123
|
+
draft: {
|
|
124
|
+
type: GraphQLBoolean
|
|
125
|
+
},
|
|
124
126
|
...config.localization ? {
|
|
125
127
|
fallbackLocale: {
|
|
126
128
|
type: graphqlResult.types.fallbackLocaleInputType
|
|
@@ -167,6 +169,9 @@ function initGlobalsGraphQL({ config, graphqlResult }) {
|
|
|
167
169
|
args: {
|
|
168
170
|
id: {
|
|
169
171
|
type: idType
|
|
172
|
+
},
|
|
173
|
+
draft: {
|
|
174
|
+
type: GraphQLBoolean
|
|
170
175
|
}
|
|
171
176
|
},
|
|
172
177
|
resolve: restoreVersionResolver(global)
|