@webiny/api-aco 5.43.3 → 6.0.0-alpha.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/apps/AcoApp.d.ts +2 -2
- package/apps/AcoApp.js.map +1 -1
- package/apps/AcoApps.d.ts +1 -1
- package/apps/AcoApps.js.map +1 -1
- package/apps/app.gql.d.ts +1 -1
- package/apps/app.gql.js.map +1 -1
- package/createAcoContext.d.ts +2 -2
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.d.ts +1 -1
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.d.ts +1 -1
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.d.ts +1 -1
- package/createAcoModels.js.map +1 -1
- package/createAcoStorageOperations.d.ts +4 -4
- package/createAcoStorageOperations.js.map +1 -1
- package/filter/filter.crud.d.ts +2 -2
- package/filter/filter.crud.js.map +1 -1
- package/filter/filter.gql.d.ts +1 -1
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.d.ts +2 -2
- package/filter/filter.so.js.map +1 -1
- package/filter/filter.types.d.ts +2 -2
- package/filter/filter.types.js.map +1 -1
- package/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/DefaultPermissionsMerger.d.ts +2 -2
- package/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/DefaultPermissionsMerger.js.map +1 -1
- package/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js.map +1 -1
- package/flp/flp.crud.d.ts +2 -2
- package/flp/flp.crud.js.map +1 -1
- package/flp/flp.so.d.ts +1 -1
- package/flp/flp.so.js.map +1 -1
- package/flp/flp.types.d.ts +2 -2
- package/flp/flp.types.js.map +1 -1
- package/flp/hooks/index.d.ts +1 -1
- package/flp/hooks/index.js.map +1 -1
- package/flp/hooks/onFolderAfterCreateFlp.hook.d.ts +1 -1
- package/flp/hooks/onFolderAfterCreateFlp.hook.js.map +1 -1
- package/flp/hooks/onFolderAfterDeleteFlp.hook.d.ts +1 -1
- package/flp/hooks/onFolderAfterDeleteFlp.hook.js.map +1 -1
- package/flp/hooks/onFolderAfterUpdateFlp.hook.d.ts +1 -1
- package/flp/hooks/onFolderAfterUpdateFlp.hook.js.map +1 -1
- package/folder/createFolderModelModifier.d.ts +2 -2
- package/folder/createFolderModelModifier.js.map +1 -1
- package/folder/createFolderTypeDefs.d.ts +1 -1
- package/folder/createFolderTypeDefs.js +8 -0
- package/folder/createFolderTypeDefs.js.map +1 -1
- package/folder/ensureFolderIsEmpty.d.ts +1 -1
- package/folder/ensureFolderIsEmpty.js.map +1 -1
- package/folder/folder.crud.d.ts +3 -2
- package/folder/folder.crud.js.map +1 -1
- package/folder/folder.gql.d.ts +2 -2
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.so.d.ts +2 -2
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +11 -2
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDeleteAco.hook.d.ts +1 -1
- package/folder/onFolderBeforeDeleteAco.hook.js.map +1 -1
- package/folder/onFolderBeforeDeleteFm.hook.d.ts +1 -1
- package/folder/onFolderBeforeDeleteFm.hook.js.map +1 -1
- package/folder/onFolderBeforeDeleteHcms.hook.d.ts +1 -1
- package/folder/onFolderBeforeDeleteHcms.hook.js.map +1 -1
- package/folder/useCases/CreateFolder/CreateFolderWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/CreateFolder/CreateFolderWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/CreateFolder/index.d.ts +2 -2
- package/folder/useCases/CreateFolder/index.js.map +1 -1
- package/folder/useCases/DeleteFolder/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/DeleteFolder/DeleteFolderWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/DeleteFolder/index.d.ts +2 -2
- package/folder/useCases/DeleteFolder/index.js.map +1 -1
- package/folder/useCases/GetAncestors/IGetAncestors.d.ts +1 -1
- package/folder/useCases/GetAncestors/IGetAncestors.js.map +1 -1
- package/folder/useCases/GetFolder/GetFolderWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/GetFolder/GetFolderWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/GetFolder/index.d.ts +1 -1
- package/folder/useCases/GetFolder/index.js.map +1 -1
- package/folder/useCases/GetFolderHierarchy/GetFolderHierarchyWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/GetFolderHierarchy/GetFolderHierarchyWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/GetFolderHierarchy/index.d.ts +1 -1
- package/folder/useCases/GetFolderHierarchy/index.js.map +1 -1
- package/folder/useCases/ListFolders/IListFolders.d.ts +1 -1
- package/folder/useCases/ListFolders/IListFolders.js.map +1 -1
- package/folder/useCases/ListFolders/ListFolders.d.ts +1 -1
- package/folder/useCases/ListFolders/ListFolders.js.map +1 -1
- package/folder/useCases/ListFolders/ListFoldersWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/ListFolders/ListFoldersWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/ListFolders/index.d.ts +1 -1
- package/folder/useCases/ListFolders/index.js.map +1 -1
- package/folder/useCases/UpdateFolder/UpdateFolderWithFolderLevelPermissions.d.ts +1 -1
- package/folder/useCases/UpdateFolder/UpdateFolderWithFolderLevelPermissions.js +1 -1
- package/folder/useCases/UpdateFolder/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
- package/folder/useCases/UpdateFolder/index.d.ts +2 -2
- package/folder/useCases/UpdateFolder/index.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/package.json +28 -28
- package/plugins/AcoAppModifierPlugin.d.ts +2 -2
- package/plugins/AcoAppModifierPlugin.js.map +1 -1
- package/plugins/AcoAppRegisterPlugin.d.ts +1 -1
- package/plugins/AcoAppRegisterPlugin.js.map +1 -1
- package/record/graphql/createAppResolvers.d.ts +2 -2
- package/record/graphql/createAppResolvers.js.map +1 -1
- package/record/graphql/createAppSchema.d.ts +2 -2
- package/record/graphql/createAppSchema.js +2 -2
- package/record/graphql/createAppSchema.js.map +1 -1
- package/record/record.crud.d.ts +2 -2
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.d.ts +1 -1
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +1 -1
- package/record/record.model.js.map +1 -1
- package/record/record.so.d.ts +2 -2
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +3 -3
- package/record/record.types.js.map +1 -1
- package/types.d.ts +9 -9
- package/types.js.map +1 -1
- package/utils/FoldersCacheFactory.d.ts +1 -1
- package/utils/FoldersCacheFactory.js.map +1 -1
- package/utils/ListFoldersRepository.d.ts +2 -2
- package/utils/ListFoldersRepository.js.map +1 -1
- package/utils/createListSort.d.ts +2 -2
- package/utils/createListSort.js.map +1 -1
- package/utils/createModelField.d.ts +1 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +2 -2
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.d.ts +2 -2
- package/utils/decorators/CmsEntriesCrudDecorators.js +14 -14
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/decorators/FilterEntriesByFolderFactory.d.ts +2 -2
- package/utils/decorators/FilterEntriesByFolderFactory.js.map +1 -1
- package/utils/decorators/ListEntriesFactory.d.ts +3 -2
- package/utils/decorators/ListEntriesFactory.js.map +1 -1
- package/utils/decorators/decorateIfModelAuthorizationEnabled.d.ts +2 -3
- package/utils/decorators/decorateIfModelAuthorizationEnabled.js +1 -5
- package/utils/decorators/decorateIfModelAuthorizationEnabled.js.map +1 -1
- package/utils/decorators/hasRootFolderId.d.ts +1 -1
- package/utils/decorators/hasRootFolderId.js.map +1 -1
- package/utils/decorators/isPageModel.d.ts +1 -1
- package/utils/decorators/isPageModel.js.map +1 -1
- package/utils/ensureAuthentication.d.ts +1 -1
- package/utils/ensureAuthentication.js.map +1 -1
- package/utils/modelFactory.d.ts +1 -1
- package/utils/modelFactory.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +1 -1
- package/utils/pickEntryFieldValues.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_filter","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_folder","_record","_flp","ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { TenancyContext, Tenant } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext } from \"@webiny/api-security/types\";\nimport { AdminUsersContext } from \"@webiny/api-admin-users/types\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { Context as TasksContext } from \"@webiny/tasks/types\";\nimport { CmsContext, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport type {\n AcoSearchRecordCrud,\n AcoSearchRecordCrudBase,\n AcoSearchRecordStorageOperations,\n GenericSearchData,\n SearchRecord\n} from \"~/record/record.types\";\nimport type { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types\";\nimport { FolderLevelPermissions } from \"~/flp\";\n\nexport * from \"./filter/filter.types\";\nexport * from \"./folder/folder.types\";\nexport * from \"./record/record.types\";\nexport * from \"./flp/flp.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n folderLevelPermissions: FolderLevelPermissions;\n apps: IAcoApps;\n registerApp: (params: IAcoAppRegisterParams) => Promise<IAcoApp>;\n getApp: (name: string) => IAcoApp;\n listApps: () => IAcoApp[];\n}\n\nexport interface CreateAcoParams {\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions;\n}\n\nexport interface AcoStorageOperations {\n folder: AcoFolderStorageOperations;\n search: AcoSearchRecordStorageOperations;\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n AdminUsersContext,\n CmsContext,\n FileManagerContext,\n TasksContext {\n aco: AdvancedContentOrganisation;\n}\n\n/**\n * @deprecated Use AcoContext instead\n */\nexport type ACOContext = AcoContext;\n\n/**\n * Apps\n */\nexport interface IAcoAppAddFieldCallable {\n (field: CmsModelField): void;\n}\n\nexport interface IAcoAppRemoveFieldCallable {\n (id: string): void;\n}\n\nexport interface IAcoAppModifyFieldCallableCallback {\n (field: CmsModelField): CmsModelField;\n}\n\nexport interface IAcoAppModifyFieldCallable {\n (id: string, cb: IAcoAppModifyFieldCallableCallback): void;\n}\n\nexport interface IAcoApp {\n context: AcoContext;\n search: AcoSearchRecordCrudBase;\n folder: AcoFolderCrud;\n name: string;\n model: CmsModel;\n getFields: () => CmsModelField[];\n addField: IAcoAppAddFieldCallable;\n removeField: IAcoAppRemoveFieldCallable;\n modifyField: IAcoAppModifyFieldCallable;\n}\n// TODO: determine correct type\nexport type IAcoAppOnEntry<T extends GenericSearchData = GenericSearchData> = (\n entry: SearchRecord<T>,\n context: AcoContext\n) => Promise<SearchRecord<T>>;\nexport type IAcoAppOnEntryList<T extends GenericSearchData = GenericSearchData> = (\n entries: SearchRecord<T>[],\n context: AcoContext\n) => Promise<SearchRecord<T>[]>;\nexport type AcoRequestAction = \"create\" | \"update\" | \"delete\" | \"move\" | \"fetch\";\nexport type IAcoAppOnAnyRequest = (context: AcoContext, action: AcoRequestAction) => Promise<void>;\n\nexport interface IAcoAppParams {\n name: string;\n apiName: string;\n model: CmsModel;\n fields: CmsModelField[];\n onEntry?: IAcoAppOnEntry;\n onEntryList?: IAcoAppOnEntryList;\n onAnyRequest?: IAcoAppOnAnyRequest;\n}\n\nexport type IAcoAppsOptions = CreateAcoParams;\n\nexport interface IAcoApps {\n list: () => IAcoApp[];\n register: (app: IAcoAppParams) => Promise<IAcoApp>;\n}\n\nexport type IAcoAppRegisterParams = Omit<IAcoAppParams, \"model\">;\n"],"mappings":";;;;;;;;;AAuBA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,OAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,OAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAA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BAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAwD7B;AACA;AACA;AAGA;AACA;AACA;AA4BA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_filter","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_folder","_record","_flp","ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import type { TenancyContext, Tenant } from \"@webiny/api-tenancy/types\";\nimport type { Context as BaseContext } from \"@webiny/handler/types\";\nimport type { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport type { SecurityContext } from \"@webiny/api-security/types\";\nimport type { AdminUsersContext } from \"@webiny/api-admin-users/types\";\nimport type { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport type { Context as TasksContext } from \"@webiny/tasks/types\";\nimport type { CmsContext, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport type {\n AcoSearchRecordCrud,\n AcoSearchRecordCrudBase,\n AcoSearchRecordStorageOperations,\n GenericSearchData,\n SearchRecord\n} from \"~/record/record.types\";\nimport type { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types\";\nimport type { FolderLevelPermissions } from \"~/flp\";\n\nexport * from \"./filter/filter.types\";\nexport * from \"./folder/folder.types\";\nexport * from \"./record/record.types\";\nexport * from \"./flp/flp.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n folderLevelPermissions: FolderLevelPermissions;\n apps: IAcoApps;\n registerApp: (params: IAcoAppRegisterParams) => Promise<IAcoApp>;\n getApp: (name: string) => IAcoApp;\n listApps: () => IAcoApp[];\n}\n\nexport interface CreateAcoParams {\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions;\n}\n\nexport interface AcoStorageOperations {\n folder: AcoFolderStorageOperations;\n search: AcoSearchRecordStorageOperations;\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n AdminUsersContext,\n CmsContext,\n FileManagerContext,\n TasksContext {\n aco: AdvancedContentOrganisation;\n}\n\n/**\n * @deprecated Use AcoContext instead\n */\nexport type ACOContext = AcoContext;\n\n/**\n * Apps\n */\nexport interface IAcoAppAddFieldCallable {\n (field: CmsModelField): void;\n}\n\nexport interface IAcoAppRemoveFieldCallable {\n (id: string): void;\n}\n\nexport interface IAcoAppModifyFieldCallableCallback {\n (field: CmsModelField): CmsModelField;\n}\n\nexport interface IAcoAppModifyFieldCallable {\n (id: string, cb: IAcoAppModifyFieldCallableCallback): void;\n}\n\nexport interface IAcoApp {\n context: AcoContext;\n search: AcoSearchRecordCrudBase;\n folder: AcoFolderCrud;\n name: string;\n model: CmsModel;\n getFields: () => CmsModelField[];\n addField: IAcoAppAddFieldCallable;\n removeField: IAcoAppRemoveFieldCallable;\n modifyField: IAcoAppModifyFieldCallable;\n}\n// TODO: determine correct type\nexport type IAcoAppOnEntry<T extends GenericSearchData = GenericSearchData> = (\n entry: SearchRecord<T>,\n context: AcoContext\n) => Promise<SearchRecord<T>>;\nexport type IAcoAppOnEntryList<T extends GenericSearchData = GenericSearchData> = (\n entries: SearchRecord<T>[],\n context: AcoContext\n) => Promise<SearchRecord<T>[]>;\nexport type AcoRequestAction = \"create\" | \"update\" | \"delete\" | \"move\" | \"fetch\";\nexport type IAcoAppOnAnyRequest = (context: AcoContext, action: AcoRequestAction) => Promise<void>;\n\nexport interface IAcoAppParams {\n name: string;\n apiName: string;\n model: CmsModel;\n fields: CmsModelField[];\n onEntry?: IAcoAppOnEntry;\n onEntryList?: IAcoAppOnEntryList;\n onAnyRequest?: IAcoAppOnAnyRequest;\n}\n\nexport type IAcoAppsOptions = CreateAcoParams;\n\nexport interface IAcoApps {\n list: () => IAcoApp[];\n register: (app: IAcoAppParams) => Promise<IAcoApp>;\n}\n\nexport type IAcoAppRegisterParams = Omit<IAcoAppParams, \"model\">;\n"],"mappings":";;;;;;;;;AAuBA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,OAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,OAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA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AAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAwD7B;AACA;AACA;AAGA;AACA;AACA;AA4BA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ListCache","require","FoldersCacheFactory","cache","Map","hasCache","namespace","cacheKey","getCacheKey","has","getCache","set","ListCache","get","deleteCache","clear","exports","folderCacheFactory"],"sources":["FoldersCacheFactory.ts"],"sourcesContent":["import { Folder } from \"~/folder/folder.types\";\nimport { ListCache } from \"~/utils/ListCache\";\n\nexport class FoldersCacheFactory {\n private cache: Map<string, ListCache<Folder>> = new Map();\n\n hasCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n return this.cache.has(cacheKey);\n }\n\n getCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n\n if (!this.cache.has(cacheKey)) {\n this.cache.set(cacheKey, new ListCache<Folder>());\n }\n\n return this.cache.get(cacheKey) as ListCache<Folder>;\n }\n\n deleteCache() {\n this.cache.clear();\n }\n\n private getCacheKey(namespace: string) {\n return namespace;\n }\n}\n\nexport const folderCacheFactory = new FoldersCacheFactory();\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,CAAC;EACrBC,KAAK,GAAmC,IAAIC,GAAG,CAAC,CAAC;EAEzDC,QAAQA,CAACC,SAAiB,EAAE;IACxB,MAAMC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACF,SAAS,CAAC;IAC5C,OAAO,IAAI,CAACH,KAAK,CAACM,GAAG,CAACF,QAAQ,CAAC;EACnC;EAEAG,QAAQA,CAACJ,SAAiB,EAAE;IACxB,MAAMC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACF,SAAS,CAAC;IAE5C,IAAI,CAAC,IAAI,CAACH,KAAK,CAACM,GAAG,CAACF,QAAQ,CAAC,EAAE;MAC3B,IAAI,CAACJ,KAAK,CAACQ,GAAG,CAACJ,QAAQ,EAAE,IAAIK,oBAAS,CAAS,CAAC,CAAC;IACrD;IAEA,OAAO,IAAI,CAACT,KAAK,CAACU,GAAG,CAACN,QAAQ,CAAC;EACnC;EAEAO,WAAWA,CAAA,EAAG;IACV,IAAI,CAACX,KAAK,CAACY,KAAK,CAAC,CAAC;EACtB;EAEQP,WAAWA,CAACF,SAAiB,EAAE;IACnC,OAAOA,SAAS;EACpB;AACJ;AAACU,OAAA,CAAAd,mBAAA,GAAAA,mBAAA;AAEM,MAAMe,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG,IAAIf,mBAAmB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_ListCache","require","FoldersCacheFactory","cache","Map","hasCache","namespace","cacheKey","getCacheKey","has","getCache","set","ListCache","get","deleteCache","clear","exports","folderCacheFactory"],"sources":["FoldersCacheFactory.ts"],"sourcesContent":["import type { Folder } from \"~/folder/folder.types\";\nimport { ListCache } from \"~/utils/ListCache\";\n\nexport class FoldersCacheFactory {\n private cache: Map<string, ListCache<Folder>> = new Map();\n\n hasCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n return this.cache.has(cacheKey);\n }\n\n getCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n\n if (!this.cache.has(cacheKey)) {\n this.cache.set(cacheKey, new ListCache<Folder>());\n }\n\n return this.cache.get(cacheKey) as ListCache<Folder>;\n }\n\n deleteCache() {\n this.cache.clear();\n }\n\n private getCacheKey(namespace: string) {\n return namespace;\n }\n}\n\nexport const folderCacheFactory = new FoldersCacheFactory();\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,CAAC;EACrBC,KAAK,GAAmC,IAAIC,GAAG,CAAC,CAAC;EAEzDC,QAAQA,CAACC,SAAiB,EAAE;IACxB,MAAMC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACF,SAAS,CAAC;IAC5C,OAAO,IAAI,CAACH,KAAK,CAACM,GAAG,CAACF,QAAQ,CAAC;EACnC;EAEAG,QAAQA,CAACJ,SAAiB,EAAE;IACxB,MAAMC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACF,SAAS,CAAC;IAE5C,IAAI,CAAC,IAAI,CAACH,KAAK,CAACM,GAAG,CAACF,QAAQ,CAAC,EAAE;MAC3B,IAAI,CAACJ,KAAK,CAACQ,GAAG,CAACJ,QAAQ,EAAE,IAAIK,oBAAS,CAAS,CAAC,CAAC;IACrD;IAEA,OAAO,IAAI,CAACT,KAAK,CAACU,GAAG,CAACN,QAAQ,CAAC;EACnC;EAEAO,WAAWA,CAAA,EAAG;IACV,IAAI,CAACX,KAAK,CAACY,KAAK,CAAC,CAAC;EACtB;EAEQP,WAAWA,CAACF,SAAiB,EAAE;IACnC,OAAOA,SAAS;EACpB;AACJ;AAACU,OAAA,CAAAd,mBAAA,GAAAA,mBAAA;AAEM,MAAMe,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG,IAAIf,mBAAmB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Folder, ListFoldersParams } from "../folder/folder.types";
|
|
2
|
-
import { ListMeta } from "../types";
|
|
1
|
+
import type { Folder, ListFoldersParams } from "../folder/folder.types";
|
|
2
|
+
import type { ListMeta } from "../types";
|
|
3
3
|
export interface ListFoldersRepositoryParams {
|
|
4
4
|
gateway: (params: ListFoldersParams) => Promise<[Folder[], ListMeta]>;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_FoldersCacheFactory","require","ListFoldersRepository","constructor","params","gateway","execute","folderType","folderCacheFactory","hasCache","getCache","getItems","hasMoreItems","cursor","response","where","type","after","folders","meta","addItems","exports"],"sources":["ListFoldersRepository.ts"],"sourcesContent":["import { folderCacheFactory } from \"~/utils/FoldersCacheFactory\";\nimport { Folder, ListFoldersParams } from \"~/folder/folder.types\";\nimport { ListMeta } from \"~/types\";\n\nexport interface ListFoldersRepositoryParams {\n gateway: (params: ListFoldersParams) => Promise<[Folder[], ListMeta]>;\n}\n\nexport class ListFoldersRepository {\n private readonly gateway: (params: ListFoldersParams) => Promise<[Folder[], ListMeta]>;\n\n constructor(params: ListFoldersRepositoryParams) {\n this.gateway = params.gateway;\n }\n\n public async execute(folderType: string): Promise<Folder[]> {\n if (folderCacheFactory.hasCache(folderType)) {\n return folderCacheFactory.getCache(folderType).getItems();\n }\n\n let hasMoreItems: ListMeta[\"hasMoreItems\"] = true;\n let cursor: ListMeta[\"cursor\"] = null;\n\n while (hasMoreItems) {\n const response: [Folder[], ListMeta] = await this.gateway({\n where: { type: folderType },\n after: cursor\n });\n\n const [folders, meta] = response;\n\n folderCacheFactory.getCache(folderType).addItems(folders);\n hasMoreItems = meta.hasMoreItems;\n cursor = meta.cursor;\n }\n\n return folderCacheFactory.getCache(folderType).getItems();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAQO,MAAMC,qBAAqB,CAAC;EAG/BC,WAAWA,CAACC,MAAmC,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAACC,UAAkB,EAAqB;IACxD,IAAIC,uCAAkB,CAACC,QAAQ,CAACF,UAAU,CAAC,EAAE;MACzC,OAAOC,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACI,QAAQ,CAAC,CAAC;IAC7D;IAEA,IAAIC,YAAsC,GAAG,IAAI;IACjD,IAAIC,MAA0B,GAAG,IAAI;IAErC,OAAOD,YAAY,EAAE;MACjB,MAAME,QAA8B,GAAG,MAAM,IAAI,CAACT,OAAO,CAAC;QACtDU,KAAK,EAAE;UAAEC,IAAI,EAAET;QAAW,CAAC;QAC3BU,KAAK,EAAEJ;MACX,CAAC,CAAC;MAEF,MAAM,CAACK,OAAO,EAAEC,IAAI,CAAC,GAAGL,QAAQ;MAEhCN,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACa,QAAQ,CAACF,OAAO,CAAC;MACzDN,YAAY,GAAGO,IAAI,CAACP,YAAY;MAChCC,MAAM,GAAGM,IAAI,CAACN,MAAM;IACxB;IAEA,OAAOL,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACI,QAAQ,CAAC,CAAC;EAC7D;AACJ;AAACU,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_FoldersCacheFactory","require","ListFoldersRepository","constructor","params","gateway","execute","folderType","folderCacheFactory","hasCache","getCache","getItems","hasMoreItems","cursor","response","where","type","after","folders","meta","addItems","exports"],"sources":["ListFoldersRepository.ts"],"sourcesContent":["import { folderCacheFactory } from \"~/utils/FoldersCacheFactory\";\nimport type { Folder, ListFoldersParams } from \"~/folder/folder.types\";\nimport type { ListMeta } from \"~/types\";\n\nexport interface ListFoldersRepositoryParams {\n gateway: (params: ListFoldersParams) => Promise<[Folder[], ListMeta]>;\n}\n\nexport class ListFoldersRepository {\n private readonly gateway: (params: ListFoldersParams) => Promise<[Folder[], ListMeta]>;\n\n constructor(params: ListFoldersRepositoryParams) {\n this.gateway = params.gateway;\n }\n\n public async execute(folderType: string): Promise<Folder[]> {\n if (folderCacheFactory.hasCache(folderType)) {\n return folderCacheFactory.getCache(folderType).getItems();\n }\n\n let hasMoreItems: ListMeta[\"hasMoreItems\"] = true;\n let cursor: ListMeta[\"cursor\"] = null;\n\n while (hasMoreItems) {\n const response: [Folder[], ListMeta] = await this.gateway({\n where: { type: folderType },\n after: cursor\n });\n\n const [folders, meta] = response;\n\n folderCacheFactory.getCache(folderType).addItems(folders);\n hasMoreItems = meta.hasMoreItems;\n cursor = meta.cursor;\n }\n\n return folderCacheFactory.getCache(folderType).getItems();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAQO,MAAMC,qBAAqB,CAAC;EAG/BC,WAAWA,CAACC,MAAmC,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAACC,UAAkB,EAAqB;IACxD,IAAIC,uCAAkB,CAACC,QAAQ,CAACF,UAAU,CAAC,EAAE;MACzC,OAAOC,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACI,QAAQ,CAAC,CAAC;IAC7D;IAEA,IAAIC,YAAsC,GAAG,IAAI;IACjD,IAAIC,MAA0B,GAAG,IAAI;IAErC,OAAOD,YAAY,EAAE;MACjB,MAAME,QAA8B,GAAG,MAAM,IAAI,CAACT,OAAO,CAAC;QACtDU,KAAK,EAAE;UAAEC,IAAI,EAAET;QAAW,CAAC;QAC3BU,KAAK,EAAEJ;MACX,CAAC,CAAC;MAEF,MAAM,CAACK,OAAO,EAAEC,IAAI,CAAC,GAAGL,QAAQ;MAEhCN,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACa,QAAQ,CAACF,OAAO,CAAC;MACzDN,YAAY,GAAGO,IAAI,CAACP,YAAY;MAChCC,MAAM,GAAGM,IAAI,CAACN,MAAM;IACxB;IAEA,OAAOL,uCAAkB,CAACE,QAAQ,CAACH,UAAU,CAAC,CAACI,QAAQ,CAAC,CAAC;EAC7D;AACJ;AAACU,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ListSort } from "../types";
|
|
2
|
-
import { CmsEntryListSort } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { ListSort } from "../types";
|
|
2
|
+
import type { CmsEntryListSort } from "@webiny/api-headless-cms/types";
|
|
3
3
|
export declare const createListSort: (sort?: ListSort) => CmsEntryListSort | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createListSort","sort","Object","keys","map","key","exports"],"sources":["createListSort.ts"],"sourcesContent":["import { ListSort } from \"~/types\";\nimport {\n CmsEntryListSort,\n CmsEntryListSortAsc,\n CmsEntryListSortDesc\n} from \"@webiny/api-headless-cms/types\";\n\nexport const createListSort = (sort?: ListSort): CmsEntryListSort | undefined => {\n if (!sort) {\n return;\n }\n\n return Object.keys(sort).map(key => {\n return `${key}_${sort[key]}` as CmsEntryListSortAsc | CmsEntryListSortDesc;\n });\n};\n"],"mappings":";;;;;;AAOO,MAAMA,cAAc,GAAIC,IAAe,IAAmC;EAC7E,IAAI,CAACA,IAAI,EAAE;IACP;EACJ;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,GAAG,CAACC,GAAG,IAAI;IAChC,OAAO,GAAGA,GAAG,IAAIJ,IAAI,CAACI,GAAG,CAAC,EAAE;EAChC,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAN,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createListSort","sort","Object","keys","map","key","exports"],"sources":["createListSort.ts"],"sourcesContent":["import type { ListSort } from \"~/types\";\nimport type {\n CmsEntryListSort,\n CmsEntryListSortAsc,\n CmsEntryListSortDesc\n} from \"@webiny/api-headless-cms/types\";\n\nexport const createListSort = (sort?: ListSort): CmsEntryListSort | undefined => {\n if (!sort) {\n return;\n }\n\n return Object.keys(sort).map(key => {\n return `${key}_${sort[key]}` as CmsEntryListSortAsc | CmsEntryListSortDesc;\n });\n};\n"],"mappings":";;;;;;AAOO,MAAMA,cAAc,GAAIC,IAAe,IAAmC;EAC7E,IAAI,CAACA,IAAI,EAAE;IACP;EACJ;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,GAAG,CAACC,GAAG,IAAI;IAChC,OAAO,GAAGA,GAAG,IAAIJ,IAAI,CAACI,GAAG,CAAC,EAAE;EAChC,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAN,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_camelCase","_interopRequireDefault","require","createModelField","params","label","fieldId","initialFieldId","type","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId","exports"],"sources":["createModelField.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: fieldId,\n storageId: `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGX,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAS,kBAAS,EAACT,cAAc,CAAC,GAAG,IAAAS,kBAAS,EAACX,KAAK,CAAC;EAE7E,OAAO;IACHY,EAAE,EAAEX,OAAO;IACXY,SAAS,EAAE,GAAGV,IAAI,IAAIF,OAAO,EAAE;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAACM,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_camelCase","_interopRequireDefault","require","createModelField","params","label","fieldId","initialFieldId","type","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId","exports"],"sources":["createModelField.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: fieldId,\n storageId: `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGX,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAS,kBAAS,EAACT,cAAc,CAAC,GAAG,IAAAS,kBAAS,EAACX,KAAK,CAAC;EAE7E,OAAO;IACHY,EAAE,EAAEX,OAAO;IACXY,SAAS,EAAE,GAAGV,IAAI,IAAIF,OAAO,EAAE;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAACM,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
|
|
2
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
|
|
2
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
3
|
interface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {
|
|
4
4
|
modelName: string;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","createOperationsWrapper","params","cms","modelName","withModel","cb","model","getModel","WebinyError","exports"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n return cb(model);\n };\n\n return { withModel };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMO,MAAMC,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGF,MAAM;EAEjC,MAAMG,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnB,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAACJ,SAAS,CAAC;IAE3C,IAAI,CAACG,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CAAC,mBAAmBL,SAAS,UAAU,EAAE,uBAAuB,CAAC;IAC1F;IAEA,OAAOE,EAAE,CAACC,KAAK,CAAC;EACpB,CAAC;EAED,OAAO;IAAEF;EAAU,CAAC;AACxB,CAAC;AAACK,OAAA,CAAAT,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","createOperationsWrapper","params","cms","modelName","withModel","cb","model","getModel","WebinyError","exports"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import type { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n return cb(model);\n };\n\n return { withModel };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMO,MAAMC,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGF,MAAM;EAEjC,MAAMG,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnB,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAACJ,SAAS,CAAC;IAE3C,IAAI,CAACG,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CAAC,mBAAmBL,SAAS,UAAU,EAAE,uBAAuB,CAAC;IAC1F;IAEA,OAAOE,EAAE,CAACC,KAAK,CAAC;EACpB,CAAC;EAED,OAAO;IAAEF;EAAU,CAAC;AACxB,CAAC;AAACK,OAAA,CAAAT,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ class CmsEntriesCrudDecorators {
|
|
|
19
19
|
const folderLevelPermissions = context.aco.folderLevelPermissions;
|
|
20
20
|
const filterEntriesByFolder = new _FilterEntriesByFolderFactory.FilterEntriesByFolderFactory(folderLevelPermissions);
|
|
21
21
|
const listEntriesHandler = new _ListEntriesFactory.ListEntriesFactory(folderLevelPermissions);
|
|
22
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "listEntries", async (...allParams) => {
|
|
22
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "listEntries", async (...allParams) => {
|
|
23
23
|
const [decoratee, model, initialParams] = allParams;
|
|
24
24
|
return await listEntriesHandler.execute({
|
|
25
25
|
decoratee,
|
|
@@ -27,7 +27,7 @@ class CmsEntriesCrudDecorators {
|
|
|
27
27
|
initialParams
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "listLatestEntries", async (...allParams) => {
|
|
30
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "listLatestEntries", async (...allParams) => {
|
|
31
31
|
const [decoratee, model, initialParams] = allParams;
|
|
32
32
|
return await listEntriesHandler.execute({
|
|
33
33
|
decoratee,
|
|
@@ -35,7 +35,7 @@ class CmsEntriesCrudDecorators {
|
|
|
35
35
|
initialParams
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "listPublishedEntries", async (...allParams) => {
|
|
38
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "listPublishedEntries", async (...allParams) => {
|
|
39
39
|
const [decoratee, model, initialParams] = allParams;
|
|
40
40
|
return await listEntriesHandler.execute({
|
|
41
41
|
decoratee,
|
|
@@ -43,7 +43,7 @@ class CmsEntriesCrudDecorators {
|
|
|
43
43
|
initialParams
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "listDeletedEntries", async (...allParams) => {
|
|
46
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "listDeletedEntries", async (...allParams) => {
|
|
47
47
|
const [decoratee, model, initialParams] = allParams;
|
|
48
48
|
return await listEntriesHandler.execute({
|
|
49
49
|
decoratee,
|
|
@@ -51,7 +51,7 @@ class CmsEntriesCrudDecorators {
|
|
|
51
51
|
initialParams
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "getEntry", async (...allParams) => {
|
|
54
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "getEntry", async (...allParams) => {
|
|
55
55
|
const [decoratee, model, params] = allParams;
|
|
56
56
|
const entry = await decoratee(model, params);
|
|
57
57
|
const folderId = entry?.location?.folderId;
|
|
@@ -65,7 +65,7 @@ class CmsEntriesCrudDecorators {
|
|
|
65
65
|
});
|
|
66
66
|
return entry;
|
|
67
67
|
});
|
|
68
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "getEntryById", async (...allParams) => {
|
|
68
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "getEntryById", async (...allParams) => {
|
|
69
69
|
const [decoratee, model, params] = allParams;
|
|
70
70
|
const entry = await decoratee(model, params);
|
|
71
71
|
const folderId = entry?.location?.folderId;
|
|
@@ -79,17 +79,17 @@ class CmsEntriesCrudDecorators {
|
|
|
79
79
|
});
|
|
80
80
|
return entry;
|
|
81
81
|
});
|
|
82
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "getLatestEntriesByIds", async (...allParams) => {
|
|
82
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "getLatestEntriesByIds", async (...allParams) => {
|
|
83
83
|
const [decoratee, model, ids] = allParams;
|
|
84
84
|
const entries = await decoratee(model, ids);
|
|
85
85
|
return filterEntriesByFolder.execute(entries);
|
|
86
86
|
});
|
|
87
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "getPublishedEntriesByIds", async (...allParams) => {
|
|
87
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "getPublishedEntriesByIds", async (...allParams) => {
|
|
88
88
|
const [decoratee, model, ids] = allParams;
|
|
89
89
|
const entries = await decoratee(model, ids);
|
|
90
90
|
return filterEntriesByFolder.execute(entries);
|
|
91
91
|
});
|
|
92
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "createEntry", async (...allParams) => {
|
|
92
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "createEntry", async (...allParams) => {
|
|
93
93
|
const [decoratee, model, params, options] = allParams;
|
|
94
94
|
const folderId = params.wbyAco_location?.folderId || params.location?.folderId;
|
|
95
95
|
if (!folderId || folderId === _constants.ROOT_FOLDER) {
|
|
@@ -102,7 +102,7 @@ class CmsEntriesCrudDecorators {
|
|
|
102
102
|
});
|
|
103
103
|
return decoratee(model, params, options);
|
|
104
104
|
});
|
|
105
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "createEntryRevisionFrom", async (...allParams) => {
|
|
105
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "createEntryRevisionFrom", async (...allParams) => {
|
|
106
106
|
const [decoratee, model, id, input, options] = allParams;
|
|
107
107
|
const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
|
|
108
108
|
id
|
|
@@ -118,7 +118,7 @@ class CmsEntriesCrudDecorators {
|
|
|
118
118
|
});
|
|
119
119
|
return decoratee(model, id, input, options);
|
|
120
120
|
});
|
|
121
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "updateEntry", async (...allParams) => {
|
|
121
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "updateEntry", async (...allParams) => {
|
|
122
122
|
const [decoratee, model, id, input, meta, options] = allParams;
|
|
123
123
|
const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
|
|
124
124
|
id
|
|
@@ -134,7 +134,7 @@ class CmsEntriesCrudDecorators {
|
|
|
134
134
|
});
|
|
135
135
|
return decoratee(model, id, input, meta, options);
|
|
136
136
|
});
|
|
137
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "deleteEntry", async (...allParams) => {
|
|
137
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "deleteEntry", async (...allParams) => {
|
|
138
138
|
const [decoratee, model, id, options] = allParams;
|
|
139
139
|
const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(model, {
|
|
140
140
|
id
|
|
@@ -150,7 +150,7 @@ class CmsEntriesCrudDecorators {
|
|
|
150
150
|
});
|
|
151
151
|
return decoratee(model, id, options);
|
|
152
152
|
});
|
|
153
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "deleteEntryRevision", async (...allParams) => {
|
|
153
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "deleteEntryRevision", async (...allParams) => {
|
|
154
154
|
const [decoratee, model, id] = allParams;
|
|
155
155
|
const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
|
|
156
156
|
id
|
|
@@ -166,7 +166,7 @@ class CmsEntriesCrudDecorators {
|
|
|
166
166
|
});
|
|
167
167
|
return decoratee(model, id);
|
|
168
168
|
});
|
|
169
|
-
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context, "moveEntry", async (...allParams) => {
|
|
169
|
+
(0, _decorateIfModelAuthorizationEnabled.decorateIfModelAuthorizationEnabled)(context.cms, "moveEntry", async (...allParams) => {
|
|
170
170
|
const [decoratee, model, id, targetFolderId] = allParams;
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","_ListEntriesFactory","_FilterEntriesByFolderFactory","_decorateIfModelAuthorizationEnabled","CmsEntriesCrudDecorators","constructor","context","decorate","folderLevelPermissions","aco","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","allParams","decoratee","model","initialParams","execute","params","entry","folderId","location","ROOT_FOLDER","permissions","getFolderLevelPermissions","ensureCanAccessFolderContent","rwd","ids","entries","options","wbyAco_location","id","input","cms","storageOperations","getRevisionById","meta","getLatestRevisionByEntryId","targetFolderId","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled\";\n\ntype Context = AcoContext;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.aco.folderLevelPermissions;\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"listLatestEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"listDeletedEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id\n }\n );\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\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MACJ,CAAC,CAAC;MAEF,MAAMX,QAAQ,GAAGD,KAAK,EAAEE,QAAQ,EAAED,QAAQ,IAAIE,sBAAW;MACzD;AACZ;AACA;MACY,IAAIF,QAAQ,KAAKkB,cAAc,EAAE;QAC7B,OAAOxB,SAAS,CAACC,KAAK,EAAEgB,EAAE,EAAEO,cAAc,CAAC;MAC/C,CAAC,MAAM,IAAIlB,QAAQ,KAAKE,sBAAW,EAAE;QACjC;AAChB;AACA;QACgB,MAAMC,WAAW,GAAG,MAAMjB,sBAAsB,CAACkB,yBAAyB,CACtEJ,QACJ,CAAC;QACD,MAAMd,sBAAsB,CAACmB,4BAA4B,CAAC;UACtDF,WAAW;UACXG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MACA;AACZ;AACA;MACY,IAAIY,cAAc,KAAKhB,sBAAW,EAAE;QAChC,MAAMC,WAAW,GAAG,MAAMjB,sBAAsB,CAACkB,yBAAyB,CACtEJ,QACJ,CAAC;QACD,MAAMd,sBAAsB,CAACmB,4BAA4B,CAAC;UACtDF,WAAW;UACXG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MAEA,OAAOZ,SAAS,CAACC,KAAK,EAAEgB,EAAE,EAAEO,cAAc,CAAC;IAC/C,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAArC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_constants","require","_ListEntriesFactory","_FilterEntriesByFolderFactory","_decorateIfModelAuthorizationEnabled","CmsEntriesCrudDecorators","constructor","context","decorate","folderLevelPermissions","aco","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","cms","allParams","decoratee","model","initialParams","execute","params","entry","folderId","location","ROOT_FOLDER","permissions","getFolderLevelPermissions","ensureCanAccessFolderContent","rwd","ids","entries","options","wbyAco_location","id","input","storageOperations","getRevisionById","meta","getLatestRevisionByEntryId","targetFolderId","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import type { AcoContext } from \"~/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.aco.folderLevelPermissions;\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context.cms, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listLatestEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listDeletedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context.cms, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context.cms, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id\n }\n );\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,oCAAA,GAAAH,OAAA;AAQO,MAAMI,wBAAwB,CAAC;EAG3BC,WAAWA,CAAC;IAAEC;EAA0C,CAAC,EAAE;IAC9D,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEOC,QAAQA,CAAA,EAAG;IACd,MAAMD,OAAO,GAAG,IAAI,CAACA,OAAO;IAC5B,MAAME,sBAAsB,GAAGF,OAAO,CAACG,GAAG,CAACD,sBAAsB;IAEjE,MAAME,qBAAqB,GAAG,IAAIC,0DAA4B,CAACH,sBAAsB,CAAC;IACtF,MAAMI,kBAAkB,GAAG,IAAIC,sCAAkB,CAACL,sBAAsB,CAAC;IAEzE,IAAAM,wEAAmC,EAACR,OAAO,CAACS,GAAG,EAAE,aAAa,EAAE,OAAO,GAAGC,SAAS,KAAK;MACpF,MAAM,CAACC,SAAS,EAAEC,KAAK,EAAEC,aAAa,CAAC,GAAGH,SAAS;MACnD,OAAO,MAAMJ,kBAAkB,CAACQ,OAAO,CAAC;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AAMf,sBAAsB,CAACoB,4BAA4B,CAAC;UACtDF,WAAW;UACXG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MAEA,OAAOZ,SAAS,CAACC,KAAK,EAAEgB,EAAE,EAAEM,cAAc,CAAC;IAC/C,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAArC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FolderLevelPermissions } from "../../flp";
|
|
2
|
-
import { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { FolderLevelPermissions } from "../../flp";
|
|
2
|
+
import type { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
3
3
|
export declare class FilterEntriesByFolderFactory {
|
|
4
4
|
private readonly folderLevelPermissions;
|
|
5
5
|
constructor(folderLevelPermissions: FolderLevelPermissions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","FilterEntriesByFolderFactory","constructor","folderLevelPermissions","execute","entries","results","Promise","all","map","entry","folderId","location","ROOT_FOLDER","permissions","getFolderLevelPermissions","canAccessFolderContent","rwd","filter","exports"],"sources":["FilterEntriesByFolderFactory.ts"],"sourcesContent":["import { FolderLevelPermissions } from \"~/flp\";\nimport { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\n\nexport class FilterEntriesByFolderFactory {\n private readonly folderLevelPermissions: FolderLevelPermissions;\n\n constructor(folderLevelPermissions: FolderLevelPermissions) {\n this.folderLevelPermissions = folderLevelPermissions;\n }\n\n public async execute(entries: CmsEntry[]): Promise<CmsEntry[]> {\n const results = await Promise.all(\n entries.map(async entry => {\n const folderId = entry.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await this.folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n const canAccessFolderContent =\n await this.folderLevelPermissions.canAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return canAccessFolderContent ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,4BAA4B,CAAC;EAGtCC,WAAWA,CAACC,sBAA8C,EAAE;IACxD,IAAI,CAACA,sBAAsB,GAAGA,sBAAsB;EACxD;EAEA,MAAaC,OAAOA,CAACC,OAAmB,EAAuB;IAC3D,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BH,OAAO,CAACI,GAAG,CAAC,MAAMC,KAAK,IAAI;MACvB,MAAMC,QAAQ,GAAGD,KAAK,CAACE,QAAQ,EAAED,QAAQ;MACzC,IAAI,CAACA,QAAQ,IAAIA,QAAQ,KAAKE,sBAAW,EAAE;QACvC,OAAOH,KAAK;MAChB;MAEA,MAAMI,WAAW,GAAG,MAAM,IAAI,CAACX,sBAAsB,CAACY,yBAAyB,CAC3EJ,QACJ,CAAC;MACD,MAAMK,sBAAsB,GACxB,MAAM,IAAI,CAACb,sBAAsB,CAACa,sBAAsB,CAAC;QACrDF,WAAW;QACXG,GAAG,EAAE;MACT,CAAC,CAAC;MACN,OAAOD,sBAAsB,GAAGN,KAAK,GAAG,IAAI;IAChD,CAAC,CACL,CAAC;IAED,OAAOJ,OAAO,CAACY,MAAM,CAAER,KAAK,IAAwB,CAAC,CAACA,KAAK,CAAC;EAChE;AACJ;AAACS,OAAA,CAAAlB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_constants","require","FilterEntriesByFolderFactory","constructor","folderLevelPermissions","execute","entries","results","Promise","all","map","entry","folderId","location","ROOT_FOLDER","permissions","getFolderLevelPermissions","canAccessFolderContent","rwd","filter","exports"],"sources":["FilterEntriesByFolderFactory.ts"],"sourcesContent":["import type { FolderLevelPermissions } from \"~/flp\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\n\nexport class FilterEntriesByFolderFactory {\n private readonly folderLevelPermissions: FolderLevelPermissions;\n\n constructor(folderLevelPermissions: FolderLevelPermissions) {\n this.folderLevelPermissions = folderLevelPermissions;\n }\n\n public async execute(entries: CmsEntry[]): Promise<CmsEntry[]> {\n const results = await Promise.all(\n entries.map(async entry => {\n const folderId = entry.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await this.folderLevelPermissions.getFolderLevelPermissions(\n folderId\n );\n const canAccessFolderContent =\n await this.folderLevelPermissions.canAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return canAccessFolderContent ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,4BAA4B,CAAC;EAGtCC,WAAWA,CAACC,sBAA8C,EAAE;IACxD,IAAI,CAACA,sBAAsB,GAAGA,sBAAsB;EACxD;EAEA,MAAaC,OAAOA,CAACC,OAAmB,EAAuB;IAC3D,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BH,OAAO,CAACI,GAAG,CAAC,MAAMC,KAAK,IAAI;MACvB,MAAMC,QAAQ,GAAGD,KAAK,CAACE,QAAQ,EAAED,QAAQ;MACzC,IAAI,CAACA,QAAQ,IAAIA,QAAQ,KAAKE,sBAAW,EAAE;QACvC,OAAOH,KAAK;MAChB;MAEA,MAAMI,WAAW,GAAG,MAAM,IAAI,CAACX,sBAAsB,CAACY,yBAAyB,CAC3EJ,QACJ,CAAC;MACD,MAAMK,sBAAsB,GACxB,MAAM,IAAI,CAACb,sBAAsB,CAACa,sBAAsB,CAAC;QACrDF,WAAW;QACXG,GAAG,EAAE;MACT,CAAC,CAAC;MACN,OAAOD,sBAAsB,GAAGN,KAAK,GAAG,IAAI;IAChD,CAAC,CACL,CAAC;IAED,OAAOJ,OAAO,CAACY,MAAM,CAAER,KAAK,IAAwB,CAAC,CAACA,KAAK,CAAC;EAChE;AACJ;AAACS,OAAA,CAAAlB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FolderLevelPermissions } from "../../flp";
|
|
2
|
-
import { CmsEntry, CmsEntryListParams, CmsEntryMeta, CmsEntryValues
|
|
1
|
+
import type { FolderLevelPermissions } from "../../flp";
|
|
2
|
+
import type { CmsEntry, CmsEntryListParams, CmsEntryMeta, CmsEntryValues } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import { type CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
4
|
interface ListEntriesFactoryCallbackParams {
|
|
4
5
|
decoratee: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
5
6
|
model: CmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_hasRootFolderId","require","ListEntriesFactory","constructor","folderLevelPermissions","permissionsCache","Map","execute","decoratee","model","initialParams","limit","where","params","hasRootFolder","hasRootFolderId","resultEntries","totalCount","hasMoreItems","cursor","fetchedAll","afterCursor","after","queryParams","entries","currentMeta","entry","folderId","values","location","push","permissions","getPermissions","length","canAccessFolderContent","rwd","has","get","getFolderLevelPermissions","set","exports"],"sources":["ListEntriesFactory.ts"],"sourcesContent":["import { FolderLevelPermissions } from \"~/flp\";\nimport {\n CmsEntry,\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryValues
|
|
1
|
+
{"version":3,"names":["_hasRootFolderId","require","ListEntriesFactory","constructor","folderLevelPermissions","permissionsCache","Map","execute","decoratee","model","initialParams","limit","where","params","hasRootFolder","hasRootFolderId","resultEntries","totalCount","hasMoreItems","cursor","fetchedAll","afterCursor","after","queryParams","entries","currentMeta","entry","folderId","values","location","push","permissions","getPermissions","length","canAccessFolderContent","rwd","has","get","getFolderLevelPermissions","set","exports"],"sources":["ListEntriesFactory.ts"],"sourcesContent":["import type { FolderLevelPermissions } from \"~/flp\";\nimport type {\n CmsEntry,\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryValues\n} from \"@webiny/api-headless-cms/types\";\nimport { type CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { hasRootFolderId } from \"~/utils/decorators/hasRootFolderId\";\nimport type { FolderPermission } from \"~/flp/flp.types\";\n\ninterface ListEntriesFactoryCallbackParams {\n decoratee: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n model: CmsModel;\n initialParams?: CmsEntryListParams;\n}\n\nexport class ListEntriesFactory {\n private readonly folderLevelPermissions: FolderLevelPermissions;\n private readonly permissionsCache: Map<string, FolderPermission[]>;\n\n constructor(folderLevelPermissions: FolderLevelPermissions) {\n this.folderLevelPermissions = folderLevelPermissions;\n this.permissionsCache = new Map();\n }\n\n public async execute({\n decoratee,\n model,\n initialParams = {}\n }: ListEntriesFactoryCallbackParams): Promise<[CmsEntry[], CmsEntryMeta]> {\n const limit = initialParams?.limit || 50;\n const where = initialParams?.where;\n const params = { ...initialParams, limit };\n const hasRootFolder = hasRootFolderId({ model, where });\n\n // If we're querying the root folder, skip permission checks\n if (hasRootFolder) {\n return await decoratee(model, params);\n }\n\n const resultEntries: CmsEntry[] = [];\n let totalCount = 0;\n let hasMoreItems = true;\n let cursor: string | null = null;\n let fetchedAll = false;\n let afterCursor = params.after;\n\n // Process entries in batches until we have enough results or reach the end\n while (!fetchedAll) {\n const queryParams: CmsEntryListParams = { ...params, after: afterCursor };\n const [entries, currentMeta] = await decoratee(model, queryParams);\n\n if (totalCount === 0) {\n totalCount = currentMeta.totalCount;\n }\n\n // Process each entry and check folder permissions\n for (const entry of entries) {\n const folderId = entry.values?.location?.folderId || entry.location?.folderId;\n\n // If entry has no folderId, it's not using ACO folders system\n // Include it in results as it's not subject to folder permissions\n if (!folderId) {\n resultEntries.push(entry);\n continue;\n }\n\n const permissions = await this.getPermissions(folderId);\n\n // If no FLP exists for the folder, the entry is accessible\n // This means the folder doesn't have any permission restrictions\n if (!permissions.length) {\n resultEntries.push(entry);\n continue;\n }\n\n // Check if user has read permission for the folder\n if (\n await this.folderLevelPermissions.canAccessFolderContent({\n permissions,\n rwd: \"r\"\n })\n ) {\n resultEntries.push(entry);\n } else {\n totalCount--;\n }\n }\n\n // Determine if we need to fetch more entries\n if (!currentMeta.hasMoreItems || resultEntries.length >= limit) {\n fetchedAll = true;\n hasMoreItems = currentMeta.hasMoreItems;\n cursor = currentMeta.cursor;\n } else {\n afterCursor = currentMeta.cursor;\n }\n }\n\n return [resultEntries, { totalCount, hasMoreItems, cursor } as CmsEntryMeta];\n }\n\n private async getPermissions(folderId: string): Promise<FolderPermission[]> {\n if (this.permissionsCache.has(folderId)) {\n return this.permissionsCache.get(folderId) ?? [];\n }\n\n const permissions = await this.folderLevelPermissions.getFolderLevelPermissions(folderId);\n this.permissionsCache.set(folderId, permissions);\n return permissions;\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,gBAAA,GAAAC,OAAA;AAYO,MAAMC,kBAAkB,CAAC;EAI5BC,WAAWA,CAACC,sBAA8C,EAAE;IACxD,IAAI,CAACA,sBAAsB,GAAGA,sBAAsB;IACpD,IAAI,CAACC,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAAC;EACrC;EAEA,MAAaC,OAAOA,CAAC;IACjBC,SAAS;IACTC,KAAK;IACLC,aAAa,GAAG,CAAC;EACa,CAAC,EAAuC;IACtE,MAAMC,KAAK,GAAGD,aAAa,EAAEC,KAAK,IAAI,EAAE;IACxC,MAAMC,KAAK,GAAGF,aAAa,EAAEE,KAAK;IAClC,MAAMC,MAAM,GAAG;MAAE,GAAGH,aAAa;MAAEC;IAAM,CAAC;IAC1C,MAAMG,aAAa,GAAG,IAAAC,gCAAe,EAAC;MAAEN,KAAK;MAAEG;IAAM,CAAC,CAAC;;IAEvD;IACA,IAAIE,aAAa,EAAE;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,CAACQ,WAAW,CAACP,YAAY,IAAIF,aAAa,CAACiB,MAAM,IAAItB,KAAK,EAAE;QAC5DS,UAAU,GAAG,IAAI;QACjBF,YAAY,GAAGO,WAAW,CAACP,YAAY;QACvCC,MAAM,GAAGM,WAAW,CAACN,MAAM;MAC/B,CAAC,MAAM;QACHE,WAAW,GAAGI,WAAW,CAACN,MAAM;MACpC;IACJ;IAEA,OAAO,CAACH,aAAa,EAAE;MAAEC,UAAU;MAAEC,YAAY;MAAEC;IAAO,CAAC,CAAiB;EAChF;EAEA,MAAca,cAAcA,CAACL,QAAgB,EAA+B;IACxE,IAAI,IAAI,CAACtB,gBAAgB,CAAC+B,GAAG,CAACT,QAAQ,CAAC,EAAE;MACrC,OAAO,IAAI,CAACtB,gBAAgB,CAACgC,GAAG,CAACV,QAAQ,CAAC,IAAI,EAAE;IACpD;IAEA,MAAMI,WAAW,GAAG,MAAM,IAAI,CAAC3B,sBAAsB,CAACkC,yBAAyB,CAACX,QAAQ,CAAC;IACzF,IAAI,CAACtB,gBAAgB,CAACkC,GAAG,CAACZ,QAAQ,EAAEI,WAAW,CAAC;IAChD,OAAOA,WAAW;EACtB;AACJ;AAACS,OAAA,CAAAtC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type { AcoContext } from "../../types";
|
|
1
|
+
import type { CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
|
|
3
2
|
/**
|
|
4
3
|
* This type matches any function that has a CmsModel as the first parameter.
|
|
5
4
|
*/
|
|
@@ -20,5 +19,5 @@ type ModelMethods<T> = Omit<FilterModelMethods<T>, "getEntryManager" | "getSingl
|
|
|
20
19
|
* Decorator takes the decoratee as the _first_ parameter, and then forwards the rest of the parameters.
|
|
21
20
|
*/
|
|
22
21
|
type Decorator<T extends ModelCallable> = (decoratee: T, ...args: Parameters<T>) => ReturnType<T>;
|
|
23
|
-
export declare const decorateIfModelAuthorizationEnabled: <M extends "getEntry" | "getEntriesByIds" | "getEntryById" | "listEntries" | "listLatestEntries" | "listPublishedEntries" | "listDeletedEntries" | "getPublishedEntriesByIds" | "getLatestEntriesByIds" | "createEntry" | "createEntryRevisionFrom" | "updateEntry" | "validateEntry" | "moveEntry" | "republishEntry" | "deleteEntryRevision" | "deleteEntry" | "restoreEntryFromBin" | "deleteMultipleEntries" | "publishEntry" | "unpublishEntry" | "getEntryRevisions" | "getUniqueFieldValues", D extends Decorator<ModelMethods<HeadlessCms>[M]>>(
|
|
22
|
+
export declare const decorateIfModelAuthorizationEnabled: <M extends "getEntry" | "getEntriesByIds" | "getEntryById" | "listEntries" | "listLatestEntries" | "listPublishedEntries" | "listDeletedEntries" | "getPublishedEntriesByIds" | "getLatestEntriesByIds" | "createEntry" | "createEntryRevisionFrom" | "updateEntry" | "validateEntry" | "moveEntry" | "republishEntry" | "deleteEntryRevision" | "deleteEntry" | "restoreEntryFromBin" | "deleteMultipleEntries" | "publishEntry" | "unpublishEntry" | "getEntryRevisions" | "getUniqueFieldValues", D extends Decorator<ModelMethods<HeadlessCms>[M]>>(root: ModelMethods<HeadlessCms>, method: M, decorator: D) => void;
|
|
24
23
|
export {};
|
|
@@ -32,18 +32,14 @@ const modelAuthorizationDisabled = model => {
|
|
|
32
32
|
const isFolderModel = model => {
|
|
33
33
|
return model.modelId === _folder.FOLDER_MODEL_ID;
|
|
34
34
|
};
|
|
35
|
-
const decorateIfModelAuthorizationEnabled = (
|
|
35
|
+
const decorateIfModelAuthorizationEnabled = (root, method, decorator) => {
|
|
36
36
|
/**
|
|
37
37
|
* We cast to `ModelCallable` because within the generic function, we only know that the first
|
|
38
38
|
* parameter is a `CmsModel`, and we forward the rest.
|
|
39
39
|
*/
|
|
40
|
-
const root = context.cms;
|
|
41
40
|
const decoratee = root[method].bind(root);
|
|
42
41
|
root[method] = (...params) => {
|
|
43
42
|
const [model, ...rest] = params;
|
|
44
|
-
if (!context.security.isAuthorizationEnabled()) {
|
|
45
|
-
return decoratee(model, ...rest);
|
|
46
|
-
}
|
|
47
43
|
if (isFolderModel(model)) {
|
|
48
44
|
return decoratee(model, ...rest);
|
|
49
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_folder","require","modelAuthorizationDisabled","model","authorization","flp","isFolderModel","modelId","FOLDER_MODEL_ID","decorateIfModelAuthorizationEnabled","
|
|
1
|
+
{"version":3,"names":["_folder","require","modelAuthorizationDisabled","model","authorization","flp","isFolderModel","modelId","FOLDER_MODEL_ID","decorateIfModelAuthorizationEnabled","root","method","decorator","decoratee","bind","params","rest","exports"],"sources":["decorateIfModelAuthorizationEnabled.ts"],"sourcesContent":["import type { CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { FOLDER_MODEL_ID } from \"~/folder/folder.model\";\n\n/**\n * This type matches any function that has a CmsModel as the first parameter.\n */\ntype ModelCallable = (model: CmsModel, ...params: any[]) => any;\n\n/**\n * This type filters only `ModelCallable` methods.\n */\ntype FilterModelMethods<T> = {\n [K in keyof T as ModelCallable extends T[K] ? K : never]: T[K];\n};\n\n/**\n * This type omits methods that have a more complex `model` type.\n * E.g., `getEntryManager` has `model` typed as `CmsModel | string`.\n * Ideally, we would filter those out in the previous utility type, but I'm not sure how to achieve that.\n */\ntype ModelMethods<T> = Omit<FilterModelMethods<T>, \"getEntryManager\" | \"getSingletonEntryManager\">;\n\n/**\n * Decorator takes the decoratee as the _first_ parameter, and then forwards the rest of the parameters.\n */\ntype Decorator<T extends ModelCallable> = (decoratee: T, ...args: Parameters<T>) => ReturnType<T>;\n\nconst modelAuthorizationDisabled = (model: CmsModel) => {\n if (typeof model.authorization === \"object\") {\n return model?.authorization?.flp === false;\n }\n\n return model.authorization === false;\n};\n\nconst isFolderModel = (model: CmsModel) => {\n return model.modelId === FOLDER_MODEL_ID;\n};\n\nexport const decorateIfModelAuthorizationEnabled = <\n /**\n * This allows us to only have an auto-complete of `ModelCallable` methods.\n */\n M extends keyof ModelMethods<HeadlessCms>,\n D extends Decorator<ModelMethods<HeadlessCms>[M]>\n>(\n root: ModelMethods<HeadlessCms>,\n method: M,\n decorator: D\n) => {\n /**\n * We cast to `ModelCallable` because within the generic function, we only know that the first\n * parameter is a `CmsModel`, and we forward the rest.\n */\n const decoratee = root[method].bind(root) as ModelCallable;\n root[method] = ((...params: Parameters<ModelMethods<HeadlessCms>[M]>) => {\n const [model, ...rest] = params;\n if (isFolderModel(model)) {\n return decoratee(model, ...rest);\n }\n\n if (modelAuthorizationDisabled(model)) {\n return decoratee(model, ...rest);\n }\n\n return decorator(decoratee, ...params);\n }) as ModelCallable;\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAMC,0BAA0B,GAAIC,KAAe,IAAK;EACpD,IAAI,OAAOA,KAAK,CAACC,aAAa,KAAK,QAAQ,EAAE;IACzC,OAAOD,KAAK,EAAEC,aAAa,EAAEC,GAAG,KAAK,KAAK;EAC9C;EAEA,OAAOF,KAAK,CAACC,aAAa,KAAK,KAAK;AACxC,CAAC;AAED,MAAME,aAAa,GAAIH,KAAe,IAAK;EACvC,OAAOA,KAAK,CAACI,OAAO,KAAKC,uBAAe;AAC5C,CAAC;AAEM,MAAMC,mCAAmC,GAAGA,CAO/CC,IAA+B,EAC/BC,MAAS,EACTC,SAAY,KACX;EACD;AACJ;AACA;AACA;EACI,MAAMC,SAAS,GAAGH,IAAI,CAACC,MAAM,CAAC,CAACG,IAAI,CAACJ,IAAI,CAAkB;EAC1DA,IAAI,CAACC,MAAM,CAAC,GAAI,CAAC,GAAGI,MAAgD,KAAK;IACrE,MAAM,CAACZ,KAAK,EAAE,GAAGa,IAAI,CAAC,GAAGD,MAAM;IAC/B,IAAIT,aAAa,CAACH,KAAK,CAAC,EAAE;MACtB,OAAOU,SAAS,CAACV,KAAK,EAAE,GAAGa,IAAI,CAAC;IACpC;IAEA,IAAId,0BAA0B,CAACC,KAAK,CAAC,EAAE;MACnC,OAAOU,SAAS,CAACV,KAAK,EAAE,GAAGa,IAAI,CAAC;IACpC;IAEA,OAAOJ,SAAS,CAACC,SAAS,EAAE,GAAGE,MAAM,CAAC;EAC1C,CAAmB;AACvB,CAAC;AAACE,OAAA,CAAAR,mCAAA,GAAAA,mCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_isPlainObject","_interopRequireDefault","require","_isPageModel","_constants","hasRootFolderId","model","where","key","isPageModel","location","isPlainObject","folderId","ROOT_FOLDER","exports"],"sources":["hasRootFolderId.ts"],"sourcesContent":["import isPlainObject from \"lodash/isPlainObject\";\nimport { isPageModel } from \"~/utils/decorators/isPageModel\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere | undefined;\n}\n\nexport const hasRootFolderId = ({ model, where }: Params): boolean => {\n if (!where) {\n return false;\n }\n\n const key = isPageModel(model) ? \"location\" : \"wbyAco_location\";\n const location = where[key];\n\n if (typeof location === \"object\" && location !== null && isPlainObject(location)) {\n return (location as Record<string, any>).folderId === ROOT_FOLDER;\n }\n\n return false;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAOO,MAAMG,eAAe,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAc,CAAC,KAAc;EAClE,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,KAAK;EAChB;EAEA,MAAMC,GAAG,GAAG,IAAAC,wBAAW,EAACH,KAAK,CAAC,GAAG,UAAU,GAAG,iBAAiB;EAC/D,MAAMI,QAAQ,GAAGH,KAAK,CAACC,GAAG,CAAC;EAE3B,IAAI,OAAOE,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,KAAK,IAAI,IAAI,IAAAC,sBAAa,EAACD,QAAQ,CAAC,EAAE;IAC9E,OAAQA,QAAQ,CAAyBE,QAAQ,KAAKC,sBAAW;EACrE;EAEA,OAAO,KAAK;AAChB,CAAC;AAACC,OAAA,CAAAT,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_isPlainObject","_interopRequireDefault","require","_isPageModel","_constants","hasRootFolderId","model","where","key","isPageModel","location","isPlainObject","folderId","ROOT_FOLDER","exports"],"sources":["hasRootFolderId.ts"],"sourcesContent":["import isPlainObject from \"lodash/isPlainObject\";\nimport { isPageModel } from \"~/utils/decorators/isPageModel\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ROOT_FOLDER } from \"~/constants\";\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere | undefined;\n}\n\nexport const hasRootFolderId = ({ model, where }: Params): boolean => {\n if (!where) {\n return false;\n }\n\n const key = isPageModel(model) ? \"location\" : \"wbyAco_location\";\n const location = where[key];\n\n if (typeof location === \"object\" && location !== null && isPlainObject(location)) {\n return (location as Record<string, any>).folderId === ROOT_FOLDER;\n }\n\n return false;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAOO,MAAMG,eAAe,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAc,CAAC,KAAc;EAClE,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,KAAK;EAChB;EAEA,MAAMC,GAAG,GAAG,IAAAC,wBAAW,EAACH,KAAK,CAAC,GAAG,UAAU,GAAG,iBAAiB;EAC/D,MAAMI,QAAQ,GAAGH,KAAK,CAACC,GAAG,CAAC;EAE3B,IAAI,OAAOE,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,KAAK,IAAI,IAAI,IAAAC,sBAAa,EAACD,QAAQ,CAAC,EAAE;IAC9E,OAAQA,QAAQ,CAAyBE,QAAQ,KAAKC,sBAAW;EACrE;EAEA,OAAO,KAAK;AAChB,CAAC;AAACC,OAAA,CAAAT,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isPageModel","model","modelId","exports"],"sources":["isPageModel.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nexport const isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,WAAW,GAAIC,KAAe,IAAc;EACrD,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,IAAI;EACf,CAAC,MAAM,IAAID,KAAK,CAACC,OAAO,KAAK,wBAAwB,EAAE;IACnD,OAAO,IAAI;EACf;EACA,OAAO,KAAK;AAChB,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["isPageModel","model","modelId","exports"],"sources":["isPageModel.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nexport const isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,WAAW,GAAIC,KAAe,IAAc;EACrD,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,IAAI;EACf,CAAC,MAAM,IAAID,KAAK,CAACC,OAAO,KAAK,wBAAwB,EAAE;IACnD,OAAO,IAAI;EACf;EACA,OAAO,KAAK;AAChB,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AcoContext } from "../types";
|
|
1
|
+
import type { AcoContext } from "../types";
|
|
2
2
|
export declare const ensureAuthentication: (context: AcoContext) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiSecurity","require","ensureAuthentication","context","identity","security","getIdentity","NotAuthorizedError","exports"],"sources":["ensureAuthentication.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { AcoContext } from \"~/types\";\n\nexport const ensureAuthentication = (context: AcoContext) => {\n const identity = context.security.getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,oBAAoB,GAAIC,OAAmB,IAAK;EACzD,MAAMC,QAAQ,GAAGD,OAAO,CAACE,QAAQ,CAACC,WAAW,CAAC,CAAC;EAC/C,IAAI,CAACF,QAAQ,EAAE;IACX,MAAM,IAAIG,+BAAkB,CAAC,CAAC;EAClC;AACJ,CAAC;AAACC,OAAA,CAAAN,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_apiSecurity","require","ensureAuthentication","context","identity","security","getIdentity","NotAuthorizedError","exports"],"sources":["ensureAuthentication.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport type { AcoContext } from \"~/types\";\n\nexport const ensureAuthentication = (context: AcoContext) => {\n const identity = context.security.getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,oBAAoB,GAAIC,OAAmB,IAAK;EACzD,MAAMC,QAAQ,GAAGD,OAAO,CAACE,QAAQ,CAACC,WAAW,CAAC,CAAC;EAC/C,IAAI,CAACF,QAAQ,EAAE;IACX,MAAM,IAAIG,+BAAkB,CAAC,CAAC;EAClC;AACJ,CAAC;AAACC,OAAA,CAAAN,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
package/utils/modelFactory.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","locale","tenant","modelDefinition","createCmsModel","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull
|
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","locale","tenant","modelDefinition","createCmsModel","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import type { CmsModelPlugin, CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\nimport { createCmsModel } from \"@webiny/api-headless-cms\";\n\ninterface Params {\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: CmsPrivateModelFull;\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n locale,\n tenant,\n ...modelDefinition\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAaO,MAAMC,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGH,MAAM;EAElD,OAAO,IAAAI,8BAAc,EAAC;IAClBH,MAAM;IACNC,MAAM;IACN,GAAGC;EACP,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAN,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["baseFields","exports","pickBaseEntryFieldValues","entry","pickedValues","fieldName","srcFieldName","targetFieldName","split","Object","assign","pickEntryFieldValues","values"],"sources":["pickEntryFieldValues.ts"],"sourcesContent":["import { CmsEntry } from \"@webiny/api-headless-cms/types\";\n\nexport const baseFields = [\n // Entry ID is mapped to \"id\" (we don't use revisions with ACO entities).\n \"id\",\n \"tenant\",\n \"locale\",\n \"createdOn\",\n \"modifiedOn\",\n \"savedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\"\n];\n\nconst pickBaseEntryFieldValues = (entry: CmsEntry) => {\n const pickedValues: Partial<CmsEntry> = {};\n for (const fieldName of baseFields) {\n const [srcFieldName, targetFieldName = srcFieldName] = fieldName.split(\":\");\n if (srcFieldName in entry) {\n Object.assign(pickedValues, {\n [targetFieldName]: entry[srcFieldName as keyof CmsEntry]\n });\n }\n }\n\n return pickedValues;\n};\n\nexport function pickEntryFieldValues<T>(entry: CmsEntry): T {\n return {\n ...pickBaseEntryFieldValues(entry),\n ...entry.values\n } as T;\n}\n"],"mappings":";;;;;;;AAEO,MAAMA,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;AACtB;AACA,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,CACZ;AAED,MAAME,wBAAwB,GAAIC,KAAe,IAAK;EAClD,MAAMC,YAA+B,GAAG,CAAC,CAAC;EAC1C,KAAK,MAAMC,SAAS,IAAIL,UAAU,EAAE;IAChC,MAAM,CAACM,YAAY,EAAEC,eAAe,GAAGD,YAAY,CAAC,GAAGD,SAAS,CAACG,KAAK,CAAC,GAAG,CAAC;IAC3E,IAAIF,YAAY,IAAIH,KAAK,EAAE;MACvBM,MAAM,CAACC,MAAM,CAACN,YAAY,EAAE;QACxB,CAACG,eAAe,GAAGJ,KAAK,CAACG,YAAY;MACzC,CAAC,CAAC;IACN;EACJ;EAEA,OAAOF,YAAY;AACvB,CAAC;AAEM,SAASO,oBAAoBA,CAAIR,KAAe,EAAK;EACxD,OAAO;IACH,GAAGD,wBAAwB,CAACC,KAAK,CAAC;IAClC,GAAGA,KAAK,CAACS;EACb,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["baseFields","exports","pickBaseEntryFieldValues","entry","pickedValues","fieldName","srcFieldName","targetFieldName","split","Object","assign","pickEntryFieldValues","values"],"sources":["pickEntryFieldValues.ts"],"sourcesContent":["import type { CmsEntry } from \"@webiny/api-headless-cms/types\";\n\nexport const baseFields = [\n // Entry ID is mapped to \"id\" (we don't use revisions with ACO entities).\n \"id\",\n \"tenant\",\n \"locale\",\n \"createdOn\",\n \"modifiedOn\",\n \"savedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\"\n];\n\nconst pickBaseEntryFieldValues = (entry: CmsEntry) => {\n const pickedValues: Partial<CmsEntry> = {};\n for (const fieldName of baseFields) {\n const [srcFieldName, targetFieldName = srcFieldName] = fieldName.split(\":\");\n if (srcFieldName in entry) {\n Object.assign(pickedValues, {\n [targetFieldName]: entry[srcFieldName as keyof CmsEntry]\n });\n }\n }\n\n return pickedValues;\n};\n\nexport function pickEntryFieldValues<T>(entry: CmsEntry): T {\n return {\n ...pickBaseEntryFieldValues(entry),\n ...entry.values\n } as T;\n}\n"],"mappings":";;;;;;;AAEO,MAAMA,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;AACtB;AACA,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,CACZ;AAED,MAAME,wBAAwB,GAAIC,KAAe,IAAK;EAClD,MAAMC,YAA+B,GAAG,CAAC,CAAC;EAC1C,KAAK,MAAMC,SAAS,IAAIL,UAAU,EAAE;IAChC,MAAM,CAACM,YAAY,EAAEC,eAAe,GAAGD,YAAY,CAAC,GAAGD,SAAS,CAACG,KAAK,CAAC,GAAG,CAAC;IAC3E,IAAIF,YAAY,IAAIH,KAAK,EAAE;MACvBM,MAAM,CAACC,MAAM,CAACN,YAAY,EAAE;QACxB,CAACG,eAAe,GAAGJ,KAAK,CAACG,YAAY;MACzC,CAAC,CAAC;IACN;EACJ;EAEA,OAAOF,YAAY;AACvB,CAAC;AAEM,SAASO,oBAAoBA,CAAIR,KAAe,EAAK;EACxD,OAAO;IACH,GAAGD,wBAAwB,CAACC,KAAK,CAAC;IAClC,GAAGA,KAAK,CAACS;EACb,CAAC;AACL","ignoreList":[]}
|
package/utils/resolve.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ErrorResponse, ListResponse, Response } from "@webiny/handler-graphql";
|
|
2
|
-
export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any
|
|
2
|
+
export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
|
|
3
3
|
export declare const resolveList: (fn: () => Promise<any>) => Promise<ErrorResponse | ListResponse<unknown, any>>;
|