@webiny/api-headless-cms 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e2758ee1cf
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/contentEntry/searchableFields.js +6 -2
- package/crud/contentEntry/searchableFields.js.map +1 -1
- 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/exports/api/cms/model.d.ts +1 -0
- package/exports/api/cms/model.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +2 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -4
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.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 +6 -0
- 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 +10 -3
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/FieldBuilder.d.ts +5 -50
- package/features/modelBuilder/fields/FieldBuilder.js +3 -165
- package/features/modelBuilder/fields/FieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/FieldBuilderRegistry.js +11 -1
- package/features/modelBuilder/fields/FieldBuilderRegistry.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 +19 -0
- package/features/modelBuilder/fields/UiAlertFieldType.js +36 -0
- package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -0
- package/features/modelBuilder/fields/UiSeparatorFieldType.d.ts +17 -0
- package/features/modelBuilder/fields/UiSeparatorFieldType.js +31 -0
- package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -0
- 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 +3 -0
- package/features/modelBuilder/index.js +3 -0
- package/features/modelBuilder/index.js.map +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +9 -4
- 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 -4
- package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
- package/graphql/index.js +2 -1
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseSchema.js +17 -15
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/createEntryResolver.d.ts +10 -0
- package/graphql/schema/cms/createEntryResolver.js +56 -0
- package/graphql/schema/cms/createEntryResolver.js.map +1 -0
- package/graphql/schema/cms/deleteEntryResolver.d.ts +10 -0
- package/graphql/schema/cms/deleteEntryResolver.js +56 -0
- package/graphql/schema/cms/deleteEntryResolver.js.map +1 -0
- package/graphql/schema/cms/getEntryResolver.d.ts +11 -0
- package/graphql/schema/cms/getEntryResolver.js +58 -0
- package/graphql/schema/cms/getEntryResolver.js.map +1 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.d.ts +23 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js +79 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -0
- package/graphql/schema/cms/helpers/getErrorMessage.d.ts +4 -0
- package/graphql/schema/cms/helpers/getErrorMessage.js +14 -0
- package/graphql/schema/cms/helpers/getErrorMessage.js.map +1 -0
- package/graphql/schema/cms/helpers/getModel.d.ts +6 -0
- package/graphql/schema/cms/helpers/getModel.js +12 -0
- package/graphql/schema/cms/helpers/getModel.js.map +1 -0
- package/graphql/schema/cms/helpers/index.d.ts +5 -0
- package/graphql/schema/cms/helpers/index.js +7 -0
- package/graphql/schema/cms/helpers/index.js.map +1 -0
- package/graphql/schema/cms/helpers/transformSortToArray.d.ts +18 -0
- package/graphql/schema/cms/helpers/transformSortToArray.js +38 -0
- package/graphql/schema/cms/helpers/transformSortToArray.js.map +1 -0
- 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 +5 -0
- package/graphql/schema/cms/helpers.js +7 -0
- package/graphql/schema/cms/helpers.js.map +1 -0
- package/graphql/schema/cms/index.d.ts +2 -0
- package/graphql/schema/cms/index.js +26 -0
- package/graphql/schema/cms/index.js.map +1 -0
- package/graphql/schema/cms/listEntriesResolver.d.ts +14 -0
- package/graphql/schema/cms/listEntriesResolver.js +97 -0
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -0
- package/graphql/schema/cms/publishEntryResolver.d.ts +10 -0
- package/graphql/schema/cms/publishEntryResolver.js +56 -0
- package/graphql/schema/cms/publishEntryResolver.js.map +1 -0
- package/graphql/schema/cms/resolvers/createEntry.d.ts +8 -0
- package/graphql/schema/cms/resolvers/createEntry.js +17 -0
- package/graphql/schema/cms/resolvers/createEntry.js.map +1 -0
- package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +8 -0
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js +17 -0
- package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -0
- package/graphql/schema/cms/resolvers/getEntry.d.ts +8 -0
- package/graphql/schema/cms/resolvers/getEntry.js +17 -0
- package/graphql/schema/cms/resolvers/getEntry.js.map +1 -0
- package/graphql/schema/cms/resolvers/index.d.ts +9 -0
- package/graphql/schema/cms/resolvers/index.js +11 -0
- package/graphql/schema/cms/resolvers/index.js.map +1 -0
- package/graphql/schema/cms/resolvers/listEntries.d.ts +8 -0
- package/graphql/schema/cms/resolvers/listEntries.js +17 -0
- package/graphql/schema/cms/resolvers/listEntries.js.map +1 -0
- package/graphql/schema/cms/resolvers/mutationCms.d.ts +8 -0
- package/graphql/schema/cms/resolvers/mutationCms.js +24 -0
- package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -0
- package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +8 -0
- package/graphql/schema/cms/resolvers/publishEntryRevision.js +17 -0
- package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -0
- package/graphql/schema/cms/resolvers/queryCms.d.ts +8 -0
- package/graphql/schema/cms/resolvers/queryCms.js +23 -0
- package/graphql/schema/cms/resolvers/queryCms.js.map +1 -0
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +8 -0
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +17 -0
- package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -0
- package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +8 -0
- package/graphql/schema/cms/resolvers/updateEntryRevision.js +17 -0
- package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -0
- package/graphql/schema/cms/typeDefs/index.d.ts +3 -0
- package/graphql/schema/cms/typeDefs/index.js +5 -0
- package/graphql/schema/cms/typeDefs/index.js.map +1 -0
- package/graphql/schema/cms/typeDefs/mutation.d.ts +8 -0
- package/graphql/schema/cms/typeDefs/mutation.js +42 -0
- package/graphql/schema/cms/typeDefs/mutation.js.map +1 -0
- package/graphql/schema/cms/typeDefs/query.d.ts +8 -0
- package/graphql/schema/cms/typeDefs/query.js +35 -0
- package/graphql/schema/cms/typeDefs/query.js.map +1 -0
- package/graphql/schema/cms/typeDefs/responses.d.ts +8 -0
- package/graphql/schema/cms/typeDefs/responses.js +35 -0
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -0
- package/graphql/schema/cms/unpublishEntryResolver.d.ts +10 -0
- package/graphql/schema/cms/unpublishEntryResolver.js +56 -0
- package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -0
- package/graphql/schema/cms/updateEntryResolver.d.ts +11 -0
- package/graphql/schema/cms/updateEntryResolver.js +58 -0
- package/graphql/schema/cms/updateEntryResolver.js.map +1 -0
- 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.map +1 -1
- package/package.json +24 -23
- 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/crud/contentModel/validateModel.d.ts +0 -9
- package/crud/contentModel/validateModel.js +0 -21
- package/crud/contentModel/validateModel.js.map +0 -1
- package/crud/contentModel/validateModelFields.d.ts +0 -9
- package/crud/contentModel/validateModelFields.js +0 -267
- package/crud/contentModel/validateModelFields.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { FieldType } from "./abstractions.js";
|
|
2
|
+
import { LayoutFieldBuilder } from "./LayoutFieldBuilder.js";
|
|
3
|
+
class TabsFieldBuilder extends LayoutFieldBuilder {
|
|
4
|
+
tabs = [];
|
|
5
|
+
constructor(registry) {
|
|
6
|
+
super("uiTabs");
|
|
7
|
+
this.registry = registry;
|
|
8
|
+
}
|
|
9
|
+
tab(id, config) {
|
|
10
|
+
const fieldBuilders = config.fields(this.registry);
|
|
11
|
+
const fields = [];
|
|
12
|
+
const layoutReplacements = new Map();
|
|
13
|
+
for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {
|
|
14
|
+
fieldBuilder.fieldId(key);
|
|
15
|
+
const result = fieldBuilder.build();
|
|
16
|
+
if (result.type === "layout") {
|
|
17
|
+
layoutReplacements.set(key, result.layoutCell);
|
|
18
|
+
if (result.fields) {
|
|
19
|
+
fields.push(...result.fields);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
fields.push(result.field);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const rawLayout = config.layout || [];
|
|
26
|
+
const layout = rawLayout.map(row => row.map(cell => layoutReplacements.get(cell) ?? cell));
|
|
27
|
+
this.tabs.push({
|
|
28
|
+
id,
|
|
29
|
+
label: config.label,
|
|
30
|
+
icon: config.icon,
|
|
31
|
+
description: config.description || "",
|
|
32
|
+
fields,
|
|
33
|
+
layout
|
|
34
|
+
});
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
build() {
|
|
38
|
+
const hoistedFields = [];
|
|
39
|
+
const layoutTabs = [];
|
|
40
|
+
for (const tab of this.tabs) {
|
|
41
|
+
hoistedFields.push(...tab.fields);
|
|
42
|
+
layoutTabs.push({
|
|
43
|
+
id: tab.id,
|
|
44
|
+
label: tab.label,
|
|
45
|
+
icon: tab.icon || null,
|
|
46
|
+
layout: tab.layout
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
type: "layout",
|
|
51
|
+
layoutCell: {
|
|
52
|
+
type: "tabs",
|
|
53
|
+
label: this.config.label,
|
|
54
|
+
description: this.config.description || null,
|
|
55
|
+
help: this.config.help || null,
|
|
56
|
+
tabs: layoutTabs
|
|
57
|
+
},
|
|
58
|
+
fields: hoistedFields
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class TabsFieldTypeFactory {
|
|
63
|
+
type = "uiTabs";
|
|
64
|
+
create(registry) {
|
|
65
|
+
return new TabsFieldBuilder(registry);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export const UiTabsFieldType = FieldType.createImplementation({
|
|
69
|
+
implementation: TabsFieldTypeFactory,
|
|
70
|
+
dependencies: []
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Module augmentation for TypeScript autocomplete
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=UiTabsFieldType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FieldType","LayoutFieldBuilder","TabsFieldBuilder","tabs","constructor","registry","tab","id","config","fieldBuilders","fields","layoutReplacements","Map","key","fieldBuilder","Object","entries","fieldId","result","build","type","set","layoutCell","push","field","rawLayout","layout","map","row","cell","get","label","icon","description","hoistedFields","layoutTabs","help","TabsFieldTypeFactory","create","UiTabsFieldType","createImplementation","implementation","dependencies"],"sources":["UiTabsFieldType.ts"],"sourcesContent":["import { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\nimport {\n BaseFieldBuilder,\n type FieldBuildResult,\n type LayoutFieldBuildResult\n} from \"./BaseFieldBuilder.js\";\nimport { LayoutFieldBuilder } from \"./LayoutFieldBuilder.js\";\nimport { type IFieldBuilderRegistry } from \"../abstractions.js\";\nimport type { CmsIcon, CmsModelField, CmsModelLayout, CmsModelLayoutCell } from \"~/types/index.js\";\n\ninterface ITab {\n id: string;\n label: string;\n icon: CmsIcon | undefined;\n description: string;\n fields: CmsModelField[];\n layout: CmsModelLayout;\n}\n\ninterface ITabConfig {\n label: string;\n icon?: CmsIcon;\n description?: string;\n fields: (registry: IFieldBuilderRegistry) => Record<string, BaseFieldBuilder<any>>;\n layout?: string[][];\n}\n\nexport interface IUiTabsFieldBuilder extends LayoutFieldBuilder<\"uiTabs\"> {\n tab(id: string, config: ITabConfig): this;\n}\n\nclass TabsFieldBuilder extends LayoutFieldBuilder<\"uiTabs\"> implements IUiTabsFieldBuilder {\n private readonly tabs: ITab[] = [];\n\n public constructor(private registry: IFieldBuilderRegistry) {\n super(\"uiTabs\");\n }\n\n public tab(id: string, config: ITabConfig): this {\n const fieldBuilders = config.fields(this.registry);\n const fields: CmsModelField[] = [];\n const layoutReplacements = new Map<string, CmsModelLayoutCell>();\n\n for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {\n fieldBuilder.fieldId(key);\n const result: FieldBuildResult = (fieldBuilder as any).build();\n if (result.type === \"layout\") {\n layoutReplacements.set(key, result.layoutCell);\n if (result.fields) {\n fields.push(...result.fields);\n }\n } else {\n fields.push(result.field);\n }\n }\n\n const rawLayout: string[][] = config.layout || [];\n const layout: CmsModelLayout = rawLayout.map(row =>\n row.map(cell => layoutReplacements.get(cell) ?? cell)\n );\n\n this.tabs.push({\n id,\n label: config.label,\n icon: config.icon,\n description: config.description || \"\",\n fields,\n layout\n });\n\n return this;\n }\n\n public override build(): LayoutFieldBuildResult {\n const hoistedFields: CmsModelField[] = [];\n const layoutTabs = [];\n\n for (const tab of this.tabs) {\n hoistedFields.push(...tab.fields);\n layoutTabs.push({\n id: tab.id,\n label: tab.label,\n icon: tab.icon || null,\n layout: tab.layout\n });\n }\n\n return {\n type: \"layout\",\n layoutCell: {\n type: \"tabs\",\n label: this.config.label,\n description: this.config.description || null,\n help: this.config.help || null,\n tabs: layoutTabs\n },\n fields: hoistedFields\n };\n }\n}\n\nclass TabsFieldTypeFactory implements IFieldTypeFactory {\n public readonly type = \"uiTabs\";\n\n public create(registry: IFieldBuilderRegistry): IUiTabsFieldBuilder {\n return new TabsFieldBuilder(registry);\n }\n}\n\nexport const UiTabsFieldType = FieldType.createImplementation({\n implementation: TabsFieldTypeFactory,\n dependencies: []\n});\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n uiTabs(): IUiTabsFieldBuilder;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAMlB,SAASC,kBAAkB;AAyB3B,MAAMC,gBAAgB,SAASD,kBAAkB,CAA0C;EACtEE,IAAI,GAAW,EAAE;EAE3BC,WAAWA,CAASC,QAA+B,EAAE;IACxD,KAAK,CAAC,QAAQ,CAAC;IAAC,KADOA,QAA+B,GAA/BA,QAA+B;EAE1D;EAEOC,GAAGA,CAACC,EAAU,EAAEC,MAAkB,EAAQ;IAC7C,MAAMC,aAAa,GAAGD,MAAM,CAACE,MAAM,CAAC,IAAI,CAACL,QAAQ,CAAC;IAClD,MAAMK,MAAuB,GAAG,EAAE;IAClC,MAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAA6B,CAAC;IAEhE,KAAK,MAAM,CAACC,GAAG,EAAEC,YAAY,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACP,aAAa,CAAC,EAAE;MAC7DK,YAAY,CAACG,OAAO,CAACJ,GAAG,CAAC;MACzB,MAAMK,MAAwB,GAAIJ,YAAY,CAASK,KAAK,CAAC,CAAC;MAC9D,IAAID,MAAM,CAACE,IAAI,KAAK,QAAQ,EAAE;QAC1BT,kBAAkB,CAACU,GAAG,CAACR,GAAG,EAAEK,MAAM,CAACI,UAAU,CAAC;QAC9C,IAAIJ,MAAM,CAACR,MAAM,EAAE;UACfA,MAAM,CAACa,IAAI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W,IAAI,IAAI;QAC5CG,IAAI,EAAE,IAAI,CAAC5B,MAAM,CAAC4B,IAAI,IAAI,IAAI;QAC9BjC,IAAI,EAAEgC;MACV,CAAC;MACDzB,MAAM,EAAEwB;IACZ,CAAC;EACL;AACJ;AAEA,MAAMG,oBAAoB,CAA8B;EACpCjB,IAAI,GAAG,QAAQ;EAExBkB,MAAMA,CAACjC,QAA+B,EAAuB;IAChE,OAAO,IAAIH,gBAAgB,CAACG,QAAQ,CAAC;EACzC;AACJ;AAEA,OAAO,MAAMkC,eAAe,GAAGvC,SAAS,CAACwC,oBAAoB,CAAC;EAC1DC,cAAc,EAAEJ,oBAAoB;EACpCK,YAAY,EAAE;AAClB,CAAC,CAAC;;AAEF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseFieldBuilder } from "./BaseFieldBuilder.js";
|
|
2
2
|
import type { IFieldBuilderRegistry } from "../abstractions.js";
|
|
3
3
|
/**
|
|
4
4
|
* Field Type Factory - creates a field builder instance
|
|
@@ -7,7 +7,7 @@ export interface IFieldTypeFactory {
|
|
|
7
7
|
/** Unique identifier for this field type */
|
|
8
8
|
readonly type: string;
|
|
9
9
|
/** Create a new field builder instance */
|
|
10
|
-
create(registry: IFieldBuilderRegistry):
|
|
10
|
+
create(registry: IFieldBuilderRegistry): BaseFieldBuilder<any>;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Field Type abstraction - use with { multiple: true } in DI
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","FieldType"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {
|
|
1
|
+
{"version":3,"names":["createAbstraction","FieldType"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { BaseFieldBuilder } from \"./BaseFieldBuilder.js\";\nimport type { IFieldBuilderRegistry } from \"../abstractions.js\";\n\n/**\n * Field Type Factory - creates a field builder instance\n */\nexport interface IFieldTypeFactory {\n /** Unique identifier for this field type */\n readonly type: string;\n\n /** Create a new field builder instance */\n create(registry: IFieldBuilderRegistry): BaseFieldBuilder<any>;\n}\n\n/**\n * Field Type abstraction - use with { multiple: true } in DI\n */\nexport const FieldType = createAbstraction<IFieldTypeFactory>(\"FieldType\");\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAIvD;AACA;AACA;;AASA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGD,iBAAiB,CAAoB,WAAW,CAAC","ignoreList":[]}
|
|
@@ -19,3 +19,6 @@ import "./fields/RefFieldType.js";
|
|
|
19
19
|
import "./fields/DynamicZoneFieldType.js";
|
|
20
20
|
import "./fields/JsonFieldType.js";
|
|
21
21
|
import "./fields/SearchableJsonFieldType.js";
|
|
22
|
+
import "./fields/UiSeparatorFieldType.js";
|
|
23
|
+
import "./fields/UiTabsFieldType.js";
|
|
24
|
+
import "./fields/UiAlertFieldType.js";
|
|
@@ -23,5 +23,8 @@ import "./fields/DynamicZoneFieldType.js";
|
|
|
23
23
|
// import "./fields/LocationFieldType.js";
|
|
24
24
|
import "./fields/JsonFieldType.js";
|
|
25
25
|
import "./fields/SearchableJsonFieldType.js";
|
|
26
|
+
import "./fields/UiSeparatorFieldType.js";
|
|
27
|
+
import "./fields/UiTabsFieldType.js";
|
|
28
|
+
import "./fields/UiAlertFieldType.js";
|
|
26
29
|
|
|
27
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ModelFactory"],"sources":["index.ts"],"sourcesContent":["export { ModelFactory } from \"./abstractions.js\";\nexport * from \"./models/BaseModelBuilder.js\";\nexport * from \"./models/ModelBuilder.js\";\nexport * from \"./models/PrivateModelBuilder.js\";\nexport * from \"./models/PublicModelBuilder.js\";\nexport * from \"./feature.js\";\nexport * from \"./fields/FieldBuilder.js\";\nexport * from \"./fields/abstractions.js\";\nexport * from \"./models/abstractions.js\";\n\n// Import all field types to ensure their module augmentations are applied\n// These imports have side effects that add methods to IFieldBuilderRegistry\nimport \"./fields/TextFieldType.js\";\nimport \"./fields/LongTextFieldType.js\";\nimport \"./fields/RichTextFieldType.js\";\nimport \"./fields/NumberFieldType.js\";\nimport \"./fields/BooleanFieldType.js\";\nimport \"./fields/FileFieldType.js\";\nimport \"./fields/DateTimeFieldType.js\";\nimport \"./fields/ObjectFieldType.js\";\nimport \"./fields/RefFieldType.js\";\nimport \"./fields/DynamicZoneFieldType.js\";\n// import \"./fields/LocationFieldType.js\";\nimport \"./fields/JsonFieldType.js\";\nimport \"./fields/SearchableJsonFieldType.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ModelFactory"],"sources":["index.ts"],"sourcesContent":["export { ModelFactory } from \"./abstractions.js\";\nexport * from \"./models/BaseModelBuilder.js\";\nexport * from \"./models/ModelBuilder.js\";\nexport * from \"./models/PrivateModelBuilder.js\";\nexport * from \"./models/PublicModelBuilder.js\";\nexport * from \"./feature.js\";\nexport * from \"./fields/FieldBuilder.js\";\nexport * from \"./fields/abstractions.js\";\nexport * from \"./models/abstractions.js\";\n\n// Import all field types to ensure their module augmentations are applied\n// These imports have side effects that add methods to IFieldBuilderRegistry\nimport \"./fields/TextFieldType.js\";\nimport \"./fields/LongTextFieldType.js\";\nimport \"./fields/RichTextFieldType.js\";\nimport \"./fields/NumberFieldType.js\";\nimport \"./fields/BooleanFieldType.js\";\nimport \"./fields/FileFieldType.js\";\nimport \"./fields/DateTimeFieldType.js\";\nimport \"./fields/ObjectFieldType.js\";\nimport \"./fields/RefFieldType.js\";\nimport \"./fields/DynamicZoneFieldType.js\";\n// import \"./fields/LocationFieldType.js\";\nimport \"./fields/JsonFieldType.js\";\nimport \"./fields/SearchableJsonFieldType.js\";\nimport \"./fields/UiSeparatorFieldType.js\";\nimport \"./fields/UiTabsFieldType.js\";\nimport \"./fields/UiAlertFieldType.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CmsModelPlugin } from "../../../plugins/
|
|
1
|
+
import { BaseFieldBuilder } from "../../../features/modelBuilder/index.js";
|
|
2
|
+
import { CmsModelPlugin } from "../../../plugins/CmsModelPlugin.js";
|
|
3
3
|
import { FieldBuilderRegistry } from "../abstractions.js";
|
|
4
|
+
import type { CmsModelField, CmsModelLayoutCell } from "../../../types/index.js";
|
|
4
5
|
/**
|
|
5
6
|
* Base class for all model builders, containing shared logic.
|
|
6
7
|
* Concrete builders (PrivateModelBuilder, PublicModelBuilder) extend this.
|
|
@@ -13,13 +14,13 @@ export declare abstract class BaseModelBuilder<TBuild = CmsModelPlugin> {
|
|
|
13
14
|
tags?: string[];
|
|
14
15
|
};
|
|
15
16
|
protected isSingleEntry: boolean;
|
|
16
|
-
protected fieldBuildersMap: Map<string,
|
|
17
|
+
protected fieldBuildersMap: Map<string, BaseFieldBuilder<any>>;
|
|
17
18
|
constructor(registry: FieldBuilderRegistry.Interface);
|
|
18
19
|
modelId(id: string): this;
|
|
19
20
|
name(name: string): this;
|
|
20
21
|
singleEntry(): this;
|
|
21
22
|
tags(tags: string[]): this;
|
|
22
|
-
fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string,
|
|
23
|
+
fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>): this;
|
|
23
24
|
/**
|
|
24
25
|
* Merge field operations from extension builder into existing builder.
|
|
25
26
|
* This handles the case where multiple fields of the same type exist,
|
|
@@ -28,6 +29,10 @@ export declare abstract class BaseModelBuilder<TBuild = CmsModelPlugin> {
|
|
|
28
29
|
* @internal
|
|
29
30
|
*/
|
|
30
31
|
private mergeFieldOperations;
|
|
32
|
+
protected buildFields(): {
|
|
33
|
+
fields: CmsModelField[];
|
|
34
|
+
layoutReplacements: Map<string, CmsModelLayoutCell>;
|
|
35
|
+
};
|
|
31
36
|
/**
|
|
32
37
|
* Get tags with common defaults applied.
|
|
33
38
|
* Always includes "type:model" and optionally "singleEntry".
|
|
@@ -98,6 +98,25 @@ export class BaseModelBuilder {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
buildFields() {
|
|
102
|
+
const fields = [];
|
|
103
|
+
const layoutReplacements = new Map();
|
|
104
|
+
for (const [fieldId, builder] of this.fieldBuildersMap) {
|
|
105
|
+
const result = builder.build();
|
|
106
|
+
if (result.type === "layout") {
|
|
107
|
+
layoutReplacements.set(fieldId, result.layoutCell);
|
|
108
|
+
if (result.fields) {
|
|
109
|
+
fields.push(...result.fields);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
fields.push(result.field);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
fields,
|
|
117
|
+
layoutReplacements
|
|
118
|
+
};
|
|
119
|
+
}
|
|
101
120
|
|
|
102
121
|
/**
|
|
103
122
|
* Get tags with common defaults applied.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseModelBuilder","config","isSingleEntry","fieldBuildersMap","Map","constructor","registry","modelId","id","name","singleEntry","tags","fields","builder","existingFields","fieldBuilders","key","fieldBuilder","Object","entries","fieldId","existingBuilder","get","isExtendMode","_extendMode","type","Error","mergeFieldOperations","set","existing","extension","existingFieldMap","extensionFieldMap","nestedKey","nestedBuilder","existingLayoutBuilder","layoutBuilder","extensionLayoutBuilder","snapshot","getSnapshot","layout","length","modifiers","setLayout","modifier","addModifier","getTags","tagsSet","Set","add","Array","from"],"sources":["BaseModelBuilder.ts"],"sourcesContent":["import { FieldBuilder } from \"~/features/modelBuilder/index.js\";\nimport { CmsModelPlugin } from \"~/plugins/index.js\";\nimport { FieldBuilderRegistry } from \"../abstractions.js\";\n\n/**\n * Base class for all model builders, containing shared logic.\n * Concrete builders (PrivateModelBuilder, PublicModelBuilder) extend this.\n */\nexport abstract class BaseModelBuilder<TBuild = CmsModelPlugin> {\n protected config: {\n modelId?: string;\n name?: string;\n tags?: string[];\n } = {};\n\n protected isSingleEntry = false;\n protected fieldBuildersMap = new Map<string, FieldBuilder<any>>();\n\n public constructor(protected registry: FieldBuilderRegistry.Interface) {}\n\n modelId(id: string): this {\n this.config.modelId = id;\n return this;\n }\n\n name(name: string): this {\n this.config.name = name;\n return this;\n }\n\n singleEntry(): this {\n this.isSingleEntry = true;\n return this;\n }\n\n tags(tags: string[]): this {\n this.config.tags = tags;\n return this;\n }\n\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, FieldBuilder<any>>\n ): this {\n // Pass existing fields to registry so it can return them when extending\n (this.registry as any).existingFields = this.fieldBuildersMap;\n\n const fieldBuilders = builder(this.registry);\n\n for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {\n // Set the fieldId from the object key\n fieldBuilder.fieldId(key);\n\n const existingBuilder = this.fieldBuildersMap.get(key);\n const isExtendMode = (fieldBuilder as any)._extendMode;\n\n if (isExtendMode && existingBuilder) {\n // Extension mode - validate type and merge operations\n if (existingBuilder.type !== fieldBuilder.type) {\n throw new Error(\n `Cannot extend field \"${key}\": type mismatch. Expected \"${existingBuilder.type}\", got \"${fieldBuilder.type}\".`\n );\n }\n // Merge operations from temporary new builder into existing builder\n this.mergeFieldOperations(key, existingBuilder, fieldBuilder);\n } else if (existingBuilder && !isExtendMode) {\n // Replacement mode - validate type\n if (existingBuilder.type !== fieldBuilder.type) {\n throw new Error(\n `Cannot redefine field \"${key}\": type mismatch. Expected \"${existingBuilder.type}\", got \"${fieldBuilder.type}\".`\n );\n }\n // Replace with new builder\n this.fieldBuildersMap.set(key, fieldBuilder);\n } else if (!existingBuilder && !isExtendMode) {\n // New field - store builder\n this.fieldBuildersMap.set(key, fieldBuilder);\n } else {\n // isExtendMode but no existingBuilder - this is an error\n throw new Error(\n `Cannot extend field \"${key}\": field does not exist. Use .extend() only for existing fields.`\n );\n }\n }\n\n return this;\n }\n\n /**\n * Merge field operations from extension builder into existing builder.\n * This handles the case where multiple fields of the same type exist,\n * and we need to transfer operations from the temporary new builder\n * to the existing builder.\n * @internal\n */\n private mergeFieldOperations(\n fieldId: string,\n existing: FieldBuilder<any>,\n extension: FieldBuilder<any>\n ): void {\n // For object fields, merge nested fields and layout operations\n if (existing.type === \"object\" && extension.type === \"object\") {\n const existingFieldMap = (existing as any).fieldBuildersMap;\n const extensionFieldMap = (extension as any).fieldBuildersMap;\n\n // Merge nested field builders\n if (extensionFieldMap) {\n for (const [nestedKey, nestedBuilder] of extensionFieldMap.entries()) {\n existingFieldMap.set(nestedKey, nestedBuilder);\n }\n }\n\n // Merge layout operations\n const existingLayoutBuilder = (existing as any).layoutBuilder;\n const extensionLayoutBuilder = (extension as any).layoutBuilder;\n\n if (extensionLayoutBuilder) {\n const snapshot = extensionLayoutBuilder.getSnapshot();\n\n // If extension called setLayout() with an array, apply it to existing\n // We detect this by checking if there's a layout but no modifiers\n if (snapshot.layout.length > 0 && snapshot.modifiers.length === 0) {\n existingLayoutBuilder.setLayout(snapshot.layout);\n }\n\n // Apply all modifiers from extension to existing\n for (const modifier of snapshot.modifiers) {\n existingLayoutBuilder.addModifier(modifier);\n }\n }\n }\n }\n\n /**\n * Get tags with common defaults applied.\n * Always includes \"type:model\" and optionally \"singleEntry\".\n */\n protected getTags(): string[] {\n const tagsSet = new Set(this.config.tags || []);\n tagsSet.add(\"type:model\");\n if (this.isSingleEntry) {\n tagsSet.add(\"singleEntry\");\n }\n return Array.from(tagsSet);\n }\n\n /**\n * Build the final model configu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AAgB,CAACH,GAAG,CAACK,SAAS,EAAEC,aAAa,CAAC;QAClD;MACJ;;MAEA;MACA,MAAMC,qBAAqB,GAAIN,QAAQ,CAASO,aAAa;MAC7D,MAAMC,sBAAsB,GAAIP,SAAS,CAASM,aAAa;MAE/D,IAAIC,sBAAsB,EAAE;QACxB,MAAMC,QAAQ,GAAGD,sBAAsB,CAACE,WAAW,CAAC,CAAC;;QAErD;QACA;QACA,IAAID,QAAQ,CAACE,MAAM,CAACC,MAAM,GAAG,CAAC,IAAIH,QAAQ,CAACI,SAAS,CAACD,MAAM,KAAK,CAAC,EAAE;UAC/DN,qBAAqB,CAACQ,SAAS,CAACL,QAAQ,CAACE,MAAM,CAAC;QACpD;;QAEA;QACA,KAAK,MAAMI,QAAQ,IAAIN,QAAQ,CAACI,SAAS,EAAE;UACvCP,qBAAqB,CAACU,WAAW,CAACD,QAAQ,CAAC;QAC/C;MACJ;IACJ;EACJ;;EAEA;AACJ;AACA;AACA;EACcE,OAAOA,CAAA,EAAa;IAC1B,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAC,IAAI,CAAC/C,MAAM,CAACU,IAAI,IAAI,EAAE,CAAC;IAC/CoC,OAAO,CAACE,GAAG,CAAC,YAAY,CAAC;IACzB,IAAI,IAAI,CAAC/C,aAAa,EAAE;MACpB6C,OAAO,CAACE,GAAG,CAAC,aAAa,CAAC;IAC9B;IACA,OAAOC,KAAK,CAACC,IAAI,CAACJ,OAAO,CAAC;EAC9B;;EAEA;AACJ;AACA;AACA;AAEA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BaseModelBuilder","config","isSingleEntry","fieldBuildersMap","Map","constructor","registry","modelId","id","name","singleEntry","tags","fields","builder","existingFields","fieldBuilders","key","fieldBuilder","Object","entries","fieldId","existingBuilder","get","isExtendMode","_extendMode","type","Error","mergeFieldOperations","set","existing","extension","existingFieldMap","extensionFieldMap","nestedKey","nestedBuilder","existingLayoutBuilder","layoutBuilder","extensionLayoutBuilder","snapshot","getSnapshot","layout","length","modifiers","setLayout","modifier","addModifier","buildFields","layoutReplacements","result","build","layoutCell","push","field","getTags","tagsSet","Set","add","Array","from"],"sources":["BaseModelBuilder.ts"],"sourcesContent":["import { BaseFieldBuilder } from \"~/features/modelBuilder/index.js\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin.js\";\nimport { FieldBuilderRegistry } from \"../abstractions.js\";\nimport type { CmsModelField, CmsModelLayoutCell } from \"~/types/index.js\";\n\n/**\n * Base class for all model builders, containing shared logic.\n * Concrete builders (PrivateModelBuilder, PublicModelBuilder) extend this.\n */\nexport abstract class BaseModelBuilder<TBuild = CmsModelPlugin> {\n protected config: {\n modelId?: string;\n name?: string;\n tags?: string[];\n } = {};\n\n protected isSingleEntry = false;\n protected fieldBuildersMap = new Map<string, BaseFieldBuilder<any>>();\n\n public constructor(protected registry: FieldBuilderRegistry.Interface) {}\n\n modelId(id: string): this {\n this.config.modelId = id;\n return this;\n }\n\n name(name: string): this {\n this.config.name = name;\n return this;\n }\n\n singleEntry(): this {\n this.isSingleEntry = true;\n return this;\n }\n\n tags(tags: string[]): this {\n this.config.tags = tags;\n return this;\n }\n\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>\n ): this {\n // Pass existing fields to registry so it can return them when extending\n (this.registry as any).existingFields = this.fieldBuildersMap;\n\n const fieldBuilders = builder(this.registry);\n\n for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {\n // Set the fieldId from the object key\n fieldBuilder.fieldId(key);\n\n const existingBuilder = this.fieldBuildersMap.get(key);\n const isExtendMode = (fieldBuilder as any)._extendMode;\n\n if (isExtendMode && existingBuilder) {\n // Extension mode - validate type and merge operations\n if (existingBuilder.type !== fieldBuilder.type) {\n throw new Error(\n `Cannot extend field \"${key}\": type mismatch. Expected \"${existingBuilder.type}\", got \"${fieldBuilder.type}\".`\n );\n }\n // Merge operations from temporary new builder into existing builder\n this.mergeFieldOperations(key, existingBuilder, fieldBuilder);\n } else if (existingBuilder && !isExtendMode) {\n // Replacement mode - validate type\n if (existingBuilder.type !== fieldBuilder.type) {\n throw new Error(\n `Cannot redefine field \"${key}\": type mismatch. Expected \"${existingBuilder.type}\", got \"${fieldBuilder.type}\".`\n );\n }\n // Replace with new builder\n this.fieldBuildersMap.set(key, fieldBuilder);\n } else if (!existingBuilder && !isExtendMode) {\n // New field - store builder\n this.fieldBuildersMap.set(key, fieldBuilder);\n } else {\n // isExtendMode but no existingBuilder - this is an error\n throw new Error(\n `Cannot extend field \"${key}\": field does not exist. Use .extend() only for existing fields.`\n );\n }\n }\n\n return this;\n }\n\n /**\n * Merge field operations from extension builder into existing builder.\n * This handles the case where multiple fields of the same type exist,\n * and we need to transfer operations from the temporary new builder\n * to the existing builder.\n * @internal\n */\n private mergeFieldOperations(\n fieldId: string,\n existing: BaseFieldBuilder<any>,\n extension: BaseFieldBuilder<any>\n ): void {\n // For object fields, merge nested fields and layout operations\n if (existing.type === \"object\" && extension.type === \"object\") {\n const existingFieldMap = (existing as any).fieldBuildersMap;\n const extensionFieldMap = (extension as any).fieldBuildersMap;\n\n // Merge nested field builders\n if (extensionFieldMap) {\n for (const [nestedKey, nestedBuilder] of extensionFieldMap.entries()) {\n existingFieldMap.set(nestedKey, nestedBuilder);\n }\n }\n\n // Merge layout operations\n const existingLayoutBuilder = (existing as any).layoutBuilder;\n const extensionLayoutBuilder = (extension as any).layoutBuilder;\n\n if (extensionLayoutBuilder) {\n const snapshot = extensionLayoutBuilder.getSnapshot();\n\n // If extension called setLayout() with an array, apply it to existing\n // We detect this by checking if there's a layout but no modifiers\n if (snapshot.layout.length > 0 && snapshot.modifiers.length === 0) {\n existingLayoutBuilder.setLayout(snapshot.layout);\n }\n\n // Apply all modifiers from extension to existing\n for (const modifier of snapshot.modifiers) {\n existingLayoutBuilder.addModifier(modifier);\n }\n }\n }\n }\n\n protected buildFields(): {\n fields: CmsModelField[];\n layoutReplacements: Map<string, CmsModelLayoutCell>;\n } {\n const fields: CmsModelField[] = [];\n const layoutReplacements = new Map<string, CmsModelLayoutCell>();\n\n for (const [fieldId, builder] of this.fieldBuildersMap) {\n const result = builder.build();\n if (result.type === \"layout\") {\n layoutReplacements.set(fieldId, result.layoutCell);\n if (result.fields) {\n fields.push(...result.fields);\n }\n } else {\n fields.push(result.field);\n }\n }\n\n return { fields, layoutReplacements };\n }\n\n /**\n * Get tags with common defaults applied.\n * Always includes \"type:model\" and optionally \"singleEntry\".\n */\n protected getTags(): string[] {\n const tagsSet = new Set(this.config.tags || []);\n tagsSet.add(\"type:model\");\n if (this.isSingleEntry) {\n tagsSet.add(\"singleEntry\");\n }\n return Array.from(tagsSet);\n }\n\n /**\n * Build the final model configuration.\n * Must be implemented by concrete builders.\n */\n abstract build(): TBuild;\n}\n"],"mappings":"AAKA;AACA;AACA;AACA;AACA,OAAO,MAAeA,gBAAgB,CAA0B;EAClDC,MAAM,GAIZ,CAAC,CAAC;EAEIC,aAAa,GAAG,KAAK;EACrBC,gBAAgB,GAAG,IAAIC,GAAG,CAAgC,CAAC;EAE9DC,WAAWA,CAAWC,QAAwC,EAAE;IAAA,KAA1CA,QAAwC,GAAxCA,QAAwC;EAAG;EAExEC,OAAOA,CAACC,EAAU,EAAQ;IACtB,IAAI,CAACP,MAAM,CAACM,OAAO,GAAGC,EAAE;IACxB,OAAO,IAAI;EACf;EAEAC,IAAIA,CAACA,IAAY,EAAQ;IACrB,IAAI,CAACR,MAAM,CAACQ,IAAI,GAAGA,IAAI;IACvB,OAAO,IAAI;EACf;EAEAC,WAAWA,CAAA,EAAS;IAChB,IAAI,CAACR,aAAa,GAAG,IAAI;IACzB,OAAO,IAAI;EACf;EAEAS,IAAIA,CAACA,IAAc,EAAQ;IACvB,IAAI,CAACV,MAAM,CAACU,IAAI,GAAGA,IAAI;IACvB,OAAO,IAAI;EACf;EAEAC,MAAMA,CACFC,OAA4F,EACxF;IACJ;IACC,IAAI,CAACP,QAAQ,CAASQ,cAAc,GAAG,IAAI,CA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M6C,MAAM,GAAGnC,OAAO,CAACoC,KAAK,CAAC,CAAC;MAC9B,IAAID,MAAM,CAACvB,IAAI,KAAK,QAAQ,EAAE;QAC1BsB,kBAAkB,CAACnB,GAAG,CAACR,OAAO,EAAE4B,MAAM,CAACE,UAAU,CAAC;QAClD,IAAIF,MAAM,CAACpC,MAAM,EAAE;UACfA,MAAM,CAACuC,IAAI,CAAC,GAAGH,MAAM,CAACpC,MAAM,CAAC;QACjC;MACJ,CAAC,MAAM;QACHA,MAAM,CAACuC,IAAI,CAACH,MAAM,CAACI,KAAK,CAAC;MAC7B;IACJ;IAEA,OAAO;MAAExC,MAAM;MAAEmC;IAAmB,CAAC;EACzC;;EAEA;AACJ;AACA;AACA;EACcM,OAAOA,CAAA,EAAa;IAC1B,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAC,IAAI,CAACtD,MAAM,CAACU,IAAI,IAAI,EAAE,CAAC;IAC/C2C,OAAO,CAACE,GAAG,CAAC,YAAY,CAAC;IACzB,IAAI,IAAI,CAACtD,aAAa,EAAE;MACpBoD,OAAO,CAACE,GAAG,CAAC,aAAa,CAAC;IAC9B;IACA,OAAOC,KAAK,CAACC,IAAI,CAACJ,OAAO,CAAC;EAC9B;;EAEA;AACJ;AACA;AACA;AAEA","ignoreList":[]}
|
|
@@ -12,8 +12,10 @@ export class PrivateModelBuilder extends BaseModelBuilder {
|
|
|
12
12
|
throw new Error("fields are required");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// Build all fields from field builders
|
|
16
|
-
const
|
|
15
|
+
// Build all fields from field builders (layout replacements ignored for private models)
|
|
16
|
+
const {
|
|
17
|
+
fields
|
|
18
|
+
} = this.buildFields();
|
|
17
19
|
return createPrivateModelPlugin({
|
|
18
20
|
modelId: this.config.modelId,
|
|
19
21
|
name: this.config.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPrivateModelPlugin","BaseModelBuilder","PrivateModelBuilder","build","config","modelId","Error","name","fieldBuildersMap","size","fields","
|
|
1
|
+
{"version":3,"names":["createPrivateModelPlugin","BaseModelBuilder","PrivateModelBuilder","build","config","modelId","Error","name","fieldBuildersMap","size","fields","buildFields","authorization","noValidate","tags","getTags"],"sources":["PrivateModelBuilder.ts"],"sourcesContent":["import { createPrivateModelPlugin } from \"~/plugins/CmsModelPlugin.js\";\nimport { BaseModelBuilder } from \"./BaseModelBuilder.js\";\n\nexport class PrivateModelBuilder extends BaseModelBuilder {\n public build() {\n if (!this.config.modelId) {\n throw new Error(\"modelId is required\");\n }\n if (!this.config.name) {\n throw new Error(\"name is required\");\n }\n if (this.fieldBuildersMap.size === 0) {\n throw new Error(\"fields are required\");\n }\n\n // Build all fields from field builders (layout replacements ignored for private models)\n const { fields } = this.buildFields();\n\n return createPrivateModelPlugin({\n modelId: this.config.modelId,\n name: this.config.name,\n fields,\n authorization: false,\n noValidate: true,\n tags: this.getTags()\n });\n }\n}\n"],"mappings":"AAAA,SAASA,wBAAwB;AACjC,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,mBAAmB,SAASD,gBAAgB,CAAC;EAC/CE,KAAKA,CAAA,EAAG;IACX,IAAI,CAAC,IAAI,CAACC,MAAM,CAACC,OAAO,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;IAC1C;IACA,IAAI,CAAC,IAAI,CAACF,MAAM,CAACG,IAAI,EAAE;MACnB,MAAM,IAAID,KAAK,CAAC,kBAAkB,CAAC;IACvC;IACA,IAAI,IAAI,CAACE,gBAAgB,CAACC,IAAI,KAAK,CAAC,EAAE;MAClC,MAAM,IAAIH,KAAK,CAAC,qBAAqB,CAAC;IAC1C;;IAEA;IACA,MAAM;MAAEI;IAAO,CAAC,GAAG,IAAI,CAACC,WAAW,CAAC,CAAC;IAErC,OAAOX,wBAAwB,CAAC;MAC5BK,OAAO,EAAE,IAAI,CAACD,MAAM,CAACC,OAAO;MAC5BE,IAAI,EAAE,IAAI,CAACH,MAAM,CAACG,IAAI;MACtBG,MAAM;MACNE,aAAa,EAAE,KAAK;MACpBC,UAAU,EAAE,IAAI;MAChBC,IAAI,EAAE,IAAI,CAACC,OAAO,CAAC;IACvB,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -81,14 +81,26 @@ export class PublicModelBuilder extends BaseModelBuilder {
|
|
|
81
81
|
throw new Error("name is required");
|
|
82
82
|
}
|
|
83
83
|
if (this.fieldBuildersMap.size === 0) {
|
|
84
|
-
|
|
84
|
+
this.fields(builder => ({
|
|
85
|
+
alert: builder.uiAlert().label("No fields defined in the code content model. Please ensure you have the fields property correctly defined."),
|
|
86
|
+
emptyPlaceholder: builder.text().label("Empty").renderer("hidden")
|
|
87
|
+
}));
|
|
88
|
+
this.titleFieldId("emptyPlaceholder");
|
|
89
|
+
this.layoutBuilder.setLayout([["alert"], ["emptyPlaceholder"]]);
|
|
85
90
|
}
|
|
86
91
|
if (!this.publicConfig.group) {
|
|
87
92
|
throw new Error("group is required");
|
|
88
93
|
}
|
|
89
94
|
|
|
90
|
-
// Build all fields from field builders
|
|
91
|
-
const
|
|
95
|
+
// Build all fields from field builders, separating data and layout results
|
|
96
|
+
const {
|
|
97
|
+
fields,
|
|
98
|
+
layoutReplacements
|
|
99
|
+
} = this.buildFields();
|
|
100
|
+
|
|
101
|
+
// Build and apply layout replacements (tabs → rich descriptors)
|
|
102
|
+
const rawLayout = this.layoutBuilder.build();
|
|
103
|
+
const layout = rawLayout.map(row => row.map(cell => layoutReplacements.get(cell) ?? cell));
|
|
92
104
|
return createModelPlugin({
|
|
93
105
|
modelId: this.config.modelId,
|
|
94
106
|
name: this.config.name,
|
|
@@ -100,7 +112,7 @@ export class PublicModelBuilder extends BaseModelBuilder {
|
|
|
100
112
|
titleFieldId: this.publicConfig.titleFieldId ?? this.findFirstFieldId(fields, "text"),
|
|
101
113
|
descriptionFieldId: this.publicConfig.descriptionFieldId,
|
|
102
114
|
imageFieldId: this.publicConfig.imageFieldId,
|
|
103
|
-
layout
|
|
115
|
+
layout,
|
|
104
116
|
fields,
|
|
105
117
|
tags: this.getTags()
|
|
106
118
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["upperFirst","camelCase","pluralize","createModelPlugin","BaseModelBuilder","LayoutBuilder","createApiName","name","createPluralApiName","Icon","from","icon","type","PublicModelBuilder","publicConfig","singularApiName","pluralApiName","group","slug","description","titleFieldId","fieldId","descriptionFieldId","imageFieldId","constructor","registry","layoutBuilder","layout","layoutOrBuilder","Array","isArray","setLayout","addModifier","build","config","modelId","Error","fieldBuildersMap","size","fields","values","map","builder","findFirstFieldId","tags","getTags","validateLayout","field","find"],"sources":["PublicModelBuilder.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\nimport pluralize from \"pluralize\";\nimport { createModelPlugin } from \"~/plugins/CmsModelPlugin.js\";\nimport { BaseModelBuilder } from \"./BaseModelBuilder.js\";\nimport type { CmsIcon, CmsModelField } from \"~/types/index.js\";\nimport { LayoutBuilder } from \"../LayoutBuilder.js\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\nclass Icon {\n static from(icon: string | CmsIcon): CmsIcon {\n if (typeof icon === \"string\") {\n return {\n type: \"icon\",\n name: icon\n };\n }\n\n return icon;\n }\n}\n\nexport class PublicModelBuilder extends BaseModelBuilder {\n private publicConfig: {\n singularApiName?: string;\n pluralApiName?: string;\n group?: string;\n icon?: CmsIcon;\n description?: string;\n titleFieldId?: string;\n descriptionFieldId?: string;\n imageFieldId?: string;\n } = {};\n private layoutBuilder: LayoutBuilder;\n\n singularApiName(name: string): this {\n this.publicConfig.singularApiName = name;\n return this;\n }\n\n pluralApiName(name: string): this {\n this.publicConfig.pluralApiName = name;\n return this;\n }\n\n group(slug: string): this {\n this.publicConfig.group = slug;\n return this;\n }\n\n icon(icon: string | CmsIcon): this {\n this.publicConfig.icon = Icon.from(icon);\n return this;\n }\n\n description(description: string): this {\n this.publicConfig.description = description;\n return this;\n }\n\n titleFieldId(fieldId: string): this {\n this.publicConfig.titleFieldId = fieldId;\n return this;\n }\n\n descriptionFieldId(fieldId: string): this {\n this.publicConfig.descriptionFieldId = fieldId;\n return this;\n }\n\n imageFieldId(fieldId: string): this {\n this.publicConfig.imageFieldId = fieldId;\n return this;\n }\n /**\n * It just creates problems if we import the FieldBuilderRegistry.\n * TODO: figure out\n */\n constructor(registry: any) {\n super(registry);\n this.layoutBuilder = new LayoutBuilder();\n }\n\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this {\n if (Array.isArray(layoutOrBuilder)) {\n // Replace layout with array\n this.layoutBuilder.setLayout(layoutOrBuilder);\n } else {\n // Queue the modifier callback\n this.layoutBuilder.addModifier(layoutOrBuilder);\n }\n return this;\n }\n\n build() {\n if (!this.config.modelId) {\n throw new Error(\"modelId is required\");\n }\n if (!this.config.name) {\n throw new Error(\"name is required\");\n }\n if (this.fieldBuildersMap.size === 0) {\n throw new Error(\"fields are required\");\n }\n if (!this.publicConfig.group) {\n throw new Error(\"group is required\");\n }\n\n // Build all fields from field builders\n const fields = Array.from(this.fieldBuildersMap.values()).map(builder => builder.build());\n\n return createModelPlugin(\n {\n modelId: this.config.modelId,\n name: this.config.name,\n singularApiName:\n this.publicConfig.singularApiName || createApiName(this.config.name),\n pluralApiName:\n this.publicConfig.pluralApiName || createPluralApiName(this.config.name),\n group: this.publicConfig.group,\n icon: this.publicConfig.icon ?? null,\n description: this.publicConfig.description || null,\n titleFieldId:\n this.publicConfig.titleFieldId ?? this.findFirstFieldId(fields, \"text\"),\n descriptionFieldId: this.publicConfig.descriptionFieldId,\n imageFieldId: this.publicConfig.imageFieldId,\n layout: this.layoutBuilder.build(),\n fields,\n tags: this.getTags()\n },\n { validateLayout: false }\n );\n }\n\n private findFirstFieldId(fields: CmsModelField[], type: string): string {\n for (const field of fields) {\n if (field.type === type) {\n return field.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IAAIQ,KAAK,CAACnC,IAAI,KAAKA,IAAI,EAAE;QACrB,OAAOmC,KAAK,CAAC1B,OAAO;MACxB;IACJ;IACA,OAAOkB,MAAM,CAACS,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACnC,IAAI,KAAK,MAAM,CAAC,EAAES,OAAO,IAAI,EAAE;EACrE;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["upperFirst","camelCase","pluralize","createModelPlugin","BaseModelBuilder","LayoutBuilder","createApiName","name","createPluralApiName","Icon","from","icon","type","PublicModelBuilder","publicConfig","singularApiName","pluralApiName","group","slug","description","titleFieldId","fieldId","descriptionFieldId","imageFieldId","constructor","registry","layoutBuilder","layout","layoutOrBuilder","Array","isArray","setLayout","addModifier","build","config","modelId","Error","fieldBuildersMap","size","fields","builder","alert","uiAlert","label","emptyPlaceholder","text","renderer","layoutReplacements","buildFields","rawLayout","map","row","cell","get","findFirstFieldId","tags","getTags","validateLayout","field","find"],"sources":["PublicModelBuilder.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\nimport pluralize from \"pluralize\";\nimport { createModelPlugin } from \"~/plugins/CmsModelPlugin.js\";\nimport { BaseModelBuilder } from \"./BaseModelBuilder.js\";\nimport type { CmsIcon, CmsModelField } from \"~/types/index.js\";\nimport { LayoutBuilder } from \"../LayoutBuilder.js\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\nclass Icon {\n static from(icon: string | CmsIcon): CmsIcon {\n if (typeof icon === \"string\") {\n return {\n type: \"icon\",\n name: icon\n };\n }\n\n return icon;\n }\n}\n\nexport class PublicModelBuilder extends BaseModelBuilder {\n private publicConfig: {\n singularApiName?: string;\n pluralApiName?: string;\n group?: string;\n icon?: CmsIcon;\n description?: string;\n titleFieldId?: string;\n descriptionFieldId?: string;\n imageFieldId?: string;\n } = {};\n private layoutBuilder: LayoutBuilder;\n\n singularApiName(name: string): this {\n this.publicConfig.singularApiName = name;\n return this;\n }\n\n pluralApiName(name: string): this {\n this.publicConfig.pluralApiName = name;\n return this;\n }\n\n group(slug: string): this {\n this.publicConfig.group = slug;\n return this;\n }\n\n icon(icon: string | CmsIcon): this {\n this.publicConfig.icon = Icon.from(icon);\n return this;\n }\n\n description(description: string): this {\n this.publicConfig.description = description;\n return this;\n }\n\n titleFieldId(fieldId: string): this {\n this.publicConfig.titleFieldId = fieldId;\n return this;\n }\n\n descriptionFieldId(fieldId: string): this {\n this.publicConfig.descriptionFieldId = fieldId;\n return this;\n }\n\n imageFieldId(fieldId: string): this {\n this.publicConfig.imageFieldId = fieldId;\n return this;\n }\n /**\n * It just creates problems if we import the FieldBuilderRegistry.\n * TODO: figure out\n */\n constructor(registry: any) {\n super(registry);\n this.layoutBuilder = new LayoutBuilder();\n }\n\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this {\n if (Array.isArray(layoutOrBuilder)) {\n // Replace layout with array\n this.layoutBuilder.setLayout(layoutOrBuilder);\n } else {\n // Queue the modifier callback\n this.layoutBuilder.addModifier(layoutOrBuilder);\n }\n return this;\n }\n\n build() {\n if (!this.config.modelId) {\n throw new Error(\"modelId is required\");\n }\n if (!this.config.name) {\n throw new Error(\"name is required\");\n }\n if (this.fieldBuildersMap.size === 0) {\n this.fields(builder => ({\n alert: builder\n .uiAlert()\n .label(\n \"No fields defined in the code content model. Please ensure you have the fields property correctly defined.\"\n ),\n emptyPlaceholder: builder.text().label(\"Empty\").renderer(\"hidden\")\n }));\n this.titleFieldId(\"emptyPlaceholder\");\n this.layoutBuilder.setLayout([[\"alert\"], [\"emptyPlaceholder\"]]);\n }\n if (!this.publicConfig.group) {\n throw new Error(\"group is required\");\n }\n\n // Build all fields from field builders, separating data and layout results\n const { fields, layoutReplacements } = this.buildFields();\n\n // Build and apply layout replacements (tabs → rich descriptors)\n const rawLayout = this.layoutBuilder.build();\n const layout = rawLayout.map(row => row.map(cell => layoutReplacements.get(cell) ?? cell));\n\n return createModelPlugin(\n {\n modelId: this.config.modelId,\n name: this.config.name,\n singularApiName:\n this.publicConfig.singularApiName || createApiName(this.config.name),\n pluralApiName:\n this.publicConfig.pluralApiName || createPluralApiName(this.config.name),\n group: this.publicConfig.group,\n icon: this.publicConfig.icon ?? null,\n description: this.publicConfig.description || null,\n titleFieldId:\n this.publicConfig.titleFieldId ?? this.findFirstFieldId(fields, \"text\"),\n descriptionFieldId: this.publicConfig.descriptionFieldId,\n imageFieldId: this.publicConfig.imageFieldId,\n layout,\n fields,\n tags: this.getTags()\n },\n { validateLayout: false }\n );\n }\n\n private findFirstFieldId(fields: CmsModelField[], type: string): string {\n for (const field of fields) {\n if (field.type === type) {\n return field.fieldId;\n }\n }\n return fields.find(field => field.type === \"text\")?.fieldId || \"\";\n }\n}\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,sBAAsB;AAC7C,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,SAAS,MAAM,WAAW;AACjC,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AAEzB,SAASC,aAAa;AAEtB,MAAMC,aAAa,GAAIC,IAAY,IAAK;EACpC,OAAOP,UAAU,CAACC,SAAS,CAACM,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,MAAMC,mBAAmB,GAAID,IAAY,IAAK;EAC1C,OAAOL,SAAS,CAACI,aAAa,CAACC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAME,IAAI,CAAC;EACP,OAAOC,IAAIA,CAACC,IAAsB,EAAW;IACzC,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO;QACHC,IAAI,EAAE,MAAM;QACZL,IAAI,EAAEI;MACV,CAAC;IACL;IAEA,OAAOA,IAAI;EACf;AACJ;AAEA,OAAO,MAAME,kBAAkB,SAAST,gBAAgB,CAAC;EAC7CU,YAAY,GAShB,CAAC,CAAC;EAGNC,eAAeA,CAAC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import { graphQLHandlerFactory } from "./graphQLHandlerFactory.js";
|
|
2
2
|
import { createBaseSchema } from "./schema/baseSchema.js";
|
|
3
|
+
import { createCmsSchema } from "./schema/cms/index.js";
|
|
3
4
|
export const createGraphQL = params => {
|
|
4
|
-
return [createBaseSchema(), ...graphQLHandlerFactory(params)];
|
|
5
|
+
return [createBaseSchema(), createCmsSchema(), ...graphQLHandlerFactory(params)];
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/graphql/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["graphQLHandlerFactory","createBaseSchema","createGraphQL","params"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { GraphQLHandlerFactoryParams } from \"./graphQLHandlerFactory.js\";\nimport { graphQLHandlerFactory } from \"./graphQLHandlerFactory.js\";\nimport { createBaseSchema } from \"~/graphql/schema/baseSchema.js\";\n\nexport type CreateGraphQLParams = GraphQLHandlerFactoryParams;\nexport const createGraphQL = (params: CreateGraphQLParams): Plugin[] => {\n return [createBaseSchema(), ...graphQLHandlerFactory(params)];\n};\n"],"mappings":"AAEA,SAASA,qBAAqB;AAC9B,SAASC,gBAAgB;
|
|
1
|
+
{"version":3,"names":["graphQLHandlerFactory","createBaseSchema","createCmsSchema","createGraphQL","params"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { GraphQLHandlerFactoryParams } from \"./graphQLHandlerFactory.js\";\nimport { graphQLHandlerFactory } from \"./graphQLHandlerFactory.js\";\nimport { createBaseSchema } from \"~/graphql/schema/baseSchema.js\";\nimport { createCmsSchema } from \"~/graphql/schema/cms/index.js\";\n\nexport type CreateGraphQLParams = GraphQLHandlerFactoryParams;\nexport const createGraphQL = (params: CreateGraphQLParams): Plugin[] => {\n return [createBaseSchema(), createCmsSchema(), ...graphQLHandlerFactory(params)];\n};\n"],"mappings":"AAEA,SAASA,qBAAqB;AAC9B,SAASC,gBAAgB;AACzB,SAASC,eAAe;AAGxB,OAAO,MAAMC,aAAa,GAAIC,MAA2B,IAAe;EACpE,OAAO,CAACH,gBAAgB,CAAC,CAAC,EAAEC,eAAe,CAAC,CAAC,EAAE,GAAGF,qBAAqB,CAACI,MAAM,CAAC,CAAC;AACpF,CAAC","ignoreList":[]}
|
|
@@ -123,25 +123,27 @@ const createSchema = plugins => {
|
|
|
123
123
|
error: CmsError
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
inReview
|
|
129
|
-
rejected
|
|
130
|
-
approved
|
|
126
|
+
type CmsEntrySystem {
|
|
127
|
+
_empty: String
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
type
|
|
134
|
-
|
|
135
|
-
stepId: ID
|
|
136
|
-
stepName: String
|
|
137
|
-
state: CmsEntryStateType
|
|
130
|
+
type CmsEntryLive {
|
|
131
|
+
version: Int!
|
|
138
132
|
}
|
|
139
133
|
|
|
140
|
-
input
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
134
|
+
input CmsEntryLiveWhereInput {
|
|
135
|
+
version: Int
|
|
136
|
+
version_gt: Int
|
|
137
|
+
version_gte: Int
|
|
138
|
+
version_lt: Int
|
|
139
|
+
version_lte: Int
|
|
140
|
+
version_not: Int
|
|
141
|
+
version_in: [Int!]
|
|
142
|
+
version_not_in: [Int!]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
input ListWhereInputCmsEntrySystem {
|
|
146
|
+
_empty: String
|
|
145
147
|
}
|
|
146
148
|
`,
|
|
147
149
|
resolvers: {}
|
|
@@ -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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CmsContext } from "../../../types/index.js";
|
|
2
|
+
export interface CreateEntryArgs {
|
|
3
|
+
modelId: string;
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
fields: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const createCreateEntryResolver: () => ({ args, context }: {
|
|
8
|
+
args: CreateEntryArgs;
|
|
9
|
+
context: CmsContext;
|
|
10
|
+
}) => Promise<{}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getModel, getErrorMessage, buildFieldsSelection } from "./helpers.js";
|
|
2
|
+
export const createCreateEntryResolver = () => {
|
|
3
|
+
return async ({
|
|
4
|
+
args,
|
|
5
|
+
context
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
modelId,
|
|
9
|
+
data,
|
|
10
|
+
fields
|
|
11
|
+
} = args;
|
|
12
|
+
try {
|
|
13
|
+
const model = await getModel(context, modelId);
|
|
14
|
+
|
|
15
|
+
// Use manage API for creating entries.
|
|
16
|
+
const apiType = "manage";
|
|
17
|
+
const executeSchema = await context.cms.getExecutableSchema(apiType);
|
|
18
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
19
|
+
const query = /* GraphQL */`
|
|
20
|
+
mutation Create${model.singularApiName}($data: ${model.singularApiName}Input!) {
|
|
21
|
+
create${model.singularApiName}(data: $data) {
|
|
22
|
+
data {
|
|
23
|
+
${fieldsSelection}
|
|
24
|
+
}
|
|
25
|
+
error {
|
|
26
|
+
message
|
|
27
|
+
code
|
|
28
|
+
data
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const result = await executeSchema({
|
|
34
|
+
query,
|
|
35
|
+
variables: {
|
|
36
|
+
data
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const operationName = `create${model.singularApiName}`;
|
|
40
|
+
return result.data?.[operationName] || {
|
|
41
|
+
data: null,
|
|
42
|
+
error: null
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return {
|
|
46
|
+
data: null,
|
|
47
|
+
error: {
|
|
48
|
+
message: getErrorMessage(error, "Failed to create entry"),
|
|
49
|
+
code: "CREATE_ENTRY_ERROR"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=createEntryResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getModel","getErrorMessage","buildFieldsSelection","createCreateEntryResolver","args","context","modelId","data","fields","model","apiType","executeSchema","cms","getExecutableSchema","fieldsSelection","query","singularApiName","result","variables","operationName","error","message","code"],"sources":["createEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface CreateEntryArgs {\n modelId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createCreateEntryResolver = () => {\n return async ({ args, context }: { args: CreateEntryArgs; context: CmsContext }) => {\n const { modelId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for creating entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Create${model.singularApiName}($data: ${model.singularApiName}Input!) {\n create${model.singularApiName}(data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { data }\n })) as ExecutionResult;\n\n const operationName = `create${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to create entry\"),\n code: \"CREATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,oBAAoB;AAQxD,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAwD,CAAC,KAAK;IAChF,MAAM;MAAEC,OAAO;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGJ,IAAI;IAEtC,IAAI;MACA,MAAMK,KAAK,GAAG,MAAMT,QAAQ,CAACK,OAAO,EAAEC,OAAO,CAAC;;MAE9C;MACA,MAAMI,OAAoB,GAAG,QAAQ;MACrC,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACO,GAAG,CAACC,mBAAmB,CAACH,OAAO,CAAC;MAEpE,MAAMI,eAAe,GAAGZ,oBAAoB,CAACM,MAAM,CAAC;MAEpD,MAAMO,KAAK,GAAG,aAAc;AACxC,iCAAiCN,KAAK,CAACO,eAAe,WAAWP,KAAK,CAACO,eAAe;AACtF,4BAA4BP,KAAK,CAACO,eAAe;AACjD;AACA,8BAA8BF,eAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;MAED,MAAMG,MAAM,GAAI,MAAMN,aAAa,CAAC;QAChCI,KAAK;QACLG,SAAS,EAAE;UAAEX;QAAK;MACtB,CAAC,CAAqB;MAEtB,MAAMY,aAAa,GAAG,SAASV,KAAK,CAACO,eAAe,EAAE;MACtD,OAAOC,MAAM,CAACV,IAAI,GAAGY,aAAa,CAAC,IAAI;QAAEZ,IAAI,EAAE,IAAI;QAAEa,KAAK,EAAE;MAAK,CAAC;IACtE,CAAC,CAAC,OAAOA,KAAK,EAAE;MACZ,OAAO;QACHb,IAAI,EAAE,IAAI;QACVa,KAAK,EAAE;UACHC,OAAO,EAAEpB,eAAe,CAACmB,KAAK,EAAE,wBAAwB,CAAC;UACzDE,IAAI,EAAE;QACV;MACJ,CAAC;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CmsContext } from "../../../types/index.js";
|
|
2
|
+
export interface DeleteEntryRevisionArgs {
|
|
3
|
+
modelId: string;
|
|
4
|
+
revisionId: string;
|
|
5
|
+
permanent?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const createDeleteEntryRevisionResolver: () => ({ args, context }: {
|
|
8
|
+
args: DeleteEntryRevisionArgs;
|
|
9
|
+
context: CmsContext;
|
|
10
|
+
}) => Promise<{}>;
|