@webiny/api-headless-cms 6.0.0-rc.1 → 6.0.0-rc.3
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/constants.d.ts +2 -1
- package/constants.js +4 -0
- package/constants.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createEntryData.js +4 -3
- package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +4 -3
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +4 -1
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +4 -1
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +2 -1
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +4 -3
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/system.d.ts +10 -0
- package/crud/contentEntry/entryDataFactories/system.js +14 -0
- package/crud/contentEntry/entryDataFactories/system.js.map +1 -0
- package/crud/contentModel/validation.d.ts +9 -9
- package/crud/contentModel/validation.js +3 -3
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentModel/errors.d.ts +1 -1
- package/domain/contentModel/errors.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +126 -8
- package/domain/contentModel/schemas.js +12 -13
- package/domain/contentModel/schemas.js.map +1 -1
- package/export/graphql/index.js +1 -1
- package/export/graphql/index.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js +4 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +12 -3
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -2
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js +4 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/modelBuilder/feature.js +2 -2
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +36 -0
- package/features/modelBuilder/fields/BaseFieldBuilder.js +41 -0
- package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -0
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +228 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js +219 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -0
- package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +2 -2
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +6 -3
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/FieldBuilder.d.ts +5 -228
- package/features/modelBuilder/fields/FieldBuilder.js +3 -231
- package/features/modelBuilder/fields/FieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/LayoutFieldBuilder.d.ts +7 -0
- package/features/modelBuilder/fields/LayoutFieldBuilder.js +9 -0
- package/features/modelBuilder/fields/LayoutFieldBuilder.js.map +1 -0
- package/features/modelBuilder/fields/ObjectFieldType.d.ts +4 -3
- package/features/modelBuilder/fields/ObjectFieldType.js +19 -4
- package/features/modelBuilder/fields/ObjectFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiAlertFieldType.d.ts +8 -4
- package/features/modelBuilder/fields/UiAlertFieldType.js +23 -6
- package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiSeparatorFieldType.d.ts +6 -4
- package/features/modelBuilder/fields/UiSeparatorFieldType.js +18 -4
- package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
- package/features/modelBuilder/fields/UiTabsFieldType.d.ts +28 -0
- package/features/modelBuilder/fields/UiTabsFieldType.js +75 -0
- package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -0
- package/features/modelBuilder/fields/abstractions.d.ts +2 -2
- package/features/modelBuilder/fields/abstractions.js.map +1 -1
- package/features/modelBuilder/index.d.ts +2 -0
- package/features/modelBuilder/index.js +2 -0
- package/features/modelBuilder/index.js.map +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +8 -3
- package/features/modelBuilder/models/BaseModelBuilder.js +19 -0
- package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js +4 -2
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PublicModelBuilder.js +16 -11
- package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
- package/graphql/schema/baseSchema.js +17 -15
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/helpers/index.d.ts +1 -0
- package/graphql/schema/cms/helpers/index.js +1 -0
- package/graphql/schema/cms/helpers/index.js.map +1 -1
- package/graphql/schema/cms/helpers/transformWhereToNested.d.ts +17 -0
- package/graphql/schema/cms/helpers/transformWhereToNested.js +54 -0
- package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -0
- package/graphql/schema/cms/helpers.d.ts +1 -0
- package/graphql/schema/cms/helpers.js +1 -0
- package/graphql/schema/cms/helpers.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +6 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/contentModels.js +21 -3
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createManageSDL.js +4 -2
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphqlFields/index.js +1 -2
- package/graphqlFields/index.js.map +1 -1
- package/package.json +22 -22
- package/plugins/CmsModelPlugin.js +19 -4
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/types/fields/objectField.d.ts +2 -0
- package/types/fields/objectField.js.map +1 -1
- package/types/model.d.ts +32 -3
- package/types/model.js.map +1 -1
- package/types/modelField.d.ts +19 -3
- package/types/modelField.js.map +1 -1
- package/types/types.d.ts +12 -9
- package/types/types.js.map +1 -1
- package/utils/createModelField.js +4 -2
- package/utils/createModelField.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/state.d.ts +0 -10
- package/crud/contentEntry/entryDataFactories/state.js +0 -16
- package/crud/contentEntry/entryDataFactories/state.js.map +0 -1
- package/features/modelBuilder/fields/UiFieldType.d.ts +0 -18
- package/features/modelBuilder/fields/UiFieldType.js +0 -25
- package/features/modelBuilder/fields/UiFieldType.js.map +0 -1
- package/graphqlFields/ui.d.ts +0 -2
- package/graphqlFields/ui.js +0 -32
- package/graphqlFields/ui.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createCmsGraphQLSchemaPlugin","GraphQLSchemaPlugin","ContextPlugin","camelCase","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","typeDefs","resolvers","corePlugin","schema","createBaseSchema","plugin","context","register"],"sources":["baseSchema.ts"],"sourcesContent":["import type { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n # permanently delete an entry without moving it to the bin\n permanently: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n\n # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\n error: CmsError\n }\n\n
|
|
1
|
+
{"version":3,"names":["createCmsGraphQLSchemaPlugin","GraphQLSchemaPlugin","ContextPlugin","camelCase","createSkipValidatorEnum","plugins","validators","byType","reduce","collection","validator","name","includes","push","length","join","createSchema","skipValidatorEnum","cmsPlugin","typeDefs","resolvers","corePlugin","schema","createBaseSchema","plugin","context","register"],"sources":["baseSchema.ts"],"sourcesContent":["import type { CmsContext, CmsModelFieldValidatorPlugin } from \"~/types/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst createSkipValidatorEnum = (plugins: PluginsContainer) => {\n const validators = plugins\n .byType<CmsModelFieldValidatorPlugin>(\"cms-model-field-validator\")\n .reduce<string[]>((collection, validator) => {\n const name = camelCase(validator.validator.name);\n if (collection.includes(name)) {\n return collection;\n }\n collection.push(name);\n return collection;\n }, []);\n\n if (validators.length === 0) {\n validators.push(\"_empty\");\n }\n return /* GraphQL */ `\n enum SkipValidatorEnum {\n ${validators.join(\"\\n\")}\n }\n `;\n};\n\nconst createSchema = (plugins: PluginsContainer): IGraphQLSchemaPlugin<CmsContext>[] => {\n const skipValidatorEnum = createSkipValidatorEnum(plugins);\n\n const cmsPlugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n # permanently delete an entry without moving it to the bin\n permanently: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n\n # Advanced Content Organization\n type WbyAcoLocation {\n folderId: ID\n }\n\n input WbyAcoLocationInput {\n folderId: ID!\n }\n\n input WbyAcoLocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n\n ${skipValidatorEnum}\n\n input CreateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CreateRevisionCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input UpdateCmsEntryOptionsInput {\n skipValidators: [SkipValidatorEnum!]\n }\n\n input CmsIdentityInput {\n id: String!\n displayName: String!\n type: String!\n }\n\n type CmsEntryValidationResponseData {\n error: String!\n id: String!\n fieldId: String!\n parents: [String!]!\n }\n\n type CmsEntryValidationResponse {\n data: [CmsEntryValidationResponseData!]\n error: CmsError\n }\n\n type CmsEntrySystem {\n _empty: String\n }\n\n type CmsEntryLive {\n version: Int!\n }\n\n input CmsEntryLiveWhereInput {\n version: Int\n version_gt: Int\n version_gte: Int\n version_lt: Int\n version_lte: Int\n version_not: Int\n version_in: [Int!]\n version_not_in: [Int!]\n }\n\n input ListWhereInputCmsEntrySystem {\n _empty: String\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n\nexport const createBaseSchema = () => {\n const plugin = new ContextPlugin(async context => {\n context.plugins.register(...createSchema(context.plugins));\n });\n\n plugin.name = \"headless-cms.graphql.createBaseSchema\";\n\n return plugin;\n};\n"],"mappings":"AACA,SAASA,4BAA4B;AAErC,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,SAASC,aAAa,QAAQ,aAAa;AAC3C,OAAOC,SAAS,MAAM,qBAAqB;AAE3C,MAAMC,uBAAuB,GAAIC,OAAyB,IAAK;EAC3D,MAAMC,UAAU,GAAGD,OAAO,CACrBE,MAAM,CAA+B,2BAA2B,CAAC,CACjEC,MAAM,CAAW,CAACC,UAAU,EAAEC,SAAS,KAAK;IACzC,MAAMC,IAAI,GAAGR,SAAS,CAACO,SAAS,CAACA,SAAS,CAACC,IAAI,CAAC;IAChD,IAAIF,UAAU,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;MAC3B,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACI,IAAI,CAACF,IAAI,CAAC;IACrB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;EAEV,IAAIH,UAAU,CAACQ,MAAM,KAAK,CAAC,EAAE;IACzBR,UAAU,CAACO,IAAI,CAAC,QAAQ,CAAC;EAC7B;EACA,OAAO,aAAc;AACzB;AACA,aAAaP,UAAU,CAACS,IAAI,CAAC,IAAI,CAAC;AAClC;AACA,KAAK;AACL,CAAC;AAED,MAAMC,YAAY,GAAIX,OAAyB,IAAyC;EACpF,MAAMY,iBAAiB,GAAGb,uBAAuB,CAACC,OAAO,CAAC;EAE1D,MAAMa,SAAS,GAAGlB,4BAA4B,CAAC;IAC3CmB,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcF,iBAAiB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDG,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFF,SAAS,CAACP,IAAI,GAAG,kCAAkC;EACnD,MAAMU,UAAU,GAAG,IAAIpB,mBAAmB,CAAa;IACnDkB,QAAQ,EAAED,SAAS,CAACI,MAAM,CAACH,QAAQ;IACnCC,SAAS,EAAEF,SAAS,CAACI,MAAM,CAACF;EAChC,CAAC,CAAC;EACFC,UAAU,CAACV,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACO,SAAS,EAAEG,UAAU,CAAC;AAClC,CAAC;AAED,OAAO,MAAME,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,MAAM,GAAG,IAAItB,aAAa,CAAC,MAAMuB,OAAO,IAAI;IAC9CA,OAAO,CAACpB,OAAO,CAACqB,QAAQ,CAAC,GAAGV,YAAY,CAACS,OAAO,CAACpB,OAAO,CAAC,CAAC;EAC9D,CAAC,CAAC;EAEFmB,MAAM,CAACb,IAAI,GAAG,uCAAuC;EAErD,OAAOa,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -2,3 +2,4 @@ export { getErrorMessage } from "./getErrorMessage.js";
|
|
|
2
2
|
export { getModel } from "./getModel.js";
|
|
3
3
|
export { transformSortToArray } from "./transformSortToArray.js";
|
|
4
4
|
export { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
5
|
+
export { transformWhereToNested } from "./transformWhereToNested.js";
|
|
@@ -2,5 +2,6 @@ export { getErrorMessage } from "./getErrorMessage.js";
|
|
|
2
2
|
export { getModel } from "./getModel.js";
|
|
3
3
|
export { transformSortToArray } from "./transformSortToArray.js";
|
|
4
4
|
export { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
5
|
+
export { transformWhereToNested } from "./transformWhereToNested.js";
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getErrorMessage","getModel","transformSortToArray","buildFieldsSelection"],"sources":["index.ts"],"sourcesContent":["export { getErrorMessage } from \"./getErrorMessage.js\";\nexport { getModel } from \"./getModel.js\";\nexport { transformSortToArray } from \"./transformSortToArray.js\";\nexport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\n"],"mappings":"AAAA,SAASA,eAAe;AACxB,SAASC,QAAQ;AACjB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getErrorMessage","getModel","transformSortToArray","buildFieldsSelection","transformWhereToNested"],"sources":["index.ts"],"sourcesContent":["export { getErrorMessage } from \"./getErrorMessage.js\";\nexport { getModel } from \"./getModel.js\";\nexport { transformSortToArray } from \"./transformSortToArray.js\";\nexport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\nexport { transformWhereToNested } from \"./transformWhereToNested.js\";\n"],"mappings":"AAAA,SAASA,eAAe;AACxB,SAASC,QAAQ;AACjB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a flat where object with dot-notation keys into a nested object.
|
|
3
|
+
* Keys without dots are passed through unchanged.
|
|
4
|
+
* Handles logical operators (AND, OR) recursively.
|
|
5
|
+
*
|
|
6
|
+
* @param where - Where clause object potentially containing dot-notation keys
|
|
7
|
+
* @returns Nested where object compatible with the GraphQL ListWhereInput type
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* transformWhereToNested({ "values.name": "Keyboard", id: "abc" })
|
|
11
|
+
* // Returns: { values: { name: "Keyboard" }, id: "abc" }
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* transformWhereToNested({ "values.price_gt": 100, "values.name_contains": "board" })
|
|
15
|
+
* // Returns: { values: { price_gt: 100, name_contains: "board" } }
|
|
16
|
+
*/
|
|
17
|
+
export declare const transformWhereToNested: (where?: Record<string, unknown>) => Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a flat where object with dot-notation keys into a nested object.
|
|
3
|
+
* Keys without dots are passed through unchanged.
|
|
4
|
+
* Handles logical operators (AND, OR) recursively.
|
|
5
|
+
*
|
|
6
|
+
* @param where - Where clause object potentially containing dot-notation keys
|
|
7
|
+
* @returns Nested where object compatible with the GraphQL ListWhereInput type
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* transformWhereToNested({ "values.name": "Keyboard", id: "abc" })
|
|
11
|
+
* // Returns: { values: { name: "Keyboard" }, id: "abc" }
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* transformWhereToNested({ "values.price_gt": 100, "values.name_contains": "board" })
|
|
15
|
+
* // Returns: { values: { price_gt: 100, name_contains: "board" } }
|
|
16
|
+
*/
|
|
17
|
+
export const transformWhereToNested = where => {
|
|
18
|
+
if (!where) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const [key, value] of Object.entries(where)) {
|
|
23
|
+
// Handle logical operators recursively.
|
|
24
|
+
if (key === "AND" || key === "OR") {
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
result[key] = value.map(item => transformWhereToNested(item));
|
|
27
|
+
} else {
|
|
28
|
+
result[key] = value;
|
|
29
|
+
}
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const dotIndex = key.indexOf(".");
|
|
33
|
+
if (dotIndex === -1) {
|
|
34
|
+
// No dot — pass through unchanged.
|
|
35
|
+
result[key] = value;
|
|
36
|
+
} else {
|
|
37
|
+
// Dot-notation key — expand into nested object.
|
|
38
|
+
const head = key.slice(0, dotIndex);
|
|
39
|
+
const tail = key.slice(dotIndex + 1);
|
|
40
|
+
if (result[head] === undefined) {
|
|
41
|
+
result[head] = {};
|
|
42
|
+
}
|
|
43
|
+
const nested = result[head];
|
|
44
|
+
// Recursively expand in case of multiple levels of nesting.
|
|
45
|
+
const expanded = transformWhereToNested({
|
|
46
|
+
[tail]: value
|
|
47
|
+
});
|
|
48
|
+
Object.assign(nested, expanded);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=transformWhereToNested.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformWhereToNested","where","undefined","result","key","value","Object","entries","Array","isArray","map","item","dotIndex","indexOf","head","slice","tail","nested","expanded","assign"],"sources":["transformWhereToNested.ts"],"sourcesContent":["/**\n * Transforms a flat where object with dot-notation keys into a nested object.\n * Keys without dots are passed through unchanged.\n * Handles logical operators (AND, OR) recursively.\n *\n * @param where - Where clause object potentially containing dot-notation keys\n * @returns Nested where object compatible with the GraphQL ListWhereInput type\n *\n * @example\n * transformWhereToNested({ \"values.name\": \"Keyboard\", id: \"abc\" })\n * // Returns: { values: { name: \"Keyboard\" }, id: \"abc\" }\n *\n * @example\n * transformWhereToNested({ \"values.price_gt\": 100, \"values.name_contains\": \"board\" })\n * // Returns: { values: { price_gt: 100, name_contains: \"board\" } }\n */\nexport const transformWhereToNested = (\n where?: Record<string, unknown>\n): Record<string, unknown> | undefined => {\n if (!where) {\n return undefined;\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(where)) {\n // Handle logical operators recursively.\n if (key === \"AND\" || key === \"OR\") {\n if (Array.isArray(value)) {\n result[key] = value.map(item =>\n transformWhereToNested(item as Record<string, unknown>)\n );\n } else {\n result[key] = value;\n }\n continue;\n }\n\n const dotIndex = key.indexOf(\".\");\n if (dotIndex === -1) {\n // No dot — pass through unchanged.\n result[key] = value;\n } else {\n // Dot-notation key — expand into nested object.\n const head = key.slice(0, dotIndex);\n const tail = key.slice(dotIndex + 1);\n\n if (result[head] === undefined) {\n result[head] = {};\n }\n\n const nested = result[head] as Record<string, unknown>;\n // Recursively expand in case of multiple levels of nesting.\n const expanded = transformWhereToNested({ [tail]: value }) as Record<string, unknown>;\n Object.assign(nested, expanded);\n }\n }\n\n return result;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,sBAAsB,GAC/BC,KAA+B,IACO;EACtC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOC,SAAS;EACpB;EAEA,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,KAAK,CAAC,EAAE;IAC9C;IACA,IAAIG,GAAG,KAAK,KAAK,IAAIA,GAAG,KAAK,IAAI,EAAE;MAC/B,IAAII,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;QACtBF,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK,CAACK,GAAG,CAACC,IAAI,IACxBX,sBAAsB,CAACW,IAA+B,CAC1D,CAAC;MACL,CAAC,MAAM;QACHR,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;MACvB;MACA;IACJ;IAEA,MAAMO,QAAQ,GAAGR,GAAG,CAACS,OAAO,CAAC,GAAG,CAAC;IACjC,IAAID,QAAQ,KAAK,CAAC,CAAC,EAAE;MACjB;MACAT,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;IACvB,CAAC,MAAM;MACH;MACA,MAAMS,IAAI,GAAGV,GAAG,CAACW,KAAK,CAAC,CAAC,EAAEH,QAAQ,CAAC;MACnC,MAAMI,IAAI,GAAGZ,GAAG,CAACW,KAAK,CAACH,QAAQ,GAAG,CAAC,CAAC;MAEpC,IAAIT,MAAM,CAACW,IAAI,CAAC,KAAKZ,SAAS,EAAE;QAC5BC,MAAM,CAACW,IAAI,CAAC,GAAG,CAAC,CAAC;MACrB;MAEA,MAAMG,MAAM,GAAGd,MAAM,CAACW,IAAI,CAA4B;MACtD;MACA,MAAMI,QAAQ,GAAGlB,sBAAsB,CAAC;QAAE,CAACgB,IAAI,GAAGX;MAAM,CAAC,CAA4B;MACrFC,MAAM,CAACa,MAAM,CAACF,MAAM,EAAEC,QAAQ,CAAC;IACnC;EACJ;EAEA,OAAOf,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -2,3 +2,4 @@ export { getErrorMessage } from "./helpers/getErrorMessage.js";
|
|
|
2
2
|
export { getModel } from "./helpers/getModel.js";
|
|
3
3
|
export { transformSortToArray } from "./helpers/transformSortToArray.js";
|
|
4
4
|
export { buildFieldsSelection } from "./helpers/buildFieldsSelection.js";
|
|
5
|
+
export { transformWhereToNested } from "./helpers/transformWhereToNested.js";
|
|
@@ -2,5 +2,6 @@ export { getErrorMessage } from "./helpers/getErrorMessage.js";
|
|
|
2
2
|
export { getModel } from "./helpers/getModel.js";
|
|
3
3
|
export { transformSortToArray } from "./helpers/transformSortToArray.js";
|
|
4
4
|
export { buildFieldsSelection } from "./helpers/buildFieldsSelection.js";
|
|
5
|
+
export { transformWhereToNested } from "./helpers/transformWhereToNested.js";
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getErrorMessage","getModel","transformSortToArray","buildFieldsSelection"],"sources":["helpers.ts"],"sourcesContent":["export { getErrorMessage } from \"./helpers/getErrorMessage.js\";\nexport { getModel } from \"./helpers/getModel.js\";\nexport { transformSortToArray } from \"./helpers/transformSortToArray.js\";\nexport { buildFieldsSelection } from \"./helpers/buildFieldsSelection.js\";\n"],"mappings":"AAAA,SAASA,eAAe;AACxB,SAASC,QAAQ;AACjB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getErrorMessage","getModel","transformSortToArray","buildFieldsSelection","transformWhereToNested"],"sources":["helpers.ts"],"sourcesContent":["export { getErrorMessage } from \"./helpers/getErrorMessage.js\";\nexport { getModel } from \"./helpers/getModel.js\";\nexport { transformSortToArray } from \"./helpers/transformSortToArray.js\";\nexport { buildFieldsSelection } from \"./helpers/buildFieldsSelection.js\";\nexport { transformWhereToNested } from \"./helpers/transformWhereToNested.js\";\n"],"mappings":"AAAA,SAASA,eAAe;AACxB,SAASC,QAAQ;AACjB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModel, getErrorMessage, buildFieldsSelection, transformSortToArray } from "./helpers.js";
|
|
1
|
+
import { getModel, getErrorMessage, buildFieldsSelection, transformSortToArray, transformWhereToNested } from "./helpers.js";
|
|
2
2
|
export const createListEntriesResolver = () => {
|
|
3
3
|
return async ({
|
|
4
4
|
args,
|
|
@@ -25,6 +25,10 @@ export const createListEntriesResolver = () => {
|
|
|
25
25
|
// Transform sort to array format expected by the underlying GraphQL schema.
|
|
26
26
|
// Handles both object format {createdOn: "desc"} and array format ["createdOn_DESC"].
|
|
27
27
|
const transformedSort = transformSortToArray(sort);
|
|
28
|
+
|
|
29
|
+
// Transform dot-notation where keys (e.g. "values.name") into nested objects
|
|
30
|
+
// (e.g. { values: { name: ... } }) so they match the typed ListWhereInput.
|
|
31
|
+
const transformedWhere = transformWhereToNested(where);
|
|
28
32
|
const query = /* GraphQL */`
|
|
29
33
|
query List${model.pluralApiName}(
|
|
30
34
|
$where: ${model.singularApiName}ListWhereInput
|
|
@@ -57,7 +61,7 @@ export const createListEntriesResolver = () => {
|
|
|
57
61
|
const result = await executeSchema({
|
|
58
62
|
query,
|
|
59
63
|
variables: {
|
|
60
|
-
where,
|
|
64
|
+
where: transformedWhere,
|
|
61
65
|
sort: transformedSort,
|
|
62
66
|
limit,
|
|
63
67
|
after
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","transformSortToArray","createListEntriesResolver","args","context","modelId","where","sort","limit","after","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","transformedSort","query","pluralApiName","singularApiName","result","variables","operationName","data","meta","cursor","hasMoreItems","totalCount","error","message","code"],"sources":["listEntriesResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport {\n getModel,\n getErrorMessage,\n buildFieldsSelection,\n transformSortToArray\n} from \"./helpers.js\";\n\nexport interface ListEntriesArgs {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, unknown> | string[];\n limit?: number;\n after?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createListEntriesResolver = () => {\n return async ({ args, context }: { args: ListEntriesArgs; context: CmsContext }) => {\n const { modelId, where, sort, limit, after, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n // Transform sort to array format expected by the underlying GraphQL schema.\n // Handles both object format {createdOn: \"desc\"} and array format [\"createdOn_DESC\"].\n const transformedSort = transformSortToArray(sort);\n\n const query = /* GraphQL */ `\n query List${model.pluralApiName}(\n $where: ${model.singularApiName}ListWhereInput\n $sort: [${model.singularApiName}ListSorter!]\n $limit: Int\n $after: String\n ) {\n list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n ${fieldsSelection}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where, sort: transformedSort, limit, after }\n })) as ExecutionResult;\n\n const operationName = `list${model.pluralApiName}`;\n return (\n result.data?.[operationName] || {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: null\n }\n );\n } catch (error) {\n return {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: {\n message: getErrorMessage(error, \"Failed to list entries\"),\n code: \"LIST_ENTRIES_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SACIA,QAAQ,EACRC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB;
|
|
1
|
+
{"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","transformSortToArray","transformWhereToNested","createListEntriesResolver","args","context","modelId","where","sort","limit","after","fields","preview","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","transformedSort","transformedWhere","query","pluralApiName","singularApiName","result","variables","operationName","data","meta","cursor","hasMoreItems","totalCount","error","message","code"],"sources":["listEntriesResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport {\n getModel,\n getErrorMessage,\n buildFieldsSelection,\n transformSortToArray,\n transformWhereToNested\n} from \"./helpers.js\";\n\nexport interface ListEntriesArgs {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, unknown> | string[];\n limit?: number;\n after?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport const createListEntriesResolver = () => {\n return async ({ args, context }: { args: ListEntriesArgs; context: CmsContext }) => {\n const { modelId, where, sort, limit, after, fields, preview = false } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Determine which API to use based on the preview flag.\n // preview=true -> preview API, preview=false -> read API\n const apiType: ApiEndpoint = preview ? \"preview\" : \"read\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n // Transform sort to array format expected by the underlying GraphQL schema.\n // Handles both object format {createdOn: \"desc\"} and array format [\"createdOn_DESC\"].\n const transformedSort = transformSortToArray(sort);\n\n // Transform dot-notation where keys (e.g. \"values.name\") into nested objects\n // (e.g. { values: { name: ... } }) so they match the typed ListWhereInput.\n const transformedWhere = transformWhereToNested(where);\n\n const query = /* GraphQL */ `\n query List${model.pluralApiName}(\n $where: ${model.singularApiName}ListWhereInput\n $sort: [${model.singularApiName}ListSorter!]\n $limit: Int\n $after: String\n ) {\n list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n ${fieldsSelection}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { where: transformedWhere, sort: transformedSort, limit, after }\n })) as ExecutionResult;\n\n const operationName = `list${model.pluralApiName}`;\n return (\n result.data?.[operationName] || {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: null\n }\n );\n } catch (error) {\n return {\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 },\n error: {\n message: getErrorMessage(error, \"Failed to list entries\"),\n code: \"LIST_ENTRIES_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SACIA,QAAQ,EACRC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB,EACpBC,sBAAsB;AAa1B,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,OAAO;MAAEC,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AEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;MACX,CAAC;IAET,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHL,IAAI,EAAE,EAAE;QACRC,IAAI,EAAE;UAAEC,MAAM,EAAE,IAAI;UAAEC,YAAY,EAAE,KAAK;UAAEC,UAAU,EAAE;QAAE,CAAC;QAC1DC,KAAK,EAAE;UACHC,OAAO,EAAElC,eAAe,CAACiC,KAAK,EAAE,wBAAwB,CAAC;UACzDE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -121,6 +121,14 @@ export const createModelsSchema = ({
|
|
|
121
121
|
settings: JSON
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
input CmsFieldRuleInput {
|
|
125
|
+
type: String!
|
|
126
|
+
target: String!
|
|
127
|
+
operator: String!
|
|
128
|
+
value: JSON
|
|
129
|
+
action: String!
|
|
130
|
+
}
|
|
131
|
+
|
|
124
132
|
input CmsContentModelFieldInput {
|
|
125
133
|
id: ID!
|
|
126
134
|
label: String!
|
|
@@ -140,6 +148,7 @@ export const createModelsSchema = ({
|
|
|
140
148
|
validation: [CmsFieldValidationInput]
|
|
141
149
|
listValidation: [CmsFieldValidationInput]
|
|
142
150
|
settings: JSON
|
|
151
|
+
rules: [CmsFieldRuleInput!]
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
input CmsContentModelCreateInput {
|
|
@@ -151,7 +160,7 @@ export const createModelsSchema = ({
|
|
|
151
160
|
icon: Icon
|
|
152
161
|
singleEntry: Boolean
|
|
153
162
|
description: String
|
|
154
|
-
layout:
|
|
163
|
+
layout: JSON
|
|
155
164
|
fields: [CmsContentModelFieldInput!]
|
|
156
165
|
titleFieldId: String
|
|
157
166
|
descriptionFieldId: String
|
|
@@ -177,7 +186,7 @@ export const createModelsSchema = ({
|
|
|
177
186
|
group: String
|
|
178
187
|
icon: Icon
|
|
179
188
|
description: String
|
|
180
|
-
layout:
|
|
189
|
+
layout: JSON!
|
|
181
190
|
fields: [CmsContentModelFieldInput!]!
|
|
182
191
|
titleFieldId: String
|
|
183
192
|
descriptionFieldId: String
|
|
@@ -226,6 +235,14 @@ export const createModelsSchema = ({
|
|
|
226
235
|
values: [CmsPredefinedValue]
|
|
227
236
|
}
|
|
228
237
|
|
|
238
|
+
type CmsFieldRule {
|
|
239
|
+
type: String!
|
|
240
|
+
target: String!
|
|
241
|
+
operator: String!
|
|
242
|
+
value: JSON
|
|
243
|
+
action: String!
|
|
244
|
+
}
|
|
245
|
+
|
|
229
246
|
type CmsContentModelField {
|
|
230
247
|
id: ID!
|
|
231
248
|
# auto-generated value
|
|
@@ -245,6 +262,7 @@ export const createModelsSchema = ({
|
|
|
245
262
|
validation: [CmsFieldValidation!]
|
|
246
263
|
listValidation: [CmsFieldValidation!]
|
|
247
264
|
settings: JSON
|
|
265
|
+
rules: [CmsFieldRule!]
|
|
248
266
|
}
|
|
249
267
|
|
|
250
268
|
type CmsContentModel {
|
|
@@ -259,7 +277,7 @@ export const createModelsSchema = ({
|
|
|
259
277
|
savedOn: DateTime
|
|
260
278
|
createdBy: CmsIdentity
|
|
261
279
|
fields: [CmsContentModelField!]!
|
|
262
|
-
layout:
|
|
280
|
+
layout: JSON!
|
|
263
281
|
titleFieldId: String
|
|
264
282
|
descriptionFieldId: String
|
|
265
283
|
imageFieldId: String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ErrorResponse","NotFoundError","Response","createCmsGraphQLSchemaPlugin","createModelsSchema","context","resolvers","Query","getContentModel","_","args","model","cms","getModel","modelId","e","listContentModels","models","listModels","includePrivate","includePlugins","CmsContentModelField","renderer","field","settings","tags","Array","isArray","CmsContentModel","hasType","find","tag","startsWith","plugin","isPlugin","manageSchema","MANAGE","createContentModel","createModel","data","createContentModelFrom","createModelFrom","updateContentModel","updateModel","deleteContentModel","deleteModel","typeDefs","name","type"],"sources":["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 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 }\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: [[ID!]!]\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: [[ID!]!]!\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 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 }\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: [[String!]!]!\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"],"mappings":"AAAA,SAASA,aAAa,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,yBAAyB;AAIhF,SAASC,4BAA4B;AAOrC,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAC/BC;AACsB,CAAC,KAA8B;EACrD,MAAMC,SAAgC,GAAG;IACrCC,KAAK,EAAE;MACHC,eAAe,EAAE,MAAAA,CAAOC,CAAU,EAAEC,IAAmB,EAAEL,OAAO,KAAK;QACjE,IAAI;UACA,MAAMM,KAAK,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,QAAQ,CAACH,IAAI,CAACI,OAAO,CAAC;UAEtD,IAAI,CAACH,KAAK,EAAE;YACR,MAAM,IAAIV,aAAa,CAAC,kBAAkBS,IAAI,CAACI,OAAO,kBAAkB,CAAC;UAC7E;UAEA,OAAO,IAAIZ,QAAQ,CAACS,KAAK,CAAC;QAC9B,CAAC,CAAC,OAAOI,CAAC,EAAE;UACR,OAAO,IAAIf,aAAa,CAACe,CAAC,CAAC;QAC/B;MACJ,CAAC;MACDC,iBAAiB,EAAE,MAAAA,CAAOP,CAAU,EAAEC,IAAmB,EAAEL,OAAmB,KAAK;QAC/E,IAAI;UACA,MAAMY,MAAM,GAAG,MAAMZ,OAAO,CAACO,GAAG,CAACM,UAAU,CAAC;YACxCC,cAAc,EAAE,KAAK;YACrBC,cAAc,EAAEV,IAAI,EAAEU,cAAc,KAAK,KAAK,GAAG,KAAK,GAAG;UAC7D,CAAC,CAAC;UACF,OAAO,IAAIlB,QAAQ,CAACe,MAAM,CAAC;QAC/B,CAAC,CAAC,OAAOF,CAAC,EAAE;UACR,OAAO,IAAIf,aAAa,CAACe,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IAC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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;EACL;EAEA,MAAMF,MAAM,GAAG9B,4BAA4B,CAAC;IACxC2C,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcX,YAAY;AAC1B,SAAS;IACD7B;EACJ,CAAC,CAAC;EACF2B,MAAM,CAACc,IAAI,GAAG,+BAA+B1C,OAAO,CAACO,GAAG,CAACoC,IAAI,iBAAiB;EAC9E,OAAOf,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ErrorResponse","NotFoundError","Response","createCmsGraphQLSchemaPlugin","createModelsSchema","context","resolvers","Query","getContentModel","_","args","model","cms","getModel","modelId","e","listContentModels","models","listModels","includePrivate","includePlugins","CmsContentModelField","renderer","field","settings","tags","Array","isArray","CmsContentModel","hasType","find","tag","startsWith","plugin","isPlugin","manageSchema","MANAGE","createContentModel","createModel","data","createContentModelFrom","createModelFrom","updateContentModel","updateModel","deleteContentModel","deleteModel","typeDefs","name","type"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,yBAAyB;AAIhF,SAASC,4BAA4B;AAOrC,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAC/BC;AACsB,CAAC,KAA8B;EACrD,MAAMC,SAAgC,GAAG;IACrCC,KAAK,EAAE;MACHC,eAAe,EAAE,MAAAA,CAAOC,CAAU,EAAEC,IAAmB,EAAEL,OAAO,KAAK;QACjE,IAAI;UACA,MAAMM,KAAK,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,QAAQ,CAACH,IAAI,CAACI,OAAO,CAAC;UAEtD,IAAI,CAACH,KAAK,EAAE;YACR,MAAM,IAAIV,aAAa,CAAC,kBAAkBS,IAAI,CAACI,OAAO,kBAAkB,CAAC;UAC7E;UAEA,OAAO,IAAIZ,QAAQ,CAACS,KAAK,CAAC;QAC9B,CAAC,CAAC,OAAOI,CAAC,EAAE;UACR,OAAO,IAAIf,aAAa,CAACe,CAAC,CAAC;QAC/B;MACJ,CAAC;MACDC,iBAAiB,EAAE,MAAAA,CAAOP,CAAU,EAAEC,IAAmB,EA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CAAU,EAAEC,IAAS,EAAEL,OAAO,KAAK;QAC1D,MAAM;UAAES;QAAQ,CAAC,GAAGJ,IAAI;QACxB,IAAI;UACA,MAAML,OAAO,CAACO,GAAG,CAACiC,WAAW,CAAC/B,OAAO,CAAC;UACtC,OAAO,IAAIZ,QAAQ,CAAC,IAAI,CAAC;QAC7B,CAAC,CAAC,OAAOa,CAAC,EAAE;UACR,OAAO,IAAIf,aAAa,CAACe,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IAEDoB,YAAY,GAAG,aAAc;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;EACL;EAEA,MAAMF,MAAM,GAAG9B,4BAA4B,CAAC;IACxC2C,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcX,YAAY;AAC1B,SAAS;IACD7B;EACJ,CAAC,CAAC;EACF2B,MAAM,CAACc,IAAI,GAAG,+BAA+B1C,OAAO,CAACO,GAAG,CAACoC,IAAI,iBAAiB;EAC9E,OAAOf,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -68,6 +68,7 @@ export const createManageSDL = ({
|
|
|
68
68
|
${onByMetaGqlFields}
|
|
69
69
|
meta: ${singularName}Meta
|
|
70
70
|
wbyAco_location: WbyAcoLocation
|
|
71
|
+
live: CmsEntryLive
|
|
71
72
|
|
|
72
73
|
values: ${singularName}Values
|
|
73
74
|
}
|
|
@@ -78,7 +79,7 @@ export const createManageSDL = ({
|
|
|
78
79
|
locked: Boolean
|
|
79
80
|
|
|
80
81
|
status: String
|
|
81
|
-
|
|
82
|
+
system: CmsEntrySystem
|
|
82
83
|
"""
|
|
83
84
|
CAUTION: this field is resolved by making an extra query to DB.
|
|
84
85
|
RECOMMENDATION: Use it only with "get" queries (avoid in "list")
|
|
@@ -130,8 +131,9 @@ export const createManageSDL = ({
|
|
|
130
131
|
input ${singularName}ListWhereInput {
|
|
131
132
|
${listFilterFieldsRender.baseFiltersAsString()}
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
system: ListWhereInputCmsEntrySystem
|
|
134
135
|
wbyAco_location: WbyAcoLocationWhereInput
|
|
136
|
+
live: CmsEntryLiveWhereInput
|
|
135
137
|
|
|
136
138
|
values: ${singularName}ListWhereInputValues
|
|
137
139
|
AND: [${singularName}ListWhereInput!]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderListFilterFields","renderSortEnum","renderGetFilterFields","renderInputFields","renderFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","createManageSDL","models","model","fieldTypePlugins","sorterPlugins","inputFields","fields","listFilterFieldsRender","type","sortEnumRender","getFilterFieldsRender","singularApiName","singularName","pluralApiName","pluralName","inputGqlFields","map","f","join","onByMetaInputGqlFields","field","fieldType","onByMetaGqlFields","description","typeDefs","fieldFiltersAsString","baseFiltersAsString"],"sources":["createManageSDL.ts"],"sourcesContent":["import type { CmsFieldTypePlugins, CmsModel } from \"~/types/index.js\";\nimport { renderListFilterFields } from \"~/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"~/utils/renderSortEnum.js\";\nimport { renderGetFilterFields } from \"~/utils/renderGetFilterFields.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport type { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/index.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\n\ninterface CreateManageSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\n\ninterface CreateManageSDL {\n (params: CreateManageSDLParams): string;\n}\n\nexport const createManageSDL: CreateManageSDL = ({\n models,\n model,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins\n });\n const getFilterFieldsRender = renderGetFilterFields({\n fields: model.fields,\n fieldTypePlugins\n });\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const { singularApiName: singularName, pluralApiName: pluralName } = model;\n\n const inputGqlFields = inputFields.map(f => f.fields).join(\"\\n\");\n\n const onByMetaInputGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentityInput\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const onByMetaGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n // Had to remove /* GraphQL */ because prettier would not format the code correctly.\n return `\n \"\"\"${model.description || singularName}\"\"\"\n \n type ${singularName}Values {\n ${fields.map(f => f.fields).join(\"\\n\") || \"_empty: String\"}\n }\n \n type ${singularName} {\n id: ID!\n entryId: String!\n \n ${onByMetaGqlFields}\n meta: ${singularName}Meta\n wbyAco_location: WbyAcoLocation\n \n values: ${singularName}Values\n }\n\n type ${singularName}Meta {\n modelId: String\n version: Int\n locked: Boolean\n \n status: String\n state: CmsEntryState\n \"\"\"\n CAUTION: this field is resolved by making an extra query to DB.\n RECOMMENDATION: Use it only with \"get\" queries (avoid in \"list\")\n \"\"\"\n revisions: [${singularName}!]\n title: String\n description: String\n image: String\n \"\"\"\n Custom meta data stored in the root of the entry object.\n \"\"\"\n data: JSON\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\n\n ${inputFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}InputValues {\n ${inputGqlFields || \"_empty: String\"}\n }\n \n input ${singularName}Input {\n id: ID\n \n # Set status of the entry.\n status: String\n \n ${onByMetaInputGqlFields}\n \n wbyAco_location: WbyAcoLocationInput\n \n values: ${singularName}InputValues\n }\n \n input ${singularName}GetWhereInputValues {\n ${getFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n \n input ${singularName}GetWhereInput {\n ${getFilterFieldsRender.baseFiltersAsString()}\n values: ${singularName}GetWhereInputValues\n }\n \n input ${singularName}ListWhereInputValues {\n ${listFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n\n input ${singularName}ListWhereInput {\n ${listFilterFieldsRender.baseFiltersAsString()}\n\n state: ListWhereInputCmsEntryState\n wbyAco_location: WbyAcoLocationWhereInput\n \n values: ${singularName}ListWhereInputValues\n AND: [${singularName}ListWhereInput!]\n OR: [${singularName}ListWhereInput!]\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n type ${singularName}MoveResponse {\n data: Boolean\n error: CmsError\n }\n\n type ${singularName}ArrayResponse {\n data: [${singularName}]\n error: CmsError\n }\n\n type ${singularName}ListResponse {\n data: [${singularName}]\n meta: CmsListMeta\n error: CmsError\n }\n\n\n enum ${singularName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type Query {\n get${singularName}(revision: ID, entryId: ID, status: CmsEntryStatusType): ${singularName}Response\n \n get${singularName}Revisions(id: ID!): ${singularName}ArrayResponse\n \n get${pluralName}ByIds(revisions: [ID!]!): ${singularName}ArrayResponse\n \n list${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n \n listDeleted${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n }\n\n extend type Mutation {\n create${singularName}(data: ${singularName}Input!, options: CreateCmsEntryOptionsInput): ${singularName}Response\n\n create${singularName}From(revision: ID!, data: ${singularName}Input, options: CreateRevisionCmsEntryOptionsInput): ${singularName}Response\n \n update${singularName}(revision: ID!, data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n\n validate${singularName}(revision: ID, data: ${singularName}Input!): CmsEntryValidationResponse!\n \n move${singularName}(revision: ID!, folderId: ID!): ${singularName}MoveResponse\n\n delete${singularName}(revision: ID!, options: CmsDeleteEntryOptions): CmsDeleteResponse\n \n restore${singularName}FromBin(revision: ID!): ${singularName}Response\n\n deleteMultiple${pluralName}(entries: [ID!]!): CmsDeleteMultipleResponse!\n \n publish${singularName}(revision: ID!): ${singularName}Response\n \n republish${singularName}(revision: ID!): ${singularName}Response\n \n unpublish${singularName}(revision: ID!): ${singularName}Response\n }\n `;\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,cAAc;AACvB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AAErB,SAASC,iBAAiB,EAAEC,wBAAwB;AAapD,OAAO,MAAMC,eAAgC,GAAGA,CAAC;EAC7CC,MAAM;EACNC,KAAK;EACLC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,MAAMC,WAAW,GAAGT,iBAAiB,CAAC;IAClCK,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC,CAAC;EAEF,MAAMI,sBAAsB,GAAGd,sBAAsB,CAAC;IAClDS,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBE,IAAI,EAAE,QAAQ;IACdL;EACJ,CAAC,CAAC;EAEF,MAAMM,cAAc,GAAGf,cAAc,CAAC;IAClCQ,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH,gBAAgB;IAChBC;EACJ,CAAC,CAAC;EACF,MAAMM,qBAAqB,GAAGf,qBAAqB,CAAC;IAChDW,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC,CAAC;EAEF,MAAMG,MAAM,GAAGT,YAAY,CAAC;IACxBI,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBE,IAAI,EAAE,QAAQ;IACdL;EACJ,CAAC,CAAC;EAEF,MAAM;IAAEQ,eAAe,EAAEC,YAAY;IAAEC,aAAa,EAAEC;EAAW,CAAC,GAAGZ,KAAK;EAE1E,MAAMa,cAAc,GAAGV,WAAW,CAACW,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACX,MAAM,CAAC,CAACY,IAAI,CAAC,IAAI,CAAC;EAEhE,MAAMC,sBAAs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YAAY,iDAAiDA,YAAY;AACnH;AACA,oBAAoBA,YAAY,6BAA6BA,YAAY,wDAAwDA,YAAY;AAC7I;AACA,oBAAoBA,YAAY,yBAAyBA,YAAY,iDAAiDA,YAAY;AAClI;AACA,sBAAsBA,YAAY,wBAAwBA,YAAY;AACtE;AACA,kBAAkBA,YAAY,mCAAmCA,YAAY;AAC7E;AACA,oBAAoBA,YAAY;AAChC;AACA,qBAAqBA,YAAY,2BAA2BA,YAAY;AACxE;AACA,4BAA4BE,UAAU;AACtC;AACA,qBAAqBF,YAAY,oBAAoBA,YAAY;AACjE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,KAAK;AACL,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["renderListFilterFields","renderSortEnum","renderGetFilterFields","renderInputFields","renderFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","createManageSDL","models","model","fieldTypePlugins","sorterPlugins","inputFields","fields","listFilterFieldsRender","type","sortEnumRender","getFilterFieldsRender","singularApiName","singularName","pluralApiName","pluralName","inputGqlFields","map","f","join","onByMetaInputGqlFields","field","fieldType","onByMetaGqlFields","description","typeDefs","fieldFiltersAsString","baseFiltersAsString"],"sources":["createManageSDL.ts"],"sourcesContent":["import type { CmsFieldTypePlugins, CmsModel } from \"~/types/index.js\";\nimport { renderListFilterFields } from \"~/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"~/utils/renderSortEnum.js\";\nimport { renderGetFilterFields } from \"~/utils/renderGetFilterFields.js\";\nimport { renderInputFields } from \"~/utils/renderInputFields.js\";\nimport { renderFields } from \"~/utils/renderFields.js\";\nimport type { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/index.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\n\ninterface CreateManageSDLParams {\n models: CmsModel[];\n model: CmsModel;\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\n\ninterface CreateManageSDL {\n (params: CreateManageSDLParams): string;\n}\n\nexport const createManageSDL: CreateManageSDL = ({\n models,\n model,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n const inputFields = renderInputFields({\n models,\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins\n });\n const getFilterFieldsRender = renderGetFilterFields({\n fields: model.fields,\n fieldTypePlugins\n });\n\n const fields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const { singularApiName: singularName, pluralApiName: pluralName } = model;\n\n const inputGqlFields = inputFields.map(f => f.fields).join(\"\\n\");\n\n const onByMetaInputGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentityInput\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const onByMetaGqlFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n // Had to remove /* GraphQL */ because prettier would not format the code correctly.\n return `\n \"\"\"${model.description || singularName}\"\"\"\n \n type ${singularName}Values {\n ${fields.map(f => f.fields).join(\"\\n\") || \"_empty: String\"}\n }\n \n type ${singularName} {\n id: ID!\n entryId: String!\n \n ${onByMetaGqlFields}\n meta: ${singularName}Meta\n wbyAco_location: WbyAcoLocation\n live: CmsEntryLive\n \n values: ${singularName}Values\n }\n\n type ${singularName}Meta {\n modelId: String\n version: Int\n locked: Boolean\n \n status: String\n system: CmsEntrySystem\n \"\"\"\n CAUTION: this field is resolved by making an extra query to DB.\n RECOMMENDATION: Use it only with \"get\" queries (avoid in \"list\")\n \"\"\"\n revisions: [${singularName}!]\n title: String\n description: String\n image: String\n \"\"\"\n Custom meta data stored in the root of the entry object.\n \"\"\"\n data: JSON\n }\n\n ${fields.map(f => f.typeDefs).join(\"\\n\")}\n\n ${inputFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input ${singularName}InputValues {\n ${inputGqlFields || \"_empty: String\"}\n }\n \n input ${singularName}Input {\n id: ID\n \n # Set status of the entry.\n status: String\n \n ${onByMetaInputGqlFields}\n \n wbyAco_location: WbyAcoLocationInput\n \n values: ${singularName}InputValues\n }\n \n input ${singularName}GetWhereInputValues {\n ${getFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n \n input ${singularName}GetWhereInput {\n ${getFilterFieldsRender.baseFiltersAsString()}\n values: ${singularName}GetWhereInputValues\n }\n \n input ${singularName}ListWhereInputValues {\n ${listFilterFieldsRender.fieldFiltersAsString() || \"_empty: String\"}\n }\n\n input ${singularName}ListWhereInput {\n ${listFilterFieldsRender.baseFiltersAsString()}\n\n system: ListWhereInputCmsEntrySystem\n wbyAco_location: WbyAcoLocationWhereInput\n live: CmsEntryLiveWhereInput\n \n values: ${singularName}ListWhereInputValues\n AND: [${singularName}ListWhereInput!]\n OR: [${singularName}ListWhereInput!]\n }\n\n type ${singularName}Response {\n data: ${singularName}\n error: CmsError\n }\n \n type ${singularName}MoveResponse {\n data: Boolean\n error: CmsError\n }\n\n type ${singularName}ArrayResponse {\n data: [${singularName}]\n error: CmsError\n }\n\n type ${singularName}ListResponse {\n data: [${singularName}]\n meta: CmsListMeta\n error: CmsError\n }\n\n\n enum ${singularName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type Query {\n get${singularName}(revision: ID, entryId: ID, status: CmsEntryStatusType): ${singularName}Response\n \n get${singularName}Revisions(id: ID!): ${singularName}ArrayResponse\n \n get${pluralName}ByIds(revisions: [ID!]!): ${singularName}ArrayResponse\n \n list${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n \n listDeleted${pluralName} (\n where: ${singularName}ListWhereInput\n sort: [${singularName}ListSorter]\n limit: Int\n after: String\n search: String\n ): ${singularName}ListResponse\n }\n\n extend type Mutation {\n create${singularName}(data: ${singularName}Input!, options: CreateCmsEntryOptionsInput): ${singularName}Response\n\n create${singularName}From(revision: ID!, data: ${singularName}Input, options: CreateRevisionCmsEntryOptionsInput): ${singularName}Response\n \n update${singularName}(revision: ID!, data: ${singularName}Input!, options: UpdateCmsEntryOptionsInput): ${singularName}Response\n\n validate${singularName}(revision: ID, data: ${singularName}Input!): CmsEntryValidationResponse!\n \n move${singularName}(revision: ID!, folderId: ID!): ${singularName}MoveResponse\n\n delete${singularName}(revision: ID!, options: CmsDeleteEntryOptions): CmsDeleteResponse\n \n restore${singularName}FromBin(revision: ID!): ${singularName}Response\n\n deleteMultiple${pluralName}(entries: [ID!]!): CmsDeleteMultipleResponse!\n \n publish${singularName}(revision: ID!): ${singularName}Response\n \n republish${singularName}(revision: ID!): ${singularName}Response\n \n unpublish${singularName}(revision: ID!): ${singularName}Response\n }\n `;\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,cAAc;AACvB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AAErB,SAASC,iBAAiB,EAAEC,wBAAwB;AAapD,OAAO,MAAMC,eAAgC,GAAGA,CAAC;EAC7CC,MAAM;EACNC,KAAK;EACLC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,MAAMC,WAAW,GAAGT,iBAAiB,CAAC;IAClCK,MAAM;IACNC,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBH;EACJ,CAAC,CAAC;EAEF,MAAMI,sBAAsB,GAAGd,sBAAsB,CAAC;IAClDS,KAAK;IACLI,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBE,IAAI,EAAE,QAAQ;IACdL;EACJ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,YAAY;AAC3B,oBAAoBA,YAAY;AAChC;AACA;AACA;AACA,eAAeA,YAAY;AAC3B;AACA;AACA;AACA;AACA,eAAeA,YAAY;AAC3B,qBAAqBA,YAAY;AACjC;AACA;AACA;AACA,eAAeA,YAAY;AAC3B,qBAAqBA,YAAY;AACjC;AACA;AACA;AACA;AACA;AACA,eAAeA,YAAY;AAC3B,cAAcH,cAAc;AAC5B;AACA;AACA;AACA,iBAAiBG,YAAY,4DAA4DA,YAAY;AACrG;AACA,iBAAiBA,YAAY,uBAAuBA,YAAY;AAChE;AACA,iBAAiBE,UAAU,6BAA6BF,YAAY;AACpE;AACA,kBAAkBE,UAAU;AAC5B,yBAAyBF,YAAY;AACrC,yBAAyBA,YAAY;AACrC;AACA;AACA;AACA,iBAAiBA,YAAY;AAC7B;AACA,yBAAyBE,UAAU;AACnC,yBAAyBF,YAAY;AACrC,yBAAyBA,YAAY;AACrC;AACA;AACA;AACA,iBAAiBA,YAAY;AAC7B;AACA;AACA;AACA,oBAAoBA,YAAY,UAAUA,YAAY,iDAAiDA,YAAY;AACnH;AACA,oBAAoBA,YAAY,6BAA6BA,YAAY,wDAAwDA,YAAY;AAC7I;AACA,oBAAoBA,YAAY,yBAAyBA,YAAY,iDAAiDA,YAAY;AAClI;AACA,sBAAsBA,YAAY,wBAAwBA,YAAY;AACtE;AACA,kBAAkBA,YAAY,mCAAmCA,YAAY;AAC7E;AACA,oBAAoBA,YAAY;AAChC;AACA,qBAAqBA,YAAY,2BAA2BA,YAAY;AACxE;AACA,4BAA4BE,UAAU;AACtC;AACA,qBAAqBF,YAAY,oBAAoBA,YAAY;AACjE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,uBAAuBA,YAAY,oBAAoBA,YAAY;AACnE;AACA,KAAK;AACL,CAAC","ignoreList":[]}
|
package/graphqlFields/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import { createObjectField } from "./object.js";
|
|
|
10
10
|
import { createDynamicZoneField } from "./dynamicZone/index.js";
|
|
11
11
|
import { createJsonField } from "./json.js";
|
|
12
12
|
import { createSearchableJsonField } from "./searchableJson.js";
|
|
13
|
-
|
|
14
|
-
export const createGraphQLFields = () => [createTextField(), createRefField(), createNumberField(), createDateTimeField(), createBooleanField(), createLongTextField(), createRichTextField(), createJsonField(), createSearchableJsonField(), createFileField(), createObjectField(), createDynamicZoneField(), createUiField()];
|
|
13
|
+
export const createGraphQLFields = () => [createTextField(), createRefField(), createNumberField(), createDateTimeField(), createBooleanField(), createLongTextField(), createRichTextField(), createJsonField(), createSearchableJsonField(), createFileField(), createObjectField(), createDynamicZoneField()];
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createTextField","createLongTextField","createRefField","createNumberField","createBooleanField","createDateTimeField","createRichTextField","createFileField","createObjectField","createDynamicZoneField","createJsonField","createSearchableJsonField","
|
|
1
|
+
{"version":3,"names":["createTextField","createLongTextField","createRefField","createNumberField","createBooleanField","createDateTimeField","createRichTextField","createFileField","createObjectField","createDynamicZoneField","createJsonField","createSearchableJsonField","createGraphQLFields"],"sources":["index.ts"],"sourcesContent":["import { createTextField } from \"./text.js\";\nimport { createLongTextField } from \"./longText.js\";\nimport { createRefField } from \"./ref.js\";\nimport { createNumberField } from \"./number.js\";\nimport { createBooleanField } from \"./boolean.js\";\nimport { createDateTimeField } from \"./datetime.js\";\nimport { createRichTextField } from \"./richText.js\";\nimport { createFileField } from \"./file.js\";\nimport { createObjectField } from \"./object.js\";\nimport { createDynamicZoneField } from \"./dynamicZone/index.js\";\nimport type { CmsModelFieldToGraphQLPlugin } from \"~/types/index.js\";\nimport { createJsonField } from \"./json.js\";\nimport { createSearchableJsonField } from \"./searchableJson.js\";\n\nexport const createGraphQLFields = (): CmsModelFieldToGraphQLPlugin<any>[] => [\n createTextField(),\n createRefField(),\n createNumberField(),\n createDateTimeField(),\n createBooleanField(),\n createLongTextField(),\n createRichTextField(),\n createJsonField(),\n createSearchableJsonField(),\n createFileField(),\n createObjectField(),\n createDynamicZoneField()\n];\n"],"mappings":"AAAA,SAASA,eAAe;AACxB,SAASC,mBAAmB;AAC5B,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAC5B,SAASC,mBAAmB;AAC5B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;AAE/B,SAASC,eAAe;AACxB,SAASC,yBAAyB;AAElC,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAA2C,CAC1EZ,eAAe,CAAC,CAAC,EACjBE,cAAc,CAAC,CAAC,EAChBC,iBAAiB,CAAC,CAAC,EACnBE,mBAAmB,CAAC,CAAC,EACrBD,kBAAkB,CAAC,CAAC,EACpBH,mBAAmB,CAAC,CAAC,EACrBK,mBAAmB,CAAC,CAAC,EACrBI,eAAe,CAAC,CAAC,EACjBC,yBAAyB,CAAC,CAAC,EAC3BJ,eAAe,CAAC,CAAC,EACjBC,iBAAiB,CAAC,CAAC,EACnBC,sBAAsB,CAAC,CAAC,CAC3B","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
"@babel/code-frame": "7.29.0",
|
|
23
23
|
"@graphql-tools/merge": "9.1.7",
|
|
24
24
|
"@graphql-tools/schema": "10.0.31",
|
|
25
|
-
"@webiny/api": "6.0.0-rc.
|
|
26
|
-
"@webiny/api-core": "6.0.0-rc.
|
|
25
|
+
"@webiny/api": "6.0.0-rc.3",
|
|
26
|
+
"@webiny/api-core": "6.0.0-rc.3",
|
|
27
27
|
"@webiny/di": "0.2.3",
|
|
28
|
-
"@webiny/error": "6.0.0-rc.
|
|
29
|
-
"@webiny/feature": "6.0.0-rc.
|
|
30
|
-
"@webiny/handler": "6.0.0-rc.
|
|
31
|
-
"@webiny/handler-aws": "6.0.0-rc.
|
|
32
|
-
"@webiny/handler-db": "6.0.0-rc.
|
|
33
|
-
"@webiny/handler-graphql": "6.0.0-rc.
|
|
34
|
-
"@webiny/plugins": "6.0.0-rc.
|
|
35
|
-
"@webiny/project": "6.0.0-rc.
|
|
36
|
-
"@webiny/utils": "6.0.0-rc.
|
|
37
|
-
"@webiny/validation": "6.0.0-rc.
|
|
28
|
+
"@webiny/error": "6.0.0-rc.3",
|
|
29
|
+
"@webiny/feature": "6.0.0-rc.3",
|
|
30
|
+
"@webiny/handler": "6.0.0-rc.3",
|
|
31
|
+
"@webiny/handler-aws": "6.0.0-rc.3",
|
|
32
|
+
"@webiny/handler-db": "6.0.0-rc.3",
|
|
33
|
+
"@webiny/handler-graphql": "6.0.0-rc.3",
|
|
34
|
+
"@webiny/plugins": "6.0.0-rc.3",
|
|
35
|
+
"@webiny/project": "6.0.0-rc.3",
|
|
36
|
+
"@webiny/utils": "6.0.0-rc.3",
|
|
37
|
+
"@webiny/validation": "6.0.0-rc.3",
|
|
38
38
|
"dot-prop-immutable": "2.1.1",
|
|
39
|
-
"graphql": "16.
|
|
39
|
+
"graphql": "16.13.0",
|
|
40
40
|
"graphql-tag": "2.12.6",
|
|
41
41
|
"lodash": "4.17.23",
|
|
42
42
|
"p-map": "7.0.4",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/babel__code-frame": "7.27.0",
|
|
50
50
|
"@types/pluralize": "0.0.33",
|
|
51
|
-
"@webiny/aws-sdk": "6.0.0-rc.
|
|
52
|
-
"@webiny/build-tools": "6.0.0-rc.
|
|
53
|
-
"@webiny/db-dynamodb": "6.0.0-rc.
|
|
51
|
+
"@webiny/aws-sdk": "6.0.0-rc.3",
|
|
52
|
+
"@webiny/build-tools": "6.0.0-rc.3",
|
|
53
|
+
"@webiny/db-dynamodb": "6.0.0-rc.3",
|
|
54
54
|
"@webiny/handler-db": "0.0.0",
|
|
55
|
-
"@webiny/project-utils": "6.0.0-rc.
|
|
56
|
-
"@webiny/sdk": "6.0.0-rc.
|
|
57
|
-
"@webiny/wcp": "6.0.0-rc.
|
|
55
|
+
"@webiny/project-utils": "6.0.0-rc.3",
|
|
56
|
+
"@webiny/sdk": "6.0.0-rc.3",
|
|
57
|
+
"@webiny/wcp": "6.0.0-rc.3",
|
|
58
58
|
"apollo-graphql": "0.9.7",
|
|
59
|
-
"graphql": "16.
|
|
59
|
+
"graphql": "16.13.0",
|
|
60
60
|
"prettier": "3.6.2",
|
|
61
61
|
"rimraf": "6.1.3",
|
|
62
62
|
"typescript": "5.9.3",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"access": "public",
|
|
68
68
|
"directory": "dist"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "228fe25e1a17f248d566bce1c33d11c291955513"
|
|
71
71
|
}
|
|
@@ -168,12 +168,27 @@ export class CmsModelPlugin extends Plugin {
|
|
|
168
168
|
if (this.options.validateLayout === false) {
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
const countFieldInLayout = (fieldId, layout) => {
|
|
172
172
|
let total = 0;
|
|
173
|
-
for (const row of
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
for (const row of layout) {
|
|
174
|
+
for (const cell of row) {
|
|
175
|
+
if (typeof cell === "string") {
|
|
176
|
+
if (cell === fieldId) {
|
|
177
|
+
total++;
|
|
178
|
+
}
|
|
179
|
+
} else if (cell && typeof cell === "object" && Array.isArray(cell.tabs)) {
|
|
180
|
+
for (const tab of cell.tabs) {
|
|
181
|
+
if (Array.isArray(tab.layout)) {
|
|
182
|
+
total += countFieldInLayout(fieldId, tab.layout);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
176
187
|
}
|
|
188
|
+
return total;
|
|
189
|
+
};
|
|
190
|
+
for (const field of model.fields) {
|
|
191
|
+
const total = countFieldInLayout(field.id, model.layout);
|
|
177
192
|
if (total === 1) {
|
|
178
193
|
continue;
|
|
179
194
|
} else if (total > 1) {
|