@payloadcms/graphql 3.0.0-beta.6 → 3.0.0-beta.60
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 +5 -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 +2 -2
- 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 +64 -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 +1 -2
- 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 +1 -2
- package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/collections/restoreVersion.js +1 -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 +1 -1
- package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/globals/restoreVersion.js +1 -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 +4 -5
- 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 +66 -40
- 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 +1 -2
- package/dist/schema/fieldToWhereInputSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts +2 -2
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +44 -16
- 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 +3 -4
- 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 +2 -2
- 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.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 +33 -23
- package/src/index.ts +0 -126
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/withOperators.ts"],"sourcesContent":["import type { GraphQLType } from 'graphql'\nimport type { FieldAffectingData, NumberField, RadioField, SelectField } from 'payload/types'\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 { GraphQLJSON } from 'graphql-type-json'\nimport { optionIsObject } from 'payload/types'\n\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","GraphQLJSON","optionIsObject","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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,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,OAAO;mBAAKZ,UAAUgB,QAAQ;aAAC,CAACP,GAAG,CAA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AAoF;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"],"
|
|
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"],"
|
|
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"],"
|
|
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,"file":"formatOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/formatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"formatOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/formatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAItD,QAAA,MAAM,aAAa,UAAW,UAAU,GAAG,WAAW,OAkBrD,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/formatOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from 'payload
|
|
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"],"
|
|
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,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"groupOrTabHasRequiredSubfield.d.ts","sourceRoot":"","sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIzC,eAAO,MAAM,6BAA6B,WAAY,KAAK,GAAG,GAAG,KAAG,OAenE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/groupOrTabHasRequiredSubfield.ts"],"sourcesContent":["import type { Field, Tab } from 'payload
|
|
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"],"
|
|
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ObjMap } from 'graphql/jsutils/ObjMap.js';
|
|
2
2
|
import type { GraphQLFieldConfig } from 'graphql/type/definition.js';
|
|
3
|
-
import type { PayloadRequest } from 'payload
|
|
3
|
+
import type { PayloadRequest } from 'payload';
|
|
4
4
|
type PayloadContext = {
|
|
5
5
|
req: PayloadRequest;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapCustomResolver.d.ts","sourceRoot":"","sources":["../../src/utilities/wrapCustomResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,4BAA4B,CAAA;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"wrapCustomResolver.d.ts","sourceRoot":"","sources":["../../src/utilities/wrapCustomResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,4BAA4B,CAAA;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,KAAK,cAAc,GAAG;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,CAAA;AAe7C,wBAAgB,gBAAgB,CAAC,OAAO,EACtC,MAAM,EAAE,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,GAC1D,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAOrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/wrapCustomResolver.ts"],"sourcesContent":["import type { ObjMap } from 'graphql/jsutils/ObjMap.js'\nimport type { GraphQLFieldConfig, GraphQLFieldResolver } from 'graphql/type/definition.js'\nimport type { PayloadRequest } from 'payload
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/wrapCustomResolver.ts"],"sourcesContent":["import type { ObjMap } from 'graphql/jsutils/ObjMap.js'\nimport type { GraphQLFieldConfig, GraphQLFieldResolver } from 'graphql/type/definition.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { isolateObjectProperty } from 'payload'\n\ntype PayloadContext = { req: PayloadRequest }\n\nfunction wrapCustomResolver<TSource, TArgs, TResult>(\n resolver: GraphQLFieldResolver<TSource, PayloadContext, TArgs, TResult>,\n): GraphQLFieldResolver<TSource, PayloadContext, TArgs, TResult> {\n return (source, args, context, info) => {\n return resolver(\n source,\n args,\n { ...context, req: isolateObjectProperty(context.req, 'transactionID') },\n info,\n )\n }\n}\n\nexport function wrapCustomFields<TSource>(\n fields: ObjMap<GraphQLFieldConfig<TSource, PayloadContext>>,\n): ObjMap<GraphQLFieldConfig<TSource, PayloadContext>> {\n for (const key in fields) {\n if (fields[key].resolve) {\n fields[key].resolve = wrapCustomResolver(fields[key].resolve)\n }\n }\n return fields\n}\n"],"names":["isolateObjectProperty","wrapCustomResolver","resolver","source","args","context","info","req","wrapCustomFields","fields","key","resolve"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,UAAS;AAI/C,SAASC,mBACPC,QAAuE;IAEvE,OAAO,CAACC,QAAQC,MAAMC,SAASC;QAC7B,OAAOJ,SACLC,QACAC,MACA;YAAE,GAAGC,OAAO;YAAEE,KAAKP,sBAAsBK,QAAQE,GAAG,EAAE;QAAiB,GACvED;IAEJ;AACF;AAEA,OAAO,SAASE,iBACdC,MAA2D;IAE3D,IAAK,MAAMC,OAAOD,OAAQ;QACxB,IAAIA,MAAM,CAACC,IAAI,CAACC,OAAO,EAAE;YACvBF,MAAM,CAACC,IAAI,CAACC,OAAO,GAAGV,mBAAmBQ,MAAM,CAACC,IAAI,CAACC,OAAO;QAC9D;IACF;IACA,OAAOF;AACT"}
|
package/package.json
CHANGED
|
@@ -1,46 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/graphql",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
4
|
-
"main": "./dist/index.js",
|
|
5
|
-
"types": "./dist/index.d.ts",
|
|
6
|
-
"type": "module",
|
|
3
|
+
"version": "3.0.0-beta.60",
|
|
7
4
|
"homepage": "https://payloadcms.com",
|
|
8
5
|
"repository": {
|
|
9
6
|
"type": "git",
|
|
10
7
|
"url": "https://github.com/payloadcms/payload.git",
|
|
11
8
|
"directory": "packages/graphql"
|
|
12
9
|
},
|
|
10
|
+
"type": "module",
|
|
13
11
|
"exports": {
|
|
14
12
|
".": {
|
|
15
13
|
"import": "./dist/index.js",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"import": "./dist/exports/types.js",
|
|
19
|
+
"types": "./dist/exports/types.d.ts",
|
|
20
|
+
"default": "./dist/exports/types.js"
|
|
21
|
+
},
|
|
22
|
+
"./utilities": {
|
|
23
|
+
"import": "./dist/exports/utilities.js",
|
|
24
|
+
"types": "./dist/exports/utilities.d.ts",
|
|
25
|
+
"default": "./dist/exports/utilities.js"
|
|
18
26
|
}
|
|
19
27
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"payload": "
|
|
24
|
-
"@payloadcms/eslint-config": "1.1.1"
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"bin": {
|
|
31
|
+
"payload-graphql": "bin.js"
|
|
25
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
26
36
|
"dependencies": {
|
|
27
|
-
"graphql": "16.8.1",
|
|
28
|
-
"graphql-http": "^1.22.0",
|
|
29
|
-
"graphql-playground-html": "1.6.30",
|
|
30
|
-
"graphql-query-complexity": "0.12.0",
|
|
31
37
|
"graphql-scalars": "1.22.2",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
38
|
+
"pluralize": "8.0.0",
|
|
39
|
+
"ts-essentials": "7.0.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/pluralize": "^0.0.33",
|
|
43
|
+
"graphql-http": "^1.22.0",
|
|
44
|
+
"@payloadcms/eslint-config": "3.0.0-beta.59",
|
|
45
|
+
"payload": "3.0.0-beta.60"
|
|
34
46
|
},
|
|
35
47
|
"peerDependencies": {
|
|
36
|
-
"
|
|
48
|
+
"graphql": "^16.8.1",
|
|
49
|
+
"payload": "3.0.0-beta.60"
|
|
37
50
|
},
|
|
38
|
-
"files": [
|
|
39
|
-
"dist"
|
|
40
|
-
],
|
|
41
51
|
"scripts": {
|
|
42
|
-
"build": "pnpm build:
|
|
43
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
|
52
|
+
"build": "pnpm build:types && pnpm build:swc",
|
|
53
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
44
54
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
45
55
|
"clean": "rimraf {dist,*.tsbuildinfo}"
|
|
46
56
|
}
|
package/src/index.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
import type { OperationArgs } from 'graphql-http'
|
|
3
|
-
import type { GraphQLInfo } from 'payload/config'
|
|
4
|
-
import type { SanitizedConfig } from 'payload/types'
|
|
5
|
-
|
|
6
|
-
import * as GraphQL from 'graphql'
|
|
7
|
-
import {
|
|
8
|
-
createComplexityRule,
|
|
9
|
-
fieldExtensionsEstimator,
|
|
10
|
-
simpleEstimator,
|
|
11
|
-
} from 'graphql-query-complexity'
|
|
12
|
-
|
|
13
|
-
import accessResolver from './resolvers/auth/access.js'
|
|
14
|
-
import buildFallbackLocaleInputType from './schema/buildFallbackLocaleInputType.js'
|
|
15
|
-
import buildLocaleInputType from './schema/buildLocaleInputType.js'
|
|
16
|
-
import buildPoliciesType from './schema/buildPoliciesType.js'
|
|
17
|
-
import initCollections from './schema/initCollections.js'
|
|
18
|
-
import initGlobals from './schema/initGlobals.js'
|
|
19
|
-
import { wrapCustomFields } from './utilities/wrapCustomResolver.js'
|
|
20
|
-
|
|
21
|
-
export async function configToSchema(config: SanitizedConfig): Promise<{
|
|
22
|
-
schema: GraphQL.GraphQLSchema
|
|
23
|
-
validationRules: (args: OperationArgs<any>) => GraphQL.ValidationRule[]
|
|
24
|
-
}> {
|
|
25
|
-
const collections = config.collections.reduce((acc, collection) => {
|
|
26
|
-
acc[collection.slug] = {
|
|
27
|
-
config: collection,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return acc
|
|
31
|
-
}, {})
|
|
32
|
-
|
|
33
|
-
const globals = {
|
|
34
|
-
config: config.globals,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const graphqlResult: GraphQLInfo = {
|
|
38
|
-
Mutation: {
|
|
39
|
-
name: 'Mutation',
|
|
40
|
-
fields: {},
|
|
41
|
-
},
|
|
42
|
-
Query: {
|
|
43
|
-
name: 'Query',
|
|
44
|
-
fields: {},
|
|
45
|
-
},
|
|
46
|
-
collections,
|
|
47
|
-
globals,
|
|
48
|
-
types: {
|
|
49
|
-
arrayTypes: {},
|
|
50
|
-
blockInputTypes: {},
|
|
51
|
-
blockTypes: {},
|
|
52
|
-
groupTypes: {},
|
|
53
|
-
tabTypes: {},
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (config.localization) {
|
|
58
|
-
graphqlResult.types['localeInputType'] = buildLocaleInputType(config.localization)
|
|
59
|
-
graphqlResult.types['fallbackLocaleInputType'] = buildFallbackLocaleInputType(
|
|
60
|
-
config.localization,
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
initCollections({ config, graphqlResult })
|
|
65
|
-
initGlobals({ config, graphqlResult })
|
|
66
|
-
|
|
67
|
-
graphqlResult.Query.fields['Access'] = {
|
|
68
|
-
type: buildPoliciesType(config),
|
|
69
|
-
resolve: accessResolver(config),
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (typeof config.graphQL.queries === 'function') {
|
|
73
|
-
const customQueries = config.graphQL.queries(GraphQL, {
|
|
74
|
-
...graphqlResult,
|
|
75
|
-
config,
|
|
76
|
-
})
|
|
77
|
-
graphqlResult.Query = {
|
|
78
|
-
...graphqlResult.Query,
|
|
79
|
-
fields: {
|
|
80
|
-
...graphqlResult.Query.fields,
|
|
81
|
-
...wrapCustomFields((customQueries || {}) as never),
|
|
82
|
-
},
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (typeof config.graphQL.mutations === 'function') {
|
|
87
|
-
const customMutations = config.graphQL.mutations(GraphQL, {
|
|
88
|
-
...graphqlResult,
|
|
89
|
-
config,
|
|
90
|
-
})
|
|
91
|
-
graphqlResult.Mutation = {
|
|
92
|
-
...graphqlResult.Mutation,
|
|
93
|
-
fields: {
|
|
94
|
-
...graphqlResult.Mutation.fields,
|
|
95
|
-
...wrapCustomFields((customMutations || {}) as never),
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const query = new GraphQL.GraphQLObjectType(graphqlResult.Query)
|
|
101
|
-
const mutation = new GraphQL.GraphQLObjectType(graphqlResult.Mutation)
|
|
102
|
-
|
|
103
|
-
const schemaToCreate = {
|
|
104
|
-
mutation,
|
|
105
|
-
query,
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const schema = new GraphQL.GraphQLSchema(schemaToCreate)
|
|
109
|
-
|
|
110
|
-
const validationRules = (args) => [
|
|
111
|
-
createComplexityRule({
|
|
112
|
-
estimators: [
|
|
113
|
-
fieldExtensionsEstimator(),
|
|
114
|
-
simpleEstimator({ defaultComplexity: 1 }), // Fallback if complexity not set
|
|
115
|
-
],
|
|
116
|
-
maximumComplexity: config.graphQL.maxComplexity,
|
|
117
|
-
variables: args.variableValues,
|
|
118
|
-
// onComplete: (complexity) => { console.log('Query Complexity:', complexity); },
|
|
119
|
-
}),
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
schema,
|
|
124
|
-
validationRules,
|
|
125
|
-
}
|
|
126
|
-
}
|