@webiny/api-headless-cms 6.4.8 → 6.4.9-beta.0
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/features/contentEntry/ContentEntriesFeature.js +2 -0
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +4 -2
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js +8 -3
- package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +4 -2
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +8 -3
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +4 -2
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +8 -3
- package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +3 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +8 -3
- package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +3 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +8 -3
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +4 -2
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -3
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +4 -4
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +8 -11
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +4 -2
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -3
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +4 -2
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -3
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +4 -2
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -3
- package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +4 -2
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -3
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +4 -2
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -3
- package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
- package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +4 -2
- package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -3
- package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
- package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +4 -2
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -3
- package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +4 -2
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -3
- package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +4 -2
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +8 -3
- package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +4 -2
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +8 -3
- package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +4 -2
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +8 -3
- package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +4 -2
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +8 -3
- package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.d.ts +4 -2
- package/features/contentModel/CreateModel/CreateModelRepository.js +8 -4
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelUseCase.js +2 -2
- package/features/contentModel/CreateModel/CreateModelUseCase.js.map +1 -1
- package/features/contentModel/CreateModel/abstractions.d.ts +1 -1
- package/features/contentModel/CreateModel/abstractions.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +4 -2
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +8 -4
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -2
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
- package/features/contentModel/CreateModelFrom/abstractions.d.ts +1 -1
- package/features/contentModel/CreateModelFrom/abstractions.js.map +1 -1
- package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +4 -2
- package/features/contentModel/DeleteModel/DeleteModelRepository.js +7 -3
- package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +4 -2
- package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -4
- package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js +2 -2
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/contentModel/UpdateModel/abstractions.d.ts +1 -1
- package/features/contentModel/UpdateModel/abstractions.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +4 -2
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +8 -4
- package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +1 -3
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +5 -7
- package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/CreateGroup/abstractions.d.ts +1 -1
- package/features/contentModelGroup/CreateGroup/abstractions.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +4 -2
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +7 -3
- package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +4 -2
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +8 -4
- package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -2
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.d.ts +1 -1
- package/features/contentModelGroup/UpdateGroup/abstractions.js.map +1 -1
- package/features/runtimeTenant/RuntimeTenant.d.ts +13 -0
- package/features/runtimeTenant/RuntimeTenant.js +22 -0
- package/features/runtimeTenant/RuntimeTenant.js.map +1 -0
- package/features/runtimeTenant/abstractions.d.ts +11 -0
- package/features/runtimeTenant/abstractions.js +5 -0
- package/features/runtimeTenant/abstractions.js.map +1 -0
- package/features/runtimeTenant/index.d.ts +2 -0
- package/features/runtimeTenant/index.js +2 -0
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/ListEntries/ListEntriesRepository.js","sources":["../../../../src/features/contentEntry/ListEntries/ListEntriesRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { ListEntriesRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsListResponse,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, SearchableFieldsProvider } from \"~/legacy/abstractions.js\";\n\n/**\n * ListEntriesRepository - Fetches entries from storage and transforms them.\n * Returns entries with pagination metadata.\n */\nclass ListEntriesRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private searchableFieldsProvider: SearchableFieldsProvider.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n async execute<T extends CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/ListEntries/ListEntriesRepository.js","sources":["../../../../src/features/contentEntry/ListEntries/ListEntriesRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { ListEntriesRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsListResponse,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, SearchableFieldsProvider } from \"~/legacy/abstractions.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * ListEntriesRepository - Fetches entries from storage and transforms them.\n * Returns entries with pagination metadata.\n */\nclass ListEntriesRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private searchableFieldsProvider: SearchableFieldsProvider.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryListParams\n ): RepositoryAbstraction.Return<T> {\n try {\n const model = this.runtimeTenant.assign(initialModel);\n const limit = params.limit && params.limit > 0 ? params.limit : 50;\n const sort = params.sort ?? [\"createdOn_DESC\"];\n const where: NonNullable<CmsEntryListParams[\"where\"]> = params.where ?? {};\n\n if (where.location) {\n where.wbyAco_location = where.location;\n delete where.location;\n }\n\n const listParams: CmsEntryStorageOperationsListParams = {\n ...params,\n sort,\n limit,\n where,\n fields: this.searchableFieldsProvider({ fields: model.fields })\n };\n\n let result: CmsEntryStorageOperationsListResponse<CmsStorageEntry<T>> | undefined;\n try {\n result = await this.storageOperations.entries.list<T>(model, listParams);\n } catch (ex) {\n return Result.fail(ex);\n }\n\n // Transform storage entries to domain entries\n const items = await Promise.all(\n result.items.map(async entry => {\n return this.entryFromStorageTransform(model, entry);\n })\n );\n\n const meta: CmsEntryMeta = {\n hasMoreItems: result.hasMoreItems,\n totalCount: result.totalCount,\n cursor: result.hasMoreItems ? result.cursor : null\n };\n\n return Result.ok({ entries: items, meta });\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListEntriesRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: ListEntriesRepositoryImpl,\n dependencies: [\n SearchableFieldsProvider,\n EntryFromStorageTransform,\n StorageOperations,\n RuntimeTenant\n ]\n});\n"],"names":["ListEntriesRepositoryImpl","searchableFieldsProvider","entryFromStorageTransform","storageOperations","runtimeTenant","initialModel","params","model","limit","sort","where","listParams","result","ex","Result","items","Promise","entry","meta","error","EntryPersistenceError","ListEntriesRepository","createImplementation","RepositoryAbstraction","SearchableFieldsProvider","EntryFromStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAoBA,MAAMA;IACF,YACYC,wBAA4D,EAC5DC,yBAA8D,EAC9DC,iBAA8C,EAC9CC,aAAsC,CAChD;aAJUH,wBAAwB,GAAxBA;aACAC,yBAAyB,GAAzBA;aACAC,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA0B,EACK;QAC/B,IAAI;YACA,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;YACxC,MAAMG,QAAQF,OAAO,KAAK,IAAIA,OAAO,KAAK,GAAG,IAAIA,OAAO,KAAK,GAAG;YAChE,MAAMG,OAAOH,OAAO,IAAI,IAAI;gBAAC;aAAiB;YAC9C,MAAMI,QAAkDJ,OAAO,KAAK,IAAI,CAAC;YAEzE,IAAII,MAAM,QAAQ,EAAE;gBAChBA,MAAM,eAAe,GAAGA,MAAM,QAAQ;gBACtC,OAAOA,MAAM,QAAQ;YACzB;YAEA,MAAMC,aAAkD;gBACpD,GAAGL,MAAM;gBACTG;gBACAD;gBACAE;gBACA,QAAQ,IAAI,CAAC,wBAAwB,CAAC;oBAAE,QAAQH,MAAM,MAAM;gBAAC;YACjE;YAEA,IAAIK;YACJ,IAAI;gBACAA,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAIL,OAAOI;YACjE,EAAE,OAAOE,IAAI;gBACT,OAAOC,OAAO,IAAI,CAACD;YACvB;YAGA,MAAME,QAAQ,MAAMC,QAAQ,GAAG,CAC3BJ,OAAO,KAAK,CAAC,GAAG,CAAC,OAAMK,QACZ,IAAI,CAAC,yBAAyB,CAACV,OAAOU;YAIrD,MAAMC,OAAqB;gBACvB,cAAcN,OAAO,YAAY;gBACjC,YAAYA,OAAO,UAAU;gBAC7B,QAAQA,OAAO,YAAY,GAAGA,OAAO,MAAM,GAAG;YAClD;YAEA,OAAOE,OAAO,EAAE,CAAC;gBAAE,SAASC;gBAAOG;YAAK;QAC5C,EAAE,OAAOC,OAAO;YACZ,OAAOL,OAAO,IAAI,CAAC,IAAIM,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QACVwB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -2,6 +2,7 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { MoveEntryRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
3
3
|
import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
4
4
|
import type { CmsModel } from "../../../types/index.js";
|
|
5
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
5
6
|
/**
|
|
6
7
|
* MoveEntryRepository - Handles storage operations for moving entries.
|
|
7
8
|
*
|
|
@@ -11,8 +12,9 @@ import type { CmsModel } from "../../../types/index.js";
|
|
|
11
12
|
*/
|
|
12
13
|
declare class MoveEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
13
14
|
private storageOperations;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
private runtimeTenant;
|
|
16
|
+
constructor(storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
17
|
+
execute(initialModel: CmsModel, id: string, folderId: string): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
16
18
|
}
|
|
17
19
|
export declare const MoveEntryRepository: import("@webiny/di").Implementation<typeof MoveEntryRepositoryImpl>;
|
|
18
20
|
export {};
|
|
@@ -2,11 +2,14 @@ import { Result, createImplementation } from "@webiny/feature/api";
|
|
|
2
2
|
import { MoveEntryRepository } from "./abstractions.js";
|
|
3
3
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
4
4
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
5
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
5
6
|
class MoveEntryRepositoryImpl {
|
|
6
|
-
constructor(storageOperations){
|
|
7
|
+
constructor(storageOperations, runtimeTenant){
|
|
7
8
|
this.storageOperations = storageOperations;
|
|
9
|
+
this.runtimeTenant = runtimeTenant;
|
|
8
10
|
}
|
|
9
|
-
async execute(
|
|
11
|
+
async execute(initialModel, id, folderId) {
|
|
12
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
10
13
|
try {
|
|
11
14
|
await this.storageOperations.entries.move(model, id, folderId);
|
|
12
15
|
return Result.ok();
|
|
@@ -19,7 +22,8 @@ const MoveEntryRepository_MoveEntryRepository = createImplementation({
|
|
|
19
22
|
abstraction: MoveEntryRepository,
|
|
20
23
|
implementation: MoveEntryRepositoryImpl,
|
|
21
24
|
dependencies: [
|
|
22
|
-
StorageOperations
|
|
25
|
+
StorageOperations,
|
|
26
|
+
RuntimeTenant
|
|
23
27
|
]
|
|
24
28
|
});
|
|
25
29
|
export { MoveEntryRepository_MoveEntryRepository as MoveEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/MoveEntry/MoveEntryRepository.js","sources":["../../../../src/features/contentEntry/MoveEntry/MoveEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { MoveEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * MoveEntryRepository - Handles storage operations for moving entries.\n *\n * Responsibilities:\n * - Call storage operation to move entry to different folder\n * - Handle storage errors\n */\nclass MoveEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(private storageOperations: StorageOperations.Interface) {}\n\n async execute(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/MoveEntry/MoveEntryRepository.js","sources":["../../../../src/features/contentEntry/MoveEntry/MoveEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { MoveEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * MoveEntryRepository - Handles storage operations for moving entries.\n *\n * Responsibilities:\n * - Call storage operation to move entry to different folder\n * - Handle storage errors\n */\nclass MoveEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute(\n initialModel: CmsModel,\n id: string,\n folderId: string\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n\n try {\n await this.storageOperations.entries.move(model, id, folderId);\n return Result.ok();\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const MoveEntryRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: MoveEntryRepositoryImpl,\n dependencies: [StorageOperations, RuntimeTenant]\n});\n"],"names":["MoveEntryRepositoryImpl","storageOperations","runtimeTenant","initialModel","id","folderId","model","Result","error","EntryPersistenceError","MoveEntryRepository","createImplementation","RepositoryAbstraction","StorageOperations","RuntimeTenant"],"mappings":";;;;;AAeA,MAAMA;IACF,YACYC,iBAA8C,EAC9CC,aAAsC,CAChD;aAFUD,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,EAAU,EACVC,QAAgB,EACkC;QAClD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACH;QAExC,IAAI;YACA,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAACG,OAAOF,IAAIC;YACrD,OAAOE,OAAO,EAAE;QACpB,EAAE,OAAOC,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,0CAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBZ;IAChB,cAAc;QAACa;QAAmBC;KAAc;AACpD"}
|
|
@@ -2,6 +2,7 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { PublishEntryRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
3
3
|
import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
4
4
|
import { EntryFromStorageTransform, EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
5
6
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../types/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* PublishEntryRepository - Handles storage operations for publishing entries.
|
|
@@ -16,8 +17,9 @@ declare class PublishEntryRepositoryImpl implements RepositoryAbstraction.Interf
|
|
|
16
17
|
private entryToStorageTransform;
|
|
17
18
|
private entryFromStorageTransform;
|
|
18
19
|
private storageOperations;
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
private runtimeTenant;
|
|
21
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, entryFromStorageTransform: EntryFromStorageTransform.Interface, storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
22
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, initialEntry: CmsEntry<T>): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>>;
|
|
21
23
|
}
|
|
22
24
|
export declare const PublishEntryRepository: import("@webiny/di").Implementation<typeof PublishEntryRepositoryImpl>;
|
|
23
25
|
export {};
|
|
@@ -2,14 +2,18 @@ import { Result, createImplementation } from "@webiny/feature/api";
|
|
|
2
2
|
import { PublishEntryRepository } from "./abstractions.js";
|
|
3
3
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
4
4
|
import { EntryFromStorageTransform, EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
5
6
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
6
7
|
class PublishEntryRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations){
|
|
8
|
+
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations, runtimeTenant){
|
|
8
9
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
10
|
this.entryFromStorageTransform = entryFromStorageTransform;
|
|
10
11
|
this.storageOperations = storageOperations;
|
|
12
|
+
this.runtimeTenant = runtimeTenant;
|
|
11
13
|
}
|
|
12
|
-
async execute(
|
|
14
|
+
async execute(initialModel, initialEntry) {
|
|
15
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
16
|
+
const entry = this.runtimeTenant.assign(initialEntry);
|
|
13
17
|
try {
|
|
14
18
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
15
19
|
const result = await this.storageOperations.entries.publish(model, {
|
|
@@ -29,7 +33,8 @@ const PublishEntryRepository_PublishEntryRepository = createImplementation({
|
|
|
29
33
|
dependencies: [
|
|
30
34
|
EntryToStorageTransform,
|
|
31
35
|
EntryFromStorageTransform,
|
|
32
|
-
StorageOperations
|
|
36
|
+
StorageOperations,
|
|
37
|
+
RuntimeTenant
|
|
33
38
|
]
|
|
34
39
|
});
|
|
35
40
|
export { PublishEntryRepository_PublishEntryRepository as PublishEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/PublishEntry/PublishEntryRepository.js","sources":["../../../../src/features/contentEntry/PublishEntry/PublishEntryRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { PublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * PublishEntryRepository - Handles storage operations for publishing entries.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Publish the entry in storage\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass PublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/PublishEntry/PublishEntryRepository.js","sources":["../../../../src/features/contentEntry/PublishEntry/PublishEntryRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { PublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * PublishEntryRepository - Handles storage operations for publishing entries.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Publish the entry in storage\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass PublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n initialEntry: CmsEntry<T>\n ): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n const entry = this.runtimeTenant.assign(initialEntry);\n\n try {\n // Transform entry to storage format\n const storageEntry = await this.entryToStorageTransform(model, entry);\n\n // Publish the entry\n const result = await this.storageOperations.entries.publish(model, {\n entry,\n storageEntry\n });\n\n // Transform result back from storage format\n const transformedEntry = await this.entryFromStorageTransform(model, result);\n\n return Result.ok(transformedEntry);\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const PublishEntryRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: PublishEntryRepositoryImpl,\n dependencies: [\n EntryToStorageTransform,\n EntryFromStorageTransform,\n StorageOperations,\n RuntimeTenant\n ]\n});\n"],"names":["PublishEntryRepositoryImpl","entryToStorageTransform","entryFromStorageTransform","storageOperations","runtimeTenant","initialModel","initialEntry","model","entry","storageEntry","result","transformedEntry","Result","error","EntryPersistenceError","PublishEntryRepository","createImplementation","RepositoryAbstraction","EntryToStorageTransform","EntryFromStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAiBA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,yBAA8D,EAC9DC,iBAA8C,EAC9CC,aAAsC,CAChD;aAJUH,uBAAuB,GAAvBA;aACAC,yBAAyB,GAAzBA;aACAC,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAa,QACTC,YAAsB,EACtBC,YAAyB,EACgC;QACzD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QACxC,MAAMG,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QAExC,IAAI;YAEA,MAAMG,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAACF,OAAOC;YAG/D,MAAME,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAACH,OAAO;gBAC/DC;gBACAC;YACJ;YAGA,MAAME,mBAAmB,MAAM,IAAI,CAAC,yBAAyB,CAACJ,OAAOG;YAErE,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,gDAAyBC,qBAAqB;IACvD,aAAaC;IACb,gBAAgBjB;IAChB,cAAc;QACVkB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -4,6 +4,7 @@ import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
|
4
4
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
5
|
import { EntryFromStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
6
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../types/index.js";
|
|
7
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
7
8
|
/**
|
|
8
9
|
* RepublishEntryRepository - Handles storage operations for republishing entries.
|
|
9
10
|
*
|
|
@@ -18,8 +19,9 @@ declare class RepublishEntryRepositoryImpl implements RepositoryAbstraction.Inte
|
|
|
18
19
|
private entryToStorageTransform;
|
|
19
20
|
private entryFromStorageTransform;
|
|
20
21
|
private storageOperations;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
private runtimeTenant;
|
|
23
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, entryFromStorageTransform: EntryFromStorageTransform.Interface, storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
24
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, initialEntry: CmsEntry<T>): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>>;
|
|
23
25
|
}
|
|
24
26
|
export declare const RepublishEntryRepository: import("@webiny/di").Implementation<typeof RepublishEntryRepositoryImpl>;
|
|
25
27
|
export {};
|
|
@@ -3,13 +3,17 @@ import { RepublishEntryRepository } from "./abstractions.js";
|
|
|
3
3
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
4
4
|
import { EntryFromStorageTransform, EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
5
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
6
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
6
7
|
class RepublishEntryRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations){
|
|
8
|
+
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations, runtimeTenant){
|
|
8
9
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
10
|
this.entryFromStorageTransform = entryFromStorageTransform;
|
|
10
11
|
this.storageOperations = storageOperations;
|
|
12
|
+
this.runtimeTenant = runtimeTenant;
|
|
11
13
|
}
|
|
12
|
-
async execute(
|
|
14
|
+
async execute(initialModel, initialEntry) {
|
|
15
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
16
|
+
const entry = this.runtimeTenant.assign(initialEntry);
|
|
13
17
|
try {
|
|
14
18
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
15
19
|
await this.storageOperations.entries.update(model, {
|
|
@@ -33,7 +37,8 @@ const RepublishEntryRepository_RepublishEntryRepository = createImplementation({
|
|
|
33
37
|
dependencies: [
|
|
34
38
|
EntryToStorageTransform,
|
|
35
39
|
EntryFromStorageTransform,
|
|
36
|
-
StorageOperations
|
|
40
|
+
StorageOperations,
|
|
41
|
+
RuntimeTenant
|
|
37
42
|
]
|
|
38
43
|
});
|
|
39
44
|
export { RepublishEntryRepository_RepublishEntryRepository as RepublishEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/RepublishEntry/RepublishEntryRepository.js","sources":["../../../../src/features/contentEntry/RepublishEntry/RepublishEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { RepublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport { EntryFromStorageTransform } from \"~/legacy/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * RepublishEntryRepository - Handles storage operations for republishing entries.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Update the entry in storage\n * - Publish the entry in storage\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass RepublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/RepublishEntry/RepublishEntryRepository.js","sources":["../../../../src/features/contentEntry/RepublishEntry/RepublishEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { RepublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport { EntryFromStorageTransform } from \"~/legacy/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * RepublishEntryRepository - Handles storage operations for republishing entries.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Update the entry in storage\n * - Publish the entry in storage\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass RepublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n initialEntry: CmsEntry<T>\n ): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n const entry = this.runtimeTenant.assign(initialEntry);\n\n try {\n // Transform entry to storage format\n const storageEntry = await this.entryToStorageTransform<T>(model, entry);\n\n // First update the entry\n await this.storageOperations.entries.update(model, {\n entry,\n storageEntry\n });\n\n // Then publish it\n const result = await this.storageOperations.entries.publish<T>(model, {\n entry,\n storageEntry\n });\n\n // Transform result back from storage format\n const transformedEntry = await this.entryFromStorageTransform<T>(model, result);\n\n return Result.ok(transformedEntry);\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const RepublishEntryRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: RepublishEntryRepositoryImpl,\n dependencies: [\n EntryToStorageTransform,\n EntryFromStorageTransform,\n StorageOperations,\n RuntimeTenant\n ]\n});\n"],"names":["RepublishEntryRepositoryImpl","entryToStorageTransform","entryFromStorageTransform","storageOperations","runtimeTenant","initialModel","initialEntry","model","entry","storageEntry","result","transformedEntry","Result","error","EntryPersistenceError","RepublishEntryRepository","createImplementation","RepositoryAbstraction","EntryToStorageTransform","EntryFromStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAoBA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,yBAA8D,EAC9DC,iBAA8C,EAC9CC,aAAsC,CAChD;aAJUH,uBAAuB,GAAvBA;aACAC,yBAAyB,GAAzBA;aACAC,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAa,QACTC,YAAsB,EACtBC,YAAyB,EACgC;QACzD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QACxC,MAAMG,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QAExC,IAAI;YAEA,MAAMG,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAAIF,OAAOC;YAGlE,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAACD,OAAO;gBAC/CC;gBACAC;YACJ;YAGA,MAAMC,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAIH,OAAO;gBAClEC;gBACAC;YACJ;YAGA,MAAME,mBAAmB,MAAM,IAAI,CAAC,yBAAyB,CAAIJ,OAAOG;YAExE,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,oDAA2BC,qBAAqB;IACzD,aAAaC;IACb,gBAAgBjB;IAChB,cAAc;QACVkB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -3,6 +3,7 @@ import { RestoreEntryFromBinRepository as RepositoryAbstraction } from "./abstra
|
|
|
3
3
|
import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
4
4
|
import { EntryFromStorageTransform, EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
5
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../types/index.js";
|
|
6
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
6
7
|
/**
|
|
7
8
|
* RestoreEntryFromBinRepository - Handles storage operations for restoring entries from bin.
|
|
8
9
|
*
|
|
@@ -16,8 +17,9 @@ declare class RestoreEntryFromBinRepositoryImpl implements RepositoryAbstraction
|
|
|
16
17
|
private entryToStorageTransform;
|
|
17
18
|
private entryFromStorageTransform;
|
|
18
19
|
private storageOperations;
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
private runtimeTenant;
|
|
21
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, entryFromStorageTransform: EntryFromStorageTransform.Interface, storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
22
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, initialEntry: CmsEntry<T>): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>>;
|
|
21
23
|
}
|
|
22
24
|
export declare const RestoreEntryFromBinRepository: import("@webiny/di").Implementation<typeof RestoreEntryFromBinRepositoryImpl>;
|
|
23
25
|
export {};
|
|
@@ -3,13 +3,17 @@ import { RestoreEntryFromBinRepository } from "./abstractions.js";
|
|
|
3
3
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
4
4
|
import { EntryFromStorageTransform, EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
5
5
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
6
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
6
7
|
class RestoreEntryFromBinRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations){
|
|
8
|
+
constructor(entryToStorageTransform, entryFromStorageTransform, storageOperations, runtimeTenant){
|
|
8
9
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
10
|
this.entryFromStorageTransform = entryFromStorageTransform;
|
|
10
11
|
this.storageOperations = storageOperations;
|
|
12
|
+
this.runtimeTenant = runtimeTenant;
|
|
11
13
|
}
|
|
12
|
-
async execute(
|
|
14
|
+
async execute(initialModel, initialEntry) {
|
|
15
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
16
|
+
const entry = this.runtimeTenant.assign(initialEntry);
|
|
13
17
|
try {
|
|
14
18
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
15
19
|
const result = await this.storageOperations.entries.restoreFromBin(model, {
|
|
@@ -29,7 +33,8 @@ const RestoreEntryFromBinRepository_RestoreEntryFromBinRepository = createImplem
|
|
|
29
33
|
dependencies: [
|
|
30
34
|
EntryToStorageTransform,
|
|
31
35
|
EntryFromStorageTransform,
|
|
32
|
-
StorageOperations
|
|
36
|
+
StorageOperations,
|
|
37
|
+
RuntimeTenant
|
|
33
38
|
]
|
|
34
39
|
});
|
|
35
40
|
export { RestoreEntryFromBinRepository_RestoreEntryFromBinRepository as RestoreEntryFromBinRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js","sources":["../../../../src/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { RestoreEntryFromBinRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * RestoreEntryFromBinRepository - Handles storage operations for restoring entries from bin.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Call storage operation to restore entry\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass RestoreEntryFromBinRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js","sources":["../../../../src/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { RestoreEntryFromBinRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryFromStorageTransform, EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * RestoreEntryFromBinRepository - Handles storage operations for restoring entries from bin.\n *\n * Responsibilities:\n * - Transform entry to storage format\n * - Call storage operation to restore entry\n * - Transform result back from storage format\n * - Handle storage errors\n */\nclass RestoreEntryFromBinRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private entryFromStorageTransform: EntryFromStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n initialEntry: CmsEntry<T>\n ): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n const entry = this.runtimeTenant.assign(initialEntry);\n\n try {\n // Transform entry to storage format\n const storageEntry = await this.entryToStorageTransform<T>(model, entry);\n\n // Call storage operation\n const result = await this.storageOperations.entries.restoreFromBin<T>(model, {\n entry,\n storageEntry\n });\n\n // Transform result back from storage format\n const transformedEntry = await this.entryFromStorageTransform<T>(model, result);\n\n return Result.ok(transformedEntry);\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const RestoreEntryFromBinRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: RestoreEntryFromBinRepositoryImpl,\n dependencies: [\n EntryToStorageTransform,\n EntryFromStorageTransform,\n StorageOperations,\n RuntimeTenant\n ]\n});\n"],"names":["RestoreEntryFromBinRepositoryImpl","entryToStorageTransform","entryFromStorageTransform","storageOperations","runtimeTenant","initialModel","initialEntry","model","entry","storageEntry","result","transformedEntry","Result","error","EntryPersistenceError","RestoreEntryFromBinRepository","createImplementation","RepositoryAbstraction","EntryToStorageTransform","EntryFromStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAiBA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,yBAA8D,EAC9DC,iBAA8C,EAC9CC,aAAsC,CAChD;aAJUH,uBAAuB,GAAvBA;aACAC,yBAAyB,GAAzBA;aACAC,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAa,QACTC,YAAsB,EACtBC,YAAyB,EACgC;QACzD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QACxC,MAAMG,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QAExC,IAAI;YAEA,MAAMG,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAAIF,OAAOC;YAGlE,MAAME,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,cAAc,CAAIH,OAAO;gBACzEC;gBACAC;YACJ;YAGA,MAAME,mBAAmB,MAAM,IAAI,CAAC,yBAAyB,CAAIJ,OAAOG;YAExE,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8DAAgCC,qBAAqB;IAC9D,aAAaC;IACb,gBAAgBjB;IAChB,cAAc;QACVkB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -4,6 +4,7 @@ import type { CmsEntry, CmsEntryValues } from "../../../types/index.js";
|
|
|
4
4
|
import type { CmsModel } from "../../../types/index.js";
|
|
5
5
|
import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
6
6
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
7
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
7
8
|
/**
|
|
8
9
|
* UnpublishEntryRepository - Handles persistence of entry unpublish.
|
|
9
10
|
* Transforms domain entry to storage format and persists unpublish operation.
|
|
@@ -11,8 +12,9 @@ import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
|
11
12
|
declare class UnpublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
12
13
|
private entryToStorageTransform;
|
|
13
14
|
private storageOperations;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
private runtimeTenant;
|
|
16
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
17
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, initialEntry: CmsEntry<T>): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>>;
|
|
16
18
|
}
|
|
17
19
|
export declare const UnpublishEntryRepository: import("@webiny/di").Implementation<typeof UnpublishEntryRepositoryImpl>;
|
|
18
20
|
export {};
|
|
@@ -3,12 +3,16 @@ import { UnpublishEntryRepository } from "./abstractions.js";
|
|
|
3
3
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
4
4
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
5
5
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
6
7
|
class UnpublishEntryRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform, storageOperations){
|
|
8
|
+
constructor(entryToStorageTransform, storageOperations, runtimeTenant){
|
|
8
9
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
10
|
this.storageOperations = storageOperations;
|
|
11
|
+
this.runtimeTenant = runtimeTenant;
|
|
10
12
|
}
|
|
11
|
-
async execute(
|
|
13
|
+
async execute(initialModel, initialEntry) {
|
|
14
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
15
|
+
const entry = this.runtimeTenant.assign(initialEntry);
|
|
12
16
|
try {
|
|
13
17
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
14
18
|
const result = await this.storageOperations.entries.unpublish(model, {
|
|
@@ -26,7 +30,8 @@ const UnpublishEntryRepository_UnpublishEntryRepository = createImplementation({
|
|
|
26
30
|
implementation: UnpublishEntryRepositoryImpl,
|
|
27
31
|
dependencies: [
|
|
28
32
|
EntryToStorageTransform,
|
|
29
|
-
StorageOperations
|
|
33
|
+
StorageOperations,
|
|
34
|
+
RuntimeTenant
|
|
30
35
|
]
|
|
31
36
|
});
|
|
32
37
|
export { UnpublishEntryRepository_UnpublishEntryRepository as UnpublishEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js","sources":["../../../../src/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { UnpublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\n\n/**\n * UnpublishEntryRepository - Handles persistence of entry unpublish.\n * Transforms domain entry to storage format and persists unpublish operation.\n */\nclass UnpublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js","sources":["../../../../src/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { UnpublishEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type { CmsEntry, CmsEntryValues } from \"~/types/index.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * UnpublishEntryRepository - Handles persistence of entry unpublish.\n * Transforms domain entry to storage format and persists unpublish operation.\n */\nclass UnpublishEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n initialEntry: CmsEntry<T>\n ): Promise<Result<CmsEntry<T>, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n const entry = this.runtimeTenant.assign(initialEntry);\n\n try {\n // Transform domain entry to storage format\n const storageEntry = await this.entryToStorageTransform<T>(model, entry);\n\n // Persist unpublish to storage\n const result = await this.storageOperations.entries.unpublish<T>(model, {\n entry,\n storageEntry\n });\n\n return Result.ok(result);\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const UnpublishEntryRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: UnpublishEntryRepositoryImpl,\n dependencies: [EntryToStorageTransform, StorageOperations, RuntimeTenant]\n});\n"],"names":["UnpublishEntryRepositoryImpl","entryToStorageTransform","storageOperations","runtimeTenant","initialModel","initialEntry","model","entry","storageEntry","result","Result","error","EntryPersistenceError","UnpublishEntryRepository","createImplementation","RepositoryAbstraction","EntryToStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAcA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,iBAA8C,EAC9CC,aAAsC,CAChD;aAHUF,uBAAuB,GAAvBA;aACAC,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAa,QACTC,YAAsB,EACtBC,YAAyB,EACgC;QACzD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QACxC,MAAMG,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QAExC,IAAI;YAEA,MAAMG,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAAIF,OAAOC;YAGlE,MAAME,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAIH,OAAO;gBACpEC;gBACAC;YACJ;YAEA,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,oDAA2BC,qBAAqB;IACzD,aAAaC;IACb,gBAAgBf;IAChB,cAAc;QAACgB;QAAyBC;QAAmBC;KAAc;AAC7E"}
|
|
@@ -3,6 +3,7 @@ import { UpdateEntryRepository as RepositoryAbstraction } from "./abstractions.j
|
|
|
3
3
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "../../../types/index.js";
|
|
4
4
|
import { StorageOperations } from "../../../features/shared/abstractions.js";
|
|
5
5
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
6
7
|
/**
|
|
7
8
|
* UpdateEntryRepository - Handles persistence of entry updates.
|
|
8
9
|
* Transforms domain entry to storage format and persists changes.
|
|
@@ -10,8 +11,9 @@ import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
|
10
11
|
declare class UpdateEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
11
12
|
private entryToStorageTransform;
|
|
12
13
|
private storageOperations;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
private readonly runtimeTenant;
|
|
15
|
+
constructor(entryToStorageTransform: EntryToStorageTransform.Interface, storageOperations: StorageOperations.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
16
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, initialEntry: CmsEntry<T>): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
15
17
|
}
|
|
16
18
|
export declare const UpdateEntryRepository: import("@webiny/di").Implementation<typeof UpdateEntryRepositoryImpl>;
|
|
17
19
|
export {};
|
|
@@ -3,12 +3,16 @@ import { UpdateEntryRepository } from "./abstractions.js";
|
|
|
3
3
|
import { EntryPersistenceError } from "../../../domain/contentEntry/errors.js";
|
|
4
4
|
import { StorageOperations } from "../../shared/abstractions.js";
|
|
5
5
|
import { EntryToStorageTransform } from "../../../legacy/abstractions.js";
|
|
6
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
6
7
|
class UpdateEntryRepositoryImpl {
|
|
7
|
-
constructor(entryToStorageTransform, storageOperations){
|
|
8
|
+
constructor(entryToStorageTransform, storageOperations, runtimeTenant){
|
|
8
9
|
this.entryToStorageTransform = entryToStorageTransform;
|
|
9
10
|
this.storageOperations = storageOperations;
|
|
11
|
+
this.runtimeTenant = runtimeTenant;
|
|
10
12
|
}
|
|
11
|
-
async execute(
|
|
13
|
+
async execute(initialModel, initialEntry) {
|
|
14
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
15
|
+
const entry = this.runtimeTenant.assign(initialEntry);
|
|
12
16
|
try {
|
|
13
17
|
const storageEntry = await this.entryToStorageTransform(model, entry);
|
|
14
18
|
await this.storageOperations.entries.update(model, {
|
|
@@ -26,7 +30,8 @@ const UpdateEntryRepository_UpdateEntryRepository = createImplementation({
|
|
|
26
30
|
implementation: UpdateEntryRepositoryImpl,
|
|
27
31
|
dependencies: [
|
|
28
32
|
EntryToStorageTransform,
|
|
29
|
-
StorageOperations
|
|
33
|
+
StorageOperations,
|
|
34
|
+
RuntimeTenant
|
|
30
35
|
]
|
|
31
36
|
});
|
|
32
37
|
export { UpdateEntryRepository_UpdateEntryRepository as UpdateEntryRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryRepository.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { UpdateEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\n\n/**\n * UpdateEntryRepository - Handles persistence of entry updates.\n * Transforms domain entry to storage format and persists changes.\n */\nclass UpdateEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n
|
|
1
|
+
{"version":3,"file":"features/contentEntry/UpdateEntry/UpdateEntryRepository.js","sources":["../../../../src/features/contentEntry/UpdateEntry/UpdateEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { UpdateEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"~/types/index.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { EntryToStorageTransform } from \"~/legacy/abstractions.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * UpdateEntryRepository - Handles persistence of entry updates.\n * Transforms domain entry to storage format and persists changes.\n */\nclass UpdateEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private entryToStorageTransform: EntryToStorageTransform.Interface,\n private storageOperations: StorageOperations.Interface,\n private readonly runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n initialEntry: CmsEntry<T>\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n const model = this.runtimeTenant.assign(initialModel);\n const entry = this.runtimeTenant.assign(initialEntry);\n\n try {\n // Transform domain entry to storage format\n const storageEntry = await this.entryToStorageTransform<T>(model, entry);\n\n // Persist to storage\n await this.storageOperations.entries.update<T>(model, {\n entry,\n storageEntry\n });\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateEntryRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: UpdateEntryRepositoryImpl,\n dependencies: [EntryToStorageTransform, StorageOperations, RuntimeTenant]\n});\n"],"names":["UpdateEntryRepositoryImpl","entryToStorageTransform","storageOperations","runtimeTenant","initialModel","initialEntry","model","entry","storageEntry","Result","error","EntryPersistenceError","UpdateEntryRepository","createImplementation","RepositoryAbstraction","EntryToStorageTransform","StorageOperations","RuntimeTenant"],"mappings":";;;;;;AAaA,MAAMA;IACF,YACYC,uBAA0D,EAC1DC,iBAA8C,EACrCC,aAAsC,CACzD;aAHUF,uBAAuB,GAAvBA;aACAC,iBAAiB,GAAjBA;aACSC,aAAa,GAAbA;IAClB;IAEH,MAAM,QACFC,YAAsB,EACtBC,YAAyB,EACyB;QAClD,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QACxC,MAAMG,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACF;QAExC,IAAI;YAEA,MAAMG,eAAe,MAAM,IAAI,CAAC,uBAAuB,CAAIF,OAAOC;YAGlE,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAID,OAAO;gBAClDC;gBACAC;YACJ;YAEA,OAAOC,OAAO,EAAE;QACpB,EAAE,OAAOC,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBd;IAChB,cAAc;QAACe;QAAyBC;QAAmBC;KAAc;AAC7E"}
|
|
@@ -6,6 +6,7 @@ import { CmsContext, StorageOperations } from "../../../features/shared/abstract
|
|
|
6
6
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
7
7
|
import type { CmsModel } from "../../../types/index.js";
|
|
8
8
|
import { ModelFieldCompression } from "../../../features/contentModel/ModelFieldCompression/index.js";
|
|
9
|
+
import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
|
|
9
10
|
/**
|
|
10
11
|
* CreateModelRepository - Validates domain rules and persists a new model.
|
|
11
12
|
*
|
|
@@ -28,8 +29,9 @@ declare class CreateModelRepositoryImpl implements RepositoryAbstraction.Interfa
|
|
|
28
29
|
private readonly tenantContext;
|
|
29
30
|
private readonly cmsContext;
|
|
30
31
|
private readonly modelFieldCompression;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
private readonly runtimeTenant;
|
|
33
|
+
constructor(modelCache: ModelCache.Interface, pluginModelsProvider: PluginModelsProvider.Interface, listModelsUseCase: ListModelsUseCase.Interface, storageOperations: StorageOperations.Interface, tenantContext: TenantContext.Interface, cmsContext: CmsContext.Interface, modelFieldCompression: ModelFieldCompression.Interface, runtimeTenant: RuntimeTenant.Interface);
|
|
34
|
+
execute(initialModel: CmsModel): Promise<Result<CmsModel, RepositoryAbstraction.Error>>;
|
|
33
35
|
}
|
|
34
36
|
export declare const CreateModelRepository: typeof CreateModelRepositoryImpl & {
|
|
35
37
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICreateModelRepository>;
|
|
@@ -13,6 +13,7 @@ import { validateSingularApiName } from "../../../domain/contentModel/validation
|
|
|
13
13
|
import { validatePluralApiName } from "../../../domain/contentModel/validation/pluralApiName.js";
|
|
14
14
|
import { validateModelFields } from "../../../domain/contentModel/validation/modelFields.js";
|
|
15
15
|
import { ModelFieldCompression } from "../ModelFieldCompression/index.js";
|
|
16
|
+
import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
|
|
16
17
|
const getModelId = (model)=>{
|
|
17
18
|
const { modelId, name } = model;
|
|
18
19
|
const value = modelId ? modelId.trim() : null;
|
|
@@ -25,7 +26,7 @@ const getModelId = (model)=>{
|
|
|
25
26
|
throw new ModelValidationError('There is no "modelId" or "name" passed into the create model method.');
|
|
26
27
|
};
|
|
27
28
|
class CreateModelRepositoryImpl {
|
|
28
|
-
constructor(modelCache, pluginModelsProvider, listModelsUseCase, storageOperations, tenantContext, cmsContext, modelFieldCompression){
|
|
29
|
+
constructor(modelCache, pluginModelsProvider, listModelsUseCase, storageOperations, tenantContext, cmsContext, modelFieldCompression, runtimeTenant){
|
|
29
30
|
this.modelCache = modelCache;
|
|
30
31
|
this.pluginModelsProvider = pluginModelsProvider;
|
|
31
32
|
this.listModelsUseCase = listModelsUseCase;
|
|
@@ -33,8 +34,10 @@ class CreateModelRepositoryImpl {
|
|
|
33
34
|
this.tenantContext = tenantContext;
|
|
34
35
|
this.cmsContext = cmsContext;
|
|
35
36
|
this.modelFieldCompression = modelFieldCompression;
|
|
37
|
+
this.runtimeTenant = runtimeTenant;
|
|
36
38
|
}
|
|
37
|
-
async execute(
|
|
39
|
+
async execute(initialModel) {
|
|
40
|
+
const model = this.runtimeTenant.assign(initialModel);
|
|
38
41
|
try {
|
|
39
42
|
const tenant = this.tenantContext.getTenant();
|
|
40
43
|
const modelId = getModelId(model);
|
|
@@ -103,7 +106,7 @@ class CreateModelRepositoryImpl {
|
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
this.modelCache.clear();
|
|
106
|
-
return Result.ok();
|
|
109
|
+
return Result.ok(model);
|
|
107
110
|
} catch (error) {
|
|
108
111
|
console.error(error, error.stack);
|
|
109
112
|
return Result.fail(new ModelPersistenceError(error));
|
|
@@ -119,7 +122,8 @@ const CreateModelRepository_CreateModelRepository = CreateModelRepository.create
|
|
|
119
122
|
StorageOperations,
|
|
120
123
|
TenantContext,
|
|
121
124
|
CmsContext,
|
|
122
|
-
ModelFieldCompression
|
|
125
|
+
ModelFieldCompression,
|
|
126
|
+
RuntimeTenant
|
|
123
127
|
]
|
|
124
128
|
});
|
|
125
129
|
export { CreateModelRepository_CreateModelRepository as CreateModelRepository };
|
|
@@ -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\";\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 ) {}\n\n async execute(model: CmsModel): Promise<Result<void, RepositoryAbstraction.Error>> {\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();\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 ]\n});\n"],"names":["getModelId","model","modelId","name","value","isModelIdValid","camelCase","ModelValidationError","CreateModelRepositoryImpl","modelCache","pluginModelsProvider","listModelsUseCase","storageOperations","tenantContext","cmsContext","modelFieldCompression","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"],"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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"}
|