@payloadcms/graphql 4.0.0-internal.e55ccef → 4.0.0-internal.ea6e8f8
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/resolvers/collections/count.d.ts +3 -1
- package/dist/resolvers/collections/count.d.ts.map +1 -1
- package/dist/resolvers/collections/count.js +11 -11
- package/dist/resolvers/collections/count.js.map +1 -1
- package/dist/resolvers/collections/create.d.ts +3 -1
- package/dist/resolvers/collections/create.d.ts.map +1 -1
- package/dist/resolvers/collections/create.js +11 -6
- package/dist/resolvers/collections/create.js.map +1 -1
- package/dist/resolvers/collections/delete.d.ts +3 -1
- package/dist/resolvers/collections/delete.d.ts.map +1 -1
- package/dist/resolvers/collections/delete.js +12 -14
- package/dist/resolvers/collections/delete.js.map +1 -1
- package/dist/resolvers/collections/docAccess.d.ts +5 -4
- package/dist/resolvers/collections/docAccess.d.ts.map +1 -1
- package/dist/resolvers/collections/docAccess.js +10 -3
- package/dist/resolvers/collections/docAccess.js.map +1 -1
- package/dist/resolvers/collections/duplicate.d.ts +3 -1
- package/dist/resolvers/collections/duplicate.d.ts.map +1 -1
- package/dist/resolvers/collections/duplicate.js +12 -9
- package/dist/resolvers/collections/duplicate.js.map +1 -1
- package/dist/resolvers/collections/find.d.ts +1 -0
- package/dist/resolvers/collections/find.d.ts.map +1 -1
- package/dist/resolvers/collections/find.js +11 -10
- package/dist/resolvers/collections/find.js.map +1 -1
- package/dist/resolvers/collections/findByID.d.ts +1 -0
- package/dist/resolvers/collections/findByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findByID.js +11 -10
- package/dist/resolvers/collections/findByID.js.map +1 -1
- package/dist/resolvers/collections/findVersionByID.d.ts +1 -0
- package/dist/resolvers/collections/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersionByID.js +11 -10
- package/dist/resolvers/collections/findVersionByID.js.map +1 -1
- package/dist/resolvers/collections/findVersions.d.ts +1 -0
- package/dist/resolvers/collections/findVersions.d.ts.map +1 -1
- package/dist/resolvers/collections/findVersions.js +11 -10
- package/dist/resolvers/collections/findVersions.js.map +1 -1
- package/dist/resolvers/collections/renameFile.d.ts +8 -0
- package/dist/resolvers/collections/renameFile.d.ts.map +1 -0
- package/dist/resolvers/collections/renameFile.js +10 -0
- package/dist/resolvers/collections/renameFile.js.map +1 -0
- package/dist/resolvers/collections/restoreVersion.d.ts +3 -1
- package/dist/resolvers/collections/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/collections/restoreVersion.js +10 -3
- package/dist/resolvers/collections/restoreVersion.js.map +1 -1
- package/dist/resolvers/collections/update.d.ts +3 -1
- package/dist/resolvers/collections/update.d.ts.map +1 -1
- package/dist/resolvers/collections/update.js +12 -14
- package/dist/resolvers/collections/update.js.map +1 -1
- package/dist/resolvers/collections/validate.d.ts +16 -0
- package/dist/resolvers/collections/validate.d.ts.map +1 -0
- package/dist/resolvers/collections/validate.js +33 -0
- package/dist/resolvers/collections/validate.js.map +1 -0
- package/dist/resolvers/getGraphQLRequest.d.ts +26 -0
- package/dist/resolvers/getGraphQLRequest.d.ts.map +1 -0
- package/dist/resolvers/getGraphQLRequest.js +69 -0
- package/dist/resolvers/getGraphQLRequest.js.map +1 -0
- package/dist/resolvers/globals/docAccess.d.ts +6 -4
- package/dist/resolvers/globals/docAccess.d.ts.map +1 -1
- package/dist/resolvers/globals/docAccess.js +10 -3
- package/dist/resolvers/globals/docAccess.js.map +1 -1
- package/dist/resolvers/globals/findOne.d.ts +1 -0
- package/dist/resolvers/globals/findOne.d.ts.map +1 -1
- package/dist/resolvers/globals/findOne.js +11 -10
- package/dist/resolvers/globals/findOne.js.map +1 -1
- package/dist/resolvers/globals/findVersionByID.d.ts +1 -0
- package/dist/resolvers/globals/findVersionByID.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersionByID.js +11 -10
- package/dist/resolvers/globals/findVersionByID.js.map +1 -1
- package/dist/resolvers/globals/findVersions.d.ts +1 -0
- package/dist/resolvers/globals/findVersions.d.ts.map +1 -1
- package/dist/resolvers/globals/findVersions.js +11 -10
- package/dist/resolvers/globals/findVersions.js.map +1 -1
- package/dist/resolvers/globals/restoreVersion.d.ts +3 -1
- package/dist/resolvers/globals/restoreVersion.d.ts.map +1 -1
- package/dist/resolvers/globals/restoreVersion.js +11 -4
- package/dist/resolvers/globals/restoreVersion.js.map +1 -1
- package/dist/resolvers/globals/update.d.ts +3 -1
- package/dist/resolvers/globals/update.d.ts.map +1 -1
- package/dist/resolvers/globals/update.js +12 -9
- package/dist/resolvers/globals/update.js.map +1 -1
- package/dist/resolvers/globals/validate.d.ts +15 -0
- package/dist/resolvers/globals/validate.d.ts.map +1 -0
- package/dist/resolvers/globals/validate.js +21 -0
- package/dist/resolvers/globals/validate.js.map +1 -0
- package/dist/schema/buildMutationInputType.d.ts.map +1 -1
- package/dist/schema/buildMutationInputType.js +8 -2
- package/dist/schema/buildMutationInputType.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 +6 -3
- package/dist/schema/buildPoliciesType.js.map +1 -1
- package/dist/schema/buildValidationResultType.d.ts +3 -0
- package/dist/schema/buildValidationResultType.d.ts.map +1 -0
- package/dist/schema/buildValidationResultType.js +30 -0
- package/dist/schema/buildValidationResultType.js.map +1 -0
- package/dist/schema/fieldToSchemaMap.d.ts.map +1 -1
- package/dist/schema/fieldToSchemaMap.js +46 -23
- package/dist/schema/fieldToSchemaMap.js.map +1 -1
- package/dist/schema/initCollections.d.ts.map +1 -1
- package/dist/schema/initCollections.js +92 -6
- package/dist/schema/initCollections.js.map +1 -1
- package/dist/schema/initGlobals.d.ts.map +1 -1
- package/dist/schema/initGlobals.js +49 -0
- package/dist/schema/initGlobals.js.map +1 -1
- package/dist/schema/withOperators.d.ts +6 -0
- package/dist/schema/withOperators.d.ts.map +1 -1
- package/dist/schema/withOperators.js +15 -0
- package/dist/schema/withOperators.js.map +1 -1
- package/dist/utilities/select.d.ts +4 -3
- package/dist/utilities/select.d.ts.map +1 -1
- package/dist/utilities/select.js +83 -45
- package/dist/utilities/select.js.map +1 -1
- package/package.json +4 -4
- package/dist/utilities/formatName.spec.js +0 -57
- package/dist/utilities/formatName.spec.js.map +0 -1
- package/dist/utilities/formatUtcOffset.spec.js +0 -142
- package/dist/utilities/formatUtcOffset.spec.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,MAAM,MAAM,QAAQ,GAAG,CACrB,CAAC,EAAE,OAAO,EACV,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,EACD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,kBAAkB,KACrB,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,wBAAgB,eAAe,CAAC,YAAY,EAAE,qBAAqB,GAAG,QAAQ,CAwB7E"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { findVersionByIDOperationGlobal
|
|
1
|
+
import { findVersionByIDOperationGlobal } from 'payload';
|
|
2
2
|
import { buildSelectForCollection } from '../../utilities/select.js';
|
|
3
|
+
import { getGraphQLRequest } from '../getGraphQLRequest.js';
|
|
3
4
|
export function findVersionByID(globalConfig) {
|
|
4
5
|
return async function resolver(_, args, context, info) {
|
|
5
|
-
const req =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const req = await getGraphQLRequest({
|
|
7
|
+
branch: args.branch,
|
|
8
|
+
context,
|
|
9
|
+
fallbackLocale: args.fallbackLocale,
|
|
10
|
+
globalSlug: globalConfig.slug,
|
|
11
|
+
info,
|
|
12
|
+
locale: args.locale
|
|
13
|
+
});
|
|
14
|
+
const select = args.select ? buildSelectForCollection(info, context) : undefined;
|
|
14
15
|
const options = {
|
|
15
16
|
id: args.id,
|
|
16
17
|
depth: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/resolvers/globals/findVersionByID.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, SanitizedGlobalConfig } from 'payload'\n\nimport { findVersionByIDOperationGlobal
|
|
1
|
+
{"version":3,"sources":["../../../src/resolvers/globals/findVersionByID.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, SanitizedGlobalConfig } from 'payload'\n\nimport { findVersionByIDOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { buildSelectForCollection } from '../../utilities/select.js'\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver = (\n _: unknown,\n args: {\n branch?: string\n draft?: boolean\n fallbackLocale?: string\n id: number | string\n locale?: string\n select?: boolean\n },\n context: Context,\n info: GraphQLResolveInfo,\n) => Promise<Document>\n\nexport function findVersionByID(globalConfig: SanitizedGlobalConfig): Resolver {\n return async function resolver(_, args, context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n fallbackLocale: args.fallbackLocale,\n globalSlug: globalConfig.slug,\n info,\n locale: args.locale,\n })\n const select = args.select ? buildSelectForCollection(info, context) : undefined\n\n const options = {\n id: args.id,\n depth: 0,\n draft: args.draft,\n globalConfig,\n req,\n select,\n }\n\n const result = await findVersionByIDOperationGlobal(options)\n return result\n }\n}\n"],"names":["findVersionByIDOperationGlobal","buildSelectForCollection","getGraphQLRequest","findVersionByID","globalConfig","resolver","_","args","context","info","req","branch","fallbackLocale","globalSlug","slug","locale","select","undefined","options","id","depth","draft","result"],"mappings":"AAGA,SAASA,8BAA8B,QAAQ,UAAS;AAIxD,SAASC,wBAAwB,QAAQ,4BAA2B;AACpE,SAASC,iBAAiB,QAAQ,0BAAyB;AAgB3D,OAAO,SAASC,gBAAgBC,YAAmC;IACjE,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI;QACnD,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBH;YACAI,gBAAgBL,KAAKK,cAAc;YACnCC,YAAYT,aAAaU,IAAI;YAC7BL;YACAM,QAAQR,KAAKQ,MAAM;QACrB;QACA,MAAMC,SAAST,KAAKS,MAAM,GAAGf,yBAAyBQ,MAAMD,WAAWS;QAEvE,MAAMC,UAAU;YACdC,IAAIZ,KAAKY,EAAE;YACXC,OAAO;YACPC,OAAOd,KAAKc,KAAK;YACjBjB;YACAM;YACAM;QACF;QAEA,MAAMM,SAAS,MAAMtB,+BAA+BkB;QACpD,OAAOI;IACT;AACF"}
|
|
@@ -2,6 +2,7 @@ import type { GraphQLResolveInfo } from 'graphql';
|
|
|
2
2
|
import type { Document, SanitizedGlobalConfig, Where } from 'payload';
|
|
3
3
|
import type { Context } from '../types.js';
|
|
4
4
|
export type Resolver = (_: unknown, args: {
|
|
5
|
+
branch?: string;
|
|
5
6
|
fallbackLocale?: string;
|
|
6
7
|
limit?: number;
|
|
7
8
|
locale?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,MAAM,MAAM,QAAQ,GAAG,CACrB,CAAC,EAAE,OAAO,EACV,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,EACD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,kBAAkB,KACrB,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,wBAAgB,YAAY,CAAC,YAAY,EAAE,qBAAqB,GAAG,QAAQ,CA6B1E"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { findVersionsOperationGlobal
|
|
1
|
+
import { findVersionsOperationGlobal } from 'payload';
|
|
2
2
|
import { buildSelectForCollectionMany } from '../../utilities/select.js';
|
|
3
|
+
import { getGraphQLRequest } from '../getGraphQLRequest.js';
|
|
3
4
|
export function findVersions(globalConfig) {
|
|
4
5
|
return async function resolver(_, args, context, info) {
|
|
5
|
-
const req =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const req = await getGraphQLRequest({
|
|
7
|
+
branch: args.branch,
|
|
8
|
+
context,
|
|
9
|
+
fallbackLocale: args.fallbackLocale,
|
|
10
|
+
globalSlug: globalConfig.slug,
|
|
11
|
+
info,
|
|
12
|
+
locale: args.locale
|
|
13
|
+
});
|
|
14
|
+
const select = args.select ? buildSelectForCollectionMany(info, context) : undefined;
|
|
14
15
|
const { sort } = args;
|
|
15
16
|
const options = {
|
|
16
17
|
depth: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/resolvers/globals/findVersions.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, SanitizedGlobalConfig, Where } from 'payload'\n\nimport { findVersionsOperationGlobal
|
|
1
|
+
{"version":3,"sources":["../../../src/resolvers/globals/findVersions.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, SanitizedGlobalConfig, Where } from 'payload'\n\nimport { findVersionsOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { buildSelectForCollectionMany } from '../../utilities/select.js'\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\nexport type Resolver = (\n _: unknown,\n args: {\n branch?: string\n fallbackLocale?: string\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n select?: boolean\n sort?: string\n where: Where\n },\n context: Context,\n info: GraphQLResolveInfo,\n) => Promise<Document>\n\nexport function findVersions(globalConfig: SanitizedGlobalConfig): Resolver {\n return async function resolver(_, args, context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n fallbackLocale: args.fallbackLocale,\n globalSlug: globalConfig.slug,\n info,\n locale: args.locale,\n })\n const select = args.select ? buildSelectForCollectionMany(info, context) : undefined\n\n const { sort } = args\n\n const options = {\n depth: 0,\n globalConfig,\n limit: args.limit,\n page: args.page,\n pagination: args.pagination,\n req,\n select,\n sort: sort && typeof sort === 'string' ? sort.split(',') : undefined,\n where: args.where,\n }\n\n const result = await findVersionsOperationGlobal(options)\n return result\n }\n}\n"],"names":["findVersionsOperationGlobal","buildSelectForCollectionMany","getGraphQLRequest","findVersions","globalConfig","resolver","_","args","context","info","req","branch","fallbackLocale","globalSlug","slug","locale","select","undefined","sort","options","depth","limit","page","pagination","split","where","result"],"mappings":"AAGA,SAASA,2BAA2B,QAAQ,UAAS;AAIrD,SAASC,4BAA4B,QAAQ,4BAA2B;AACxE,SAASC,iBAAiB,QAAQ,0BAAyB;AAmB3D,OAAO,SAASC,aAAaC,YAAmC;IAC9D,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI;QACnD,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBH;YACAI,gBAAgBL,KAAKK,cAAc;YACnCC,YAAYT,aAAaU,IAAI;YAC7BL;YACAM,QAAQR,KAAKQ,MAAM;QACrB;QACA,MAAMC,SAAST,KAAKS,MAAM,GAAGf,6BAA6BQ,MAAMD,WAAWS;QAE3E,MAAM,EAAEC,IAAI,EAAE,GAAGX;QAEjB,MAAMY,UAAU;YACdC,OAAO;YACPhB;YACAiB,OAAOd,KAAKc,KAAK;YACjBC,MAAMf,KAAKe,IAAI;YACfC,YAAYhB,KAAKgB,UAAU;YAC3Bb;YACAM;YACAE,MAAMA,QAAQ,OAAOA,SAAS,WAAWA,KAAKM,KAAK,CAAC,OAAOP;YAC3DQ,OAAOlB,KAAKkB,KAAK;QACnB;QAEA,MAAMC,SAAS,MAAM1B,4BAA4BmB;QACjD,OAAOO;IACT;AACF"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
1
2
|
import type { Document, PayloadRequest, SanitizedGlobalConfig } from 'payload';
|
|
2
3
|
type Resolver = (_: unknown, args: {
|
|
4
|
+
branch?: string;
|
|
3
5
|
draft?: boolean;
|
|
4
6
|
id: number | string;
|
|
5
7
|
}, context: {
|
|
6
8
|
req: PayloadRequest;
|
|
7
|
-
}) => Promise<Document>;
|
|
9
|
+
}, info: GraphQLResolveInfo) => Promise<Document>;
|
|
8
10
|
export declare function restoreVersion(globalConfig: SanitizedGlobalConfig): Resolver;
|
|
9
11
|
export {};
|
|
10
12
|
//# sourceMappingURL=restoreVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAQ9E,KAAK,QAAQ,GAAG,CACd,CAAC,EAAE,OAAO,EACV,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB,EACD,OAAO,EAAE;IACP,GAAG,EAAE,cAAc,CAAA;CACpB,EACD,IAAI,EAAE,kBAAkB,KACrB,OAAO,CAAC,QAAQ,CAAC,CAAA;AACtB,wBAAgB,cAAc,CAAC,YAAY,EAAE,qBAAqB,GAAG,QAAQ,CAmB5E"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { restoreVersionOperationGlobal } from 'payload';
|
|
2
|
+
import { getGraphQLRequest } from '../getGraphQLRequest.js';
|
|
2
3
|
export function restoreVersion(globalConfig) {
|
|
3
|
-
return async function resolver(_, args, context) {
|
|
4
|
+
return async function resolver(_, args, context, info) {
|
|
5
|
+
const req = await getGraphQLRequest({
|
|
6
|
+
branch: args.branch,
|
|
7
|
+
context,
|
|
8
|
+
globalSlug: globalConfig.slug,
|
|
9
|
+
info
|
|
10
|
+
});
|
|
4
11
|
const options = {
|
|
5
12
|
id: args.id,
|
|
6
13
|
depth: 0,
|
|
7
14
|
draft: args.draft,
|
|
8
15
|
globalConfig,
|
|
9
|
-
req
|
|
16
|
+
req
|
|
10
17
|
};
|
|
11
18
|
const result = await restoreVersionOperationGlobal(options);
|
|
12
|
-
return result;
|
|
19
|
+
return result.version;
|
|
13
20
|
};
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/resolvers/globals/restoreVersion.ts"],"sourcesContent":["import type { Document, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/resolvers/globals/restoreVersion.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type { Document, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nimport { restoreVersionOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\ntype Resolver = (\n _: unknown,\n args: {\n branch?: string\n draft?: boolean\n id: number | string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<Document>\nexport function restoreVersion(globalConfig: SanitizedGlobalConfig): Resolver {\n return async function resolver(_, args, context: Context, info) {\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n globalSlug: globalConfig.slug,\n info,\n })\n const options = {\n id: args.id,\n depth: 0,\n draft: args.draft,\n globalConfig,\n req,\n }\n\n const result = await restoreVersionOperationGlobal(options)\n return result.version\n }\n}\n"],"names":["restoreVersionOperationGlobal","getGraphQLRequest","restoreVersion","globalConfig","resolver","_","args","context","info","req","branch","globalSlug","slug","options","id","depth","draft","result","version"],"mappings":"AAGA,SAASA,6BAA6B,QAAQ,UAAS;AAIvD,SAASC,iBAAiB,QAAQ,0BAAyB;AAc3D,OAAO,SAASC,eAAeC,YAAmC;IAChE,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAMC,MAAM,MAAMR,kBAAkB;YAClCS,QAAQJ,KAAKI,MAAM;YACnBH;YACAI,YAAYR,aAAaS,IAAI;YAC7BJ;QACF;QACA,MAAMK,UAAU;YACdC,IAAIR,KAAKQ,EAAE;YACXC,OAAO;YACPC,OAAOV,KAAKU,KAAK;YACjBb;YACAM;QACF;QAEA,MAAMQ,SAAS,MAAMjB,8BAA8Ba;QACnD,OAAOI,OAAOC,OAAO;IACvB;AACF"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
1
2
|
import type { DataFromGlobalSlug, GlobalSlug, PayloadRequest, SanitizedGlobalConfig } from 'payload';
|
|
2
3
|
import type { DeepPartial } from 'ts-essentials';
|
|
3
4
|
type Resolver<TSlug extends GlobalSlug> = (_: unknown, args: {
|
|
5
|
+
branch?: string;
|
|
4
6
|
data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>;
|
|
5
7
|
draft?: boolean;
|
|
6
8
|
fallbackLocale?: string;
|
|
7
9
|
locale?: string;
|
|
8
10
|
}, context: {
|
|
9
11
|
req: PayloadRequest;
|
|
10
|
-
}) => Promise<DataFromGlobalSlug<TSlug>>;
|
|
12
|
+
}, info: GraphQLResolveInfo) => Promise<DataFromGlobalSlug<TSlug>>;
|
|
11
13
|
export declare function update<TSlug extends GlobalSlug>(globalConfig: SanitizedGlobalConfig): Resolver<TSlug>;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAQhD,KAAK,QAAQ,CAAC,KAAK,SAAS,UAAU,IAAI,CACxC,CAAC,EAAE,OAAO,EACV,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACzD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE;IACP,GAAG,EAAE,cAAc,CAAA;CACpB,EACD,IAAI,EAAE,kBAAkB,KACrB,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAA;AAEvC,wBAAgB,MAAM,CAAC,KAAK,SAAS,UAAU,EAC7C,YAAY,EAAE,qBAAqB,GAClC,QAAQ,CAAC,KAAK,CAAC,CAwBjB"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { updateOperationGlobal } from 'payload';
|
|
2
|
+
import { getGraphQLRequest } from '../getGraphQLRequest.js';
|
|
2
3
|
export function update(globalConfig) {
|
|
3
|
-
return async function resolver(_, args, context) {
|
|
4
|
-
if (args.locale) {
|
|
5
|
-
context.req.locale = args.locale;
|
|
6
|
-
}
|
|
7
|
-
if (args.fallbackLocale) {
|
|
8
|
-
context.req.fallbackLocale = args.fallbackLocale;
|
|
9
|
-
}
|
|
4
|
+
return async function resolver(_, args, context, info) {
|
|
10
5
|
const { slug } = globalConfig;
|
|
6
|
+
const req = await getGraphQLRequest({
|
|
7
|
+
branch: args.branch,
|
|
8
|
+
context,
|
|
9
|
+
fallbackLocale: args.fallbackLocale,
|
|
10
|
+
globalSlug: slug,
|
|
11
|
+
info,
|
|
12
|
+
locale: args.locale
|
|
13
|
+
});
|
|
11
14
|
const options = {
|
|
12
15
|
slug,
|
|
13
16
|
data: args.data,
|
|
14
17
|
depth: 0,
|
|
15
18
|
draft: args.draft,
|
|
16
19
|
globalConfig,
|
|
17
|
-
req
|
|
20
|
+
req
|
|
18
21
|
};
|
|
19
22
|
const result = await updateOperationGlobal(options);
|
|
20
23
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/resolvers/globals/update.ts"],"sourcesContent":["import type {\n DataFromGlobalSlug,\n GlobalSlug,\n PayloadRequest,\n SanitizedGlobalConfig,\n SelectType,\n} from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/resolvers/globals/update.ts"],"sourcesContent":["import type { GraphQLResolveInfo } from 'graphql'\nimport type {\n DataFromGlobalSlug,\n GlobalSlug,\n PayloadRequest,\n SanitizedGlobalConfig,\n SelectType,\n} from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport { updateOperationGlobal } from 'payload'\n\nimport type { Context } from '../types.js'\n\nimport { getGraphQLRequest } from '../getGraphQLRequest.js'\n\ntype Resolver<TSlug extends GlobalSlug> = (\n _: unknown,\n args: {\n branch?: string\n data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n draft?: boolean\n fallbackLocale?: string\n locale?: string\n },\n context: {\n req: PayloadRequest\n },\n info: GraphQLResolveInfo,\n) => Promise<DataFromGlobalSlug<TSlug>>\n\nexport function update<TSlug extends GlobalSlug>(\n globalConfig: SanitizedGlobalConfig,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context, info) {\n const { slug } = globalConfig\n const req = await getGraphQLRequest({\n branch: args.branch,\n context,\n fallbackLocale: args.fallbackLocale,\n globalSlug: slug,\n info,\n locale: args.locale,\n })\n\n const options = {\n slug,\n data: args.data,\n depth: 0,\n draft: args.draft,\n globalConfig,\n req,\n }\n\n const result = await updateOperationGlobal<TSlug, SelectType>(options)\n return result\n }\n}\n"],"names":["updateOperationGlobal","getGraphQLRequest","update","globalConfig","resolver","_","args","context","info","slug","req","branch","fallbackLocale","globalSlug","locale","options","data","depth","draft","result"],"mappings":"AAUA,SAASA,qBAAqB,QAAQ,UAAS;AAI/C,SAASC,iBAAiB,QAAQ,0BAAyB;AAiB3D,OAAO,SAASC,OACdC,YAAmC;IAEnC,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB,EAAEC,IAAI;QAC5D,MAAM,EAAEC,IAAI,EAAE,GAAGN;QACjB,MAAMO,MAAM,MAAMT,kBAAkB;YAClCU,QAAQL,KAAKK,MAAM;YACnBJ;YACAK,gBAAgBN,KAAKM,cAAc;YACnCC,YAAYJ;YACZD;YACAM,QAAQR,KAAKQ,MAAM;QACrB;QAEA,MAAMC,UAAU;YACdN;YACAO,MAAMV,KAAKU,IAAI;YACfC,OAAO;YACPC,OAAOZ,KAAKY,KAAK;YACjBf;YACAO;QACF;QAEA,MAAMS,SAAS,MAAMnB,sBAAyCe;QAC9D,OAAOI;IACT;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataFromGlobalSlug, GlobalSlug, SanitizedGlobalConfig, ValidationResult } from 'payload';
|
|
2
|
+
import type { DeepPartial } from 'ts-essentials';
|
|
3
|
+
import type { Context } from '../types.js';
|
|
4
|
+
export type Resolver<TSlug extends GlobalSlug> = (_: unknown, args: {
|
|
5
|
+
data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>;
|
|
6
|
+
draft?: boolean;
|
|
7
|
+
locale?: string;
|
|
8
|
+
}, context: Context) => Promise<ValidationResult>;
|
|
9
|
+
/**
|
|
10
|
+
* Validates a single locale — the request's resolved locale, or the `locale` argument when
|
|
11
|
+
* provided. Unlike the Local and REST APIs, this does not support validating multiple locales or
|
|
12
|
+
* `locale: 'all'` in one call.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateResolver<TSlug extends GlobalSlug>(globalConfig: SanitizedGlobalConfig): Resolver<TSlug>;
|
|
15
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/resolvers/globals/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAIhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,UAAU,IAAI,CAC/C,CAAC,EAAE,OAAO,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACzD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE9B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,UAAU,EACvD,YAAY,EAAE,qBAAqB,GAClC,QAAQ,CAAC,KAAK,CAAC,CAcjB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isolateObjectProperty } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a single locale — the request's resolved locale, or the `locale` argument when
|
|
4
|
+
* provided. Unlike the Local and REST APIs, this does not support validating multiple locales or
|
|
5
|
+
* `locale: 'all'` in one call.
|
|
6
|
+
*/ export function validateResolver(globalConfig) {
|
|
7
|
+
return async function resolver(_, args, context) {
|
|
8
|
+
const { req } = context;
|
|
9
|
+
const locale = req.payload.config.localization ? args.locale || req.locale : null;
|
|
10
|
+
return req.payload.validateGlobal({
|
|
11
|
+
slug: globalConfig.slug,
|
|
12
|
+
data: args.data,
|
|
13
|
+
draft: args.draft,
|
|
14
|
+
locale,
|
|
15
|
+
overrideAccess: false,
|
|
16
|
+
req: isolateObjectProperty(req, 'transactionID')
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resolvers/globals/validate.ts"],"sourcesContent":["import type {\n DataFromGlobalSlug,\n GlobalSlug,\n SanitizedGlobalConfig,\n ValidationResult,\n} from 'payload'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport { isolateObjectProperty } from 'payload'\n\nimport type { Context } from '../types.js'\n\nexport type Resolver<TSlug extends GlobalSlug> = (\n _: unknown,\n args: {\n data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n draft?: boolean\n locale?: string\n },\n context: Context,\n) => Promise<ValidationResult>\n\n/**\n * Validates a single locale — the request's resolved locale, or the `locale` argument when\n * provided. Unlike the Local and REST APIs, this does not support validating multiple locales or\n * `locale: 'all'` in one call.\n */\nexport function validateResolver<TSlug extends GlobalSlug>(\n globalConfig: SanitizedGlobalConfig,\n): Resolver<TSlug> {\n return async function resolver(_, args, context: Context) {\n const { req } = context\n const locale = req.payload.config.localization ? args.locale || req.locale : null\n\n return req.payload.validateGlobal({\n slug: globalConfig.slug as TSlug,\n data: args.data,\n draft: args.draft,\n locale,\n overrideAccess: false,\n req: isolateObjectProperty(req, 'transactionID'),\n })\n }\n}\n"],"names":["isolateObjectProperty","validateResolver","globalConfig","resolver","_","args","context","req","locale","payload","config","localization","validateGlobal","slug","data","draft","overrideAccess"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ,UAAS;AAc/C;;;;CAIC,GACD,OAAO,SAASC,iBACdC,YAAmC;IAEnC,OAAO,eAAeC,SAASC,CAAC,EAAEC,IAAI,EAAEC,OAAgB;QACtD,MAAM,EAAEC,GAAG,EAAE,GAAGD;QAChB,MAAME,SAASD,IAAIE,OAAO,CAACC,MAAM,CAACC,YAAY,GAAGN,KAAKG,MAAM,IAAID,IAAIC,MAAM,GAAG;QAE7E,OAAOD,IAAIE,OAAO,CAACG,cAAc,CAAC;YAChCC,MAAMX,aAAaW,IAAI;YACvBC,MAAMT,KAAKS,IAAI;YACfC,OAAOV,KAAKU,KAAK;YACjBP;YACAQ,gBAAgB;YAChBT,KAAKP,sBAAsBO,KAAK;QAClC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAOhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAUhB,QAAA,MAAM,YAAY;IAChB,MAAM;IACN,IAAI;CACL,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAOhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAUhB,QAAA,MAAM,YAAY;IAChB,MAAM;IACN,IAAI;CACL,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,CA0W5D"}
|
|
@@ -36,6 +36,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
36
36
|
name: fullName,
|
|
37
37
|
config,
|
|
38
38
|
fields: field.fields,
|
|
39
|
+
forceNullable,
|
|
39
40
|
graphqlResult,
|
|
40
41
|
parentIsLocalized: parentIsLocalized || field.localized,
|
|
41
42
|
parentName: fullName
|
|
@@ -116,6 +117,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
116
117
|
name: fullName,
|
|
117
118
|
config,
|
|
118
119
|
fields: field.fields,
|
|
120
|
+
forceNullable,
|
|
119
121
|
graphqlResult,
|
|
120
122
|
parentIsLocalized: parentIsLocalized || field.localized,
|
|
121
123
|
parentName: fullName
|
|
@@ -123,7 +125,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
123
125
|
if (!type) {
|
|
124
126
|
return inputObjectTypeConfig;
|
|
125
127
|
}
|
|
126
|
-
if (requiresAtLeastOneField) {
|
|
128
|
+
if (requiresAtLeastOneField && !forceNullable) {
|
|
127
129
|
type = new GraphQLNonNull(type);
|
|
128
130
|
}
|
|
129
131
|
return {
|
|
@@ -285,6 +287,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
285
287
|
name: fullName,
|
|
286
288
|
config,
|
|
287
289
|
fields: tab.fields,
|
|
290
|
+
forceNullable,
|
|
288
291
|
graphqlResult,
|
|
289
292
|
parentIsLocalized: parentIsLocalized || tab.localized,
|
|
290
293
|
parentName: fullName
|
|
@@ -292,7 +295,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
292
295
|
if (!type) {
|
|
293
296
|
return acc;
|
|
294
297
|
}
|
|
295
|
-
if (requiresAtLeastOneField) {
|
|
298
|
+
if (requiresAtLeastOneField && !forceNullable) {
|
|
296
299
|
type = new GraphQLNonNull(type);
|
|
297
300
|
}
|
|
298
301
|
return {
|
|
@@ -373,6 +376,9 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
|
|
|
373
376
|
};
|
|
374
377
|
const fieldName = formatName(name);
|
|
375
378
|
const fieldSchemas = fields.reduce((inputObjectTypeConfig, field)=>{
|
|
379
|
+
if ('hidden' in field && field.hidden) {
|
|
380
|
+
return inputObjectTypeConfig;
|
|
381
|
+
}
|
|
376
382
|
const fieldSchema = fieldToSchemaMap[field.type];
|
|
377
383
|
if (typeof fieldSchema !== 'function') {
|
|
378
384
|
return inputObjectTypeConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n SlugField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } 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 { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n slug: (inputObjectTypeConfig: InputObjectTypeConfig, field: SlugField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig)\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\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 type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","slug","inputObjectTypeConfig","array","fullName","localized","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","fieldSchema","schema","Object","keys","length"],"mappings":"AA6BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6B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AEA,OAAO;YACL,GAAGA,qBAAqB;YACxB,GAAG0C,YAAY1C,uBAAuBV,MAAM;QAC9C;IACF,GAAG,CAAC;IAEJ,IAAIsD,OAAOC,IAAI,CAACJ,cAAcK,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAIhF,uBAAuB;QAChCyB,MAAM,CAAC,QAAQ,EAAEiD,UAAU,KAAK,CAAC;QACjCpD,QAAQqD;IACV;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n SlugField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } 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 { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n slug: (inputObjectTypeConfig: InputObjectTypeConfig, field: SlugField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n if (fieldAffectsData(field)) {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n } else {\n return field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig)\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\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 type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n forceNullable,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField && !forceNullable) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [formatName(field.name)]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [formatName(field.name)]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n if ('hidden' in field && field.hidden) {\n return inputObjectTypeConfig\n }\n\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","slug","inputObjectTypeConfig","array","fullName","localized","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","hidden","fieldSchema","schema","Object","keys","length"],"mappings":"AA6BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,6BAA6B,QAAQ,gDAA+C;AAC7F,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,MAAMC,eAAe;IACnBC,QAAQf;IACRgB,MAAMb;AACR;AAEA,OAAO,MAAMc,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUhB,sBAAsBe,WAAWE,MAAM,EAAEC,IAAI,CAC3D,CAACC,QAAUjB,iBAAiBiB,UAAUA,MAAMC,IAAI,KAAK;IAGvD,IAAI,CAACJ,SAAS;QACZ,OAAON,YAAY,CAACI,KAAK;IAC3B;IAEA,OAAOJ,YAAY,CAACM,QAAQF,IAAI,CAAC;AACnC,EAAC;AAgBD,OAAO,SAASO,uBAAuB,EACrCD,IAAI,EACJE,MAAM,EACNL,MAAM,EACNM,gBAAgB,KAAK,EACrBC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,E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ACT,CAAC9C,WAAW+C,QAAQ,EAAE;4CACpBC,OAAOD;wCACT;oCACF,CAAA,GACA,CAAC;4BAEL;wBACF;wBACAC,OAAO;4BAAEzC,MAAMT;wBAAY;oBAC7B;gBACF;YACF,OAAO;gBACLS,OAAOD,oBACLS,OAAOkC,EAAE,CAACC,aAAa,EACvBjC,cAAckC,WAAW,CAACR,WAAW,CAAC5B,MAAM;YAEhD;YAEA,OAAO;gBACL,GAAGO,qBAAqB;gBACxB,CAACtB,WAAWY,MAAMC,IAAI,EAAE,EAAE;oBAAEN,MAAMK,MAAM2B,OAAO,GAAG,IAAIjD,YAAYiB,QAAQA;gBAAK;YACjF;QACF;IACF;IAEA,MAAMuD,YAAY9D,WAAWa;IAE7B,MAAMkD,eAAerD,OAAOoB,MAAM,CAAC,CAACR,uBAAuBV;QACzD,IAAI,YAAYA,SAASA,MAAMoD,MAAM,EAAE;YACrC,OAAO1C;QACT;QAEA,MAAM2C,cAAc7C,gBAAgB,CAACR,MAAML,IAAI,CAAC;QAEhD,IAAI,OAAO0D,gBAAgB,YAAY;YACrC,OAAO3C;QACT;QAEA,MAAM4C,SAASD,YAAY3C,uBAAuBV;QAClD,IAAIuD,OAAOC,IAAI,CAACF,QAAQG,MAAM,KAAK,GAAG;YACpC,OAAO/C;QACT;QAEA,OAAO;YACL,GAAGA,qBAAqB;YACxB,GAAG2C,YAAY3C,uBAAuBV,MAAM;QAC9C;IACF,GAAG,CAAC;IAEJ,IAAIuD,OAAOC,IAAI,CAACL,cAAcM,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAIjF,uBAAuB;QAChCyB,MAAM,CAAC,QAAQ,EAAEiD,UAAU,KAAK,CAAC;QACjCpD,QAAQqD;IACV;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionConfig, Field, GlobalConfig, SanitizedConfig } from 'payload';
|
|
2
2
|
import { GraphQLObjectType } from 'graphql';
|
|
3
|
-
type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update';
|
|
3
|
+
type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update' | 'validate';
|
|
4
4
|
type AccessScopes = 'docAccess' | undefined;
|
|
5
5
|
type BuildEntityPolicy = {
|
|
6
6
|
entityFields: Field[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPoliciesType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPoliciesType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EAEZ,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAM3E,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"buildPoliciesType.d.ts","sourceRoot":"","sources":["../../src/schema/buildPoliciesType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EAEZ,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAM3E,KAAK,aAAa,GACd,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,cAAc,GACd,QAAQ,GACR,QAAQ,GACR,UAAU,CAAA;AAEd,KAAK,YAAY,GAAG,WAAW,GAAG,SAAS,CAAA;AA6F3C,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,iBAAiB,SAAU,iBAAiB;;QAMnD,IAAI;;CAsBT,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,CACA;IACE,MAAM,EAAE,gBAAgB,CAAA;IACxB,IAAI,EAAE,YAAY,CAAA;CACnB,GACD;IACE,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAA;CACf,CACJ,CAAA;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAyDxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAyC5E"}
|
|
@@ -11,7 +11,8 @@ const buildFields = (label, fieldsToBuild)=>fieldsToBuild.reduce((builtFields, f
|
|
|
11
11
|
'create',
|
|
12
12
|
'read',
|
|
13
13
|
'update',
|
|
14
|
-
'delete'
|
|
14
|
+
'delete',
|
|
15
|
+
'validate'
|
|
15
16
|
].reduce((operations, operation)=>{
|
|
16
17
|
const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
17
18
|
return {
|
|
@@ -119,7 +120,8 @@ export function buildPolicyType(args) {
|
|
|
119
120
|
'create',
|
|
120
121
|
'read',
|
|
121
122
|
'update',
|
|
122
|
-
'delete'
|
|
123
|
+
'delete',
|
|
124
|
+
'validate'
|
|
123
125
|
];
|
|
124
126
|
if (entity.auth && typeof entity.auth === 'object' && typeof entity.auth.maxLoginAttempts !== 'undefined' && entity.auth.maxLoginAttempts !== 0) {
|
|
125
127
|
operations.push('unlock');
|
|
@@ -141,7 +143,8 @@ export function buildPolicyType(args) {
|
|
|
141
143
|
// else create global type
|
|
142
144
|
operations = [
|
|
143
145
|
'read',
|
|
144
|
-
'update'
|
|
146
|
+
'update',
|
|
147
|
+
'validate'
|
|
145
148
|
];
|
|
146
149
|
if (entity.versions) {
|
|
147
150
|
operations.push('readVersions');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/buildPoliciesType.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Field,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport { toWords } from 'payload'\n\nimport { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'\nimport { formatName } from '../utilities/formatName.js'\n\ntype OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update'\n\ntype AccessScopes = 'docAccess' | undefined\n\ntype ObjectTypeFields = {\n [key in 'fields' | OperationType]?: { type: GraphQLObjectType }\n}\n\nconst buildFields = (label, fieldsToBuild) =>\n fieldsToBuild.reduce((builtFields, field) => {\n const includeField = !field.hidden && field.type !== 'ui'\n if (includeField) {\n if (field.name) {\n const fieldName = formatName(field.name)\n\n const objectTypeFields: ObjectTypeFields = ['create', 'read', 'update', 'delete'].reduce(\n (operations, operation) => {\n const capitalizedOperation = operation.charAt(0).toUpperCase() + operation.slice(1)\n\n return {\n ...operations,\n [operation]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_${capitalizedOperation}`,\n fields: {\n permission: {\n type: new GraphQLNonNull(GraphQLBoolean),\n },\n },\n }),\n },\n }\n },\n {},\n )\n\n if (field.fields) {\n objectTypeFields.fields = {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}_Fields`,\n fields: buildFields(`${label}_${fieldName}`, field.fields),\n }),\n }\n }\n\n return {\n ...builtFields,\n [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\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 if ('name' in tab) {\n if (tab.fields.length) {\n const tabName = formatName(tab.name)\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: buildFields(`${label}_${tabName}`, tab.fields),\n }),\n }\n }\n return fieldsWithTabFields\n }\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) {\n return null\n }\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 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","length","subFields","tabs","fieldsWithTabFields","tab","tabName","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,SAASC,UAAU,QAAQ,6BAA4B;AAUvD,MAAMC,cA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B,MAAM0B,OAAOG,OAAO,GAAGH,QAAQG,SAAS7B,QAAQ4B,OAAOA;YACvDT,cAAcO,OAAOjB,MAAM;YAC3BN;YACAiB;QACF;IACF;AACF;AAEA,OAAO,SAASiB,kBAAkBC,MAAuB;IACvD,MAAM7B,SAAS;QACb8B,gBAAgB;YACdxC,MAAM,IAAIb,eAAeD;QAC3B;IACF;IAEAuD,OAAOC,MAAM,CAACH,OAAOI,WAAW,EAAEpB,OAAO,CAAC,CAACqB;QACzC,IAAIA,WAAWd,OAAO,KAAK,OAAO;YAChC;QACF;QACA,MAAMe,uBAAuBnB,gBAAgB;YAC3C1B,MAAM;YACN2B,QAAQiB;YACRhB,YAAY;QACd;QAEAlB,MAAM,CAACnB,WAAWqD,WAAWf,IAAI,EAAE,GAAG;YACpC7B,MAAM6C;QACR;IACF;IAEAJ,OAAOC,MAAM,CAACH,OAAOO,OAAO,EAAEvB,OAAO,CAAC,CAACc;QACrC,IAAIA,QAAOP,OAAO,KAAK,OAAO;YAC5B;QACF;QACA,MAAMiB,mBAAmBrB,gBAAgB;YACvC1B,MAAM;YACN2B,QAAQU;YACRT,YAAY;QACd;QAEAlB,MAAM,CAACnB,WAAW8C,QAAOR,IAAI,EAAE,GAAG;YAChC7B,MAAM+C;QACR;IACF;IAEA,OAAO,IAAI3D,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 =\n | 'create'\n | 'delete'\n | 'read'\n | 'readVersions'\n | 'unlock'\n | 'update'\n | 'validate'\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 = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'validate',\n ].reduce((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 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 [formatName(field.name)]: {\n type: new GraphQLObjectType({\n name: `${label}_${fieldName}`,\n fields: objectTypeFields,\n }),\n },\n }\n }\n\n if (!field.name && field.fields && field.fields.length) {\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 if ('name' in tab) {\n if (tab.fields.length) {\n const tabName = formatName(tab.name)\n fieldsWithTabFields[tabName] = {\n type: new GraphQLObjectType({\n name: `${label}_${tabName}`,\n fields: buildFields(`${label}_${tabName}`, tab.fields),\n }),\n }\n }\n return fieldsWithTabFields\n }\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) {\n return null\n }\n\n if (type === 'collection') {\n operations = ['create', 'read', 'update', 'delete', 'validate']\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', 'validate']\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 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","length","subFields","tabs","fieldsWithTabFields","tab","tabName","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,SAASC,UAAU,QAAQ,6BAA4B;AAiBvD,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;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