@webiny/api-headless-cms 6.4.12-beta.5 → 6.5.0-beta.1
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/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.js +33 -18
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry.crud.js +12 -39
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/defaultFields.js +3 -2
- package/crud/contentModel/defaultFields.js.map +1 -1
- package/crud/contentModel/validate/endingAllowed.js +1 -1
- package/crud/contentModel/validate/endingAllowed.js.map +1 -1
- package/crud/contentModel/validate/pluralApiName.js +1 -1
- package/crud/contentModel/validate/pluralApiName.js.map +1 -1
- package/crud/contentModel/validate/singularApiName.js +1 -1
- package/crud/contentModel/validate/singularApiName.js.map +1 -1
- package/crud/contentModel/validation.js +2 -2
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +4 -0
- package/domain/contentModel/schemas.js +5 -2
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModel/validation/endingAllowed.js +1 -1
- package/domain/contentModel/validation/endingAllowed.js.map +1 -1
- package/domain/contentModel/validation/pluralApiName.js +1 -1
- package/domain/contentModel/validation/pluralApiName.js.map +1 -1
- package/domain/contentModel/validation/singularApiName.js +1 -1
- package/domain/contentModel/validation/singularApiName.js.map +1 -1
- package/export/crud/exporting.js +2 -2
- package/export/crud/exporting.js.map +1 -1
- package/export/crud/imports/importGroups.js +2 -1
- package/export/crud/imports/importGroups.js.map +1 -1
- package/export/crud/imports/validateModels.js +1 -1
- package/export/crud/imports/validateModels.js.map +1 -1
- package/exports/api/cms/model.d.ts +4 -1
- package/exports/api/cms/model.js +2 -0
- package/extension.d.ts +3 -0
- package/extension.js +19 -0
- package/extension.js.map +1 -0
- package/features/contentEntry/ContentEntriesFeature.js +2 -0
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +1 -2
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +1 -3
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +4 -12
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
- package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +1 -0
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js +1 -3
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +1 -3
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +4 -10
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +3 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +3 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +3 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.d.ts +14 -0
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js +34 -0
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js.map +1 -0
- package/features/contentEntry/UpdateRevision/abstractions.d.ts +10 -0
- package/features/contentEntry/UpdateRevision/abstractions.js +5 -0
- package/features/contentEntry/UpdateRevision/abstractions.js.map +1 -0
- package/features/contentEntry/UpdateRevision/feature.d.ts +4 -0
- package/features/contentEntry/UpdateRevision/feature.js +11 -0
- package/features/contentEntry/UpdateRevision/feature.js.map +1 -0
- package/features/contentEntry/UpdateRevision/index.d.ts +1 -0
- package/features/contentEntry/UpdateRevision/index.js +1 -0
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
- package/features/contentEntry/ensureItemIds.d.ts +13 -0
- package/features/contentEntry/ensureItemIds.js +22 -0
- package/features/contentEntry/ensureItemIds.js.map +1 -0
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +9 -3
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +7 -5
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +48 -18
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +5 -3
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +22 -16
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
- package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +5 -3
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +17 -13
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
- package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +6 -6
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +17 -18
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
- package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +7 -3
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +73 -30
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/expiresAt.js +2 -2
- package/features/contentEntry/entryDataFactories/expiresAt.js.map +1 -1
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
- package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.d.ts +14 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js +32 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js +5 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/feature.d.ts +4 -0
- package/features/contentModel/ComponentMapGenerator/feature.js +11 -0
- package/features/contentModel/ComponentMapGenerator/feature.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/index.d.ts +2 -0
- package/features/contentModel/ComponentMapGenerator/index.js +2 -0
- package/features/contentModel/ContentModelFeature.js +6 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js +2 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +2 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.d.ts +19 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +56 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/abstractions.d.ts +11 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js +5 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/feature.d.ts +4 -0
- package/features/contentModel/RefModelsGenerator/feature.js +11 -0
- package/features/contentModel/RefModelsGenerator/feature.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/index.d.ts +2 -0
- package/features/contentModel/RefModelsGenerator/index.js +2 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.d.ts +16 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +54 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js +5 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.d.ts +4 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js +11 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.d.ts +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.js +1 -0
- package/features/graphql/feature.js +2 -0
- package/features/graphql/feature.js.map +1 -1
- package/features/graphql/fields/base/AssetToGraphQL.d.ts +26 -0
- package/features/graphql/fields/base/AssetToGraphQL.js +153 -0
- package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -0
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js +12 -2
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/ObjectToGraphQL.js +8 -5
- package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
- package/features/modelBuilder/abstractions.d.ts +9 -0
- package/features/modelBuilder/abstractions.js.map +1 -1
- package/features/modelBuilder/feature.js +2 -0
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/AssetFieldType.d.ts +20 -0
- package/features/modelBuilder/fields/AssetFieldType.js +46 -0
- package/features/modelBuilder/fields/AssetFieldType.js.map +1 -0
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +62 -18
- package/features/modelBuilder/fields/DataFieldBuilder.js +8 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +1 -0
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +2 -6
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/resolveAssetUrl.d.ts +35 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js +26 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js.map +1 -0
- package/features/modelBuilder/index.d.ts +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +3 -1
- package/features/modelBuilder/models/BaseModelBuilder.js +7 -0
- package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js +2 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PublicModelBuilder.js +2 -1
- package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
- package/features/sortMapper/SortMapper.js +2 -5
- package/features/sortMapper/SortMapper.js.map +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
- package/features/storage/fields/DateStorageTransform.js +4 -3
- package/features/storage/fields/DateStorageTransform.js.map +1 -1
- package/features/storage/fields/DynamicZoneStorageTransform.js +2 -2
- package/features/storage/fields/DynamicZoneStorageTransform.js.map +1 -1
- package/features/storage/fields/JsonStorageTransform.js +1 -1
- package/features/storage/fields/JsonStorageTransform.js.map +1 -1
- package/features/storage/fields/LongTextStorageTransform.js +1 -1
- package/features/storage/fields/LongTextStorageTransform.js.map +1 -1
- package/features/storage/fields/ObjectStorageTransform.js +27 -7
- package/features/storage/fields/ObjectStorageTransform.js.map +1 -1
- package/features/storage/fields/RichTextStorageTransform.js +1 -1
- package/features/storage/fields/RichTextStorageTransform.js.map +1 -1
- package/features/validation/validators/DateGteValidator.js +1 -1
- package/features/validation/validators/DateGteValidator.js.map +1 -1
- package/features/validation/validators/DateLteValidator.js +1 -1
- package/features/validation/validators/DateLteValidator.js.map +1 -1
- package/features/validation/validators/PatternValidator.js +1 -1
- package/features/validation/validators/PatternValidator.js.map +1 -1
- package/features/whereMapper/WhereMapper.js +10 -7
- package/features/whereMapper/WhereMapper.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +8 -2
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +8 -2
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/index.d.ts +1 -1
- package/graphql/getSchema/generateCacheKey.js +1 -1
- package/graphql/getSchema/generateCacheKey.js.map +1 -1
- package/graphql/scalars/RevisionId.js +1 -1
- package/graphql/scalars/RevisionId.js.map +1 -1
- package/graphql/schema/baseSchema.js +5 -25
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +3 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getModelResolver.d.ts +35 -0
- package/graphql/schema/cms/getModelResolver.js +49 -0
- package/graphql/schema/cms/getModelResolver.js.map +1 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js +9 -2
- package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -1
- package/graphql/schema/cms/helpers/expandFieldWildcards.d.ts +2 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js +13 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js.map +1 -0
- package/graphql/schema/cms/helpers/index.d.ts +1 -0
- package/graphql/schema/cms/helpers/index.js +1 -0
- package/graphql/schema/cms/helpers.d.ts +1 -0
- package/graphql/schema/cms/helpers.js +1 -0
- package/graphql/schema/cms/index.js +2 -1
- package/graphql/schema/cms/index.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +3 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/getModel.d.ts +8 -0
- package/graphql/schema/cms/resolvers/getModel.js +18 -0
- package/graphql/schema/cms/resolvers/getModel.js.map +1 -0
- package/graphql/schema/cms/resolvers/index.d.ts +1 -0
- package/graphql/schema/cms/resolvers/index.js +1 -0
- package/graphql/schema/cms/typeDefs/query.js +1 -0
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.js +5 -0
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
- package/graphql/schema/contentModels.js +40 -1
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/index.d.ts +2 -5
- package/index.js +1 -21
- package/package.json +27 -30
- package/plugins/CmsModelPlugin.js +12 -10
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/types/fields/dynamicZoneField.d.ts +1 -0
- package/types/model.d.ts +6 -0
- package/types/modelField.d.ts +13 -0
- package/types/types.d.ts +8 -4
- package/types/types.js.map +1 -1
- package/utils/caching/Cache.js +1 -1
- package/utils/caching/Cache.js.map +1 -1
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.d.ts +28 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js +324 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js.map +1 -0
- package/utils/contentModelToJsonSchema/index.d.ts +2 -0
- package/utils/contentModelToJsonSchema/index.js +1 -0
- package/utils/contentModelToJsonSchema/types.d.ts +24 -0
- package/utils/contentModelToJsonSchema/types.js +0 -0
- package/utils/createModelField.js +2 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/date.js +1 -1
- package/utils/date.js.map +1 -1
- package/utils/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/renderFields.js +1 -1
- package/utils/renderFields.js.map +1 -1
- package/index.js.map +0 -1
package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { createImplementation } from "@webiny/feature/api";
|
|
1
|
+
import { Result, createImplementation } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryDataFactory } from "./abstractions.js";
|
|
3
3
|
import { CmsContext } from "../../../shared/abstractions.js";
|
|
4
4
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
5
|
import { getDate } from "../../../../utils/date.js";
|
|
6
6
|
import { getIdentity } from "../../../../utils/identity.js";
|
|
7
|
-
import {
|
|
7
|
+
import { validateModelEntryData } from "../../../../crud/contentEntry/entryDataValidation.js";
|
|
8
|
+
import { EntryValidationError } from "../../../../domain/contentEntry/errors.js";
|
|
8
9
|
import { referenceFieldsMapping } from "../../../../crud/contentEntry/referenceFieldsMapping.js";
|
|
9
10
|
import { mapAndCleanUpdatedInputData } from "../mapAndCleanUpdatedInputData.js";
|
|
10
11
|
import { getSystem } from "../system.js";
|
|
11
12
|
import { getExpiresAt } from "../expiresAt.js";
|
|
13
|
+
import { ModelToAstConverter } from "../../../contentModel/ModelToAstConverter/abstractions.js";
|
|
14
|
+
import { ensureItemIds } from "../../ensureItemIds.js";
|
|
15
|
+
import { hasEntryContentChanged } from "../hasEntryContentChanged.js";
|
|
16
|
+
import { GetLatestRevisionByEntryIdUseCase } from "../../GetLatestRevisionByEntryId/index.js";
|
|
12
17
|
const allowedEntryStatus = [
|
|
13
18
|
"draft",
|
|
14
19
|
"published",
|
|
@@ -16,23 +21,33 @@ const allowedEntryStatus = [
|
|
|
16
21
|
];
|
|
17
22
|
const transformEntryStatus = (status)=>allowedEntryStatus.includes(status) ? status : "draft";
|
|
18
23
|
class UpdateEntryDataFactoryImpl {
|
|
19
|
-
constructor(cmsContext, identityContext){
|
|
24
|
+
constructor(cmsContext, identityContext, modelToAstConverter, getLatestRevision){
|
|
20
25
|
this.cmsContext = cmsContext;
|
|
21
26
|
this.identityContext = identityContext;
|
|
27
|
+
this.modelToAstConverter = modelToAstConverter;
|
|
28
|
+
this.getLatestRevision = getLatestRevision;
|
|
22
29
|
}
|
|
23
30
|
async create(model, rawInput, originalEntry, options) {
|
|
31
|
+
const latestResult = await this.getLatestRevision.execute(model, {
|
|
32
|
+
id: originalEntry.entryId
|
|
33
|
+
});
|
|
34
|
+
if (latestResult.isFail()) return Result.fail(latestResult.error);
|
|
35
|
+
const latestEntry = latestResult.value;
|
|
24
36
|
const cleanedValues = mapAndCleanUpdatedInputData(model, rawInput?.values || {});
|
|
25
|
-
await
|
|
37
|
+
const invalidFields = await validateModelEntryData({
|
|
26
38
|
context: this.cmsContext,
|
|
27
39
|
model,
|
|
28
40
|
values: cleanedValues,
|
|
29
41
|
entry: originalEntry,
|
|
30
|
-
|
|
42
|
+
skipValidation: options?.skipValidation
|
|
31
43
|
});
|
|
44
|
+
if (invalidFields.length > 0) return Result.fail(new EntryValidationError("Validation failed.", invalidFields));
|
|
32
45
|
const mergedValues = {
|
|
33
46
|
...originalEntry.values,
|
|
34
47
|
...cleanedValues
|
|
35
48
|
};
|
|
49
|
+
const modelAst = this.modelToAstConverter.toAst(model);
|
|
50
|
+
await ensureItemIds(modelAst, mergedValues);
|
|
36
51
|
const values = await referenceFieldsMapping({
|
|
37
52
|
context: this.cmsContext,
|
|
38
53
|
model,
|
|
@@ -41,36 +56,62 @@ class UpdateEntryDataFactoryImpl {
|
|
|
41
56
|
});
|
|
42
57
|
const currentIdentity = this.identityContext.getIdentity();
|
|
43
58
|
const currentDateTime = new Date();
|
|
59
|
+
const contentChanged = hasEntryContentChanged({
|
|
60
|
+
values,
|
|
61
|
+
baselineValues: originalEntry.values
|
|
62
|
+
});
|
|
63
|
+
const entryLevelSaved = contentChanged ? {
|
|
64
|
+
savedOn: currentDateTime,
|
|
65
|
+
modifiedOn: currentDateTime,
|
|
66
|
+
savedBy: currentIdentity,
|
|
67
|
+
modifiedBy: currentIdentity
|
|
68
|
+
} : {
|
|
69
|
+
savedOn: latestEntry.savedOn,
|
|
70
|
+
modifiedOn: latestEntry.modifiedOn,
|
|
71
|
+
savedBy: latestEntry.savedBy,
|
|
72
|
+
modifiedBy: latestEntry.modifiedBy
|
|
73
|
+
};
|
|
74
|
+
const revisionLevelSaved = contentChanged ? {
|
|
75
|
+
revisionSavedOn: currentDateTime,
|
|
76
|
+
revisionModifiedOn: currentDateTime,
|
|
77
|
+
revisionSavedBy: currentIdentity,
|
|
78
|
+
revisionModifiedBy: currentIdentity
|
|
79
|
+
} : {
|
|
80
|
+
revisionSavedOn: originalEntry.revisionSavedOn,
|
|
81
|
+
revisionModifiedOn: originalEntry.revisionModifiedOn,
|
|
82
|
+
revisionSavedBy: originalEntry.revisionSavedBy,
|
|
83
|
+
revisionModifiedBy: originalEntry.revisionModifiedBy
|
|
84
|
+
};
|
|
44
85
|
const entry = {
|
|
45
86
|
...originalEntry,
|
|
46
87
|
revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),
|
|
47
|
-
revisionModifiedOn: getDate(rawInput.revisionModifiedOn,
|
|
48
|
-
revisionSavedOn: getDate(rawInput.revisionSavedOn,
|
|
49
|
-
revisionDeletedOn: getDate(rawInput.revisionDeletedOn,
|
|
50
|
-
revisionRestoredOn: getDate(rawInput.revisionRestoredOn,
|
|
88
|
+
revisionModifiedOn: getDate(rawInput.revisionModifiedOn, revisionLevelSaved.revisionModifiedOn),
|
|
89
|
+
revisionSavedOn: getDate(rawInput.revisionSavedOn, revisionLevelSaved.revisionSavedOn),
|
|
90
|
+
revisionDeletedOn: getDate(rawInput.revisionDeletedOn, originalEntry.revisionDeletedOn),
|
|
91
|
+
revisionRestoredOn: getDate(rawInput.revisionRestoredOn, originalEntry.revisionRestoredOn),
|
|
51
92
|
revisionFirstPublishedOn: getDate(rawInput.revisionFirstPublishedOn, originalEntry.revisionFirstPublishedOn),
|
|
52
93
|
revisionLastPublishedOn: getDate(rawInput.revisionLastPublishedOn, originalEntry.revisionLastPublishedOn),
|
|
53
94
|
revisionCreatedBy: getIdentity(rawInput.revisionCreatedBy, originalEntry.revisionCreatedBy),
|
|
54
|
-
revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy,
|
|
55
|
-
revisionSavedBy: getIdentity(rawInput.revisionSavedBy,
|
|
56
|
-
revisionDeletedBy: getIdentity(rawInput.
|
|
57
|
-
revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy,
|
|
95
|
+
revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, revisionLevelSaved.revisionModifiedBy),
|
|
96
|
+
revisionSavedBy: getIdentity(rawInput.revisionSavedBy, revisionLevelSaved.revisionSavedBy),
|
|
97
|
+
revisionDeletedBy: getIdentity(rawInput.revisionDeletedBy, originalEntry.revisionDeletedBy),
|
|
98
|
+
revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, originalEntry.revisionRestoredBy),
|
|
58
99
|
revisionFirstPublishedBy: getIdentity(rawInput.revisionFirstPublishedBy, originalEntry.revisionFirstPublishedBy),
|
|
59
100
|
revisionLastPublishedBy: getIdentity(rawInput.revisionLastPublishedBy, originalEntry.revisionLastPublishedBy),
|
|
60
|
-
createdOn: getDate(rawInput.createdOn,
|
|
61
|
-
savedOn: getDate(rawInput.savedOn,
|
|
62
|
-
modifiedOn: getDate(rawInput.modifiedOn,
|
|
63
|
-
deletedOn: getDate(rawInput.deletedOn,
|
|
64
|
-
restoredOn: getDate(rawInput.restoredOn,
|
|
65
|
-
firstPublishedOn: getDate(rawInput.firstPublishedOn,
|
|
66
|
-
lastPublishedOn: getDate(rawInput.lastPublishedOn,
|
|
67
|
-
createdBy: getIdentity(rawInput.createdBy,
|
|
68
|
-
savedBy: getIdentity(rawInput.savedBy,
|
|
69
|
-
modifiedBy: getIdentity(rawInput.modifiedBy,
|
|
70
|
-
deletedBy: getIdentity(rawInput.deletedBy,
|
|
71
|
-
restoredBy: getIdentity(rawInput.restoredBy,
|
|
72
|
-
firstPublishedBy: getIdentity(rawInput.firstPublishedBy,
|
|
73
|
-
lastPublishedBy: getIdentity(rawInput.lastPublishedBy,
|
|
101
|
+
createdOn: getDate(rawInput.createdOn, latestEntry.createdOn),
|
|
102
|
+
savedOn: getDate(rawInput.savedOn, entryLevelSaved.savedOn),
|
|
103
|
+
modifiedOn: getDate(rawInput.modifiedOn, entryLevelSaved.modifiedOn),
|
|
104
|
+
deletedOn: getDate(rawInput.deletedOn, latestEntry.deletedOn),
|
|
105
|
+
restoredOn: getDate(rawInput.restoredOn, latestEntry.restoredOn),
|
|
106
|
+
firstPublishedOn: getDate(rawInput.firstPublishedOn, latestEntry.firstPublishedOn),
|
|
107
|
+
lastPublishedOn: getDate(rawInput.lastPublishedOn, latestEntry.lastPublishedOn),
|
|
108
|
+
createdBy: getIdentity(rawInput.createdBy, latestEntry.createdBy),
|
|
109
|
+
savedBy: getIdentity(rawInput.savedBy, entryLevelSaved.savedBy),
|
|
110
|
+
modifiedBy: getIdentity(rawInput.modifiedBy, entryLevelSaved.modifiedBy),
|
|
111
|
+
deletedBy: getIdentity(rawInput.deletedBy, latestEntry.deletedBy),
|
|
112
|
+
restoredBy: getIdentity(rawInput.restoredBy, latestEntry.restoredBy),
|
|
113
|
+
firstPublishedBy: getIdentity(rawInput.firstPublishedBy, latestEntry.firstPublishedBy),
|
|
114
|
+
lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestEntry.lastPublishedBy),
|
|
74
115
|
values,
|
|
75
116
|
status: transformEntryStatus(originalEntry.status),
|
|
76
117
|
system: getSystem({
|
|
@@ -86,13 +127,13 @@ class UpdateEntryDataFactoryImpl {
|
|
|
86
127
|
if (folderId) entry.location = {
|
|
87
128
|
folderId
|
|
88
129
|
};
|
|
89
|
-
return {
|
|
130
|
+
return Result.ok({
|
|
90
131
|
entry,
|
|
91
132
|
input: {
|
|
92
133
|
...rawInput,
|
|
93
134
|
values: structuredClone(values)
|
|
94
135
|
}
|
|
95
|
-
};
|
|
136
|
+
});
|
|
96
137
|
}
|
|
97
138
|
}
|
|
98
139
|
const UpdateEntryDataFactory_UpdateEntryDataFactory = createImplementation({
|
|
@@ -100,7 +141,9 @@ const UpdateEntryDataFactory_UpdateEntryDataFactory = createImplementation({
|
|
|
100
141
|
implementation: UpdateEntryDataFactoryImpl,
|
|
101
142
|
dependencies: [
|
|
102
143
|
CmsContext,
|
|
103
|
-
IdentityContext
|
|
144
|
+
IdentityContext,
|
|
145
|
+
ModelToAstConverter,
|
|
146
|
+
GetLatestRevisionByEntryIdUseCase
|
|
104
147
|
]
|
|
105
148
|
});
|
|
106
149
|
export { UpdateEntryDataFactory_UpdateEntryDataFactory as UpdateEntryDataFactory };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport {\n type IUpdateEntryDataFactory,\n type IUpdateEntryDataResponse,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryDataOrThrow } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>> {\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n await validateModelEntryDataOrThrow({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidators: options?.skipValidators\n });\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(rawInput.revisionModifiedOn, currentDateTime),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, currentDateTime),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, null),\n revisionRestoredOn: getDate(rawInput.revisionRestoredOn, null),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(rawInput.revisionModifiedBy, currentIdentity),\n revisionSavedBy: getIdentity(rawInput.revisionSavedBy, currentIdentity)!,\n revisionDeletedBy: getIdentity(rawInput.revisionSavedBy, null),\n revisionRestoredBy: getIdentity(rawInput.revisionRestoredBy, null),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, originalEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, currentDateTime),\n modifiedOn: getDate(rawInput.modifiedOn, currentDateTime),\n deletedOn: getDate(rawInput.deletedOn, null),\n restoredOn: getDate(rawInput.restoredOn, null),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, originalEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, originalEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, originalEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, currentIdentity)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, currentIdentity),\n deletedBy: getIdentity(rawInput.deletedBy, null),\n restoredBy: getIdentity(rawInput.restoredBy, null),\n firstPublishedBy: getIdentity(\n rawInput.firstPublishedBy,\n originalEntry.firstPublishedBy\n ),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, originalEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt }, originalEntry)\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return {\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n };\n }\n}\n\nexport const UpdateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [CmsContext, IdentityContext]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","model","rawInput","originalEntry","options","cleanedValues","mapAndCleanUpdatedInputData","validateModelEntryDataOrThrow","mergedValues","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","entry","getDate","getIdentity","getSystem","getExpiresAt","folderId","structuredClone","UpdateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport {\n type IUpdateEntryDataFactory,\n UpdateEntryDataFactory as FactoryAbstraction\n} from \"./abstractions.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryStatus,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { validateModelEntryData } from \"~/crud/contentEntry/entryDataValidation.js\";\nimport { EntryValidationError } from \"~/domain/contentEntry/errors.js\";\nimport { referenceFieldsMapping } from \"~/crud/contentEntry/referenceFieldsMapping.js\";\nimport { mapAndCleanUpdatedInputData } from \"../mapAndCleanUpdatedInputData.js\";\nimport { getSystem } from \"../system.js\";\nimport { getExpiresAt } from \"../expiresAt.js\";\nimport { ModelToAstConverter } from \"~/features/contentModel/ModelToAstConverter/abstractions.js\";\nimport { ensureItemIds } from \"../../ensureItemIds.js\";\nimport { hasEntryContentChanged } from \"../hasEntryContentChanged.js\";\nimport { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\n\nconst allowedEntryStatus: string[] = [\"draft\", \"published\", \"unpublished\"];\n\nconst transformEntryStatus = (status: CmsEntryStatus | string): CmsEntryStatus => {\n return allowedEntryStatus.includes(status) ? (status as CmsEntryStatus) : \"draft\";\n};\n\nclass UpdateEntryDataFactoryImpl implements IUpdateEntryDataFactory {\n public constructor(\n private readonly cmsContext: CmsContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly modelToAstConverter: ModelToAstConverter.Interface,\n private readonly getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface\n ) {}\n\n public async create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<FactoryAbstraction.Return<TValues>> {\n const latestResult = await this.getLatestRevision.execute<TValues>(model, {\n id: originalEntry.entryId\n });\n if (latestResult.isFail()) {\n return Result.fail(latestResult.error);\n }\n const latestEntry = latestResult.value;\n\n const cleanedValues = mapAndCleanUpdatedInputData<TValues>(\n model,\n rawInput?.values || ({} as TValues)\n );\n\n const invalidFields = await validateModelEntryData({\n context: this.cmsContext,\n model,\n values: cleanedValues,\n entry: originalEntry,\n skipValidation: options?.skipValidation\n });\n if (invalidFields.length > 0) {\n return Result.fail(new EntryValidationError(\"Validation failed.\", invalidFields));\n }\n\n const mergedValues: TValues = {\n ...originalEntry.values,\n ...cleanedValues\n };\n\n const modelAst = this.modelToAstConverter.toAst(model);\n await ensureItemIds(modelAst, mergedValues);\n\n const values = await referenceFieldsMapping<TValues>({\n context: this.cmsContext,\n model,\n values: mergedValues,\n validateEntries: false\n });\n\n const currentIdentity = this.identityContext.getIdentity();\n const currentDateTime = new Date();\n\n /**\n * Saving without changing the content (e.g. clicking \"Save\" without editing anything) is\n * not a modification, so the saved/modified meta fields are kept. Entry-level values are\n * then taken from the latest revision, because storage copies them onto the latest\n * revision when a non-latest revision is updated. Revision-level values are this\n * revision's own. Explicitly provided meta field values always take precedence.\n */\n const contentChanged = hasEntryContentChanged({\n values,\n baselineValues: originalEntry.values\n });\n\n const entryLevelSaved = contentChanged\n ? {\n savedOn: currentDateTime,\n modifiedOn: currentDateTime,\n savedBy: currentIdentity,\n modifiedBy: currentIdentity\n }\n : {\n savedOn: latestEntry.savedOn,\n modifiedOn: latestEntry.modifiedOn,\n savedBy: latestEntry.savedBy,\n modifiedBy: latestEntry.modifiedBy\n };\n\n const revisionLevelSaved = contentChanged\n ? {\n revisionSavedOn: currentDateTime,\n revisionModifiedOn: currentDateTime,\n revisionSavedBy: currentIdentity,\n revisionModifiedBy: currentIdentity\n }\n : {\n revisionSavedOn: originalEntry.revisionSavedOn,\n revisionModifiedOn: originalEntry.revisionModifiedOn,\n revisionSavedBy: originalEntry.revisionSavedBy,\n revisionModifiedBy: originalEntry.revisionModifiedBy\n };\n\n const entry: CmsEntry<TValues> = {\n ...originalEntry,\n revisionCreatedOn: getDate(rawInput.revisionCreatedOn, originalEntry.revisionCreatedOn),\n revisionModifiedOn: getDate(\n rawInput.revisionModifiedOn,\n revisionLevelSaved.revisionModifiedOn\n ),\n revisionSavedOn: getDate(rawInput.revisionSavedOn, revisionLevelSaved.revisionSavedOn),\n revisionDeletedOn: getDate(rawInput.revisionDeletedOn, originalEntry.revisionDeletedOn),\n revisionRestoredOn: getDate(\n rawInput.revisionRestoredOn,\n originalEntry.revisionRestoredOn\n ),\n revisionFirstPublishedOn: getDate(\n rawInput.revisionFirstPublishedOn,\n originalEntry.revisionFirstPublishedOn\n ),\n revisionLastPublishedOn: getDate(\n rawInput.revisionLastPublishedOn,\n originalEntry.revisionLastPublishedOn\n ),\n revisionCreatedBy: getIdentity(\n rawInput.revisionCreatedBy,\n originalEntry.revisionCreatedBy\n )!,\n revisionModifiedBy: getIdentity(\n rawInput.revisionModifiedBy,\n revisionLevelSaved.revisionModifiedBy\n ),\n revisionSavedBy: getIdentity(\n rawInput.revisionSavedBy,\n revisionLevelSaved.revisionSavedBy\n )!,\n revisionDeletedBy: getIdentity(\n rawInput.revisionDeletedBy,\n originalEntry.revisionDeletedBy\n ),\n revisionRestoredBy: getIdentity(\n rawInput.revisionRestoredBy,\n originalEntry.revisionRestoredBy\n ),\n revisionFirstPublishedBy: getIdentity(\n rawInput.revisionFirstPublishedBy,\n originalEntry.revisionFirstPublishedBy\n ),\n revisionLastPublishedBy: getIdentity(\n rawInput.revisionLastPublishedBy,\n originalEntry.revisionLastPublishedBy\n ),\n createdOn: getDate(rawInput.createdOn, latestEntry.createdOn),\n savedOn: getDate(rawInput.savedOn, entryLevelSaved.savedOn),\n modifiedOn: getDate(rawInput.modifiedOn, entryLevelSaved.modifiedOn),\n deletedOn: getDate(rawInput.deletedOn, latestEntry.deletedOn),\n restoredOn: getDate(rawInput.restoredOn, latestEntry.restoredOn),\n firstPublishedOn: getDate(rawInput.firstPublishedOn, latestEntry.firstPublishedOn),\n lastPublishedOn: getDate(rawInput.lastPublishedOn, latestEntry.lastPublishedOn),\n createdBy: getIdentity(rawInput.createdBy, latestEntry.createdBy)!,\n savedBy: getIdentity(rawInput.savedBy, entryLevelSaved.savedBy)!,\n modifiedBy: getIdentity(rawInput.modifiedBy, entryLevelSaved.modifiedBy),\n deletedBy: getIdentity(rawInput.deletedBy, latestEntry.deletedBy),\n restoredBy: getIdentity(rawInput.restoredBy, latestEntry.restoredBy),\n firstPublishedBy: getIdentity(rawInput.firstPublishedBy, latestEntry.firstPublishedBy),\n lastPublishedBy: getIdentity(rawInput.lastPublishedBy, latestEntry.lastPublishedBy),\n values,\n status: transformEntryStatus(originalEntry.status),\n system: getSystem({\n input: rawInput,\n original: originalEntry\n }),\n live: originalEntry.live,\n expiresAt: getExpiresAt({ expiresAt: rawInput.expiresAt }, originalEntry)\n };\n\n const folderId = rawInput.wbyAco_location?.folderId;\n if (folderId) {\n entry.location = {\n folderId\n };\n }\n\n return Result.ok({\n entry,\n input: {\n ...rawInput,\n values: structuredClone(values)\n }\n });\n }\n}\n\nexport const UpdateEntryDataFactory = createImplementation({\n abstraction: FactoryAbstraction,\n implementation: UpdateEntryDataFactoryImpl,\n dependencies: [\n CmsContext,\n IdentityContext,\n ModelToAstConverter,\n GetLatestRevisionByEntryIdUseCase\n ]\n});\n"],"names":["allowedEntryStatus","transformEntryStatus","status","UpdateEntryDataFactoryImpl","cmsContext","identityContext","modelToAstConverter","getLatestRevision","model","rawInput","originalEntry","options","latestResult","Result","latestEntry","cleanedValues","mapAndCleanUpdatedInputData","invalidFields","validateModelEntryData","EntryValidationError","mergedValues","modelAst","ensureItemIds","values","referenceFieldsMapping","currentIdentity","currentDateTime","Date","contentChanged","hasEntryContentChanged","entryLevelSaved","revisionLevelSaved","entry","getDate","getIdentity","getSystem","getExpiresAt","folderId","structuredClone","UpdateEntryDataFactory","createImplementation","FactoryAbstraction","CmsContext","IdentityContext","ModelToAstConverter","GetLatestRevisionByEntryIdUseCase"],"mappings":"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"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GetLatestRevisionByEntryIdUseCase } from "../../../../features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
3
|
+
import type { EntryValidationError } from "../../../../domain/contentEntry/errors.js";
|
|
1
4
|
import type { CmsEntry, CmsEntryValues, CmsModel, UpdateCmsEntryInput, UpdateCmsEntryOptionsInput } from "../../../../types/index.js";
|
|
2
5
|
export interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
3
6
|
entry: CmsEntry<TValues>;
|
|
4
7
|
input: UpdateCmsEntryInput<TValues>;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Expected failures of building the data of an entry being updated.
|
|
11
|
+
*/
|
|
12
|
+
export interface IUpdateEntryDataFactoryErrors {
|
|
13
|
+
latest: GetLatestRevisionByEntryIdUseCase.Error;
|
|
14
|
+
validation: EntryValidationError;
|
|
15
|
+
}
|
|
16
|
+
type FactoryError = IUpdateEntryDataFactoryErrors[keyof IUpdateEntryDataFactoryErrors];
|
|
6
17
|
export interface IUpdateEntryDataFactory {
|
|
7
|
-
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: UpdateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, options?: UpdateCmsEntryOptionsInput): Promise<IUpdateEntryDataResponse<TValues>>;
|
|
18
|
+
create<TValues extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: UpdateCmsEntryInput<TValues>, originalEntry: CmsEntry<TValues>, options?: UpdateCmsEntryOptionsInput): Promise<Result<IUpdateEntryDataResponse<TValues>, FactoryError>>;
|
|
8
19
|
}
|
|
9
20
|
export declare const UpdateEntryDataFactory: import("@webiny/di").Abstraction<IUpdateEntryDataFactory>;
|
|
10
21
|
export declare namespace UpdateEntryDataFactory {
|
|
11
22
|
type Interface = IUpdateEntryDataFactory;
|
|
23
|
+
type Error = FactoryError;
|
|
24
|
+
type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<IUpdateEntryDataResponse<TValues>, FactoryError>;
|
|
12
25
|
type Response<TValues extends CmsEntryValues = CmsEntryValues> = IUpdateEntryDataResponse<TValues>;
|
|
13
26
|
}
|
|
27
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\n\nexport interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\nexport interface IUpdateEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<IUpdateEntryDataResponse<TValues>>;\n}\n\nexport const UpdateEntryDataFactory = createAbstraction<IUpdateEntryDataFactory>(\n \"Cms/Entry/UpdateEntryDataFactory\"\n);\n\nexport namespace UpdateEntryDataFactory {\n export type Interface = IUpdateEntryDataFactory;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n IUpdateEntryDataResponse<TValues>;\n}\n"],"names":["UpdateEntryDataFactory","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js","sources":["../../../../../src/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport type { EntryValidationError } from \"~/domain/contentEntry/errors.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"~/types/index.js\";\n\nexport interface IUpdateEntryDataResponse<TValues extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<TValues>;\n input: UpdateCmsEntryInput<TValues>;\n}\n\n/**\n * Expected failures of building the data of an entry being updated.\n */\nexport interface IUpdateEntryDataFactoryErrors {\n latest: GetLatestRevisionByEntryIdUseCase.Error;\n validation: EntryValidationError;\n}\n\ntype FactoryError = IUpdateEntryDataFactoryErrors[keyof IUpdateEntryDataFactoryErrors];\n\nexport interface IUpdateEntryDataFactory {\n create<TValues extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: UpdateCmsEntryInput<TValues>,\n originalEntry: CmsEntry<TValues>,\n options?: UpdateCmsEntryOptionsInput\n ): Promise<Result<IUpdateEntryDataResponse<TValues>, FactoryError>>;\n}\n\nexport const UpdateEntryDataFactory = createAbstraction<IUpdateEntryDataFactory>(\n \"Cms/Entry/UpdateEntryDataFactory\"\n);\n\nexport namespace UpdateEntryDataFactory {\n export type Interface = IUpdateEntryDataFactory;\n export type Error = FactoryError;\n export type Return<TValues extends CmsEntryValues = CmsEntryValues> = Result<\n IUpdateEntryDataResponse<TValues>,\n FactoryError\n >;\n export type Response<TValues extends CmsEntryValues = CmsEntryValues> =\n IUpdateEntryDataResponse<TValues>;\n}\n"],"names":["UpdateEntryDataFactory","createAbstraction"],"mappings":";AAmCO,MAAMA,yBAAyBC,kBAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const getExpiresAt = (input, original)=>{
|
|
2
2
|
if (void 0 === input.expiresAt) return original?.expiresAt ?? null;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
if (input.expiresAt instanceof Date) return input.expiresAt.getTime() / 1000;
|
|
4
|
+
if ("number" == typeof input.expiresAt && !isNaN(input.expiresAt) && input.expiresAt > 0) return input.expiresAt;
|
|
5
5
|
return null;
|
|
6
6
|
};
|
|
7
7
|
export { getExpiresAt };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/entryDataFactories/expiresAt.js","sources":["../../../../src/features/contentEntry/entryDataFactories/expiresAt.ts"],"sourcesContent":["import type { CmsEntry } from \"~/types/index.js\";\n\nexport interface IRawInput {\n expiresAt: Date | number | null | undefined;\n}\n\nexport const getExpiresAt = (input: IRawInput, original?: CmsEntry): number | null => {\n if (input.expiresAt === undefined) {\n return original?.expiresAt ?? null;\n } else if (input.expiresAt instanceof Date) {\n return input.expiresAt.getTime() / 1000;\n } else if (\n typeof input.expiresAt === \"number\" &&\n !isNaN(input.expiresAt) &&\n input.expiresAt > 0\n ) {\n return input.expiresAt;\n }\n return null;\n};\n"],"names":["getExpiresAt","input","original","undefined","Date","isNaN"],"mappings":"AAMO,MAAMA,eAAe,CAACC,OAAkBC;IAC3C,IAAID,AAAoBE,WAApBF,MAAM,SAAS,EACf,OAAOC,UAAU,aAAa;
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/expiresAt.js","sources":["../../../../src/features/contentEntry/entryDataFactories/expiresAt.ts"],"sourcesContent":["import type { CmsEntry } from \"~/types/index.js\";\n\nexport interface IRawInput {\n expiresAt: Date | number | null | undefined;\n}\n\nexport const getExpiresAt = (input: IRawInput, original?: CmsEntry): number | null => {\n if (input.expiresAt === undefined) {\n return original?.expiresAt ?? null;\n } else if (input.expiresAt instanceof Date) {\n return input.expiresAt.getTime() / 1000;\n } else if (\n typeof input.expiresAt === \"number\" &&\n !isNaN(input.expiresAt) &&\n input.expiresAt > 0\n ) {\n return input.expiresAt;\n }\n return null;\n};\n"],"names":["getExpiresAt","input","original","undefined","Date","isNaN"],"mappings":"AAMO,MAAMA,eAAe,CAACC,OAAkBC;IAC3C,IAAID,AAAoBE,WAApBF,MAAM,SAAS,EACf,OAAOC,UAAU,aAAa;IAC3B,IAAID,MAAM,SAAS,YAAYG,MAClC,OAAOH,MAAM,SAAS,CAAC,OAAO,KAAK;IAChC,IACH,AAA2B,YAA3B,OAAOA,MAAM,SAAS,IACtB,CAACI,MAAMJ,MAAM,SAAS,KACtBA,MAAM,SAAS,GAAG,GAElB,OAAOA,MAAM,SAAS;IAE1B,OAAO;AACX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CmsEntryValues } from "../../../types/index.js";
|
|
2
|
+
export interface IHasEntryContentChangedParams<TValues extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
/**
|
|
4
|
+
* The values as they will be stored (normalized).
|
|
5
|
+
*/
|
|
6
|
+
values: TValues;
|
|
7
|
+
/**
|
|
8
|
+
* The values to compare against, as currently stored.
|
|
9
|
+
*/
|
|
10
|
+
baselineValues: TValues;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Decides whether saving `values` changes the content of an entry. Used to keep the
|
|
14
|
+
* saved/modified meta fields untouched when an entry is saved without actual changes, e.g. when
|
|
15
|
+
* the "Save" button is clicked without editing anything.
|
|
16
|
+
*
|
|
17
|
+
* Only the content counts: moving an entry to another folder is not a content change, the same
|
|
18
|
+
* as with the dedicated move operation.
|
|
19
|
+
*
|
|
20
|
+
* Values must already be normalized the same way as the stored ones (item IDs assigned, reference
|
|
21
|
+
* fields mapped). A value that does not normalize identically is treated as a change, which only
|
|
22
|
+
* means the meta fields get updated, exactly as they did before this check existed.
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasEntryContentChanged: <TValues extends CmsEntryValues = CmsEntryValues>(params: IHasEntryContentChangedParams<TValues>) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isEqual from "lodash/isEqual.js";
|
|
2
|
+
const withoutEmptyKeys = (value)=>{
|
|
3
|
+
if (Array.isArray(value)) return value.map(withoutEmptyKeys);
|
|
4
|
+
if (null === value || "object" != typeof value || value instanceof Date) return value;
|
|
5
|
+
return Object.entries(value).reduce((result, [key, item])=>{
|
|
6
|
+
if (null != item) result[key] = withoutEmptyKeys(item);
|
|
7
|
+
return result;
|
|
8
|
+
}, {});
|
|
9
|
+
};
|
|
10
|
+
const hasEntryContentChanged = (params)=>!isEqual(withoutEmptyKeys(params.values), withoutEmptyKeys(params.baselineValues));
|
|
11
|
+
export { hasEntryContentChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=hasEntryContentChanged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryDataFactories/hasEntryContentChanged.js","sources":["../../../../src/features/contentEntry/entryDataFactories/hasEntryContentChanged.ts"],"sourcesContent":["import lodashIsEqual from \"lodash/isEqual.js\";\nimport type { CmsEntryValues } from \"~/types/index.js\";\n\n/**\n * Removes object keys with `null` or `undefined` values, recursively, so that a field that was\n * never set and a field that is explicitly empty compare as equal.\n */\nconst withoutEmptyKeys = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n return value.map(withoutEmptyKeys);\n }\n if (value === null || typeof value !== \"object\" || value instanceof Date) {\n return value;\n }\n return Object.entries(value).reduce<Record<string, unknown>>((result, [key, item]) => {\n if (item !== null && item !== undefined) {\n result[key] = withoutEmptyKeys(item);\n }\n return result;\n }, {});\n};\n\nexport interface IHasEntryContentChangedParams<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * The values as they will be stored (normalized).\n */\n values: TValues;\n /**\n * The values to compare against, as currently stored.\n */\n baselineValues: TValues;\n}\n\n/**\n * Decides whether saving `values` changes the content of an entry. Used to keep the\n * saved/modified meta fields untouched when an entry is saved without actual changes, e.g. when\n * the \"Save\" button is clicked without editing anything.\n *\n * Only the content counts: moving an entry to another folder is not a content change, the same\n * as with the dedicated move operation.\n *\n * Values must already be normalized the same way as the stored ones (item IDs assigned, reference\n * fields mapped). A value that does not normalize identically is treated as a change, which only\n * means the meta fields get updated, exactly as they did before this check existed.\n */\nexport const hasEntryContentChanged = <TValues extends CmsEntryValues = CmsEntryValues>(\n params: IHasEntryContentChangedParams<TValues>\n): boolean => {\n return !lodashIsEqual(withoutEmptyKeys(params.values), withoutEmptyKeys(params.baselineValues));\n};\n"],"names":["withoutEmptyKeys","value","Array","Date","Object","result","key","item","hasEntryContentChanged","params","lodashIsEqual"],"mappings":";AAOA,MAAMA,mBAAmB,CAACC;IACtB,IAAIC,MAAM,OAAO,CAACD,QACd,OAAOA,MAAM,GAAG,CAACD;IAErB,IAAIC,AAAU,SAAVA,SAAkB,AAAiB,YAAjB,OAAOA,SAAsBA,iBAAiBE,MAChE,OAAOF;IAEX,OAAOG,OAAO,OAAO,CAACH,OAAO,MAAM,CAA0B,CAACI,QAAQ,CAACC,KAAKC,KAAK;QAC7E,IAAIA,QAAAA,MACAF,MAAM,CAACC,IAAI,GAAGN,iBAAiBO;QAEnC,OAAOF;IACX,GAAG,CAAC;AACR;AAyBO,MAAMG,yBAAyB,CAClCC,SAEO,CAACC,QAAcV,iBAAiBS,OAAO,MAAM,GAAGT,iBAAiBS,OAAO,cAAc"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IComponentMapGenerator } from "./abstractions.js";
|
|
2
|
+
import { ModelToAstConverter } from "../ModelToAstConverter/abstractions.js";
|
|
3
|
+
import type { CmsModel } from "../../../types/index.js";
|
|
4
|
+
declare class ComponentMapGeneratorImpl implements IComponentMapGenerator {
|
|
5
|
+
private readonly modelToAst;
|
|
6
|
+
constructor(modelToAst: ModelToAstConverter.Interface);
|
|
7
|
+
generate(model: CmsModel): Record<string, string>;
|
|
8
|
+
private walkNode;
|
|
9
|
+
private walkCollection;
|
|
10
|
+
}
|
|
11
|
+
export declare const ComponentMapGenerator: typeof ComponentMapGeneratorImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<IComponentMapGenerator>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentMapGenerator } from "./abstractions.js";
|
|
2
|
+
import { ModelToAstConverter } from "../ModelToAstConverter/abstractions.js";
|
|
3
|
+
class ComponentMapGeneratorImpl {
|
|
4
|
+
constructor(modelToAst){
|
|
5
|
+
this.modelToAst = modelToAst;
|
|
6
|
+
}
|
|
7
|
+
generate(model) {
|
|
8
|
+
const ast = this.modelToAst.toAst(model);
|
|
9
|
+
const map = {};
|
|
10
|
+
this.walkNode(ast, map);
|
|
11
|
+
return map;
|
|
12
|
+
}
|
|
13
|
+
walkNode(node, map) {
|
|
14
|
+
for (const child of node.children)if ("collection" === child.type) this.walkCollection(child, map);
|
|
15
|
+
else this.walkNode(child, map);
|
|
16
|
+
}
|
|
17
|
+
walkCollection(node, map) {
|
|
18
|
+
const { collection } = node;
|
|
19
|
+
if (collection.componentName && collection.id) map[collection.id] = collection.componentName;
|
|
20
|
+
for (const child of node.children)if ("collection" === child.type) this.walkCollection(child, map);
|
|
21
|
+
else this.walkNode(child, map);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const ComponentMapGenerator_ComponentMapGenerator = ComponentMapGenerator.createImplementation({
|
|
25
|
+
implementation: ComponentMapGeneratorImpl,
|
|
26
|
+
dependencies: [
|
|
27
|
+
ModelToAstConverter
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
export { ComponentMapGenerator_ComponentMapGenerator as ComponentMapGenerator };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=ComponentMapGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.ts"],"sourcesContent":["import {\n ComponentMapGenerator as Abstraction,\n type IComponentMapGenerator\n} from \"./abstractions.js\";\nimport { ModelToAstConverter } from \"../ModelToAstConverter/abstractions.js\";\nimport type {\n CmsModel,\n CmsModelAst,\n CmsModelFieldAstNode,\n CmsModelFieldAstNodeCollection\n} from \"~/types/index.js\";\n\nclass ComponentMapGeneratorImpl implements IComponentMapGenerator {\n constructor(private readonly modelToAst: ModelToAstConverter.Interface) {}\n\n generate(model: CmsModel): Record<string, string> {\n const ast = this.modelToAst.toAst(model);\n const map: Record<string, string> = {};\n this.walkNode(ast, map);\n return map;\n }\n\n private walkNode(node: CmsModelAst | CmsModelFieldAstNode, map: Record<string, string>) {\n for (const child of node.children) {\n if (child.type === \"collection\") {\n this.walkCollection(child, map);\n } else {\n this.walkNode(child, map);\n }\n }\n }\n\n private walkCollection(node: CmsModelFieldAstNodeCollection, map: Record<string, string>) {\n const { collection } = node;\n if (collection.componentName && collection.id) {\n map[collection.id] = collection.componentName;\n }\n\n for (const child of node.children) {\n if (child.type === \"collection\") {\n this.walkCollection(child, map);\n } else {\n this.walkNode(child, map);\n }\n }\n }\n}\n\nexport const ComponentMapGenerator = Abstraction.createImplementation({\n implementation: ComponentMapGeneratorImpl,\n dependencies: [ModelToAstConverter]\n});\n"],"names":["ComponentMapGeneratorImpl","modelToAst","model","ast","map","node","child","collection","ComponentMapGenerator","Abstraction","ModelToAstConverter"],"mappings":";;AAYA,MAAMA;IACF,YAA6BC,UAAyC,CAAE;aAA3CA,UAAU,GAAVA;IAA4C;IAEzE,SAASC,KAAe,EAA0B;QAC9C,MAAMC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAACD;QAClC,MAAME,MAA8B,CAAC;QACrC,IAAI,CAAC,QAAQ,CAACD,KAAKC;QACnB,OAAOA;IACX;IAEQ,SAASC,IAAwC,EAAED,GAA2B,EAAE;QACpF,KAAK,MAAME,SAASD,KAAK,QAAQ,CAC7B,IAAIC,AAAe,iBAAfA,MAAM,IAAI,EACV,IAAI,CAAC,cAAc,CAACA,OAAOF;aAE3B,IAAI,CAAC,QAAQ,CAACE,OAAOF;IAGjC;IAEQ,eAAeC,IAAoC,EAAED,GAA2B,EAAE;QACtF,MAAM,EAAEG,UAAU,EAAE,GAAGF;QACvB,IAAIE,WAAW,aAAa,IAAIA,WAAW,EAAE,EACzCH,GAAG,CAACG,WAAW,EAAE,CAAC,GAAGA,WAAW,aAAa;QAGjD,KAAK,MAAMD,SAASD,KAAK,QAAQ,CAC7B,IAAIC,AAAe,iBAAfA,MAAM,IAAI,EACV,IAAI,CAAC,cAAc,CAACA,OAAOF;aAE3B,IAAI,CAAC,QAAQ,CAACE,OAAOF;IAGjC;AACJ;AAEO,MAAMI,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBT;IAChB,cAAc;QAACU;KAAoB;AACvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CmsModel } from "../../../types/index.js";
|
|
2
|
+
export interface IComponentMapGenerator {
|
|
3
|
+
generate(model: CmsModel): Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export declare const ComponentMapGenerator: import("@webiny/di").Abstraction<IComponentMapGenerator>;
|
|
6
|
+
export declare namespace ComponentMapGenerator {
|
|
7
|
+
type Interface = IComponentMapGenerator;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/abstractions.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"~/types/index.js\";\n\nexport interface IComponentMapGenerator {\n generate(model: CmsModel): Record<string, string>;\n}\n\nexport const ComponentMapGenerator =\n createAbstraction<IComponentMapGenerator>(\"ComponentMapGenerator\");\n\nexport namespace ComponentMapGenerator {\n export type Interface = IComponentMapGenerator;\n}\n"],"names":["ComponentMapGenerator","createAbstraction"],"mappings":";AAOO,MAAMA,wBACTC,kBAA0C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ComponentMapGenerator } from "./ComponentMapGenerator.js";
|
|
3
|
+
const ComponentMapGeneratorFeature = createFeature({
|
|
4
|
+
name: "CmsContentModel/ComponentMapGenerator",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ComponentMapGenerator);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ComponentMapGeneratorFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentModel/ComponentMapGenerator/feature.js","sources":["../../../../src/features/contentModel/ComponentMapGenerator/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ComponentMapGenerator } from \"./ComponentMapGenerator.js\";\n\nexport const ComponentMapGeneratorFeature = createFeature({\n name: \"CmsContentModel/ComponentMapGenerator\",\n register(container) {\n container.register(ComponentMapGenerator);\n }\n});\n"],"names":["ComponentMapGeneratorFeature","createFeature","container","ComponentMapGenerator"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -10,6 +10,9 @@ import { DeleteModelFeature } from "./DeleteModel/feature.js";
|
|
|
10
10
|
import { GetModelFeature } from "./GetModel/feature.js";
|
|
11
11
|
import { ListModelsFeature } from "./ListModels/feature.js";
|
|
12
12
|
import { ModelToAstConverterFeature } from "./ModelToAstConverter/feature.js";
|
|
13
|
+
import { ValuesSelectionGeneratorFeature } from "./ValuesSelectionGenerator/feature.js";
|
|
14
|
+
import { ComponentMapGeneratorFeature } from "./ComponentMapGenerator/feature.js";
|
|
15
|
+
import { RefModelsGeneratorFeature } from "./RefModelsGenerator/feature.js";
|
|
13
16
|
import { ModelFieldCompressionFeature } from "./ModelFieldCompression/feature.js";
|
|
14
17
|
const ContentModelFeature = createFeature({
|
|
15
18
|
name: "ContentModel",
|
|
@@ -18,6 +21,9 @@ const ContentModelFeature = createFeature({
|
|
|
18
21
|
container.register(PluginModelsProvider).inSingletonScope();
|
|
19
22
|
container.register(ModelsFetcher).inSingletonScope();
|
|
20
23
|
ModelToAstConverterFeature.register(container);
|
|
24
|
+
ValuesSelectionGeneratorFeature.register(container);
|
|
25
|
+
ComponentMapGeneratorFeature.register(container);
|
|
26
|
+
RefModelsGeneratorFeature.register(container);
|
|
21
27
|
ModelFieldCompressionFeature.register(container);
|
|
22
28
|
GetModelFeature.register(container);
|
|
23
29
|
ListModelsFeature.register(container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentModel/ContentModelFeature.js","sources":["../../../src/features/contentModel/ContentModelFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport { PluginModelsProvider } from \"./shared/PluginModelsProvider.js\";\nimport { ModelCache } from \"./shared/abstractions.js\";\nimport { ModelsFetcher } from \"./shared/ModelsFetcher.js\";\nimport { CreateModelFeature } from \"./CreateModel/feature.js\";\nimport { CreateModelFromFeature } from \"./CreateModelFrom/feature.js\";\nimport { UpdateModelFeature } from \"./UpdateModel/feature.js\";\nimport { DeleteModelFeature } from \"./DeleteModel/feature.js\";\nimport { GetModelFeature } from \"./GetModel/feature.js\";\nimport { ListModelsFeature } from \"./ListModels/feature.js\";\nimport { ModelToAstConverterFeature } from \"./ModelToAstConverter/feature.js\";\nimport { ModelFieldCompressionFeature } from \"./ModelFieldCompression/feature.js\";\n\nexport const ContentModelFeature = createFeature({\n name: \"ContentModel\",\n register(container) {\n container.registerInstance(ModelCache, createMemoryCache());\n container.register(PluginModelsProvider).inSingletonScope();\n container.register(ModelsFetcher).inSingletonScope();\n\n ModelToAstConverterFeature.register(container);\n\n ModelFieldCompressionFeature.register(container);\n\n // Query features\n GetModelFeature.register(container);\n ListModelsFeature.register(container);\n\n // Command features\n CreateModelFeature.register(container);\n CreateModelFromFeature.register(container);\n UpdateModelFeature.register(container);\n DeleteModelFeature.register(container);\n }\n});\n"],"names":["ContentModelFeature","createFeature","container","ModelCache","createMemoryCache","PluginModelsProvider","ModelsFetcher","ModelToAstConverterFeature","ModelFieldCompressionFeature","GetModelFeature","ListModelsFeature","CreateModelFeature","CreateModelFromFeature","UpdateModelFeature","DeleteModelFeature"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/contentModel/ContentModelFeature.js","sources":["../../../src/features/contentModel/ContentModelFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport { PluginModelsProvider } from \"./shared/PluginModelsProvider.js\";\nimport { ModelCache } from \"./shared/abstractions.js\";\nimport { ModelsFetcher } from \"./shared/ModelsFetcher.js\";\nimport { CreateModelFeature } from \"./CreateModel/feature.js\";\nimport { CreateModelFromFeature } from \"./CreateModelFrom/feature.js\";\nimport { UpdateModelFeature } from \"./UpdateModel/feature.js\";\nimport { DeleteModelFeature } from \"./DeleteModel/feature.js\";\nimport { GetModelFeature } from \"./GetModel/feature.js\";\nimport { ListModelsFeature } from \"./ListModels/feature.js\";\nimport { ModelToAstConverterFeature } from \"./ModelToAstConverter/feature.js\";\nimport { ValuesSelectionGeneratorFeature } from \"./ValuesSelectionGenerator/feature.js\";\nimport { ComponentMapGeneratorFeature } from \"./ComponentMapGenerator/feature.js\";\nimport { RefModelsGeneratorFeature } from \"./RefModelsGenerator/feature.js\";\nimport { ModelFieldCompressionFeature } from \"./ModelFieldCompression/feature.js\";\n\nexport const ContentModelFeature = createFeature({\n name: \"ContentModel\",\n register(container) {\n container.registerInstance(ModelCache, createMemoryCache());\n container.register(PluginModelsProvider).inSingletonScope();\n container.register(ModelsFetcher).inSingletonScope();\n\n ModelToAstConverterFeature.register(container);\n ValuesSelectionGeneratorFeature.register(container);\n ComponentMapGeneratorFeature.register(container);\n RefModelsGeneratorFeature.register(container);\n\n ModelFieldCompressionFeature.register(container);\n\n // Query features\n GetModelFeature.register(container);\n ListModelsFeature.register(container);\n\n // Command features\n CreateModelFeature.register(container);\n CreateModelFromFeature.register(container);\n UpdateModelFeature.register(container);\n DeleteModelFeature.register(container);\n }\n});\n"],"names":["ContentModelFeature","createFeature","container","ModelCache","createMemoryCache","PluginModelsProvider","ModelsFetcher","ModelToAstConverterFeature","ValuesSelectionGeneratorFeature","ComponentMapGeneratorFeature","RefModelsGeneratorFeature","ModelFieldCompressionFeature","GetModelFeature","ListModelsFeature","CreateModelFeature","CreateModelFromFeature","UpdateModelFeature","DeleteModelFeature"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,gBAAgB,CAACC,YAAYC;QACvCF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;QACzDH,UAAU,QAAQ,CAACI,eAAe,gBAAgB;QAElDC,2BAA2B,QAAQ,CAACL;QACpCM,gCAAgC,QAAQ,CAACN;QACzCO,6BAA6B,QAAQ,CAACP;QACtCQ,0BAA0B,QAAQ,CAACR;QAEnCS,6BAA6B,QAAQ,CAACT;QAGtCU,gBAAgB,QAAQ,CAACV;QACzBW,kBAAkB,QAAQ,CAACX;QAG3BY,mBAAmB,QAAQ,CAACZ;QAC5Ba,uBAAuB,QAAQ,CAACb;QAChCc,mBAAmB,QAAQ,CAACd;QAC5Be,mBAAmB,QAAQ,CAACf;IAChC;AACJ"}
|
|
@@ -21,7 +21,8 @@ const getModelId = (model)=>{
|
|
|
21
21
|
const isModelIdValid = camelCase(value).toLowerCase() === value.toLowerCase();
|
|
22
22
|
if (isModelIdValid) return value;
|
|
23
23
|
return camelCase(value);
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
|
+
if (name) return camelCase(name.trim());
|
|
25
26
|
throw new ModelValidationError('There is no "modelId" or "name" passed into the create model method.');
|
|
26
27
|
};
|
|
27
28
|
class CreateModelRepositoryImpl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentModel/CreateModel/CreateModelRepository.js","sources":["../../../../src/features/contentModel/CreateModel/CreateModelRepository.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport { Result } from \"@webiny/feature/api\";\nimport { CreateModelRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ModelCache, PluginModelsProvider } from \"~/features/contentModel/shared/abstractions.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport {\n ModelAlreadyExistsError,\n ModelPersistenceError,\n ModelValidationError\n} from \"~/domain/contentModel/errors.js\";\nimport { CmsContext, StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport {\n validateExistingModelId,\n validateModelIdAllowed\n} from \"~/crud/contentModel/validate/modelId.js\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { ensureTypeTag } from \"~/domain/contentModel/ensureTypeTag.js\";\nimport { validateSingularApiName } from \"~/domain/contentModel/validation/singularApiName.js\";\nimport { validatePluralApiName } from \"~/domain/contentModel/validation/pluralApiName.js\";\nimport { validateModelFields } from \"~/domain/contentModel/validation/modelFields.js\";\nimport { ModelFieldCompression } from \"~/features/contentModel/ModelFieldCompression/index.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * Generate modelId from model following the exact logic from beforeCreate.ts\n */\nconst getModelId = (model: { modelId?: string; name?: string }): string => {\n const { modelId, name } = model;\n const value = modelId ? modelId.trim() : null;\n if (value) {\n const isModelIdValid = camelCase(value).toLowerCase() === value.toLowerCase();\n if (isModelIdValid) {\n return value;\n }\n return camelCase(value);\n } else if (name) {\n return camelCase(name.trim());\n }\n throw new ModelValidationError(\n `There is no \"modelId\" or \"name\" passed into the create model method.`\n );\n};\n\n/**\n * CreateModelRepository - Validates domain rules and persists a new model.\n *\n * Responsibilities:\n * - Generate modelId from input\n * - Validate modelId is allowed (not in disallowed list)\n * - Validate API name endings\n * - Validate modelId uniqueness (database + plugins)\n * - Validate API name uniqueness (database + plugins)\n * - Validate plugin conflicts\n * - Validate model fields\n * - Persist to storage\n * - Clear ModelCache after successful create\n */\nclass CreateModelRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private readonly modelCache: ModelCache.Interface,\n private readonly pluginModelsProvider: PluginModelsProvider.Interface,\n private readonly listModelsUseCase: ListModelsUseCase.Interface,\n private readonly storageOperations: StorageOperations.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly cmsContext: CmsContext.Interface,\n private readonly modelFieldCompression: ModelFieldCompression.Interface,\n private readonly runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute(initialModel: CmsModel): Promise<Result<CmsModel, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n try {\n const tenant = this.tenantContext.getTenant();\n\n // TODO: this will eventually become part of the Model domain object.\n const modelId = getModelId(model);\n model.modelId = modelId;\n\n // Validate modelId is allowed (not in disallowed list)\n try {\n validateModelIdAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({\n message: error.message,\n data: error.data\n })\n );\n }\n\n // Validate API name endings\n try {\n validateEndingAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({\n message: error.message,\n data: error.data\n })\n );\n }\n\n // Check for plugin model conflicts\n const pluginModels = await this.pluginModelsProvider.list(tenant.id);\n const pluginModelConflict = pluginModels.find(pm => {\n return pm.modelId === model.modelId;\n });\n\n if (pluginModelConflict) {\n return Result.fail(\n new ModelAlreadyExistsError({\n modelId,\n message: `Model \"${modelId}\" is already registered via a plugin.`\n })\n );\n }\n\n // Get all models for further validation\n const modelsResult = await this.listModelsUseCase.execute();\n\n if (modelsResult.isFail()) {\n return Result.fail(new ModelPersistenceError(modelsResult.error));\n }\n\n const models = modelsResult.value;\n\n try {\n /**\n * We need to check for the existence of:\n * - modelId\n * - singularApiName\n * - pluralApiName\n */\n for (const existingModel of models) {\n validateExistingModelId({\n existingModel,\n model\n });\n validateSingularApiName({\n existingModel,\n model\n });\n validatePluralApiName({\n existingModel,\n model\n });\n }\n\n await validateModelFields({\n models,\n model,\n context: this.cmsContext\n });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n // TODO: ideally, this will eventually be handled by the Model domain object\n model.tags = ensureTypeTag(model);\n\n const fields = await this.modelFieldCompression.compress(model.fields);\n\n // Persist to storage\n await this.storageOperations.models.create({\n model: {\n ...model,\n fields\n }\n });\n\n // Clear cache\n this.modelCache.clear();\n\n return Result.ok(model);\n } catch (error) {\n console.error(error, error.stack);\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n}\n\nexport const CreateModelRepository = RepositoryAbstraction.createImplementation({\n implementation: CreateModelRepositoryImpl,\n dependencies: [\n ModelCache,\n PluginModelsProvider,\n ListModelsUseCase,\n StorageOperations,\n TenantContext,\n CmsContext,\n ModelFieldCompression,\n RuntimeTenant\n ]\n});\n"],"names":["getModelId","model","modelId","name","value","isModelIdValid","camelCase","ModelValidationError","CreateModelRepositoryImpl","modelCache","pluginModelsProvider","listModelsUseCase","storageOperations","tenantContext","cmsContext","modelFieldCompression","runtimeTenant","initialModel","tenant","validateModelIdAllowed","error","Result","validateEndingAllowed","pluginModels","pluginModelConflict","pm","ModelAlreadyExistsError","modelsResult","ModelPersistenceError","models","existingModel","validateExistingModelId","validateSingularApiName","validatePluralApiName","validateModelFields","ensureTypeTag","fields","console","CreateModelRepository","RepositoryAbstraction","ModelCache","PluginModelsProvider","ListModelsUseCase","StorageOperations","TenantContext","CmsContext","ModelFieldCompression","RuntimeTenant"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"features/contentModel/CreateModel/CreateModelRepository.js","sources":["../../../../src/features/contentModel/CreateModel/CreateModelRepository.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport { Result } from \"@webiny/feature/api\";\nimport { CreateModelRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { ModelCache, PluginModelsProvider } from \"~/features/contentModel/shared/abstractions.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport {\n ModelAlreadyExistsError,\n ModelPersistenceError,\n ModelValidationError\n} from \"~/domain/contentModel/errors.js\";\nimport { CmsContext, StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport {\n validateExistingModelId,\n validateModelIdAllowed\n} from \"~/crud/contentModel/validate/modelId.js\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { ensureTypeTag } from \"~/domain/contentModel/ensureTypeTag.js\";\nimport { validateSingularApiName } from \"~/domain/contentModel/validation/singularApiName.js\";\nimport { validatePluralApiName } from \"~/domain/contentModel/validation/pluralApiName.js\";\nimport { validateModelFields } from \"~/domain/contentModel/validation/modelFields.js\";\nimport { ModelFieldCompression } from \"~/features/contentModel/ModelFieldCompression/index.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * Generate modelId from model following the exact logic from beforeCreate.ts\n */\nconst getModelId = (model: { modelId?: string; name?: string }): string => {\n const { modelId, name } = model;\n const value = modelId ? modelId.trim() : null;\n if (value) {\n const isModelIdValid = camelCase(value).toLowerCase() === value.toLowerCase();\n if (isModelIdValid) {\n return value;\n }\n return camelCase(value);\n } else if (name) {\n return camelCase(name.trim());\n }\n throw new ModelValidationError(\n `There is no \"modelId\" or \"name\" passed into the create model method.`\n );\n};\n\n/**\n * CreateModelRepository - Validates domain rules and persists a new model.\n *\n * Responsibilities:\n * - Generate modelId from input\n * - Validate modelId is allowed (not in disallowed list)\n * - Validate API name endings\n * - Validate modelId uniqueness (database + plugins)\n * - Validate API name uniqueness (database + plugins)\n * - Validate plugin conflicts\n * - Validate model fields\n * - Persist to storage\n * - Clear ModelCache after successful create\n */\nclass CreateModelRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private readonly modelCache: ModelCache.Interface,\n private readonly pluginModelsProvider: PluginModelsProvider.Interface,\n private readonly listModelsUseCase: ListModelsUseCase.Interface,\n private readonly storageOperations: StorageOperations.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly cmsContext: CmsContext.Interface,\n private readonly modelFieldCompression: ModelFieldCompression.Interface,\n private readonly runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute(initialModel: CmsModel): Promise<Result<CmsModel, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n try {\n const tenant = this.tenantContext.getTenant();\n\n // TODO: this will eventually become part of the Model domain object.\n const modelId = getModelId(model);\n model.modelId = modelId;\n\n // Validate modelId is allowed (not in disallowed list)\n try {\n validateModelIdAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({\n message: error.message,\n data: error.data\n })\n );\n }\n\n // Validate API name endings\n try {\n validateEndingAllowed({ model });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({\n message: error.message,\n data: error.data\n })\n );\n }\n\n // Check for plugin model conflicts\n const pluginModels = await this.pluginModelsProvider.list(tenant.id);\n const pluginModelConflict = pluginModels.find(pm => {\n return pm.modelId === model.modelId;\n });\n\n if (pluginModelConflict) {\n return Result.fail(\n new ModelAlreadyExistsError({\n modelId,\n message: `Model \"${modelId}\" is already registered via a plugin.`\n })\n );\n }\n\n // Get all models for further validation\n const modelsResult = await this.listModelsUseCase.execute();\n\n if (modelsResult.isFail()) {\n return Result.fail(new ModelPersistenceError(modelsResult.error));\n }\n\n const models = modelsResult.value;\n\n try {\n /**\n * We need to check for the existence of:\n * - modelId\n * - singularApiName\n * - pluralApiName\n */\n for (const existingModel of models) {\n validateExistingModelId({\n existingModel,\n model\n });\n validateSingularApiName({\n existingModel,\n model\n });\n validatePluralApiName({\n existingModel,\n model\n });\n }\n\n await validateModelFields({\n models,\n model,\n context: this.cmsContext\n });\n } catch (error) {\n return Result.fail(\n new ModelValidationError({ message: error.message, data: error.data })\n );\n }\n\n // TODO: ideally, this will eventually be handled by the Model domain object\n model.tags = ensureTypeTag(model);\n\n const fields = await this.modelFieldCompression.compress(model.fields);\n\n // Persist to storage\n await this.storageOperations.models.create({\n model: {\n ...model,\n fields\n }\n });\n\n // Clear cache\n this.modelCache.clear();\n\n return Result.ok(model);\n } catch (error) {\n console.error(error, error.stack);\n return Result.fail(new ModelPersistenceError(error as Error));\n }\n }\n}\n\nexport const CreateModelRepository = RepositoryAbstraction.createImplementation({\n implementation: CreateModelRepositoryImpl,\n dependencies: [\n ModelCache,\n PluginModelsProvider,\n ListModelsUseCase,\n StorageOperations,\n TenantContext,\n CmsContext,\n ModelFieldCompression,\n RuntimeTenant\n ]\n});\n"],"names":["getModelId","model","modelId","name","value","isModelIdValid","camelCase","ModelValidationError","CreateModelRepositoryImpl","modelCache","pluginModelsProvider","listModelsUseCase","storageOperations","tenantContext","cmsContext","modelFieldCompression","runtimeTenant","initialModel","tenant","validateModelIdAllowed","error","Result","validateEndingAllowed","pluginModels","pluginModelConflict","pm","ModelAlreadyExistsError","modelsResult","ModelPersistenceError","models","existingModel","validateExistingModelId","validateSingularApiName","validatePluralApiName","validateModelFields","ensureTypeTag","fields","console","CreateModelRepository","RepositoryAbstraction","ModelCache","PluginModelsProvider","ListModelsUseCase","StorageOperations","TenantContext","CmsContext","ModelFieldCompression","RuntimeTenant"],"mappings":"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"}
|
|
@@ -20,7 +20,8 @@ const getModelId = (model)=>{
|
|
|
20
20
|
const isModelIdValid = camelCase(value).toLowerCase() === value.toLowerCase();
|
|
21
21
|
if (isModelIdValid) return value;
|
|
22
22
|
return camelCase(value);
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
|
+
if (name) return camelCase(name.trim());
|
|
24
25
|
throw new ModelValidationError('There is no "modelId" or "name" passed into the create model from method.');
|
|
25
26
|
};
|
|
26
27
|
class CreateModelFromRepositoryImpl {
|