From 8d262925ac9afd19c5025731a9dc3008d1681ef4 Mon Sep 17 00:00:00 2001 From: Quentin Leonetti Date: Tue, 22 Oct 2024 15:26:16 +0200 Subject: [PATCH] Saving manuscript count (#4425) * Saving manuscript count * linting * add test * simplify code --- .../contentful/manuscript.data-provider.ts | 20 ++ .../manuscript.data-provider.test.ts | 35 +++- .../test/fixtures/manuscript.fixtures.ts | 2 + .../src/crn/autogenerated-gql/gql.ts | 14 +- .../src/crn/autogenerated-gql/graphql.ts | 178 +++++++++++++++++- .../src/crn/queries/manuscript.queries.ts | 21 +++ .../crn/schema/autogenerated-schema.graphql | 24 +++ packages/fixtures/src/manuscripts.ts | 1 + packages/model/src/manuscript.ts | 1 + 9 files changed, 287 insertions(+), 9 deletions(-) diff --git a/apps/crn-server/src/data-providers/contentful/manuscript.data-provider.ts b/apps/crn-server/src/data-providers/contentful/manuscript.data-provider.ts index 22b816cff8..8956ca1892 100644 --- a/apps/crn-server/src/data-providers/contentful/manuscript.data-provider.ts +++ b/apps/crn-server/src/data-providers/contentful/manuscript.data-provider.ts @@ -3,6 +3,8 @@ import { Environment, FetchManuscriptByIdQuery, FetchManuscriptByIdQueryVariables, + FetchManuscriptsByTeamIdQuery, + FETCH_MANUSCRIPTS_BY_TEAM_ID, FETCH_MANUSCRIPT_BY_ID, getLinkAsset, getLinkAssets, @@ -46,6 +48,19 @@ export class ManuscriptContentfulDataProvider throw new Error('Method not implemented.'); } + async fetchCountByTeamId(id: string) { + const { teams } = await this.contentfulClient.request< + FetchManuscriptsByTeamIdQuery, + FetchManuscriptByIdQueryVariables + >(FETCH_MANUSCRIPTS_BY_TEAM_ID, { id }); + + return ( + teams?.linkedFrom?.manuscriptsCollection?.items.filter( + (item) => item?.teamsCollection?.items[0]?.sys.id === id, + ).length || 0 + ); + } + async fetchById(id: string): Promise { const { manuscripts } = await this.contentfulClient.request< FetchManuscriptByIdQuery, @@ -95,6 +110,7 @@ export class ManuscriptContentfulDataProvider { fields: addLocaleToFields({ ...version, + count: 1, teams: getLinkEntities(version.teams), firstAuthors: getLinkEntities(version.firstAuthors), correspondingAuthor: getLinkEntities(version.correspondingAuthor), @@ -120,9 +136,12 @@ export class ManuscriptContentfulDataProvider const { id: manuscriptVersionId } = manuscriptVersionEntry.sys; + const currentCount = (await this.fetchCountByTeamId(teamId)) || 0; + const manuscriptEntry = await environment.createEntry('manuscripts', { fields: addLocaleToFields({ ...plainFields, + count: currentCount + 1, teams: getLinkEntities([teamId]), versions: getLinkEntities([manuscriptVersionId]), }), @@ -138,6 +157,7 @@ const parseGraphQLManuscript = ( manuscripts: ManuscriptItem, ): ManuscriptDataObject => ({ id: manuscripts.sys.id, + count: manuscripts.count || 0, title: manuscripts.title || '', teamId: manuscripts.teamsCollection?.items[0]?.sys.id || '', status: manuscriptMapStatus(manuscripts.status) || undefined, diff --git a/apps/crn-server/test/data-providers/contentful/manuscript.data-provider.test.ts b/apps/crn-server/test/data-providers/contentful/manuscript.data-provider.test.ts index dc07c25441..1c19b98088 100644 --- a/apps/crn-server/test/data-providers/contentful/manuscript.data-provider.test.ts +++ b/apps/crn-server/test/data-providers/contentful/manuscript.data-provider.test.ts @@ -15,7 +15,10 @@ import { getManuscriptCreateDataObject, getManuscriptDataObject, } from '../../fixtures/manuscript.fixtures'; -import { getUsersTeamsCollection } from '../../fixtures/teams.fixtures'; +import { + getContentfulGraphql, + getUsersTeamsCollection, +} from '../../fixtures/teams.fixtures'; import { getContentfulGraphqlClientMock } from '../../mocks/contentful-graphql-client.mock'; import { getContentfulEnvironmentMock } from '../../mocks/contentful-rest-client.mock'; @@ -32,6 +35,7 @@ describe('Manuscripts Contentful Data Provider', () => { const contentfulGraphqlClientMockServer = getContentfulGraphqlClientMockServer({ + ...getContentfulGraphql(), UsersTeamsCollection: () => getUsersTeamsCollection(), Manuscripts: () => getContentfulGraphqlManuscript(), ManuscriptsVersionsCollection: () => @@ -60,6 +64,22 @@ describe('Manuscripts Contentful Data Provider', () => { }); }); + describe('FetchCountByTeamId', () => { + it('Should return 0 when team does not exist', async () => { + const teamId = 'team-id-2'; + const result = + await manuscriptDataProviderMockGraphql.fetchCountByTeamId(teamId); + expect(result).toBe(0); + }); + + it('Should fetch the count of existing manuscripts for a given team', async () => { + const teamId = 'team-id-1'; + const result = + await manuscriptDataProviderMockGraphql.fetchCountByTeamId(teamId); + expect(result).toBe(0); + }); + }); + describe('Fetch-by-id', () => { test('Should fetch the manuscript from Contentful GraphQl', async () => { const manuscriptId = 'manuscript-id-1'; @@ -148,6 +168,7 @@ describe('Manuscripts Contentful Data Provider', () => { const result = await manuscriptDataProvider.fetchById('1'); expect(result).toEqual({ id: 'manuscript-id-1', + count: 1, teamId: '', title: '', versions: [], @@ -237,7 +258,7 @@ describe('Manuscripts Contentful Data Provider', () => { .calledWith(manuscriptCreateDataObject.versions[0]!.manuscriptFile.id) .mockResolvedValue(assetMock); - const result = await manuscriptDataProvider.create({ + const result = await manuscriptDataProviderMockGraphql.create({ ...manuscriptCreateDataObject, userId: 'user-id-0', }); @@ -284,6 +305,7 @@ describe('Manuscripts Contentful Data Provider', () => { }, submissionDate: { 'en-US': undefined }, correspondingAuthor: { 'en-US': [] }, + count: { 'en-US': 1 }, additionalAuthors: { 'en-US': [] }, teams: { 'en-US': [ @@ -328,6 +350,9 @@ describe('Manuscripts Contentful Data Provider', () => { eligibilityReasons: { 'en-US': [], }, + count: { + 'en-US': 3, + }, versions: { 'en-US': [ { @@ -384,7 +409,7 @@ describe('Manuscripts Contentful Data Provider', () => { ) .mockResolvedValue(assetMock); - const result = await manuscriptDataProvider.create({ + const result = await manuscriptDataProviderMockGraphql.create({ ...manuscriptCreateDataObject, userId: 'user-id-0', }); @@ -445,6 +470,7 @@ describe('Manuscripts Contentful Data Provider', () => { }, submissionDate: { 'en-US': undefined }, correspondingAuthor: { 'en-US': [] }, + count: { 'en-US': 1 }, additionalAuthors: { 'en-US': [] }, teams: { 'en-US': [ @@ -475,6 +501,9 @@ describe('Manuscripts Contentful Data Provider', () => { title: { 'en-US': 'Manuscript Title', }, + count: { + 'en-US': 3, + }, teams: { 'en-US': [ { diff --git a/apps/crn-server/test/fixtures/manuscript.fixtures.ts b/apps/crn-server/test/fixtures/manuscript.fixtures.ts index 3b2df16eb4..76fed1c446 100644 --- a/apps/crn-server/test/fixtures/manuscript.fixtures.ts +++ b/apps/crn-server/test/fixtures/manuscript.fixtures.ts @@ -15,6 +15,7 @@ export const getManuscriptDataObject = ( id: 'manuscript-id-1', title: 'Manuscript Title', teamId: 'team-1', + count: 1, versions: [ { id: 'version-1', @@ -62,6 +63,7 @@ export const getContentfulGraphqlManuscript = ( id: 'manuscript-id-1', }, title: 'Manuscript Title', + count: 1, teamsCollection: { items: [{ sys: { id: 'team-1' } }], }, diff --git a/packages/contentful/src/crn/autogenerated-gql/gql.ts b/packages/contentful/src/crn/autogenerated-gql/gql.ts index 23491c4bd7..a7c4059ec2 100644 --- a/packages/contentful/src/crn/autogenerated-gql/gql.ts +++ b/packages/contentful/src/crn/autogenerated-gql/gql.ts @@ -73,10 +73,12 @@ const documents = { types.FetchInterestGroupsByUserIdDocument, '\n query FetchLabs($limit: Int, $skip: Int, $where: LabsFilter) {\n labsCollection(limit: $limit, skip: $skip, where: $where, order: name_ASC) {\n total\n items {\n sys {\n id\n }\n name\n }\n }\n }\n': types.FetchLabsDocument, - '\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n': + '\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n count\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n': types.ManuscriptsContentFragmentDoc, '\n query FetchManuscriptById($id: String!) {\n manuscripts(id: $id) {\n ...ManuscriptsContent\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n \n': types.FetchManuscriptByIdDocument, + '\n query FetchManuscriptsByTeamId($id: String!) {\n teams(id: $id) {\n linkedFrom {\n manuscriptsCollection(limit: 500) {\n items {\n teamsCollection {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n': + types.FetchManuscriptsByTeamIdDocument, '\n fragment NewsContent on News {\n sys {\n id\n firstPublishedAt\n }\n title\n shortText\n frequency\n link\n linkText\n thumbnail {\n url\n }\n text {\n json\n links {\n entries {\n inline {\n sys {\n id\n }\n __typename\n ... on Media {\n url\n }\n }\n }\n assets {\n block {\n sys {\n id\n }\n url\n description\n contentType\n width\n height\n }\n }\n }\n }\n tagsCollection(limit: 20) {\n items {\n name\n }\n }\n publishDate\n }\n': types.NewsContentFragmentDoc, '\n query FetchNewsById($id: String!) {\n news(id: $id) {\n ...NewsContent\n }\n }\n \n': @@ -333,14 +335,20 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n', -): (typeof documents)['\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n']; + source: '\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n count\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n', +): (typeof documents)['\n fragment ManuscriptsContent on Manuscripts {\n sys {\n id\n }\n title\n status\n count\n versionsCollection(limit: 20, order: sys_publishedAt_DESC) {\n items {\n sys {\n id\n publishedAt\n firstPublishedAt\n }\n type\n lifecycle\n description\n manuscriptFile {\n sys {\n id\n }\n fileName\n url\n }\n keyResourceTable {\n sys {\n id\n }\n fileName\n url\n }\n additionalFilesCollection(limit: 10) {\n items {\n sys {\n id\n }\n fileName\n url\n }\n }\n preprintDoi\n publicationDoi\n requestingApcCoverage\n submitterName\n submissionDate\n otherDetails\n acknowledgedGrantNumber\n acknowledgedGrantNumberDetails\n asapAffiliationIncluded\n asapAffiliationIncludedDetails\n manuscriptLicense\n manuscriptLicenseDetails\n datasetsDeposited\n datasetsDepositedDetails\n codeDeposited\n codeDepositedDetails\n protocolsDeposited\n protocolsDepositedDetails\n labMaterialsRegistered\n labMaterialsRegisteredDetails\n availabilityStatement\n availabilityStatementDetails\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n displayName\n inactiveSince\n }\n }\n labsCollection(limit: 10) {\n items {\n sys {\n id\n }\n name\n }\n }\n createdBy {\n sys {\n id\n }\n firstName\n nickname\n lastName\n alumniSinceDate\n avatar {\n url\n }\n teamsCollection(limit: 3) {\n items {\n team {\n sys {\n id\n }\n displayName\n }\n }\n }\n }\n linkedFrom {\n complianceReportsCollection(limit: 1) {\n items {\n url\n description\n }\n }\n }\n }\n }\n }\n']; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( source: '\n query FetchManuscriptById($id: String!) {\n manuscripts(id: $id) {\n ...ManuscriptsContent\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n \n', ): (typeof documents)['\n query FetchManuscriptById($id: String!) {\n manuscripts(id: $id) {\n ...ManuscriptsContent\n teamsCollection(limit: 10) {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n \n']; +/** + * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function gql( + source: '\n query FetchManuscriptsByTeamId($id: String!) {\n teams(id: $id) {\n linkedFrom {\n manuscriptsCollection(limit: 500) {\n items {\n teamsCollection {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n', +): (typeof documents)['\n query FetchManuscriptsByTeamId($id: String!) {\n teams(id: $id) {\n linkedFrom {\n manuscriptsCollection(limit: 500) {\n items {\n teamsCollection {\n items {\n sys {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n']; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/packages/contentful/src/crn/autogenerated-gql/graphql.ts b/packages/contentful/src/crn/autogenerated-gql/graphql.ts index fc9ef58c55..1450680152 100644 --- a/packages/contentful/src/crn/autogenerated-gql/graphql.ts +++ b/packages/contentful/src/crn/autogenerated-gql/graphql.ts @@ -694,10 +694,26 @@ export enum ComplianceReportsOrder { } export type ContentfulMetadata = { + concepts: Array>; tags: Array>; }; +export type ContentfulMetadataConceptsDescendantsFilter = { + id_contains_all?: InputMaybe>>; + id_contains_none?: InputMaybe>>; + id_contains_some?: InputMaybe>>; +}; + +export type ContentfulMetadataConceptsFilter = { + descendants?: InputMaybe; + id_contains_all?: InputMaybe>>; + id_contains_none?: InputMaybe>>; + id_contains_some?: InputMaybe>>; +}; + export type ContentfulMetadataFilter = { + concepts?: InputMaybe; + concepts_exists?: InputMaybe; tags?: InputMaybe; tags_exists?: InputMaybe; }; @@ -8187,6 +8203,14 @@ export type SysFilter = { publishedVersion_not_in?: InputMaybe>>; }; +/** + * Represents a tag entity for finding and organizing content easily. + * Find out more here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-concepts + */ +export type TaxonomyConcept = { + id?: Maybe; +}; + /** [See type definition](https://app.contentful.com/spaces/5v6w5j61tndm/content_types/teamMembership) */ export type TeamMembership = Entry & _Node & { @@ -17452,7 +17476,7 @@ export type FetchLabsQuery = { export type ManuscriptsContentFragment = Pick< Manuscripts, - 'title' | 'status' + 'title' | 'status' | 'count' > & { sys: Pick; versionsCollection?: Maybe<{ @@ -17547,7 +17571,7 @@ export type FetchManuscriptByIdQueryVariables = Exact<{ export type FetchManuscriptByIdQuery = { manuscripts?: Maybe< - Pick & { + Pick & { teamsCollection?: Maybe<{ items: Array }>>; }>; @@ -17644,6 +17668,26 @@ export type FetchManuscriptByIdQuery = { >; }; +export type FetchManuscriptsByTeamIdQueryVariables = Exact<{ + id: Scalars['String']; +}>; + +export type FetchManuscriptsByTeamIdQuery = { + teams?: Maybe<{ + linkedFrom?: Maybe<{ + manuscriptsCollection?: Maybe<{ + items: Array< + Maybe<{ + teamsCollection?: Maybe<{ + items: Array }>>; + }>; + }> + >; + }>; + }>; + }>; +}; + export type NewsContentFragment = Pick< News, 'title' | 'shortText' | 'frequency' | 'link' | 'linkText' | 'publishDate' @@ -19233,7 +19277,7 @@ export type FetchTeamByIdQuery = { manuscriptsCollection?: Maybe<{ items: Array< Maybe< - Pick & { + Pick & { sys: Pick; versionsCollection?: Maybe<{ items: Array< @@ -22978,6 +23022,7 @@ export const ManuscriptsContentFragmentDoc = { }, { kind: 'Field', name: { kind: 'Name', value: 'title' } }, { kind: 'Field', name: { kind: 'Name', value: 'status' } }, + { kind: 'Field', name: { kind: 'Name', value: 'count' } }, { kind: 'Field', name: { kind: 'Name', value: 'versionsCollection' }, @@ -31962,6 +32007,133 @@ export const FetchManuscriptByIdDocument = { FetchManuscriptByIdQuery, FetchManuscriptByIdQueryVariables >; +export const FetchManuscriptsByTeamIdDocument = { + kind: 'Document', + definitions: [ + { + kind: 'OperationDefinition', + operation: 'query', + name: { kind: 'Name', value: 'FetchManuscriptsByTeamId' }, + variableDefinitions: [ + { + kind: 'VariableDefinition', + variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } }, + type: { + kind: 'NonNullType', + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'String' }, + }, + }, + }, + ], + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'teams' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'id' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'id' }, + }, + }, + ], + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'linkedFrom' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'manuscriptsCollection' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'limit' }, + value: { kind: 'IntValue', value: '500' }, + }, + ], + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'items' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { + kind: 'Name', + value: 'teamsCollection', + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { + kind: 'Name', + value: 'items', + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { + kind: 'Name', + value: 'sys', + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { + kind: 'Name', + value: 'id', + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + FetchManuscriptsByTeamIdQuery, + FetchManuscriptsByTeamIdQueryVariables +>; export const FetchNewsByIdDocument = { kind: 'Document', definitions: [ diff --git a/packages/contentful/src/crn/queries/manuscript.queries.ts b/packages/contentful/src/crn/queries/manuscript.queries.ts index 5aca0b3705..5982317d70 100644 --- a/packages/contentful/src/crn/queries/manuscript.queries.ts +++ b/packages/contentful/src/crn/queries/manuscript.queries.ts @@ -9,6 +9,7 @@ export const manuscriptContentQueryFragment = gql` } title status + count versionsCollection(limit: 20, order: sys_publishedAt_DESC) { items { sys { @@ -131,3 +132,23 @@ export const FETCH_MANUSCRIPT_BY_ID = gql` } ${manuscriptContentQueryFragment} `; + +export const FETCH_MANUSCRIPTS_BY_TEAM_ID = gql` + query FetchManuscriptsByTeamId($id: String!) { + teams(id: $id) { + linkedFrom { + manuscriptsCollection(limit: 500) { + items { + teamsCollection { + items { + sys { + id + } + } + } + } + } + } + } + } +`; diff --git a/packages/contentful/src/crn/schema/autogenerated-schema.graphql b/packages/contentful/src/crn/schema/autogenerated-schema.graphql index 3e59267c35..453d08993d 100644 --- a/packages/contentful/src/crn/schema/autogenerated-schema.graphql +++ b/packages/contentful/src/crn/schema/autogenerated-schema.graphql @@ -430,10 +430,26 @@ enum ComplianceReportsOrder { } type ContentfulMetadata { + concepts: [TaxonomyConcept]! tags: [ContentfulTag]! } +input ContentfulMetadataConceptsDescendantsFilter { + id_contains_all: [String] + id_contains_none: [String] + id_contains_some: [String] +} + +input ContentfulMetadataConceptsFilter { + descendants: ContentfulMetadataConceptsDescendantsFilter + id_contains_all: [String] + id_contains_none: [String] + id_contains_some: [String] +} + input ContentfulMetadataFilter { + concepts: ContentfulMetadataConceptsFilter + concepts_exists: Boolean tags: ContentfulMetadataTagsFilter tags_exists: Boolean } @@ -5451,6 +5467,14 @@ input SysFilter { publishedVersion_not_in: [Float] } +""" +Represents a tag entity for finding and organizing content easily. + Find out more here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-concepts +""" +type TaxonomyConcept { + id: String +} + """[See type definition](https://app.contentful.com/spaces/5v6w5j61tndm/content_types/teamMembership)""" type TeamMembership implements Entry & _Node { _id: ID! diff --git a/packages/fixtures/src/manuscripts.ts b/packages/fixtures/src/manuscripts.ts index 7a13619631..03287dfd56 100644 --- a/packages/fixtures/src/manuscripts.ts +++ b/packages/fixtures/src/manuscripts.ts @@ -23,6 +23,7 @@ export const createManuscriptResponse = ( title: `Manuscript ${itemIndex + 1}`, teamId: 'team-1', status: 'Waiting for Report', + count: 1, versions: [ { id: 'version-1', diff --git a/packages/model/src/manuscript.ts b/packages/model/src/manuscript.ts index 4e3a142d39..d221a55cff 100644 --- a/packages/model/src/manuscript.ts +++ b/packages/model/src/manuscript.ts @@ -273,6 +273,7 @@ export type ManuscriptDataObject = { status?: ManuscriptStatus; teamId: string; versions: ManuscriptVersion[]; + count: number; }; export type ManuscriptResponse = ManuscriptDataObject;