@webiny/api-headless-cms 6.4.12-beta.6 → 6.4.12-beta.8
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/context.js +6 -1
- package/context.js.map +1 -1
- package/crud/AccessControl/AccessControl.d.ts +11 -1
- package/crud/AccessControl/AccessControl.js +18 -1
- package/crud/AccessControl/AccessControl.js.map +1 -1
- package/crud/contentModel/validation.js +4 -4
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentModel/schemas.js +3 -3
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModelGroup/validation.js +2 -2
- package/domain/contentModelGroup/validation.js.map +1 -1
- package/export/crud/importing.js +8 -0
- package/export/crud/importing.js.map +1 -1
- package/export/types.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +2 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +5 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +5 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +5 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +16 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/abstractions.d.ts +2 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/abstractions.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +7 -2
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +18 -4
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionById/abstractions.d.ts +4 -2
- package/features/contentEntry/GetRevisionById/abstractions.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +3 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +9 -6
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/shared/entryOwnerAccess.d.ts +15 -0
- package/features/contentEntry/shared/entryOwnerAccess.js +21 -0
- package/features/contentEntry/shared/entryOwnerAccess.js.map +1 -0
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
- package/features/contentModel/ModelAccessGuard/abstractions.d.ts +30 -0
- package/features/contentModel/ModelAccessGuard/abstractions.js +5 -0
- package/features/contentModel/ModelAccessGuard/abstractions.js.map +1 -0
- package/features/contentModel/ModelAccessGuard/index.d.ts +2 -0
- package/features/contentModel/ModelAccessGuard/index.js +1 -0
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/modelBuilder/fields/TextFieldType.js.map +1 -1
- package/graphql/handleRequest.js +18 -9
- package/graphql/handleRequest.js.map +1 -1
- package/graphql/schema/contentEntries.js +15 -5
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +11 -12
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +1 -1
- package/graphql/schema/contentModels.js.map +1 -1
- package/package.json +29 -29
- package/types/types.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\n\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","getContentEntries","params","args","method","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","result","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","a","b"],"mappings":";;;;;;;;;;AA0BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AA+CA,MAAMC,uBAAuB,CAACC,OAAiBC,QACpC;QACH,IAAIA,MAAM,EAAE;QACZ,SAASA,MAAM,OAAO;QACtB,OAAO;YACH,SAASD,MAAM,OAAO;YACtB,MAAMA,MAAM,IAAI;QACpB;QACA,QAAQC,MAAM,MAAM;QACpB,OAAOC,cAAcF,OAAOC;QAC5B,aAAaE,oBAAoBH,OAAOC;QACxC,OAAOG,cAA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pB;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,0BAAyBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAChD,OAAO0B,gBAAgB;wBACnBpB;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,mBAAkBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBACzC,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAC/C,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAClD,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEAuC,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEvC,QAAQ,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAE/E,OAAOuC;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\n\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels({ includePrivate: false });\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\n/**\n * The generic entry queries in this file take any model ID. Private models are internal (system\n * data, no GraphQL schema of their own), so these queries treat them as unknown models.\n */\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels({ includePrivate: false });\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels({ includePrivate: false });\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels({ includePrivate: false });\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels({ includePrivate: false });\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","getContentEntries","params","args","method","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","result","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","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14 @@
|
|
|
1
1
|
import { ErrorResponse, NotFoundError, Response } from "@webiny/handler-graphql";
|
|
2
2
|
import { CmsGroupPlugin } from "../../plugins/CmsGroupPlugin.js";
|
|
3
3
|
import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
4
|
+
import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
|
|
5
|
+
const listGroupModels = async (context, groupSlug)=>{
|
|
6
|
+
const result = await context.container.resolve(ListModelsUseCase).execute({
|
|
7
|
+
includePrivate: false
|
|
8
|
+
});
|
|
9
|
+
if (result.isFail()) return [];
|
|
10
|
+
return result.value.filter((model)=>model.group === groupSlug);
|
|
11
|
+
};
|
|
4
12
|
const createGroupsSchema = ({ context })=>{
|
|
5
13
|
let manageSchema = "";
|
|
6
14
|
if (context.cms.MANAGE) manageSchema = `
|
|
@@ -44,19 +52,10 @@ const createGroupsSchema = ({ context })=>{
|
|
|
44
52
|
let resolvers = {};
|
|
45
53
|
if (context.cms.MANAGE) resolvers = {
|
|
46
54
|
CmsContentModelGroup: {
|
|
47
|
-
contentModels: async (group, _, context)=>
|
|
48
|
-
const models = await context.security.withoutAuthorization(async ()=>context.cms.listModels());
|
|
49
|
-
return models.filter((model)=>{
|
|
50
|
-
if (true === model.isPrivate) return false;
|
|
51
|
-
return model.group === group.slug;
|
|
52
|
-
});
|
|
53
|
-
},
|
|
55
|
+
contentModels: async (group, _, context)=>listGroupModels(context, group.slug),
|
|
54
56
|
totalContentModels: async (group, _, context)=>{
|
|
55
|
-
const models = await context
|
|
56
|
-
return models.
|
|
57
|
-
if (true === model.isPrivate) return false;
|
|
58
|
-
return model.group === group.slug;
|
|
59
|
-
}).length;
|
|
57
|
+
const models = await listGroupModels(context, group.slug);
|
|
58
|
+
return models.length;
|
|
60
59
|
},
|
|
61
60
|
plugin: async (group, _, context)=>context.plugins.byType(CmsGroupPlugin.type).some((item)=>item.contentModelGroup.id === group.id)
|
|
62
61
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\n\n/**\n * Models of a group that the current identity can read. No error when it can't read any model.\n */\nconst listGroupModels = async (context: CmsContext, groupSlug: string) => {\n const result = await context.container\n .resolve(ListModelsUseCase)\n .execute({ includePrivate: false });\n if (result.isFail()) {\n return [];\n }\n // `model.group` holds the group slug.\n return result.value.filter(model => model.group === groupSlug);\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n return listGroupModels(context, group.slug);\n },\n totalContentModels: async (group, _, context) => {\n const models = await listGroupModels(context, group.slug);\n return models.length;\n },\n plugin: async (group, _, context: CmsContext): Promise<boolean> => {\n return context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .some(item => item.contentModelGroup.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const group = await context.cms.getGroup(id);\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const groups = await context.cms.listGroups();\n return new Response(groups.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const model = await context.cms.createGroup(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const group = await context.cms.updateGroup(args.id, args.data);\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n await context.cms.deleteGroup(args.id);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["listGroupModels","context","groupSlug","result","ListModelsUseCase","model","createGroupsSchema","manageSchema","resolvers","group","_","models","CmsGroupPlugin","item","args","id","NotFoundError","Response","e","ErrorResponse","__","groups","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;;;AAWA,MAAMA,kBAAkB,OAAOC,SAAqBC;IAChD,MAAMC,SAAS,MAAMF,QAAQ,SAAS,CACjC,OAA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GAAG,CAAC,UAAU;oBAC3C,OAAO,IAAIgB,SAASI,OAAO,MAAM,CAACZ,CAAAA,QAASA,AAAoB,SAApBA,MAAM,SAAS;gBAC9D,EAAE,OAAOS,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QACA,UAAU;YACN,yBAAyB,OAAOR,GAAGI,MAAWb;gBAC1C,IAAI;oBACA,MAAMI,QAAQ,MAAMJ,QAAQ,GAAG,CAAC,WAAW,CAACa,KAAK,IAAI;oBACrD,OAAO,IAAIG,SAASZ;gBACxB,EAAE,OAAOa,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOR,GAAGI,MAAWb;gBAC1C,IAAI;oBACA,MAAMQ,QAAQ,MAAMR,QAAQ,GAAG,CAAC,WAAW,CAACa,KAAK,EAAE,EAAEA,KAAK,IAAI;oBAC9D,OAAO,IAAIG,SAASR;gBACxB,EAAE,OAAOS,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,yBAAyB,OAAOR,GAAGI,MAAWb;gBAC1C,IAAI;oBACA,MAAMA,QAAQ,GAAG,CAAC,WAAW,CAACa,KAAK,EAAE;oBACrC,OAAO,IAAIG,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;IAGJ,MAAMI,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;YAgBrB,EAAEhB,aAAa;QACnB,CAAC;QACDC;IACJ;IAEAc,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAErB,QAAQ,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IAEpF,OAAOqB;AACX"}
|
|
@@ -6,7 +6,7 @@ const createModelsSchema = ({ context })=>{
|
|
|
6
6
|
getContentModel: async (_, args, context)=>{
|
|
7
7
|
try {
|
|
8
8
|
const model = await context.cms.getModel(args.modelId);
|
|
9
|
-
if (!model) throw new NotFoundError(`Content model "${args.modelId}" was not found!`);
|
|
9
|
+
if (!model || model.isPrivate) throw new NotFoundError(`Content model "${args.modelId}" was not found!`);
|
|
10
10
|
return new Response(model);
|
|
11
11
|
} catch (e) {
|
|
12
12
|
return new ErrorResponse(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/schema/contentModels.js","sources":["../../../src/graphql/schema/contentModels.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext, CmsModel } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface CreateModelsSchemaParams {\n context: CmsContext;\n}\n\nexport const createModelsSchema = ({\n context\n}: CreateModelsSchemaParams): ICmsGraphQLSchemaPlugin => {\n const resolvers: Resolvers<CmsContext> = {\n Query: {\n getContentModel: async (_: unknown, args: GenericRecord, context) => {\n try {\n const model = await context.cms.getModel(args.modelId);\n\n if (!model) {\n throw new NotFoundError(`Content model \"${args.modelId}\" was not found!`);\n }\n\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModels: async (_: unknown, args: GenericRecord, context: CmsContext) => {\n try {\n const models = await context.cms.listModels({\n includePrivate: false,\n includePlugins: args?.includePlugins === false ? false : true\n });\n return new Response(models);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsContentModelField: {\n renderer: field => {\n // Make sure `settings` is an object.\n if (field.renderer) {\n // We're using `||` here, because we want to use the fallback value for both `undefined` and `null`.\n return { ...field.renderer, settings: field.renderer.settings || {} };\n }\n\n return field.renderer;\n },\n tags(field) {\n // Make sure `tags` are always returned as an array.\n return Array.isArray(field.tags) ? field.tags : [];\n }\n },\n CmsContentModel: {\n tags(model: CmsModel) {\n // Make sure `tags` always contain a `type` tag, to differentiate between models.\n const hasType = (model.tags || []).find(tag => tag.startsWith(\"type:\"));\n\n return hasType ? model.tags : [\"type:model\", ...(model.tags || [])];\n },\n plugin: (model: CmsModel) => {\n return model.isPlugin ?? false;\n }\n }\n };\n\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n resolvers[\"Mutation\"] = {\n createContentModel: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModel(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n createContentModelFrom: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModelFrom(args.modelId, args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModel: async (_: unknown, args: any, context) => {\n const { modelId, data } = args;\n try {\n const model = await context.cms.updateModel(modelId, data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModel: async (_: unknown, args: any, context) => {\n const { modelId } = args;\n try {\n await context.cms.deleteModel(modelId);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n };\n\n manageSchema = /* GraphQL */ `\n input CmsPredefinedValueInput {\n label: String!\n value: String!\n selected: Boolean\n }\n\n input CmsPredefinedValuesInput {\n enabled: Boolean\n values: [CmsPredefinedValueInput]\n }\n input CmsFieldRendererInput {\n name: String\n settings: JSON\n }\n\n input CmsFieldValidationInput {\n name: String!\n message: String\n settings: JSON\n }\n\n input CmsFieldRuleInput {\n type: String!\n target: String!\n operator: String!\n value: JSON\n action: String!\n }\n\n input CmsContentModelFieldInput {\n id: ID!\n label: String!\n help: String\n description: String\n note: String\n placeholder: String\n # we never use user input - this is here to the GraphQL does not break when posting from our UI\n # used for debugging purposes\n storageId: String\n fieldId: String!\n type: String!\n tags: [String!]\n list: Boolean\n predefinedValues: CmsPredefinedValuesInput\n renderer: CmsFieldRendererInput\n validation: [CmsFieldValidationInput]\n listValidation: [CmsFieldValidationInput]\n settings: JSON\n rules: [CmsFieldRuleInput!]\n }\n\n input CmsContentModelCreateInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String\n group: String!\n icon: Icon\n singleEntry: Boolean\n description: String\n layout: JSON\n fields: [CmsContentModelFieldInput!]\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n defaultFields: Boolean\n }\n\n input CmsContentModelCreateFromInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String\n group: String!\n icon: Icon\n description: String\n }\n\n input CmsContentModelUpdateInput {\n name: String\n singularApiName: String\n pluralApiName: String\n group: String\n icon: Icon\n description: String\n layout: JSON!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n extend type Mutation {\n createContentModel(data: CmsContentModelCreateInput!): CmsContentModelResponse\n\n createContentModelFrom(\n modelId: ID!\n data: CmsContentModelCreateFromInput!\n ): CmsContentModelResponse\n\n updateContentModel(\n modelId: ID!\n data: CmsContentModelUpdateInput!\n ): CmsContentModelResponse\n\n deleteContentModel(modelId: ID!): CmsDeleteResponse\n }\n `;\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsFieldValidation {\n name: String!\n message: String\n settings: JSON\n }\n\n type CmsFieldRenderer {\n name: String\n settings: JSON\n }\n\n type CmsPredefinedValue {\n label: String\n value: String\n selected: Boolean\n }\n\n type CmsPredefinedValues {\n enabled: Boolean\n values: [CmsPredefinedValue]\n }\n\n type CmsFieldRule {\n type: String!\n target: String!\n operator: String!\n value: JSON\n action: String!\n }\n\n type CmsContentModelField {\n id: ID!\n # auto-generated value\n # used for debugging purposes\n storageId: String\n fieldId: String!\n label: String!\n help: String\n description: String\n note: String\n placeholder: String\n type: String!\n tags: [String!]!\n list: Boolean\n predefinedValues: CmsPredefinedValues\n renderer: CmsFieldRenderer\n validation: [CmsFieldValidation!]\n listValidation: [CmsFieldValidation!]\n settings: JSON\n rules: [CmsFieldRule!]\n }\n\n type CmsContentModel {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n description: String\n group: String!\n icon: Icon\n createdOn: DateTime\n savedOn: DateTime\n createdBy: CmsIdentity\n fields: [CmsContentModelField!]!\n layout: JSON!\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]!\n tenant: String!\n # Returns true if the content model is registered via a plugin.\n plugin: Boolean!\n }\n\n type CmsContentModelResponse {\n data: CmsContentModel\n error: CmsError\n }\n\n type CmsContentModelListResponse {\n data: [CmsContentModel]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModel(modelId: ID!, where: JSON, sort: String): CmsContentModelResponse\n\n listContentModels(includePlugins: Boolean = true): CmsContentModelListResponse\n }\n\n ${manageSchema}\n `,\n resolvers\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-models`;\n return plugin;\n};\n"],"names":["createModelsSchema","context","resolvers","_","args","model","NotFoundError","Response","e","ErrorResponse","models","field","Array","hasType","tag","manageSchema","modelId","data","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;AAWO,MAAMA,qBAAqB,CAAC,EAC/BC,OAAO,EACgB;IACvB,MAAMC,YAAmC;QACrC,OAAO;YACH,iBAAiB,OAAOC,GAAYC,MAAqBH;gBACrD,IAAI;oBACA,MAAMI,QAAQ,MAAMJ,QAAQ,GAAG,CAAC,QAAQ,CAACG,KAAK,OAAO;oBAErD,IAAI,CAACC,OACD,MAAM,IAAIC,cAAc,CAAC,eAAe,EAAEF,KAAK,OAAO,CAAC,gBAAgB,CAAC;oBAG5E,OAAO,IAAIG,SAASF;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,mBAAmB,OAAOL,GAAYC,MAAqBH;gBACvD,IAAI;oBACA,MAAMS,SAAS,MAAMT,QAAQ,GAAG,CAAC,UAAU,CAAC;wBACxC,gBAAgB;wBAChB,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oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,oBAAoB,OAAOL,GAAYC,MAAWH;gBAC9C,MAAM,EAAEe,OAAO,EAAEC,IAAI,EAAE,GAAGb;gBAC1B,IAAI;oBACA,MAAMC,QAAQ,MAAMJ,QAAQ,GAAG,CAAC,WAAW,CAACe,SAASC;oBACrD,OAAO,IAAIV,SAASF;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,oBAAoB,OAAOL,GAAYC,MAAWH;gBAC9C,MAAM,EAAEe,OAAO,EAAE,GAAGZ;gBACpB,IAAI;oBACA,MAAMH,QAAQ,GAAG,CAAC,WAAW,CAACe;oBAC9B,OAAO,IAAIT,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QAEAO,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8G9B,CAAC;IACL;IAEA,MAAMG,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA4FrB,EAAEJ,aAAa;QACnB,CAAC;QACDb;IACJ;IACAgB,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEjB,QAAQ,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;IAC9E,OAAOiB;AACX"}
|
|
1
|
+
{"version":3,"file":"graphql/schema/contentModels.js","sources":["../../../src/graphql/schema/contentModels.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext, CmsModel } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface CreateModelsSchemaParams {\n context: CmsContext;\n}\n\nexport const createModelsSchema = ({\n context\n}: CreateModelsSchemaParams): ICmsGraphQLSchemaPlugin => {\n const resolvers: Resolvers<CmsContext> = {\n Query: {\n getContentModel: async (_: unknown, args: GenericRecord, context) => {\n try {\n const model = await context.cms.getModel(args.modelId);\n\n // Private models are internal and not exposed through the GraphQL API.\n if (!model || model.isPrivate) {\n throw new NotFoundError(`Content model \"${args.modelId}\" was not found!`);\n }\n\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModels: async (_: unknown, args: GenericRecord, context: CmsContext) => {\n try {\n const models = await context.cms.listModels({\n includePrivate: false,\n includePlugins: args?.includePlugins === false ? false : true\n });\n return new Response(models);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsContentModelField: {\n renderer: field => {\n // Make sure `settings` is an object.\n if (field.renderer) {\n // We're using `||` here, because we want to use the fallback value for both `undefined` and `null`.\n return { ...field.renderer, settings: field.renderer.settings || {} };\n }\n\n return field.renderer;\n },\n tags(field) {\n // Make sure `tags` are always returned as an array.\n return Array.isArray(field.tags) ? field.tags : [];\n }\n },\n CmsContentModel: {\n tags(model: CmsModel) {\n // Make sure `tags` always contain a `type` tag, to differentiate between models.\n const hasType = (model.tags || []).find(tag => tag.startsWith(\"type:\"));\n\n return hasType ? model.tags : [\"type:model\", ...(model.tags || [])];\n },\n plugin: (model: CmsModel) => {\n return model.isPlugin ?? false;\n }\n }\n };\n\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n resolvers[\"Mutation\"] = {\n createContentModel: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModel(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n createContentModelFrom: async (_: unknown, args: any, context) => {\n try {\n const model = await context.cms.createModelFrom(args.modelId, args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModel: async (_: unknown, args: any, context) => {\n const { modelId, data } = args;\n try {\n const model = await context.cms.updateModel(modelId, data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModel: async (_: unknown, args: any, context) => {\n const { modelId } = args;\n try {\n await context.cms.deleteModel(modelId);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n };\n\n manageSchema = /* GraphQL */ `\n input CmsPredefinedValueInput {\n label: String!\n value: String!\n selected: Boolean\n }\n\n input CmsPredefinedValuesInput {\n enabled: Boolean\n values: [CmsPredefinedValueInput]\n }\n input CmsFieldRendererInput {\n name: String\n settings: JSON\n }\n\n input CmsFieldValidationInput {\n name: String!\n message: String\n settings: JSON\n }\n\n input CmsFieldRuleInput {\n type: String!\n target: String!\n operator: String!\n value: JSON\n action: String!\n }\n\n input CmsContentModelFieldInput {\n id: ID!\n label: String!\n help: String\n description: String\n note: String\n placeholder: String\n # we never use user input - this is here to the GraphQL does not break when posting from our UI\n # used for debugging purposes\n storageId: String\n fieldId: String!\n type: String!\n tags: [String!]\n list: Boolean\n predefinedValues: CmsPredefinedValuesInput\n renderer: CmsFieldRendererInput\n validation: [CmsFieldValidationInput]\n listValidation: [CmsFieldValidationInput]\n settings: JSON\n rules: [CmsFieldRuleInput!]\n }\n\n input CmsContentModelCreateInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String\n group: String!\n icon: Icon\n singleEntry: Boolean\n description: String\n layout: JSON\n fields: [CmsContentModelFieldInput!]\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n defaultFields: Boolean\n }\n\n input CmsContentModelCreateFromInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String\n group: String!\n icon: Icon\n description: String\n }\n\n input CmsContentModelUpdateInput {\n name: String\n singularApiName: String\n pluralApiName: String\n group: String\n icon: Icon\n description: String\n layout: JSON!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n extend type Mutation {\n createContentModel(data: CmsContentModelCreateInput!): CmsContentModelResponse\n\n createContentModelFrom(\n modelId: ID!\n data: CmsContentModelCreateFromInput!\n ): CmsContentModelResponse\n\n updateContentModel(\n modelId: ID!\n data: CmsContentModelUpdateInput!\n ): CmsContentModelResponse\n\n deleteContentModel(modelId: ID!): CmsDeleteResponse\n }\n `;\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsFieldValidation {\n name: String!\n message: String\n settings: JSON\n }\n\n type CmsFieldRenderer {\n name: String\n settings: JSON\n }\n\n type CmsPredefinedValue {\n label: String\n value: String\n selected: Boolean\n }\n\n type CmsPredefinedValues {\n enabled: Boolean\n values: [CmsPredefinedValue]\n }\n\n type CmsFieldRule {\n type: String!\n target: String!\n operator: String!\n value: JSON\n action: String!\n }\n\n type CmsContentModelField {\n id: ID!\n # auto-generated value\n # used for debugging purposes\n storageId: String\n fieldId: String!\n label: String!\n help: String\n description: String\n note: String\n placeholder: String\n type: String!\n tags: [String!]!\n list: Boolean\n predefinedValues: CmsPredefinedValues\n renderer: CmsFieldRenderer\n validation: [CmsFieldValidation!]\n listValidation: [CmsFieldValidation!]\n settings: JSON\n rules: [CmsFieldRule!]\n }\n\n type CmsContentModel {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n description: String\n group: String!\n icon: Icon\n createdOn: DateTime\n savedOn: DateTime\n createdBy: CmsIdentity\n fields: [CmsContentModelField!]!\n layout: JSON!\n titleFieldId: String\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]!\n tenant: String!\n # Returns true if the content model is registered via a plugin.\n plugin: Boolean!\n }\n\n type CmsContentModelResponse {\n data: CmsContentModel\n error: CmsError\n }\n\n type CmsContentModelListResponse {\n data: [CmsContentModel]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModel(modelId: ID!, where: JSON, sort: String): CmsContentModelResponse\n\n listContentModels(includePlugins: Boolean = true): CmsContentModelListResponse\n }\n\n ${manageSchema}\n `,\n resolvers\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-models`;\n return plugin;\n};\n"],"names":["createModelsSchema","context","resolvers","_","args","model","NotFoundError","Response","e","ErrorResponse","models","field","Array","hasType","tag","manageSchema","modelId","data","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;AAWO,MAAMA,qBAAqB,CAAC,EAC/BC,OAAO,EACgB;IACvB,MAAMC,YAAmC;QACrC,OAAO;YACH,iBAAiB,OAAOC,GAAYC,MAAqBH;gBACrD,IAAI;oBACA,MAAMI,QAAQ,MAAMJ,QAAQ,GAAG,CAAC,QAAQ,CAACG,KAAK,OAAO;oBAGrD,IAAI,CAACC,SAASA,MAAM,SAAS,EACzB,MAAM,IAAIC,cAAc,CAAC,eAAe,EAAEF,KAAK,OAAO,CAAC,gBAAgB,CAAC;oBAG5E,OAAO,IAAIG,SAASF;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,mBAAmB,OAAOL,GAAYC,MAAqBH;gBACvD,IAAI;oBACA,MAAMS,SAAS,MAAMT,QAAQ,GAAG,CAAC,UAAU,CAAC;wBACxC,gBAAgB;wBAChB,gBAAgBG,MAAM,mBAAmB;oBAC7C;oBACA,OAAO,IAAIG,SAASG;gBACxB,EAAE,OAAOF,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QACA,sBAAsB;YAClB,UAAUG,CAAAA;gBAEN,IAAIA,MAAM,QAAQ,EAEd,OAAO;oBAAE,GAAGA,MAAM,QAAQ;oBAAE,UAAUA,MAAM,QAAQ,CAAC,QAAQ,IAAI,CAAC;gBAAE;gBAGxE,OAAOA,MAAM,QAAQ;YACzB;YACA,MAAKA,KA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AC9C,MAAM,EAAEe,OAAO,EAAE,GAAGZ;gBACpB,IAAI;oBACA,MAAMH,QAAQ,GAAG,CAAC,WAAW,CAACe;oBAC9B,OAAO,IAAIT,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QAEAO,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8G9B,CAAC;IACL;IAEA,MAAMG,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA4FrB,EAAEJ,aAAa;QACnB,CAAC;QACDb;IACJ;IACAgB,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEjB,QAAQ,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;IAC9E,OAAOiB;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "6.4.12-beta.
|
|
3
|
+
"version": "6.4.12-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -23,47 +23,47 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/code-frame": "8.0.6",
|
|
26
|
-
"@graphql-tools/merge": "
|
|
27
|
-
"@graphql-tools/schema": "
|
|
28
|
-
"@webiny/api": "6.4.12-beta.
|
|
29
|
-
"@webiny/api-core": "6.4.12-beta.
|
|
26
|
+
"@graphql-tools/merge": "10.0.9",
|
|
27
|
+
"@graphql-tools/schema": "11.0.9",
|
|
28
|
+
"@webiny/api": "6.4.12-beta.8",
|
|
29
|
+
"@webiny/api-core": "6.4.12-beta.8",
|
|
30
30
|
"@webiny/di": "1.1.0",
|
|
31
|
-
"@webiny/error": "6.4.12-beta.
|
|
32
|
-
"@webiny/feature": "6.4.12-beta.
|
|
33
|
-
"@webiny/handler": "6.4.12-beta.
|
|
34
|
-
"@webiny/handler-aws": "6.4.12-beta.
|
|
35
|
-
"@webiny/handler-db": "6.4.12-beta.
|
|
36
|
-
"@webiny/handler-graphql": "6.4.12-beta.
|
|
37
|
-
"@webiny/plugins": "6.4.12-beta.
|
|
38
|
-
"@webiny/project": "6.4.12-beta.
|
|
39
|
-
"@webiny/utils": "6.4.12-beta.
|
|
40
|
-
"@webiny/validation": "6.4.12-beta.
|
|
31
|
+
"@webiny/error": "6.4.12-beta.8",
|
|
32
|
+
"@webiny/feature": "6.4.12-beta.8",
|
|
33
|
+
"@webiny/handler": "6.4.12-beta.8",
|
|
34
|
+
"@webiny/handler-aws": "6.4.12-beta.8",
|
|
35
|
+
"@webiny/handler-db": "6.4.12-beta.8",
|
|
36
|
+
"@webiny/handler-graphql": "6.4.12-beta.8",
|
|
37
|
+
"@webiny/plugins": "6.4.12-beta.8",
|
|
38
|
+
"@webiny/project": "6.4.12-beta.8",
|
|
39
|
+
"@webiny/utils": "6.4.12-beta.8",
|
|
40
|
+
"@webiny/validation": "6.4.12-beta.8",
|
|
41
41
|
"dot-prop-immutable": "2.1.1",
|
|
42
|
-
"graphql": "16.
|
|
42
|
+
"graphql": "16.15.0",
|
|
43
43
|
"graphql-tag": "2.12.7",
|
|
44
44
|
"lodash": "4.18.1",
|
|
45
|
-
"p-map": "7.
|
|
45
|
+
"p-map": "7.1.1",
|
|
46
46
|
"p-reduce": "3.0.0",
|
|
47
47
|
"pluralize": "8.0.0",
|
|
48
48
|
"slugify": "1.6.9",
|
|
49
|
-
"zod": "4.6.
|
|
49
|
+
"zod": "4.6.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/babel__code-frame": "7.27.0",
|
|
53
53
|
"@types/pluralize": "0.0.33",
|
|
54
|
-
"@webiny/aws-sdk": "6.4.12-beta.
|
|
55
|
-
"@webiny/build-tools": "6.4.12-beta.
|
|
56
|
-
"@webiny/db-dynamodb": "6.4.12-beta.
|
|
57
|
-
"@webiny/handler-db": "6.4.12-beta.
|
|
58
|
-
"@webiny/project-utils": "6.4.12-beta.
|
|
59
|
-
"@webiny/sdk": "6.4.12-beta.
|
|
60
|
-
"@webiny/wcp": "6.4.12-beta.
|
|
54
|
+
"@webiny/aws-sdk": "6.4.12-beta.8",
|
|
55
|
+
"@webiny/build-tools": "6.4.12-beta.8",
|
|
56
|
+
"@webiny/db-dynamodb": "6.4.12-beta.8",
|
|
57
|
+
"@webiny/handler-db": "6.4.12-beta.8",
|
|
58
|
+
"@webiny/project-utils": "6.4.12-beta.8",
|
|
59
|
+
"@webiny/sdk": "6.4.12-beta.8",
|
|
60
|
+
"@webiny/wcp": "6.4.12-beta.8",
|
|
61
61
|
"apollo-graphql": "0.9.7",
|
|
62
|
-
"graphql": "16.
|
|
63
|
-
"oxfmt": "0.
|
|
64
|
-
"rimraf": "6.1.
|
|
62
|
+
"graphql": "16.15.0",
|
|
63
|
+
"oxfmt": "0.78.0",
|
|
64
|
+
"rimraf": "6.1.4",
|
|
65
65
|
"typescript": "6.0.3",
|
|
66
|
-
"vitest": "5.0
|
|
66
|
+
"vitest": "5.1.0",
|
|
67
67
|
"write-json-file": "7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
package/types/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types/types.js","sources":["../../src/types/types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type { GraphQLFieldResolver, GraphQLRequestBody } from \"@webiny/handler-graphql/types.js\";\nimport type { processRequestBody } from \"@webiny/handler-graphql\";\nimport type { DbContext } from \"@webiny/handler-db/types.js\";\nimport type { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection.js\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"~/export/types.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport type { CmsModelToAstConverter } from \"~/utils/contentModelAst/CmsModelToAstConverter.js\";\nimport type { ICmsModelFieldToGraphQLRegistry } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type {\n CmsModel,\n CmsModelCreateFromInput,\n CmsModelCreateInput,\n StorageCmsModel\n} from \"./model.js\";\nimport type { CmsGroup } from \"./modelGroup.js\";\nimport type { CmsIdentity } from \"./identity.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator,\n IdMixedInterfaceGenerator,\n NumericInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport type CmsIcon = {\n type: string;\n name: string;\n value?: string;\n};\n\nexport interface CmsError {\n message: string;\n code: string;\n data: GenericRecord;\n stack?: string;\n}\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\nexport interface HeadlessCms extends CmsGroupContext, CmsModelContext, CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n\n /**\n * Use to ensure perform authorization and ensure identities have access to the groups, models and entries.\n */\n accessControl: AccessControl;\n\n /**\n * Export operations.\n */\n export: HeadlessCmsExport;\n importing: HeadlessCmsImport;\n getExecutableSchema: GetExecutableSchema;\n}\n\nexport type GetExecutableSchema = (\n type: ApiEndpoint\n) => Promise<\n <TData = Record<string, any>, TExtensions = Record<string, any>>(\n input: GraphQLRequestBody | GraphQLRequestBody[]\n ) => ReturnType<typeof processRequestBody<TData, TExtensions>>\n>;\n\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext extends Context, DbContext, ApiCoreContext {\n cms: HeadlessCms;\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\n/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains `type` property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * A value to be validated.\n */\n value: T[keyof T];\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry<T>;\n}\n\n/**\n * When sending model to the storage operations, it must contain createValueKeyToStorageConverter and createValueKeyFromStorageConverter\n *\n * @category CmsModel\n */\nexport interface StorageOperationsCmsModel<\n T extends CmsEntryValues = CmsEntryValues\n> extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable<T>;\n convertValueKeyFromStorage: CmsModelConverterCallable<T>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n id?: string;\n name: string;\n slug?: string;\n description?: string | null;\n icon?: CmsIcon | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: CmsIcon;\n}\n\n/**\n * A `data.where` parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n };\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n}\n\n/**\n * A content entry values definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\nexport interface ICmsEntryLocation {\n folderId?: string;\n}\n\nexport interface ICmsEntryLive {\n version: number;\n}\n\nexport interface ICmsEntrySystem {\n // to be extended\n}\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n\n /**\n * Revision-level meta fields. 👇\n */\n\n /**\n * An ISO 8601 date/time string.\n */\n revisionCreatedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionSavedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionModifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionDeletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionRestoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionFirstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionLastPublishedOn: string | null;\n\n /**\n * Identity that last ionCreated the entry.\n */\n revisionCreatedBy: CmsIdentity;\n /**\n * Identity that last ionSaved the entry.\n */\n revisionSavedBy: CmsIdentity;\n /**\n * Identity that last ionModified the entry.\n */\n revisionModifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the revision.\n */\n revisionDeletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the revision.\n */\n revisionRestoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n revisionFirstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * An ISO 8601 date/time string.\n */\n createdOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n savedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n modifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n deletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n restoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n firstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n lastPublishedOn: string | null;\n\n /**\n * Identity that last created the entry.\n */\n createdBy: CmsIdentity;\n /**\n * Identity that last saved the entry.\n */\n savedBy: CmsIdentity;\n /**\n * Identity that last modified the entry.\n */\n modifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the entry.\n */\n deletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the entry.\n */\n restoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n firstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped storageId -> value object.\n *\n * @see CmsModelField\n */\n values: TValues;\n /**\n * Advanced Content Organization\n */\n location?: ICmsEntryLocation;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean | null;\n /**\n * This field preserves the original folderId value, as the ROOT_FOLDER is set upon deletion.\n * The value is used when restoring the entry from the trash bin.\n */\n binOriginalFolderId?: string;\n\n system?: ICmsEntrySystem;\n /**\n * Is this CMS Entry live (no matter the revision).\n */\n live: ICmsEntryLive | null;\n /**\n * A revision description.\n */\n revisionDescription: string | undefined;\n /**\n * A timestamp of when the entry should be automatically deleted from the database.\n */\n expiresAt: number | null;\n}\n\nexport interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\nexport interface ICmsModelListParams {\n /**\n * Defaults to true.\n */\n includePrivate?: boolean;\n includePlugins?: boolean;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n *\n * @throws NotFoundError\n */\n getModel(modelId: string): Promise<CmsModel>;\n /**\n * Get model to AST converter.\n */\n getModelToAstConverter: () => CmsModelToAstConverter;\n /**\n * Get all content models.\n */\n listModels(params?: ICmsModelListParams): Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel(data: CmsModelCreateInput): Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom(modelId: string, data: CmsModelCreateFromInput): Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel(modelId: string, data: CmsModelUpdateInput): Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel(modelId: string): Promise<void>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache(): void;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\nexport interface CmsEntryListWhereRef\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"modelId\"> {}\n\nexport interface CmsEntryListWhereValues {\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]:\n | string\n | number\n | boolean\n | Date\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhereValues[]\n | CmsEntryListWhereValues\n | CmsEntryListWhereRef;\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\n\nexport interface CmsEntryListWhere\n extends\n IdMixedInterfaceGenerator<\"id\">,\n IdMixedInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"status\", CmsEntryStatus>,\n /**\n * Revision-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"revisionCreatedBy\">,\n IdentityInterfaceGenerator<\"revisionModifiedBy\">,\n IdentityInterfaceGenerator<\"revisionSavedBy\">,\n IdentityInterfaceGenerator<\"revisionFirstPublishedBy\">,\n IdentityInterfaceGenerator<\"revisionLastPublishedBy\">,\n /**\n * Entry-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"createdBy\">,\n IdentityInterfaceGenerator<\"modifiedBy\">,\n IdentityInterfaceGenerator<\"savedBy\">,\n IdentityInterfaceGenerator<\"firstPublishedBy\">,\n IdentityInterfaceGenerator<\"lastPublishedBy\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n DateStringInterfaceGenerator<\"deletedOn\">,\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n NumericInterfaceGenerator<\"version\">,\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n TruthfulInterfaceGenerator<\"published\">,\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n TruthfulInterfaceGenerator<\"latest\"> {\n /**\n * ACO related parameters.\n */\n wbyAco_location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n\n values?: CmsEntryListWhereValues;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean;\n wbyDeleted_not?: boolean;\n\n /**\n * To allow querying via nested queries, we added the AND / OR properties.\n */\n AND?: CmsEntryListWhere[];\n OR?: CmsEntryListWhere[];\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSortAsc = `${string}_ASC`;\nexport type CmsEntryListSortDesc = `${string}_DESC`;\nexport type CmsEntryListSort = (CmsEntryListSortAsc | CmsEntryListSortDesc)[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n // TODO remove wbyAco_location\n wbyAco_location?: {\n folderId?: string | null;\n };\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues | undefined;\n\n expiresAt?: Date | undefined;\n}\n\nexport interface CreateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date;\n revisionSavedOn?: Date;\n revisionModifiedOn?: Date;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity;\n revisionSavedBy?: CmsIdentity;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date;\n savedOn?: Date;\n modifiedOn?: Date;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues;\n}\n\nexport interface CreateRevisionCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values?: Partial<TValues>;\n\n expiresAt?: Date | number | null | undefined;\n}\n\nexport interface UpdateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface GetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\n/**\n * @category CmsEntry\n */\nexport interface CmsDeleteEntryOptions {\n /**\n * Runs the delete commands even if the entry is not found in the DynamoDB.\n * This is to force clean the entry records that might have been left behind a failed delete.\n */\n force?: boolean;\n /**\n * Destroying the entry directly, without moving it to the bin.\n */\n permanently?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = {\n id: string;\n}[];\n\nexport interface CmsEntryValidateResponse {\n [key: string]: any;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n fieldRegistry: ICmsModelFieldToGraphQLRegistry;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n models?: string[];\n groups?: string[];\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n groups?: string[];\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n models?: string[];\n groups?: string[];\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: any;\n}\n\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<void>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<void>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<StorageCmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<StorageCmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<StorageCmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<StorageCmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry<T>;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: CmsStorageEntry<T>;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: CmsStorageEntry<T> | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsMoveToBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsRestoreFromBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as restored.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsGetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations {\n /**\n * Get all the entries of the ids.\n */\n getByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Gets entry by given params.\n */\n get: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;\n /**\n * Create a new entry.\n */\n create: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Update existing entry.\n */\n update: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Move entry and all its entries into a new folder.\n */\n move: (model: CmsModel, id: string, folderId: string) => Promise<void>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Move the entry to bin.\n */\n moveToBin: (model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams) => Promise<void>;\n /**\n * Restore the entry from the bin.\n */\n restoreFromBin: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsRestoreFromBinParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Delete multiple entries, with a limit on how much can be deleted in one call.\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteEntriesParams\n ) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsPublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Unpublish the entry.\n */\n unpublish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUnpublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Method to list all the unique values for the given field id.\n * Simplest use case would be to aggregate tags for some content.\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\"\n}\n\nexport interface HeadlessCmsStorageOperations<C extends CmsContext = CmsContext> {\n name: string;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit: (context: C) => Promise<void>;\n init?: (context: C) => Promise<void>;\n}\n"],"names":["CONTENT_ENTRY_STATUS"],"mappings":"AA24CO,IAAKA,6BAAoBA,WAAAA,GAAAA,SAApBA,oBAAoB;;;;WAApBA"}
|
|
1
|
+
{"version":3,"file":"types/types.js","sources":["../../src/types/types.ts"],"sourcesContent":["import type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type { GraphQLFieldResolver, GraphQLRequestBody } from \"@webiny/handler-graphql/types.js\";\nimport type { processRequestBody } from \"@webiny/handler-graphql\";\nimport type { DbContext } from \"@webiny/handler-db/types.js\";\nimport type { CmsModelConverterCallable } from \"~/utils/converters/ConverterCollection.js\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"~/export/types.js\";\nimport type { AccessControl } from \"~/crud/AccessControl/AccessControl.js\";\nimport type { CmsModelToAstConverter } from \"~/utils/contentModelAst/CmsModelToAstConverter.js\";\nimport type { ICmsModelFieldToGraphQLRegistry } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type { CmsEntryContext } from \"./context.js\";\nimport type { CmsModelField, CmsModelFieldValidation, CmsModelUpdateInput } from \"./modelField.js\";\nimport type {\n CmsModel,\n CmsModelCreateFromInput,\n CmsModelCreateInput,\n StorageCmsModel\n} from \"./model.js\";\nimport type { CmsGroup } from \"./modelGroup.js\";\nimport type { CmsIdentity } from \"./identity.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator,\n IdMixedInterfaceGenerator,\n NumericInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport type CmsIcon = {\n type: string;\n name: string;\n value?: string;\n};\n\nexport interface CmsError {\n message: string;\n code: string;\n data: GenericRecord;\n stack?: string;\n}\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\n\nexport interface HeadlessCms extends CmsGroupContext, CmsModelContext, CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n\n /**\n * Use to ensure perform authorization and ensure identities have access to the groups, models and entries.\n */\n accessControl: AccessControl;\n\n /**\n * Export operations.\n */\n export: HeadlessCmsExport;\n importing: HeadlessCmsImport;\n getExecutableSchema: GetExecutableSchema;\n}\n\nexport type GetExecutableSchema = (\n type: ApiEndpoint\n) => Promise<\n <TData = Record<string, any>, TExtensions = Record<string, any>>(\n input: GraphQLRequestBody | GraphQLRequestBody[]\n ) => ReturnType<typeof processRequestBody<TData, TExtensions>>\n>;\n\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext extends Context, DbContext, ApiCoreContext {\n cms: HeadlessCms;\n}\n\n/**\n * Used for our internal functionality.\n */\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\n/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains `type` property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * A value to be validated.\n */\n value: T[keyof T];\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry<T>;\n}\n\n/**\n * When sending model to the storage operations, it must contain createValueKeyToStorageConverter and createValueKeyFromStorageConverter\n *\n * @category CmsModel\n */\nexport interface StorageOperationsCmsModel<\n T extends CmsEntryValues = CmsEntryValues\n> extends CmsModel {\n convertValueKeyToStorage: CmsModelConverterCallable<T>;\n convertValueKeyFromStorage: CmsModelConverterCallable<T>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\n/**\n * A GraphQL `params.data` parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n id?: string;\n name: string;\n slug?: string;\n description?: string | null;\n icon?: CmsIcon | null;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: CmsIcon;\n}\n\n/**\n * A `data.where` parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n };\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n}\n\n/**\n * A content entry values definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\nexport interface ICmsEntryLocation {\n folderId?: string;\n}\n\nexport interface ICmsEntryLive {\n version: number;\n}\n\nexport interface ICmsEntrySystem {\n // to be extended\n}\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n\n /**\n * Revision-level meta fields. 👇\n */\n\n /**\n * An ISO 8601 date/time string.\n */\n revisionCreatedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionSavedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n revisionModifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionDeletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionRestoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionFirstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n revisionLastPublishedOn: string | null;\n\n /**\n * Identity that last ionCreated the entry.\n */\n revisionCreatedBy: CmsIdentity;\n /**\n * Identity that last ionSaved the entry.\n */\n revisionSavedBy: CmsIdentity;\n /**\n * Identity that last ionModified the entry.\n */\n revisionModifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the revision.\n */\n revisionDeletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the revision.\n */\n revisionRestoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n revisionFirstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n revisionLastPublishedBy: CmsIdentity | null;\n\n /**\n * An ISO 8601 date/time string.\n */\n createdOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n savedOn: string;\n /**\n * An ISO 8601 date/time string.\n */\n modifiedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n deletedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n restoredOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n firstPublishedOn: string | null;\n /**\n * An ISO 8601 date/time string.\n */\n lastPublishedOn: string | null;\n\n /**\n * Identity that last created the entry.\n */\n createdBy: CmsIdentity;\n /**\n * Identity that last saved the entry.\n */\n savedBy: CmsIdentity;\n /**\n * Identity that last modified the entry.\n */\n modifiedBy: CmsIdentity | null;\n /**\n * Identity that last deleted the entry.\n */\n deletedBy: CmsIdentity | null;\n /**\n * Identity that last restored the entry.\n */\n restoredBy: CmsIdentity | null;\n /**\n * Identity that first published the entry.\n */\n firstPublishedBy: CmsIdentity | null;\n /**\n * Identity that last published the entry.\n */\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped storageId -> value object.\n *\n * @see CmsModelField\n */\n values: TValues;\n /**\n * Advanced Content Organization\n */\n location?: ICmsEntryLocation;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean | null;\n /**\n * This field preserves the original folderId value, as the ROOT_FOLDER is set upon deletion.\n * The value is used when restoring the entry from the trash bin.\n */\n binOriginalFolderId?: string;\n\n system?: ICmsEntrySystem;\n /**\n * Is this CMS Entry live (no matter the revision).\n */\n live: ICmsEntryLive | null;\n /**\n * A revision description.\n */\n revisionDescription: string | undefined;\n /**\n * A timestamp of when the entry should be automatically deleted from the database.\n */\n expiresAt: number | null;\n}\n\nexport interface CmsStorageEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n [key: string]: any;\n}\n\nexport interface CmsEntryUniqueValue {\n value: string;\n count: number;\n}\n\nexport interface ICmsModelListParams {\n /**\n * Defaults to true.\n */\n includePrivate?: boolean;\n includePlugins?: boolean;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n *\n * @throws NotFoundError\n */\n getModel(modelId: string): Promise<CmsModel>;\n /**\n * Get model to AST converter.\n */\n getModelToAstConverter: () => CmsModelToAstConverter;\n /**\n * Get all content models.\n */\n listModels(params?: ICmsModelListParams): Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel(data: CmsModelCreateInput): Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom(modelId: string, data: CmsModelCreateFromInput): Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel(modelId: string, data: CmsModelUpdateInput): Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel(modelId: string): Promise<void>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache(): void;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\nexport interface CmsEntryListWhereRef\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"modelId\"> {}\n\nexport interface CmsEntryListWhereValues {\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]:\n | string\n | number\n | boolean\n | Date\n | undefined\n | string[]\n | number[]\n | null\n | CmsEntryListWhereValues[]\n | CmsEntryListWhereValues\n | CmsEntryListWhereRef;\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\n\nexport interface CmsEntryListWhere\n extends\n IdMixedInterfaceGenerator<\"id\">,\n IdMixedInterfaceGenerator<\"entryId\">,\n IdInterfaceGenerator<\"status\", CmsEntryStatus>,\n /**\n * Revision-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"revisionCreatedBy\">,\n IdentityInterfaceGenerator<\"revisionModifiedBy\">,\n IdentityInterfaceGenerator<\"revisionSavedBy\">,\n IdentityInterfaceGenerator<\"revisionFirstPublishedBy\">,\n IdentityInterfaceGenerator<\"revisionLastPublishedBy\">,\n /**\n * Entry-level meta fields. 👇\n */\n IdentityInterfaceGenerator<\"createdBy\">,\n IdentityInterfaceGenerator<\"modifiedBy\">,\n IdentityInterfaceGenerator<\"savedBy\">,\n IdentityInterfaceGenerator<\"firstPublishedBy\">,\n IdentityInterfaceGenerator<\"lastPublishedBy\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n DateStringInterfaceGenerator<\"deletedOn\">,\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n NumericInterfaceGenerator<\"version\">,\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n TruthfulInterfaceGenerator<\"published\">,\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n TruthfulInterfaceGenerator<\"latest\"> {\n /**\n * ACO related parameters.\n */\n wbyAco_location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n location?: {\n folderId?: string;\n folderId_not?: string;\n folderId_in?: string[];\n folderId_not_in?: string[];\n };\n\n values?: CmsEntryListWhereValues;\n /**\n * Is the entry in the bin?\n */\n wbyDeleted?: boolean;\n wbyDeleted_not?: boolean;\n\n /**\n * To allow querying via nested queries, we added the AND / OR properties.\n */\n AND?: CmsEntryListWhere[];\n OR?: CmsEntryListWhere[];\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSortAsc = `${string}_ASC`;\nexport type CmsEntryListSortDesc = `${string}_DESC`;\nexport type CmsEntryListSort = (CmsEntryListSortAsc | CmsEntryListSortDesc)[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n // TODO remove wbyAco_location\n wbyAco_location?: {\n folderId?: string | null;\n };\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues | undefined;\n\n expiresAt?: Date | undefined;\n}\n\nexport interface CreateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date;\n revisionSavedOn?: Date;\n revisionModifiedOn?: Date;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity;\n revisionSavedBy?: CmsIdentity;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date;\n savedOn?: Date;\n modifiedOn?: Date;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n system?: Partial<ICmsEntrySystem>;\n\n values: TValues;\n}\n\nexport interface CreateRevisionCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n\n location?: {\n folderId?: string | null;\n };\n\n system?: Partial<ICmsEntrySystem>;\n\n values?: Partial<TValues>;\n\n expiresAt?: Date | number | null | undefined;\n}\n\nexport interface UpdateCmsEntryOptionsInput {\n skipValidators?: string[];\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface GetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\n/**\n * @category CmsEntry\n */\nexport interface CmsDeleteEntryOptions {\n /**\n * Runs the delete commands even if the entry is not found in the DynamoDB.\n * This is to force clean the entry records that might have been left behind a failed delete.\n */\n force?: boolean;\n /**\n * Destroying the entry directly, without moving it to the bin.\n */\n permanently?: boolean;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface DeleteMultipleEntriesParams {\n entries: string[];\n}\n\nexport type DeleteMultipleEntriesResponse = {\n id: string;\n}[];\n\nexport interface CmsEntryValidateResponse {\n [key: string]: any;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n fieldRegistry: ICmsModelFieldToGraphQLRegistry;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string;\n}\n\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n models?: string[];\n groups?: string[];\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n groups?: string[];\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n models?: string[];\n groups?: string[];\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: any;\n}\n\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<void>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<void>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: StorageCmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<StorageCmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<StorageCmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<StorageCmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<StorageCmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<void>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry<T>;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry<T>;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: CmsStorageEntry<T>;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: CmsStorageEntry<T> | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsMoveToBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsRestoreFromBinParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as restored.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsDeleteEntriesParams {\n entries: string[];\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<T extends CmsEntryValues = CmsEntryValues> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsEntryValues = CmsEntryValues\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry<T>;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface CmsEntryStorageOperationsGetUniqueFieldValuesParams {\n where: CmsEntryListWhere;\n fieldId: string;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations {\n /**\n * Get all the entries of the ids.\n */\n getByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<CmsEntry<T>[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * Gets entry by given params.\n */\n get: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => Promise<CmsEntry<T> | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;\n /**\n * Create a new entry.\n */\n create: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Update existing entry.\n */\n update: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Move entry and all its entries into a new folder.\n */\n move: (model: CmsModel, id: string, folderId: string) => Promise<void>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Move the entry to bin.\n */\n moveToBin: (model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams) => Promise<void>;\n /**\n * Restore the entry from the bin.\n */\n restoreFromBin: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsRestoreFromBinParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Delete multiple entries, with a limit on how much can be deleted in one call.\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteEntriesParams\n ) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsPublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Unpublish the entry.\n */\n unpublish: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUnpublishParams<T>\n ) => Promise<CmsEntry<T>>;\n /**\n * Method to list all the unique values for the given field id.\n * Simplest use case would be to aggregate tags for some content.\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\"\n}\n\nexport interface HeadlessCmsStorageOperations<C extends CmsContext = CmsContext> {\n name: string;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit: (context: C) => Promise<void>;\n init?: (context: C) => Promise<void>;\n}\n"],"names":["CONTENT_ENTRY_STATUS"],"mappings":"AA24CO,IAAKA,6BAAoBA,WAAAA,GAAAA,SAAAA,oBAAAA"}
|