@strapi/plugin-graphql 5.36.1 → 5.37.0
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/admin/package.json.js +6 -6
- package/dist/admin/package.json.mjs +6 -6
- package/dist/server/services/builders/resolvers/association.js +24 -1
- package/dist/server/services/builders/resolvers/association.js.map +1 -1
- package/dist/server/services/builders/resolvers/association.mjs +24 -1
- package/dist/server/services/builders/resolvers/association.mjs.map +1 -1
- package/dist/server/services/builders/utils.js +16 -7
- package/dist/server/services/builders/utils.js.map +1 -1
- package/dist/server/services/builders/utils.mjs +17 -8
- package/dist/server/services/builders/utils.mjs.map +1 -1
- package/dist/server/services/internals/args/has-published-version.js +8 -0
- package/dist/server/services/internals/args/has-published-version.js.map +1 -0
- package/dist/server/services/internals/args/has-published-version.mjs +6 -0
- package/dist/server/services/internals/args/has-published-version.mjs.map +1 -0
- package/dist/server/services/internals/args/index.js +3 -1
- package/dist/server/services/internals/args/index.js.map +1 -1
- package/dist/server/services/internals/args/index.mjs +3 -1
- package/dist/server/services/internals/args/index.mjs.map +1 -1
- package/dist/server/src/index.d.ts +2 -15
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/builders/index.d.ts +1 -15
- package/dist/server/src/services/builders/index.d.ts.map +1 -1
- package/dist/server/src/services/builders/resolvers/association.d.ts.map +1 -1
- package/dist/server/src/services/builders/utils.d.ts +1 -15
- package/dist/server/src/services/builders/utils.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +2 -15
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/internals/args/has-published-version.d.ts +3 -0
- package/dist/server/src/services/internals/args/has-published-version.d.ts.map +1 -0
- package/dist/server/src/services/internals/args/index.d.ts +1 -0
- package/dist/server/src/services/internals/args/index.d.ts.map +1 -1
- package/dist/server/src/services/internals/index.d.ts +1 -0
- package/dist/server/src/services/internals/index.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/plugin-graphql";
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.37.0";
|
|
7
7
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
8
8
|
var repository = {
|
|
9
9
|
type: "git",
|
|
@@ -64,7 +64,7 @@ var dependencies = {
|
|
|
64
64
|
"@koa/cors": "5.0.0",
|
|
65
65
|
"@strapi/design-system": "2.1.2",
|
|
66
66
|
"@strapi/icons": "2.1.2",
|
|
67
|
-
"@strapi/utils": "5.
|
|
67
|
+
"@strapi/utils": "5.37.0",
|
|
68
68
|
graphql: "^16.8.1",
|
|
69
69
|
"graphql-depth-limit": "^1.1.0",
|
|
70
70
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -76,19 +76,19 @@ var dependencies = {
|
|
|
76
76
|
pluralize: "8.0.0"
|
|
77
77
|
};
|
|
78
78
|
var devDependencies = {
|
|
79
|
-
"@strapi/strapi": "5.
|
|
80
|
-
"@strapi/types": "5.
|
|
79
|
+
"@strapi/strapi": "5.37.0",
|
|
80
|
+
"@strapi/types": "5.37.0",
|
|
81
81
|
"@types/graphql-depth-limit": "1.1.5",
|
|
82
82
|
"@types/koa-bodyparser": "4.3.12",
|
|
83
83
|
"@types/koa__cors": "5.0.0",
|
|
84
84
|
"cross-env": "^7.0.3",
|
|
85
|
-
"eslint-config-custom": "5.
|
|
85
|
+
"eslint-config-custom": "5.37.0",
|
|
86
86
|
koa: "2.16.3",
|
|
87
87
|
react: "18.3.1",
|
|
88
88
|
"react-dom": "18.3.1",
|
|
89
89
|
"react-router-dom": "6.30.3",
|
|
90
90
|
"styled-components": "6.1.8",
|
|
91
|
-
tsconfig: "5.
|
|
91
|
+
tsconfig: "5.37.0",
|
|
92
92
|
typescript: "5.4.4"
|
|
93
93
|
};
|
|
94
94
|
var peerDependencies = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/plugin-graphql";
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.37.0";
|
|
3
3
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
4
4
|
var repository = {
|
|
5
5
|
type: "git",
|
|
@@ -60,7 +60,7 @@ var dependencies = {
|
|
|
60
60
|
"@koa/cors": "5.0.0",
|
|
61
61
|
"@strapi/design-system": "2.1.2",
|
|
62
62
|
"@strapi/icons": "2.1.2",
|
|
63
|
-
"@strapi/utils": "5.
|
|
63
|
+
"@strapi/utils": "5.37.0",
|
|
64
64
|
graphql: "^16.8.1",
|
|
65
65
|
"graphql-depth-limit": "^1.1.0",
|
|
66
66
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -72,19 +72,19 @@ var dependencies = {
|
|
|
72
72
|
pluralize: "8.0.0"
|
|
73
73
|
};
|
|
74
74
|
var devDependencies = {
|
|
75
|
-
"@strapi/strapi": "5.
|
|
76
|
-
"@strapi/types": "5.
|
|
75
|
+
"@strapi/strapi": "5.37.0",
|
|
76
|
+
"@strapi/types": "5.37.0",
|
|
77
77
|
"@types/graphql-depth-limit": "1.1.5",
|
|
78
78
|
"@types/koa-bodyparser": "4.3.12",
|
|
79
79
|
"@types/koa__cors": "5.0.0",
|
|
80
80
|
"cross-env": "^7.0.3",
|
|
81
|
-
"eslint-config-custom": "5.
|
|
81
|
+
"eslint-config-custom": "5.37.0",
|
|
82
82
|
koa: "2.16.3",
|
|
83
83
|
react: "18.3.1",
|
|
84
84
|
"react-dom": "18.3.1",
|
|
85
85
|
"react-router-dom": "6.30.3",
|
|
86
86
|
"styled-components": "6.1.8",
|
|
87
|
-
tsconfig: "5.
|
|
87
|
+
tsconfig: "5.37.0",
|
|
88
88
|
typescript: "5.4.4"
|
|
89
89
|
};
|
|
90
90
|
var peerDependencies = {
|
|
@@ -53,7 +53,30 @@ var associationResolvers = (({ strapi })=>{
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
} : {};
|
|
56
|
-
|
|
56
|
+
// Inherit hasPublishedVersion from root query (same pattern as status)
|
|
57
|
+
const inheritedHasPublishedVersion = context.rootQueryArgs?.hasPublishedVersion !== undefined && context.rootQueryArgs?._originField && isBuiltInQueryField(context.rootQueryArgs._originField) ? context.rootQueryArgs.hasPublishedVersion : undefined;
|
|
58
|
+
// Build hasPublishedVersion condition for this relation's model
|
|
59
|
+
let hasPublishedVersionFilters = {};
|
|
60
|
+
if (isTargetDraftAndPublishContentType && inheritedHasPublishedVersion !== undefined) {
|
|
61
|
+
const meta = strapi.db.metadata.get(targetUID);
|
|
62
|
+
const tableName = meta.tableName;
|
|
63
|
+
const documentIdAttr = meta.attributes.documentId;
|
|
64
|
+
const publishedAtAttr = meta.attributes.publishedAt;
|
|
65
|
+
const documentIdColumn = 'columnName' in documentIdAttr && documentIdAttr.columnName || 'document_id';
|
|
66
|
+
const publishedAtColumn = 'columnName' in publishedAtAttr && publishedAtAttr.columnName || 'published_at';
|
|
67
|
+
const knex = strapi.db.connection;
|
|
68
|
+
const subquery = knex(tableName).distinct(documentIdColumn).whereNotNull(publishedAtColumn);
|
|
69
|
+
hasPublishedVersionFilters = {
|
|
70
|
+
where: {
|
|
71
|
+
documentId: inheritedHasPublishedVersion ? {
|
|
72
|
+
$in: subquery
|
|
73
|
+
} : {
|
|
74
|
+
$notIn: subquery
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const dbQuery = fp.merge(fp.merge(defaultFilters, hasPublishedVersionFilters), transformedQuery);
|
|
57
80
|
// Sign media URLs if upload plugin is available and using private provider
|
|
58
81
|
const data = await (async ()=>{
|
|
59
82
|
const rawData = await strapi.db.query(contentTypeUID).load(parent, attributeName, dbQuery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.js","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n\n // Helper to check if a field is from built-in queries (not custom resolvers)\n // Use the precomputed lookup populated by the content-api service at schema build time.\n const isBuiltInQueryField = (fieldName: string) => {\n const graphqlService = strapi.plugin('graphql').service('content-api');\n return graphqlService.isBuiltInQueryField(fieldName);\n };\n\n // Only inherit status from built-in queries to avoid conflicts with custom resolvers\n const inheritedStatus =\n context.rootQueryArgs?.status &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.status\n : null;\n\n const statusToApply = args.status || inheritedStatus;\n\n const defaultFilters =\n isTargetDraftAndPublishContentType && statusToApply\n ? {\n where: {\n publishedAt: statusToApply === 'published' ? { $notNull: true } : { $null: true },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const sanitizeInfo = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, sanitizeInfo);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, sanitizeInfo);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","isBuiltInQueryField","fieldName","graphqlService","inheritedStatus","rootQueryArgs","status","_originField","statusToApply","defaultFilters","where","publishedAt","$notNull","$null","dbQuery","merge","data","rawData","db","load","signFileUrls","Array","isArray","async","map","item","sanitizeInfo","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanitizeMorphAttribute","pipe"],"mappings":";;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,2BAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC,IAAA,MAAM,EAAEC,OAASC,EAAAA,iBAAiB,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAErD,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGH,iBAAAA,CAAkB,SAASI,UAAU;AAC1E,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAGL,iBAAAA,CAAkB,YAAYM,KAAK;IAC7D,MAAM,EAAEC,gBAAgB,EAAEC,0BAA0B,EAAE,GAAGR,iBAAAA,CAAkB,UAAUS,WAAW;IAEhG,OAAO;AACLC,QAAAA,wBAAAA,CAAAA,CAAyB,EACvBC,cAAc,EACdC,aAAa,EAId,EAAA;YACC,MAAMC,WAAAA,GAAcf,MAAOgB,CAAAA,QAAQ,CAACH,cAAAA,CAAAA;AACpC,YAAA,MAAMI,SAAiBF,GAAAA,WAAAA,CAAYT,UAAU,CAACQ,aAAc,CAAA;AAE5D,YAAA,IAAI,CAACG,SAAW,EAAA;gBACd,MAAM,IAAInB,iBACR,CAAC,4CAA4C,EAAEe,cAAe,CAAA,EAAE,EAAEC,aAAe,CAAA,CAAA,CAAA;AAErF;AAEA,YAAA,MAAMI,mBAAmBb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AAAA;AACxD;AAEA,wBAAA,IAAIR,OAAS,EAAA;AACX,4BAAA,OAAOG,YAAaH,CAAAA,OAAAA,CAAAA;AACtB;AACF;oBAEA,OAAOA,OAAAA;iBACT,GAAA;AAEA,gBAAA,MAAMS,YAAe,GAAA;oBACnB1C,IAAMS,EAAAA,cAAAA;oBACNkC,WAAanD,EAAAA;AACf,iBAAA;;;;AAKA,gBAAA,IAAID,gBAAkB,EAAA;;oBAEpB,MAAMqD,QAAAA,GAAW,CAACC,UAAAA,IAAqB;AAAE,4BAAA,CAAC3D,gBAAgB2D;yBAAW,CAAA;AACrE,oBAAA,MAAMC,eAAe,CAACC,cAAAA,GAAAA;wBACpB,OAAO3E,MAAAA,CAAOkC,UAAU,CAACI,QAAQ,CAACsC,MAAM,CAACD,gBAAgB5D,WAAa,EAAA;AAAEe,4BAAAA;AAAK,yBAAA,CAAA;AAC/E,qBAAA;AACA,oBAAA,MAAM+C,aAAarC,MAAI1B,CAAAA,aAAAA,CAAAA;;AAGvB,oBAAA,MAAMgE,sBAAyBX,GAAAA,WAAAA,CAAMY,IAAI,CAACP,UAAUE,YAAcG,EAAAA,UAAAA,CAAAA;AAElE,oBAAA,OAAOC,sBAAuBlB,CAAAA,IAAAA,CAAAA;AAChC;;;AAIA,gBAAA,IAAItC,QAAU,EAAA;AACZ,oBAAA,OAAOZ,2BAA2BkD,IAAMU,EAAAA,YAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAO7D,iBAAiBmD,IAAMU,EAAAA,YAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"association.js","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n\n // Helper to check if a field is from built-in queries (not custom resolvers)\n // Use the precomputed lookup populated by the content-api service at schema build time.\n const isBuiltInQueryField = (fieldName: string) => {\n const graphqlService = strapi.plugin('graphql').service('content-api');\n return graphqlService.isBuiltInQueryField(fieldName);\n };\n\n // Only inherit status from built-in queries to avoid conflicts with custom resolvers\n const inheritedStatus =\n context.rootQueryArgs?.status &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.status\n : null;\n\n const statusToApply = args.status || inheritedStatus;\n\n const defaultFilters =\n isTargetDraftAndPublishContentType && statusToApply\n ? {\n where: {\n publishedAt: statusToApply === 'published' ? { $notNull: true } : { $null: true },\n },\n }\n : {};\n\n // Inherit hasPublishedVersion from root query (same pattern as status)\n const inheritedHasPublishedVersion =\n context.rootQueryArgs?.hasPublishedVersion !== undefined &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.hasPublishedVersion\n : undefined;\n\n // Build hasPublishedVersion condition for this relation's model\n let hasPublishedVersionFilters: Record<string, any> = {};\n if (isTargetDraftAndPublishContentType && inheritedHasPublishedVersion !== undefined) {\n const meta = strapi.db.metadata.get(targetUID);\n const tableName = meta.tableName;\n const documentIdAttr = meta.attributes.documentId;\n const publishedAtAttr = meta.attributes.publishedAt;\n const documentIdColumn =\n ('columnName' in documentIdAttr && documentIdAttr.columnName) || 'document_id';\n const publishedAtColumn =\n ('columnName' in publishedAtAttr && publishedAtAttr.columnName) || 'published_at';\n\n const knex = strapi.db.connection;\n const subquery = knex(tableName)\n .distinct(documentIdColumn)\n .whereNotNull(publishedAtColumn);\n\n hasPublishedVersionFilters = {\n where: {\n documentId: inheritedHasPublishedVersion ? { $in: subquery } : { $notIn: subquery },\n },\n };\n }\n\n const dbQuery = merge(merge(defaultFilters, hasPublishedVersionFilters), transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const sanitizeInfo = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, sanitizeInfo);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, sanitizeInfo);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","isBuiltInQueryField","fieldName","graphqlService","inheritedStatus","rootQueryArgs","status","_originField","statusToApply","defaultFilters","where","publishedAt","$notNull","$null","inheritedHasPublishedVersion","hasPublishedVersion","undefined","hasPublishedVersionFilters","meta","db","metadata","tableName","documentIdAttr","documentId","publishedAtAttr","documentIdColumn","columnName","publishedAtColumn","knex","connection","subquery","distinct","whereNotNull","$in","$notIn","dbQuery","merge","data","rawData","load","signFileUrls","Array","isArray","async","map","item","sanitizeInfo","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanitizeMorphAttribute","pipe"],"mappings":";;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,2BAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC,IAAA,MAA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AK,yBAAA,CAAA;AAC/E,qBAAA;AACA,oBAAA,MAAMmE,aAAazD,MAAI1B,CAAAA,aAAAA,CAAAA;;AAGvB,oBAAA,MAAMoF,sBAAyBX,GAAAA,WAAAA,CAAMY,IAAI,CAACP,UAAUE,YAAcG,EAAAA,UAAAA,CAAAA;AAElE,oBAAA,OAAOC,sBAAuBjB,CAAAA,IAAAA,CAAAA;AAChC;;;AAIA,gBAAA,IAAI3D,QAAU,EAAA;AACZ,oBAAA,OAAOZ,2BAA2BuE,IAAMS,EAAAA,YAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAOjF,iBAAiBwE,IAAMS,EAAAA,YAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -51,7 +51,30 @@ var associationResolvers = (({ strapi })=>{
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
} : {};
|
|
54
|
-
|
|
54
|
+
// Inherit hasPublishedVersion from root query (same pattern as status)
|
|
55
|
+
const inheritedHasPublishedVersion = context.rootQueryArgs?.hasPublishedVersion !== undefined && context.rootQueryArgs?._originField && isBuiltInQueryField(context.rootQueryArgs._originField) ? context.rootQueryArgs.hasPublishedVersion : undefined;
|
|
56
|
+
// Build hasPublishedVersion condition for this relation's model
|
|
57
|
+
let hasPublishedVersionFilters = {};
|
|
58
|
+
if (isTargetDraftAndPublishContentType && inheritedHasPublishedVersion !== undefined) {
|
|
59
|
+
const meta = strapi.db.metadata.get(targetUID);
|
|
60
|
+
const tableName = meta.tableName;
|
|
61
|
+
const documentIdAttr = meta.attributes.documentId;
|
|
62
|
+
const publishedAtAttr = meta.attributes.publishedAt;
|
|
63
|
+
const documentIdColumn = 'columnName' in documentIdAttr && documentIdAttr.columnName || 'document_id';
|
|
64
|
+
const publishedAtColumn = 'columnName' in publishedAtAttr && publishedAtAttr.columnName || 'published_at';
|
|
65
|
+
const knex = strapi.db.connection;
|
|
66
|
+
const subquery = knex(tableName).distinct(documentIdColumn).whereNotNull(publishedAtColumn);
|
|
67
|
+
hasPublishedVersionFilters = {
|
|
68
|
+
where: {
|
|
69
|
+
documentId: inheritedHasPublishedVersion ? {
|
|
70
|
+
$in: subquery
|
|
71
|
+
} : {
|
|
72
|
+
$notIn: subquery
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const dbQuery = merge(merge(defaultFilters, hasPublishedVersionFilters), transformedQuery);
|
|
55
78
|
// Sign media URLs if upload plugin is available and using private provider
|
|
56
79
|
const data = await (async ()=>{
|
|
57
80
|
const rawData = await strapi.db.query(contentTypeUID).load(parent, attributeName, dbQuery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.mjs","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n\n // Helper to check if a field is from built-in queries (not custom resolvers)\n // Use the precomputed lookup populated by the content-api service at schema build time.\n const isBuiltInQueryField = (fieldName: string) => {\n const graphqlService = strapi.plugin('graphql').service('content-api');\n return graphqlService.isBuiltInQueryField(fieldName);\n };\n\n // Only inherit status from built-in queries to avoid conflicts with custom resolvers\n const inheritedStatus =\n context.rootQueryArgs?.status &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.status\n : null;\n\n const statusToApply = args.status || inheritedStatus;\n\n const defaultFilters =\n isTargetDraftAndPublishContentType && statusToApply\n ? {\n where: {\n publishedAt: statusToApply === 'published' ? { $notNull: true } : { $null: true },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const sanitizeInfo = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, sanitizeInfo);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, sanitizeInfo);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","isBuiltInQueryField","fieldName","graphqlService","inheritedStatus","rootQueryArgs","status","_originField","statusToApply","defaultFilters","where","publishedAt","$notNull","$null","dbQuery","merge","data","rawData","db","load","signFileUrls","Array","isArray","async","map","item","sanitizeInfo","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanitizeMorphAttribute","pipe"],"mappings":";;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,2BAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC,IAAA,MAAM,EAAEC,OAASC,EAAAA,iBAAiB,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAErD,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGH,iBAAAA,CAAkB,SAASI,UAAU;AAC1E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ACP,UAAUE,YAAcG,EAAAA,UAAAA,CAAAA;AAElE,oBAAA,OAAOC,sBAAuBlB,CAAAA,IAAAA,CAAAA;AAChC;;;AAIA,gBAAA,IAAItC,QAAU,EAAA;AACZ,oBAAA,OAAOZ,2BAA2BkD,IAAMU,EAAAA,YAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAO7D,iBAAiBmD,IAAMU,EAAAA,YAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"association.mjs","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n\n // Helper to check if a field is from built-in queries (not custom resolvers)\n // Use the precomputed lookup populated by the content-api service at schema build time.\n const isBuiltInQueryField = (fieldName: string) => {\n const graphqlService = strapi.plugin('graphql').service('content-api');\n return graphqlService.isBuiltInQueryField(fieldName);\n };\n\n // Only inherit status from built-in queries to avoid conflicts with custom resolvers\n const inheritedStatus =\n context.rootQueryArgs?.status &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.status\n : null;\n\n const statusToApply = args.status || inheritedStatus;\n\n const defaultFilters =\n isTargetDraftAndPublishContentType && statusToApply\n ? {\n where: {\n publishedAt: statusToApply === 'published' ? { $notNull: true } : { $null: true },\n },\n }\n : {};\n\n // Inherit hasPublishedVersion from root query (same pattern as status)\n const inheritedHasPublishedVersion =\n context.rootQueryArgs?.hasPublishedVersion !== undefined &&\n context.rootQueryArgs?._originField &&\n isBuiltInQueryField(context.rootQueryArgs._originField)\n ? context.rootQueryArgs.hasPublishedVersion\n : undefined;\n\n // Build hasPublishedVersion condition for this relation's model\n let hasPublishedVersionFilters: Record<string, any> = {};\n if (isTargetDraftAndPublishContentType && inheritedHasPublishedVersion !== undefined) {\n const meta = strapi.db.metadata.get(targetUID);\n const tableName = meta.tableName;\n const documentIdAttr = meta.attributes.documentId;\n const publishedAtAttr = meta.attributes.publishedAt;\n const documentIdColumn =\n ('columnName' in documentIdAttr && documentIdAttr.columnName) || 'document_id';\n const publishedAtColumn =\n ('columnName' in publishedAtAttr && publishedAtAttr.columnName) || 'published_at';\n\n const knex = strapi.db.connection;\n const subquery = knex(tableName)\n .distinct(documentIdColumn)\n .whereNotNull(publishedAtColumn);\n\n hasPublishedVersionFilters = {\n where: {\n documentId: inheritedHasPublishedVersion ? { $in: subquery } : { $notIn: subquery },\n },\n };\n }\n\n const dbQuery = merge(merge(defaultFilters, hasPublishedVersionFilters), transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const sanitizeInfo = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, sanitizeInfo);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, sanitizeInfo);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","isBuiltInQueryField","fieldName","graphqlService","inheritedStatus","rootQueryArgs","status","_originField","statusToApply","defaultFilters","where","publishedAt","$notNull","$null","inheritedHasPublishedVersion","hasPublishedVersion","undefined","hasPublishedVersionFilters","meta","db","metadata","tableName","documentIdAttr","documentId","publishedAtAttr","documentIdColumn","columnName","publishedAtColumn","knex","connection","subquery","distinct","whereNotNull","$in","$notIn","dbQuery","merge","data","rawData","load","signFileUrls","Array","isArray","async","map","item","sanitizeInfo","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanitizeMorphAttribute","pipe"],"mappings":";;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,2BAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC,IAAA,MAAM,EAAEC,OAASC,EAAAA,iBAAiB,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAErD,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGH,iBAAAA,CAAkB,SAASI,UAAU;AAC1E,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAGL,iBAAAA,CAAkB,YAAYM,KAAK;IAC7D,MAAM,EAAEC,gBAAgB,EAAEC,0BAA0B,EAAE,GAAGR,iBAAAA,CAAkB,UAAUS,WAAW;IAEhG,OAAO;AACLC,QAAAA,wBAAAA,CAAAA,CAAyB,EACvBC,cAAc,EACdC,aAAa,EAId,EAAA;YACC,MAAMC,WAAAA,GAAcf,MAAOgB,CAAAA,QAAQ,CAACH,cAAAA,CAAAA;AACpC,YAAA,MAAMI,SAAiBF,GAAAA,WAAAA,CAAYT,UAAU,CAACQ,aAAc,CAAA;AAE5D,YAAA,IAAI,CAACG,SAAW,EAAA;gBACd,MAAM,IAAInB,iBACR,CAAC,4CAA4C,EAAEe,cAAe,CAAA,EAAE,EAAEC,aAAe,CAAA,CAAA,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AA,IAAAA,CAAAA,CAAAA;AACxD;AAEA,wBAAA,IAAIP,OAAS,EAAA;AACX,4BAAA,OAAOE,YAAaF,CAAAA,OAAAA,CAAAA;AACtB;AACF;oBAEA,OAAOA,OAAAA;iBACT,GAAA;AAEA,gBAAA,MAAMQ,YAAe,GAAA;oBACnB9D,IAAMS,EAAAA,cAAAA;oBACNsD,WAAavE,EAAAA;AACf,iBAAA;;;;AAKA,gBAAA,IAAID,gBAAkB,EAAA;;oBAEpB,MAAMyE,QAAAA,GAAW,CAACC,UAAAA,IAAqB;AAAE,4BAAA,CAAC/E,gBAAgB+E;yBAAW,CAAA;AACrE,oBAAA,MAAMC,eAAe,CAACC,cAAAA,GAAAA;wBACpB,OAAO/F,MAAAA,CAAOkC,UAAU,CAACI,QAAQ,CAAC0D,MAAM,CAACD,gBAAgBhF,WAAa,EAAA;AAAEe,4BAAAA;AAAK,yBAAA,CAAA;AAC/E,qBAAA;AACA,oBAAA,MAAMmE,aAAazD,GAAI1B,CAAAA,aAAAA,CAAAA;;AAGvB,oBAAA,MAAMoF,sBAAyBX,GAAAA,KAAAA,CAAMY,IAAI,CAACP,UAAUE,YAAcG,EAAAA,UAAAA,CAAAA;AAElE,oBAAA,OAAOC,sBAAuBjB,CAAAA,IAAAA,CAAAA;AAChC;;;AAIA,gBAAA,IAAI3D,QAAU,EAAA;AACZ,oBAAA,OAAOZ,2BAA2BuE,IAAMS,EAAAA,YAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAOjF,iBAAiBwE,IAAMS,EAAAA,YAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -22,22 +22,30 @@ var utils = (({ strapi })=>{
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
const { kind } = contentType;
|
|
25
|
+
const hasDraftAndPublish = utils$1.contentTypes.hasDraftAndPublish(contentType);
|
|
25
26
|
// Collection Types
|
|
26
27
|
if (kind === 'collectionType') {
|
|
27
28
|
if (!multiple) {
|
|
28
|
-
|
|
29
|
-
documentId: nexus.nonNull(nexus.idArg())
|
|
30
|
-
status: args.PublicationStatusArg
|
|
29
|
+
const params = {
|
|
30
|
+
documentId: nexus.nonNull(nexus.idArg())
|
|
31
31
|
};
|
|
32
|
+
if (hasDraftAndPublish) {
|
|
33
|
+
Object.assign(params, {
|
|
34
|
+
status: args.PublicationStatusArg,
|
|
35
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return params;
|
|
32
39
|
}
|
|
33
40
|
const params = {
|
|
34
41
|
filters: naming.getFiltersInputTypeName(contentType),
|
|
35
42
|
pagination: args.PaginationArg,
|
|
36
43
|
sort: args.SortArg
|
|
37
44
|
};
|
|
38
|
-
if (!isNested) {
|
|
45
|
+
if (!isNested && hasDraftAndPublish) {
|
|
39
46
|
Object.assign(params, {
|
|
40
|
-
status: args.PublicationStatusArg
|
|
47
|
+
status: args.PublicationStatusArg,
|
|
48
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
return params;
|
|
@@ -45,9 +53,10 @@ var utils = (({ strapi })=>{
|
|
|
45
53
|
// Single Types
|
|
46
54
|
if (kind === 'singleType') {
|
|
47
55
|
const params = {};
|
|
48
|
-
if (!isNested) {
|
|
56
|
+
if (!isNested && hasDraftAndPublish) {
|
|
49
57
|
Object.assign(params, {
|
|
50
|
-
status: args.PublicationStatusArg
|
|
58
|
+
status: args.PublicationStatusArg,
|
|
59
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
51
60
|
});
|
|
52
61
|
}
|
|
53
62
|
return params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../server/src/services/builders/utils.ts"],"sourcesContent":["import { entries, mapValues, omit } from 'lodash/fp';\nimport { idArg, nonNull } from 'nexus';\nimport { pagination } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nconst { withDefaultPagination } = pagination;\n\ntype ContentTypeArgsOptions = {\n multiple?: boolean;\n isNested?: boolean;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const { service: getService } = strapi.plugin('graphql');\n\n return {\n getContentTypeArgs(\n contentType: Struct.Schema,\n { multiple = true, isNested = false }: ContentTypeArgsOptions = {}\n ) {\n const { naming } = getService('utils');\n const { args } = getService('internals');\n\n const { modelType } = contentType;\n\n // Components\n if (modelType === 'component') {\n if (!multiple) return {};\n\n return {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n }\n\n const { kind } = contentType;\n\n // Collection Types\n if (kind === 'collectionType') {\n if (!multiple) {\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../server/src/services/builders/utils.ts"],"sourcesContent":["import { entries, mapValues, omit } from 'lodash/fp';\nimport { idArg, nonNull } from 'nexus';\nimport { contentTypes, pagination } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nconst { withDefaultPagination } = pagination;\n\ntype ContentTypeArgsOptions = {\n multiple?: boolean;\n isNested?: boolean;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const { service: getService } = strapi.plugin('graphql');\n\n return {\n getContentTypeArgs(\n contentType: Struct.Schema,\n { multiple = true, isNested = false }: ContentTypeArgsOptions = {}\n ) {\n const { naming } = getService('utils');\n const { args } = getService('internals');\n\n const { modelType } = contentType;\n\n // Components\n if (modelType === 'component') {\n if (!multiple) return {};\n\n return {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n }\n\n const { kind } = contentType;\n\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);\n\n // Collection Types\n if (kind === 'collectionType') {\n if (!multiple) {\n const params: Record<string, unknown> = {\n documentId: nonNull(idArg()),\n };\n\n if (hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n\n const params = {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n\n if (!isNested && hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n\n // Single Types\n if (kind === 'singleType') {\n const params = {};\n\n if (!isNested && hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n },\n\n /**\n * Filter an object entries and keep only those whose value is a unique scalar attribute\n */\n getUniqueScalarAttributes(attributes: Struct.SchemaAttributes) {\n const { isStrapiScalar } = getService('utils').attributes;\n\n const uniqueAttributes = entries(attributes).filter(\n ([, attribute]) => isStrapiScalar(attribute) && 'unique' in attribute && attribute.unique\n );\n\n return Object.fromEntries(uniqueAttributes);\n },\n\n /**\n * Map each value from an attribute to a FiltersInput type name\n * @param {object} attributes - The attributes object to transform\n * @return {Object<string, string>}\n */\n scalarAttributesToFiltersMap(attributes: Struct.SchemaAttributes) {\n return mapValues((attribute) => {\n const { mappers, naming } = getService('utils');\n\n const gqlScalar = mappers.strapiScalarToGraphQLScalar(attribute.type);\n\n return naming.getScalarFilterInputTypeName(gqlScalar);\n }, attributes);\n },\n\n /**\n * Apply basic transform to GQL args\n */\n transformArgs(\n args: any,\n {\n contentType,\n usePagination = false,\n }: { contentType: Struct.ContentTypeSchema; usePagination?: boolean }\n ) {\n const { mappers } = getService('utils');\n const { config } = strapi.plugin('graphql');\n const { pagination = {}, filters = {} } = args;\n\n // Init\n const newArgs = omit(['pagination', 'filters'], args);\n\n // Pagination\n if (usePagination) {\n const defaultLimit: number = config('defaultLimit');\n const maxLimit: number = config('maxLimit');\n\n Object.assign(\n newArgs,\n withDefaultPagination(pagination, {\n maxLimit,\n defaults: {\n offset: { limit: defaultLimit },\n page: { pageSize: defaultLimit },\n },\n })\n );\n }\n\n // Filters\n if (args.filters) {\n Object.assign(newArgs, {\n filters: mappers.graphQLFiltersToStrapiQuery(filters, contentType),\n });\n }\n\n return newArgs;\n },\n };\n};\n"],"names":["withDefaultPagination","pagination","strapi","service","getService","plugin","getContentTypeArgs","contentType","multiple","isNested","naming","args","modelType","filters","getFiltersInputTypeName","PaginationArg","sort","SortArg","kind","hasDraftAndPublish","contentTypes","params","documentId","nonNull","idArg","Object","assign","status","PublicationStatusArg","hasPublishedVersion","HasPublishedVersionArg","getUniqueScalarAttributes","attributes","isStrapiScalar","uniqueAttributes","entries","filter","attribute","unique","fromEntries","scalarAttributesToFiltersMap","mapValues","mappers","gqlScalar","strapiScalarToGraphQLScalar","type","getScalarFilterInputTypeName","transformArgs","usePagination","config","newArgs","omit","defaultLimit","maxLimit","defaults","offset","limit","page","pageSize","graphQLFiltersToStrapiQuery"],"mappings":";;;;;;AAKA,MAAM,EAAEA,qBAAqB,EAAE,GAAGC,kBAAAA;AAOlC,YAAe,CAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;AACjD,IAAA,MAAM,EAAEC,OAASC,EAAAA,UAAU,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAE9C,OAAO;QACLC,kBACEC,CAAAA,CAAAA,WAA0B,EAC1B,EAAEC,QAAW,GAAA,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAA0B,GAAG,EAAE,EAAA;AAElE,YAAA,MAAM,EAAEC,MAAM,EAAE,GAAGN,UAAW,CAAA,OAAA,CAAA;AAC9B,YAAA,MAAM,EAAEO,IAAI,EAAE,GAAGP,UAAW,CAAA,WAAA,CAAA;YAE5B,MAAM,EAAEQ,SAAS,EAAE,GAAGL,WAAAA;;AAGtB,YAAA,IAAIK,cAAc,WAAa,EAAA;gBAC7B,IAAI,CAACJ,QAAU,EAAA,OAAO,EAAC;gBAEvB,OAAO;oBACLK,OAASH,EAAAA,MAAAA,CAAOI,uBAAuB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AGF,IAAAA;;AAG1C,YAAA,MAAMuC,UAAUC,OAAK,CAAA;AAAC,gBAAA,YAAA;AAAc,gBAAA;aAAU,EAAExC,IAAAA,CAAAA;;AAGhD,YAAA,IAAIqC,aAAe,EAAA;AACjB,gBAAA,MAAMI,eAAuBH,MAAO,CAAA,cAAA,CAAA;AACpC,gBAAA,MAAMI,WAAmBJ,MAAO,CAAA,UAAA,CAAA;AAEhCxB,gBAAAA,MAAAA,CAAOC,MAAM,CACXwB,OACAlD,EAAAA,qBAAAA,CAAsBC,UAAY,EAAA;AAChCoD,oBAAAA,QAAAA;oBACAC,QAAU,EAAA;wBACRC,MAAQ,EAAA;4BAAEC,KAAOJ,EAAAA;AAAa,yBAAA;wBAC9BK,IAAM,EAAA;4BAAEC,QAAUN,EAAAA;AAAa;AACjC;AACF,iBAAA,CAAA,CAAA;AAEJ;;YAGA,IAAIzC,IAAAA,CAAKE,OAAO,EAAE;gBAChBY,MAAOC,CAAAA,MAAM,CAACwB,OAAS,EAAA;oBACrBrC,OAAS6B,EAAAA,OAAAA,CAAQiB,2BAA2B,CAAC9C,OAASN,EAAAA,WAAAA;AACxD,iBAAA,CAAA;AACF;YAEA,OAAO2C,OAAAA;AACT;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { entries, mapValues, omit } from 'lodash/fp';
|
|
2
2
|
import { nonNull, idArg } from 'nexus';
|
|
3
|
-
import { pagination } from '@strapi/utils';
|
|
3
|
+
import { contentTypes, pagination } from '@strapi/utils';
|
|
4
4
|
|
|
5
5
|
const { withDefaultPagination } = pagination;
|
|
6
6
|
var utils = (({ strapi })=>{
|
|
@@ -20,22 +20,30 @@ var utils = (({ strapi })=>{
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
const { kind } = contentType;
|
|
23
|
+
const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);
|
|
23
24
|
// Collection Types
|
|
24
25
|
if (kind === 'collectionType') {
|
|
25
26
|
if (!multiple) {
|
|
26
|
-
|
|
27
|
-
documentId: nonNull(idArg())
|
|
28
|
-
status: args.PublicationStatusArg
|
|
27
|
+
const params = {
|
|
28
|
+
documentId: nonNull(idArg())
|
|
29
29
|
};
|
|
30
|
+
if (hasDraftAndPublish) {
|
|
31
|
+
Object.assign(params, {
|
|
32
|
+
status: args.PublicationStatusArg,
|
|
33
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return params;
|
|
30
37
|
}
|
|
31
38
|
const params = {
|
|
32
39
|
filters: naming.getFiltersInputTypeName(contentType),
|
|
33
40
|
pagination: args.PaginationArg,
|
|
34
41
|
sort: args.SortArg
|
|
35
42
|
};
|
|
36
|
-
if (!isNested) {
|
|
43
|
+
if (!isNested && hasDraftAndPublish) {
|
|
37
44
|
Object.assign(params, {
|
|
38
|
-
status: args.PublicationStatusArg
|
|
45
|
+
status: args.PublicationStatusArg,
|
|
46
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
return params;
|
|
@@ -43,9 +51,10 @@ var utils = (({ strapi })=>{
|
|
|
43
51
|
// Single Types
|
|
44
52
|
if (kind === 'singleType') {
|
|
45
53
|
const params = {};
|
|
46
|
-
if (!isNested) {
|
|
54
|
+
if (!isNested && hasDraftAndPublish) {
|
|
47
55
|
Object.assign(params, {
|
|
48
|
-
status: args.PublicationStatusArg
|
|
56
|
+
status: args.PublicationStatusArg,
|
|
57
|
+
hasPublishedVersion: args.HasPublishedVersionArg
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
return params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../../../server/src/services/builders/utils.ts"],"sourcesContent":["import { entries, mapValues, omit } from 'lodash/fp';\nimport { idArg, nonNull } from 'nexus';\nimport { pagination } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nconst { withDefaultPagination } = pagination;\n\ntype ContentTypeArgsOptions = {\n multiple?: boolean;\n isNested?: boolean;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const { service: getService } = strapi.plugin('graphql');\n\n return {\n getContentTypeArgs(\n contentType: Struct.Schema,\n { multiple = true, isNested = false }: ContentTypeArgsOptions = {}\n ) {\n const { naming } = getService('utils');\n const { args } = getService('internals');\n\n const { modelType } = contentType;\n\n // Components\n if (modelType === 'component') {\n if (!multiple) return {};\n\n return {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n }\n\n const { kind } = contentType;\n\n // Collection Types\n if (kind === 'collectionType') {\n if (!multiple) {\n
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../../../server/src/services/builders/utils.ts"],"sourcesContent":["import { entries, mapValues, omit } from 'lodash/fp';\nimport { idArg, nonNull } from 'nexus';\nimport { contentTypes, pagination } from '@strapi/utils';\nimport type { Core, Struct } from '@strapi/types';\n\nconst { withDefaultPagination } = pagination;\n\ntype ContentTypeArgsOptions = {\n multiple?: boolean;\n isNested?: boolean;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const { service: getService } = strapi.plugin('graphql');\n\n return {\n getContentTypeArgs(\n contentType: Struct.Schema,\n { multiple = true, isNested = false }: ContentTypeArgsOptions = {}\n ) {\n const { naming } = getService('utils');\n const { args } = getService('internals');\n\n const { modelType } = contentType;\n\n // Components\n if (modelType === 'component') {\n if (!multiple) return {};\n\n return {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n }\n\n const { kind } = contentType;\n\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);\n\n // Collection Types\n if (kind === 'collectionType') {\n if (!multiple) {\n const params: Record<string, unknown> = {\n documentId: nonNull(idArg()),\n };\n\n if (hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n\n const params = {\n filters: naming.getFiltersInputTypeName(contentType),\n pagination: args.PaginationArg,\n sort: args.SortArg,\n };\n\n if (!isNested && hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n\n // Single Types\n if (kind === 'singleType') {\n const params = {};\n\n if (!isNested && hasDraftAndPublish) {\n Object.assign(params, {\n status: args.PublicationStatusArg,\n hasPublishedVersion: args.HasPublishedVersionArg,\n });\n }\n\n return params;\n }\n },\n\n /**\n * Filter an object entries and keep only those whose value is a unique scalar attribute\n */\n getUniqueScalarAttributes(attributes: Struct.SchemaAttributes) {\n const { isStrapiScalar } = getService('utils').attributes;\n\n const uniqueAttributes = entries(attributes).filter(\n ([, attribute]) => isStrapiScalar(attribute) && 'unique' in attribute && attribute.unique\n );\n\n return Object.fromEntries(uniqueAttributes);\n },\n\n /**\n * Map each value from an attribute to a FiltersInput type name\n * @param {object} attributes - The attributes object to transform\n * @return {Object<string, string>}\n */\n scalarAttributesToFiltersMap(attributes: Struct.SchemaAttributes) {\n return mapValues((attribute) => {\n const { mappers, naming } = getService('utils');\n\n const gqlScalar = mappers.strapiScalarToGraphQLScalar(attribute.type);\n\n return naming.getScalarFilterInputTypeName(gqlScalar);\n }, attributes);\n },\n\n /**\n * Apply basic transform to GQL args\n */\n transformArgs(\n args: any,\n {\n contentType,\n usePagination = false,\n }: { contentType: Struct.ContentTypeSchema; usePagination?: boolean }\n ) {\n const { mappers } = getService('utils');\n const { config } = strapi.plugin('graphql');\n const { pagination = {}, filters = {} } = args;\n\n // Init\n const newArgs = omit(['pagination', 'filters'], args);\n\n // Pagination\n if (usePagination) {\n const defaultLimit: number = config('defaultLimit');\n const maxLimit: number = config('maxLimit');\n\n Object.assign(\n newArgs,\n withDefaultPagination(pagination, {\n maxLimit,\n defaults: {\n offset: { limit: defaultLimit },\n page: { pageSize: defaultLimit },\n },\n })\n );\n }\n\n // Filters\n if (args.filters) {\n Object.assign(newArgs, {\n filters: mappers.graphQLFiltersToStrapiQuery(filters, contentType),\n });\n }\n\n return newArgs;\n },\n };\n};\n"],"names":["withDefaultPagination","pagination","strapi","service","getService","plugin","getContentTypeArgs","contentType","multiple","isNested","naming","args","modelType","filters","getFiltersInputTypeName","PaginationArg","sort","SortArg","kind","hasDraftAndPublish","contentTypes","params","documentId","nonNull","idArg","Object","assign","status","PublicationStatusArg","hasPublishedVersion","HasPublishedVersionArg","getUniqueScalarAttributes","attributes","isStrapiScalar","uniqueAttributes","entries","filter","attribute","unique","fromEntries","scalarAttributesToFiltersMap","mapValues","mappers","gqlScalar","strapiScalarToGraphQLScalar","type","getScalarFilterInputTypeName","transformArgs","usePagination","config","newArgs","omit","defaultLimit","maxLimit","defaults","offset","limit","page","pageSize","graphQLFiltersToStrapiQuery"],"mappings":";;;;AAKA,MAAM,EAAEA,qBAAqB,EAAE,GAAGC,UAAAA;AAOlC,YAAe,CAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;AACjD,IAAA,MAAM,EAAEC,OAASC,EAAAA,UAAU,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAE9C,OAAO;QACLC,kBACEC,CAAAA,CAAAA,WAA0B,EAC1B,EAAEC,QAAW,GAAA,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAA0B,GAAG,EAAE,EAAA;AAElE,YAAA,MAAM,EAAEC,MAAM,EAAE,GAAGN,UAAW,CAAA,OAAA,CAAA;AAC9B,YAAA,MAAM,EAAEO,IAAI,EAAE,GAAGP,UAAW,CAAA,WAAA,CAAA;YAE5B,MAAM,EAAEQ,SAAS,EAAE,GAAGL,WAAAA;;AAGtB,YAAA,IAAIK,cAAc,WAAa,EAAA;gBAC7B,IAAI,CAACJ,QAAU,EAAA,OAAO,EAAC;gBAEvB,OAAO;oBACLK,OAASH,EAAAA,MAAAA,CAAOI,uBAAuB,CAACP,W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A;;AAG1C,YAAA,MAAMuC,UAAUC,IAAK,CAAA;AAAC,gBAAA,YAAA;AAAc,gBAAA;aAAU,EAAExC,IAAAA,CAAAA;;AAGhD,YAAA,IAAIqC,aAAe,EAAA;AACjB,gBAAA,MAAMI,eAAuBH,MAAO,CAAA,cAAA,CAAA;AACpC,gBAAA,MAAMI,WAAmBJ,MAAO,CAAA,UAAA,CAAA;AAEhCxB,gBAAAA,MAAAA,CAAOC,MAAM,CACXwB,OACAlD,EAAAA,qBAAAA,CAAsBC,UAAY,EAAA;AAChCoD,oBAAAA,QAAAA;oBACAC,QAAU,EAAA;wBACRC,MAAQ,EAAA;4BAAEC,KAAOJ,EAAAA;AAAa,yBAAA;wBAC9BK,IAAM,EAAA;4BAAEC,QAAUN,EAAAA;AAAa;AACjC;AACF,iBAAA,CAAA,CAAA;AAEJ;;YAGA,IAAIzC,IAAAA,CAAKE,OAAO,EAAE;gBAChBY,MAAOC,CAAAA,MAAM,CAACwB,OAAS,EAAA;oBACrBrC,OAAS6B,EAAAA,OAAAA,CAAQiB,2BAA2B,CAAC9C,OAASN,EAAAA,WAAAA;AACxD,iBAAA,CAAA;AACF;YAEA,OAAO2C,OAAAA;AACT;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-published-version.js","sources":["../../../../../server/src/services/internals/args/has-published-version.ts"],"sourcesContent":["import { booleanArg } from 'nexus';\n\nexport default () => booleanArg();\n"],"names":["booleanArg"],"mappings":";;;;AAEA,0BAAe,CAAA,IAAMA,gBAAAA,EAAW;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-published-version.mjs","sources":["../../../../../server/src/services/internals/args/has-published-version.ts"],"sourcesContent":["import { booleanArg } from 'nexus';\n\nexport default () => booleanArg();\n"],"names":["booleanArg"],"mappings":";;AAEA,0BAAe,CAAA,IAAMA,UAAAA,EAAW;;;;"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var sort = require('./sort.js');
|
|
4
4
|
var publicationStatus = require('./publication-status.js');
|
|
5
|
+
var hasPublishedVersion = require('./has-published-version.js');
|
|
5
6
|
var pagination = require('./pagination.js');
|
|
6
7
|
|
|
7
8
|
var args = ((context)=>({
|
|
8
9
|
SortArg: sort,
|
|
9
10
|
PaginationArg: pagination,
|
|
10
|
-
PublicationStatusArg: publicationStatus(context)
|
|
11
|
+
PublicationStatusArg: publicationStatus(context),
|
|
12
|
+
HasPublishedVersionArg: hasPublishedVersion()
|
|
11
13
|
}));
|
|
12
14
|
|
|
13
15
|
module.exports = args;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../server/src/services/internals/args/index.ts"],"sourcesContent":["import SortArg from './sort';\nimport publicationStatus from './publication-status';\nimport PaginationArg from './pagination';\nimport type { Context } from '../../types';\n\nexport default (context: Context) => ({\n SortArg,\n PaginationArg,\n PublicationStatusArg: publicationStatus(context),\n});\n"],"names":["context","SortArg","PaginationArg","PublicationStatusArg","publicationStatus"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../server/src/services/internals/args/index.ts"],"sourcesContent":["import SortArg from './sort';\nimport publicationStatus from './publication-status';\nimport hasPublishedVersion from './has-published-version';\nimport PaginationArg from './pagination';\nimport type { Context } from '../../types';\n\nexport default (context: Context) => ({\n SortArg,\n PaginationArg,\n PublicationStatusArg: publicationStatus(context),\n HasPublishedVersionArg: hasPublishedVersion(),\n});\n"],"names":["context","SortArg","PaginationArg","PublicationStatusArg","publicationStatus","HasPublishedVersionArg","hasPublishedVersion"],"mappings":";;;;;;;AAMA,WAAe,CAAA,CAACA,OAAAA,IAAsB;AACpCC,iBAAAA,IAAAA;AACAC,uBAAAA,UAAAA;AACAC,QAAAA,oBAAAA,EAAsBC,iBAAkBJ,CAAAA,OAAAA,CAAAA;QACxCK,sBAAwBC,EAAAA,mBAAAA;AAC1B,KAAA,CAAC;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import SortArg from './sort.mjs';
|
|
2
2
|
import publicationStatus from './publication-status.mjs';
|
|
3
|
+
import hasPublishedVersion from './has-published-version.mjs';
|
|
3
4
|
import PaginationArg from './pagination.mjs';
|
|
4
5
|
|
|
5
6
|
var args = ((context)=>({
|
|
6
7
|
SortArg,
|
|
7
8
|
PaginationArg,
|
|
8
|
-
PublicationStatusArg: publicationStatus(context)
|
|
9
|
+
PublicationStatusArg: publicationStatus(context),
|
|
10
|
+
HasPublishedVersionArg: hasPublishedVersion()
|
|
9
11
|
}));
|
|
10
12
|
|
|
11
13
|
export { args as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../server/src/services/internals/args/index.ts"],"sourcesContent":["import SortArg from './sort';\nimport publicationStatus from './publication-status';\nimport PaginationArg from './pagination';\nimport type { Context } from '../../types';\n\nexport default (context: Context) => ({\n SortArg,\n PaginationArg,\n PublicationStatusArg: publicationStatus(context),\n});\n"],"names":["context","SortArg","PaginationArg","PublicationStatusArg","publicationStatus"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../server/src/services/internals/args/index.ts"],"sourcesContent":["import SortArg from './sort';\nimport publicationStatus from './publication-status';\nimport hasPublishedVersion from './has-published-version';\nimport PaginationArg from './pagination';\nimport type { Context } from '../../types';\n\nexport default (context: Context) => ({\n SortArg,\n PaginationArg,\n PublicationStatusArg: publicationStatus(context),\n HasPublishedVersionArg: hasPublishedVersion(),\n});\n"],"names":["context","SortArg","PaginationArg","PublicationStatusArg","publicationStatus","HasPublishedVersionArg","hasPublishedVersion"],"mappings":";;;;;AAMA,WAAe,CAAA,CAACA,OAAAA,IAAsB;AACpCC,QAAAA,OAAAA;AACAC,QAAAA,aAAAA;AACAC,QAAAA,oBAAAA,EAAsBC,iBAAkBJ,CAAAA,OAAAA,CAAAA;QACxCK,sBAAwBC,EAAAA,mBAAAA;AAC1B,KAAA,CAAC;;;;"}
|
|
@@ -30,24 +30,10 @@ declare const _default: {
|
|
|
30
30
|
getContentTypeArgs(contentType: import("@strapi/types/dist/struct").Schema, { multiple, isNested }?: {
|
|
31
31
|
multiple?: boolean | undefined;
|
|
32
32
|
isNested?: boolean | undefined;
|
|
33
|
-
}): {
|
|
34
|
-
filters?: undefined;
|
|
35
|
-
pagination?: undefined;
|
|
36
|
-
sort?: undefined;
|
|
37
|
-
documentId?: undefined;
|
|
38
|
-
status?: undefined;
|
|
39
|
-
} | {
|
|
33
|
+
}): Record<string, unknown> | {
|
|
40
34
|
filters: any;
|
|
41
35
|
pagination: any;
|
|
42
36
|
sort: any;
|
|
43
|
-
documentId?: undefined;
|
|
44
|
-
status?: undefined;
|
|
45
|
-
} | {
|
|
46
|
-
documentId: import("nexus/dist/core").NexusNonNullDef<any>;
|
|
47
|
-
status: any;
|
|
48
|
-
filters?: undefined;
|
|
49
|
-
pagination?: undefined;
|
|
50
|
-
sort?: undefined;
|
|
51
37
|
} | undefined;
|
|
52
38
|
getUniqueScalarAttributes(attributes: import("@strapi/types/dist/struct").SchemaAttributes): {
|
|
53
39
|
[k: string]: import("@strapi/types/dist/schema/attribute").AnyAttribute;
|
|
@@ -184,6 +170,7 @@ declare const _default: {
|
|
|
184
170
|
SortArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
185
171
|
PaginationArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
186
172
|
PublicationStatusArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
173
|
+
HasPublishedVersionArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
187
174
|
};
|
|
188
175
|
scalars: {
|
|
189
176
|
JSON: import("nexus/dist/core").AllNexusOutputTypeDefs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGxC,wBAIE"}
|
|
@@ -29,24 +29,10 @@ declare const _default: ({ strapi }: {
|
|
|
29
29
|
getContentTypeArgs(contentType: import("@strapi/types/dist/struct").Schema, { multiple, isNested }?: {
|
|
30
30
|
multiple?: boolean | undefined;
|
|
31
31
|
isNested?: boolean | undefined;
|
|
32
|
-
}): {
|
|
33
|
-
filters?: undefined;
|
|
34
|
-
pagination?: undefined;
|
|
35
|
-
sort?: undefined;
|
|
36
|
-
documentId?: undefined;
|
|
37
|
-
status?: undefined;
|
|
38
|
-
} | {
|
|
32
|
+
}): Record<string, unknown> | {
|
|
39
33
|
filters: any;
|
|
40
34
|
pagination: any;
|
|
41
35
|
sort: any;
|
|
42
|
-
documentId?: undefined;
|
|
43
|
-
status?: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
documentId: import("nexus/dist/core").NexusNonNullDef<any>;
|
|
46
|
-
status: any;
|
|
47
|
-
filters?: undefined;
|
|
48
|
-
pagination?: undefined;
|
|
49
|
-
sort?: undefined;
|
|
50
36
|
} | undefined;
|
|
51
37
|
getUniqueScalarAttributes(attributes: import("@strapi/types/dist/struct").SchemaAttributes): {
|
|
52
38
|
[k: string]: import("@strapi/types/dist/schema/attribute").AnyAttribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/builders/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAsB1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;qCAkBzB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;IAI/C;;OAEG;gBACO,MAAM,YAAY,YAAY;IAexC;;;OAGG;iBACU,MAAM;IAInB;;;OAGG;cACO,MAAM
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/builders/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAsB1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;qCAkBzB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;IAI/C;;OAEG;gBACO,MAAM,YAAY,YAAY;IAexC;;;OAGG;iBACU,MAAM;IAInB;;;OAGG;cACO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlCpB,wBA4CE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/builders/resolvers/association.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;qCAIf,OAAO;iEAW5B;QACD,cAAc,EAAE,SAAS,GAAG,CAAC,WAAW,CAAC;QACzC,aAAa,EAAE,MAAM,CAAC;KACvB,YAkBuB,GAAG,SAAQ,GAAG,YAAgB,GAAG;;AAhC7D,
|
|
1
|
+
{"version":3,"file":"association.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/builders/resolvers/association.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;qCAIf,OAAO;iEAW5B;QACD,cAAc,EAAE,SAAS,GAAG,CAAC,WAAW,CAAC;QACzC,aAAa,EAAE,MAAM,CAAC;KACvB,YAkBuB,GAAG,SAAQ,GAAG,YAAgB,GAAG;;AAhC7D,wBA0KE"}
|
|
@@ -7,24 +7,10 @@ type ContentTypeArgsOptions = {
|
|
|
7
7
|
declare const _default: ({ strapi }: {
|
|
8
8
|
strapi: Core.Strapi;
|
|
9
9
|
}) => {
|
|
10
|
-
getContentTypeArgs(contentType: Struct.Schema, { multiple, isNested }?: ContentTypeArgsOptions): {
|
|
11
|
-
filters?: undefined;
|
|
12
|
-
pagination?: undefined;
|
|
13
|
-
sort?: undefined;
|
|
14
|
-
documentId?: undefined;
|
|
15
|
-
status?: undefined;
|
|
16
|
-
} | {
|
|
10
|
+
getContentTypeArgs(contentType: Struct.Schema, { multiple, isNested }?: ContentTypeArgsOptions): Record<string, unknown> | {
|
|
17
11
|
filters: any;
|
|
18
12
|
pagination: any;
|
|
19
13
|
sort: any;
|
|
20
|
-
documentId?: undefined;
|
|
21
|
-
status?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
documentId: import("nexus/dist/core").NexusNonNullDef<any>;
|
|
24
|
-
status: any;
|
|
25
|
-
filters?: undefined;
|
|
26
|
-
pagination?: undefined;
|
|
27
|
-
sort?: undefined;
|
|
28
14
|
} | undefined;
|
|
29
15
|
/**
|
|
30
16
|
* Filter an object entries and keep only those whose value is a unique scalar attribute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/builders/utils.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIlD,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;qCAE0B;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;oCAKhC,OAAO,MAAM,2BACa,sBAAsB
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/builders/utils.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIlD,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;qCAE0B;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;oCAKhC,OAAO,MAAM,2BACa,sBAAsB;;;;;IAsE/D;;OAEG;0CACmC,OAAO,gBAAgB;;;IAU7D;;;;OAIG;6CACsC,OAAO,gBAAgB;IAUhE;;OAEG;wBAEK,GAAG,mCAIN;QAAE,WAAW,EAAE,OAAO,iBAAiB,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE;;AAhH3E,wBAoJE"}
|
|
@@ -17,24 +17,10 @@ export declare const services: {
|
|
|
17
17
|
getContentTypeArgs(contentType: import("@strapi/types/dist/struct").Schema, { multiple, isNested }?: {
|
|
18
18
|
multiple?: boolean | undefined;
|
|
19
19
|
isNested?: boolean | undefined;
|
|
20
|
-
}): {
|
|
21
|
-
filters?: undefined;
|
|
22
|
-
pagination?: undefined;
|
|
23
|
-
sort?: undefined;
|
|
24
|
-
documentId?: undefined;
|
|
25
|
-
status?: undefined;
|
|
26
|
-
} | {
|
|
20
|
+
}): Record<string, unknown> | {
|
|
27
21
|
filters: any;
|
|
28
22
|
pagination: any;
|
|
29
23
|
sort: any;
|
|
30
|
-
documentId?: undefined;
|
|
31
|
-
status?: undefined;
|
|
32
|
-
} | {
|
|
33
|
-
documentId: import("nexus/dist/core").NexusNonNullDef<any>;
|
|
34
|
-
status: any;
|
|
35
|
-
filters?: undefined;
|
|
36
|
-
pagination?: undefined;
|
|
37
|
-
sort?: undefined;
|
|
38
24
|
} | undefined;
|
|
39
25
|
getUniqueScalarAttributes(attributes: import("@strapi/types/dist/struct").SchemaAttributes): {
|
|
40
26
|
[k: string]: import("@strapi/types/dist/schema/attribute").AnyAttribute;
|
|
@@ -171,6 +157,7 @@ export declare const services: {
|
|
|
171
157
|
SortArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
172
158
|
PaginationArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
173
159
|
PublicationStatusArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
160
|
+
HasPublishedVersionArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
174
161
|
};
|
|
175
162
|
scalars: {
|
|
176
163
|
JSON: import("nexus/dist/core").AllNexusOutputTypeDefs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";AASA,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";AASA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-published-version.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/internals/args/has-published-version.ts"],"names":[],"mappings":";AAEA,wBAAkC"}
|
|
@@ -3,6 +3,7 @@ declare const _default: (context: Context) => {
|
|
|
3
3
|
SortArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
4
4
|
PaginationArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
5
5
|
PublicationStatusArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
6
|
+
HasPublishedVersionArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
6
7
|
};
|
|
7
8
|
export default _default;
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/internals/args/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/internals/args/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;kCAElB,OAAO;;;;;;AAAhC,wBAKG"}
|
|
@@ -4,6 +4,7 @@ declare const _default: (context: Context) => {
|
|
|
4
4
|
SortArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
5
5
|
PaginationArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
6
6
|
PublicationStatusArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
7
|
+
HasPublishedVersionArg: import("nexus/dist/core").NexusArgDef<any>;
|
|
7
8
|
};
|
|
8
9
|
scalars: {
|
|
9
10
|
JSON: import("nexus/dist/core").AllNexusOutputTypeDefs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/internals/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;kCAEf,OAAO
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/internals/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;kCAEf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAhC,wBAKG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-graphql",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.37.0",
|
|
4
4
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@koa/cors": "5.0.0",
|
|
62
62
|
"@strapi/design-system": "2.1.2",
|
|
63
63
|
"@strapi/icons": "2.1.2",
|
|
64
|
-
"@strapi/utils": "5.
|
|
64
|
+
"@strapi/utils": "5.37.0",
|
|
65
65
|
"graphql": "^16.8.1",
|
|
66
66
|
"graphql-depth-limit": "^1.1.0",
|
|
67
67
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
"pluralize": "8.0.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@strapi/strapi": "5.
|
|
77
|
-
"@strapi/types": "5.
|
|
76
|
+
"@strapi/strapi": "5.37.0",
|
|
77
|
+
"@strapi/types": "5.37.0",
|
|
78
78
|
"@types/graphql-depth-limit": "1.1.5",
|
|
79
79
|
"@types/koa-bodyparser": "4.3.12",
|
|
80
80
|
"@types/koa__cors": "5.0.0",
|
|
81
81
|
"cross-env": "^7.0.3",
|
|
82
|
-
"eslint-config-custom": "5.
|
|
82
|
+
"eslint-config-custom": "5.37.0",
|
|
83
83
|
"koa": "2.16.3",
|
|
84
84
|
"react": "18.3.1",
|
|
85
85
|
"react-dom": "18.3.1",
|
|
86
86
|
"react-router-dom": "6.30.3",
|
|
87
87
|
"styled-components": "6.1.8",
|
|
88
|
-
"tsconfig": "5.
|
|
88
|
+
"tsconfig": "5.37.0",
|
|
89
89
|
"typescript": "5.4.4"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|