@webiny/api-aco 5.40.0-beta.2 → 5.40.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/AcoApp.js.map +1 -1
- package/apps/AcoApps.js.map +1 -1
- package/apps/app.gql.js +1 -2
- package/apps/app.gql.js.map +1 -1
- package/apps/index.js.map +1 -1
- package/createAcoContext.js +0 -1
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.js.map +1 -1
- package/createAcoStorageOperations.js.map +1 -1
- package/filter/filter.crud.js.map +1 -1
- package/filter/filter.gql.js +1 -2
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.model.js +1 -2
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.js.map +1 -1
- package/filter/filter.types.js +1 -2
- package/filter/filter.types.js.map +1 -1
- package/folder/folder.crud.js.map +1 -1
- package/folder/folder.gql.js +1 -2
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.js +1 -3
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.js +0 -1
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDeleteAco.hook.js.map +1 -1
- package/folder/onFolderBeforeDeleteFm.hook.js.map +1 -1
- package/folder/onFolderBeforeDeleteHcms.hook.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +31 -32
- package/plugins/AcoAppModifierPlugin.js.map +1 -1
- package/plugins/AcoAppRegisterPlugin.js.map +1 -1
- package/plugins/index.js.map +1 -1
- package/record/graphql/createAppResolvers.js.map +1 -1
- package/record/graphql/createAppSchema.js +2 -3
- package/record/graphql/createAppSchema.js.map +1 -1
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.js.map +1 -1
- package/record/record.model.js +2 -5
- package/record/record.model.js.map +1 -1
- package/record/record.so.js.map +1 -1
- package/record/record.types.js.map +1 -1
- package/types.js +1 -2
- package/types.js.map +1 -1
- package/utils/FolderLevelPermissions.js +7 -3
- package/utils/FolderLevelPermissions.js.map +1 -1
- package/utils/acoRecordId.js.map +1 -1
- package/utils/createListSort.js.map +1 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +42 -0
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/decorators/constants.js +1 -2
- package/utils/decorators/constants.js.map +1 -1
- package/utils/decorators/createFolderType.js.map +1 -1
- package/utils/decorators/decorateIfModelAuthorizationEnabled.d.ts +1 -1
- package/utils/decorators/decorateIfModelAuthorizationEnabled.js.map +1 -1
- package/utils/decorators/filterEntriesByFolderFactory.js.map +1 -1
- package/utils/decorators/isPageModel.js.map +1 -1
- package/utils/decorators/where.js.map +1 -1
- package/utils/ensureAuthentication.js.map +1 -1
- package/utils/getFolderAndItsAncestors.js.map +1 -1
- package/utils/modelFactory.js.map +1 -1
- package/utils/pickEntryFieldValues.js +1 -2
- package/utils/pickEntryFieldValues.js.map +1 -1
- package/utils/resolve.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_where","require","_constants","_filterEntriesByFolderFactory","_createFolderType","_decorateIfModelAuthorizationEnabled","CmsEntriesCrudDecorators","constructor","context","decorate","folderLevelPermissions","aco","filterEntriesByFolder","filterEntriesByFolderFactory","decorateIfModelAuthorizationEnabled","cms","allParams","decoratee","model","params","folderType","createFolderType","folders","listAllFoldersWithPermissions","where","createWhere","entry","folderId","location","ROOT_FOLDER","folder","get","ensureCanAccessFolderContent","rwd","ids","entries","options","wbyAco_location","id","input","storageOperations","getRevisionById","meta","getLatestRevisionByEntryId","targetFolderId","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { createWhere } from \"./where\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { filterEntriesByFolderFactory } from \"./filterEntriesByFolderFactory\";\nimport { createFolderType } from \"./createFolderType\";\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 = filterEntriesByFolderFactory(context, folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context.cms, \"listEntries\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(folderType);\n\n const where = createWhere({\n model,\n where: params.where,\n folders\n });\n return decoratee(model, {\n ...params,\n where\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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(model, 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(model, entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(targetFolderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAA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AAM;UACNG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MACA;AACZ;AACA;MACY,IAAIW,cAAc,KAAKf,sBAAW,EAAE;QAChC,MAAMC,MAAM,GAAG,MAAMtB,OAAO,CAACG,GAAG,CAACmB,MAAM,CAACC,GAAG,CAACa,cAAc,CAAC;QAC3D,MAAMlC,sBAAsB,CAACsB,4BAA4B,CAAC;UACtDF,MAAM;UACNG,GAAG,EAAE;QACT,CAAC,CAAC;MACN;MAEA,OAAOhB,SAAS,CAACC,KAAK,EAAEoB,EAAE,EAAEM,cAAc,CAAC;IAC/C,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAvC,wBAAA,GAAAA,wBAAA"}
|
|
1
|
+
{"version":3,"names":["_where","require","_constants","_filterEntriesByFolderFactory","_createFolderType","_decorateIfModelAuthorizationEnabled","CmsEntriesCrudDecorators","constructor","context","decorate","folderLevelPermissions","aco","filterEntriesByFolder","filterEntriesByFolderFactory","decorateIfModelAuthorizationEnabled","cms","allParams","decoratee","model","params","folderType","createFolderType","folders","listAllFoldersWithPermissions","where","createWhere","entry","folderId","location","ROOT_FOLDER","folder","get","ensureCanAccessFolderContent","rwd","ids","entries","options","wbyAco_location","id","input","storageOperations","getRevisionById","meta","getLatestRevisionByEntryId","targetFolderId","exports"],"sources":["CmsEntriesCrudDecorators.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { createWhere } from \"./where\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { filterEntriesByFolderFactory } from \"./filterEntriesByFolderFactory\";\nimport { createFolderType } from \"./createFolderType\";\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 = filterEntriesByFolderFactory(context, folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context.cms, \"listEntries\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(folderType);\n\n const where = createWhere({\n model,\n where: params.where,\n folders\n });\n return decoratee(model, {\n ...params,\n where\n });\n });\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listLatestEntries\",\n async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(\n folderType\n );\n\n const where = createWhere({\n model,\n where: params?.where || {},\n folders\n });\n return decoratee(model, {\n ...params,\n where\n });\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(\n folderType\n );\n\n const where = createWhere({\n model,\n where: params?.where || {},\n folders\n });\n return decoratee(model, {\n ...params,\n where\n });\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context.cms,\n \"listDeletedEntries\",\n async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const folderType = createFolderType(model);\n const folders = await folderLevelPermissions.listAllFoldersWithPermissions(\n folderType\n );\n\n const where = createWhere({\n model,\n where: params?.where || {},\n folders\n });\n return decoratee(model, {\n ...params,\n where\n });\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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(model, 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(model, entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context.cms, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\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 folder = await context.aco.folder.get(targetFolderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n folder,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,oCAAA,GAAAJ,OAAA;AAQO,MAAMK,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,IAAAC,0DAA4B,EAACL,OAAO,EAAEE,sBAAsB,CAAC;IAE3F,IAAAI,wEAAmC,EAACN,OAAO,CAACO,GAAG,EAAE,aAAa,EAAE,OAAO,GAAGC,SAAS,KAAK;MACpF,MAAM,CAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,CAAC,GAAGH,SAAS;MAC5C,MAAMI,UAAU,GAAG,IAAAC,kCAAgB,EAACH,KAAK,CAAC;MAC1C,MAAMI,OAAO,GAAG,MAAMZ,sBAAsB,CAACa,6BAA6B,CAACH,UAAU,CAAC;MAEtF,MAAMI,KAAK,GAAG,IAAAC,kBAAW,EAAC;QACtBP,KAAK;QACLM,KAAK,EAAEL,MAAM,CAACK,KAAK;QACnBF;MACJ,CAAC,CAAC;MACF,OAAOL,SAAS,CAACC,KAAK,EAAE;QACpB,GAAGC,MAA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1
|
-
{"version":3,"names":["ROOT_FOLDER","exports"],"sources":["constants.ts"],"sourcesContent":["export const ROOT_FOLDER = \"root\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,
|
|
1
|
+
{"version":3,"names":["ROOT_FOLDER","exports"],"sources":["constants.ts"],"sourcesContent":["export const ROOT_FOLDER = \"root\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,MAAM","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_isPageModel","require","createFolderType","model","modelId","isPageModel","exports"],"sources":["createFolderType.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { isPageModel } from \"./isPageModel\";\n\nexport const createFolderType = (model: CmsModel): \"FmFile\" | \"PbPage\" | `cms:${string}` => {\n if (model.modelId === \"fmFile\") {\n return \"FmFile\";\n } else if (isPageModel(model)) {\n return \"PbPage\";\n }\n return `cms:${model.modelId}`;\n};\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,gBAAgB,GAAIC,KAAe,IAA4C;EACxF,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,QAAQ;EACnB,CAAC,MAAM,IAAI,IAAAC,wBAAW,EAACF,KAAK,CAAC,EAAE;IAC3B,OAAO,QAAQ;EACnB;EACA,OAAQ,OAAMA,KAAK,CAACC,OAAQ,EAAC;AACjC,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
|
|
1
|
+
{"version":3,"names":["_isPageModel","require","createFolderType","model","modelId","isPageModel","exports"],"sources":["createFolderType.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { isPageModel } from \"./isPageModel\";\n\nexport const createFolderType = (model: CmsModel): \"FmFile\" | \"PbPage\" | `cms:${string}` => {\n if (model.modelId === \"fmFile\") {\n return \"FmFile\";\n } else if (isPageModel(model)) {\n return \"PbPage\";\n }\n return `cms:${model.modelId}`;\n};\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,gBAAgB,GAAIC,KAAe,IAA4C;EACxF,IAAIA,KAAK,CAACC,OAAO,KAAK,QAAQ,EAAE;IAC5B,OAAO,QAAQ;EACnB,CAAC,MAAM,IAAI,IAAAC,wBAAW,EAACF,KAAK,CAAC,EAAE;IAC3B,OAAO,QAAQ;EACnB;EACA,OAAQ,OAAMA,KAAK,CAACC,OAAQ,EAAC;AACjC,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -19,5 +19,5 @@ declare type ModelMethods<T> = Omit<FilterModelMethods<T>, "getEntryManager">;
|
|
|
19
19
|
* Decorator takes the decoratee as the _first_ parameter, and then forwards the rest of the parameters.
|
|
20
20
|
*/
|
|
21
21
|
declare type Decorator<T extends ModelCallable> = (decoratee: T, ...args: Parameters<T>) => ReturnType<T>;
|
|
22
|
-
export declare const decorateIfModelAuthorizationEnabled: <M extends "getEntry" | "getEntriesByIds" | "getEntryById" | "listEntries" | "listLatestEntries" | "listPublishedEntries" | "getPublishedEntriesByIds" | "getLatestEntriesByIds" | "createEntry" | "createEntryRevisionFrom" | "updateEntry" | "validateEntry" | "moveEntry" | "republishEntry" | "deleteEntryRevision" | "deleteEntry" | "deleteMultipleEntries" | "publishEntry" | "unpublishEntry" | "getEntryRevisions" | "getUniqueFieldValues", D extends Decorator<ModelMethods<HeadlessCms>[M]>>(root: ModelMethods<HeadlessCms>, method: M, decorator: D) => void;
|
|
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;
|
|
23
23
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["modelAuthorizationDisabled","model","authorization","flp","decorateIfModelAuthorizationEnabled","root","method","decorator","decoratee","bind","params","rest","exports"],"sources":["decorateIfModelAuthorizationEnabled.ts"],"sourcesContent":["import { CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\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\">;\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\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 (modelAuthorizationDisabled(model)) {\n return decoratee(model, ...rest);\n }\n\n return decorator(decoratee, ...params);\n }) as ModelCallable;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAMA,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;AAEM,MAAME,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,CAACT,KAAK,EAAE,GAAGU,IAAI,CAAC,GAAGD,MAAM;IAC/B,IAAIV,0BAA0B,CAACC,KAAK,CAAC,EAAE;MACnC,OAAOO,SAAS,CAACP,KAAK,EAAE,GAAGU,IAAI,CAAC;IACpC;IAEA,OAAOJ,SAAS,CAACC,SAAS,EAAE,GAAGE,MAAM,CAAC;EAC1C,CAAmB;AACvB,CAAC;AAACE,OAAA,CAAAR,mCAAA,GAAAA,mCAAA"}
|
|
1
|
+
{"version":3,"names":["modelAuthorizationDisabled","model","authorization","flp","decorateIfModelAuthorizationEnabled","root","method","decorator","decoratee","bind","params","rest","exports"],"sources":["decorateIfModelAuthorizationEnabled.ts"],"sourcesContent":["import { CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\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\">;\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\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 (modelAuthorizationDisabled(model)) {\n return decoratee(model, ...rest);\n }\n\n return decorator(decoratee, ...params);\n }) as ModelCallable;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAMA,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;AAEM,MAAME,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,CAACT,KAAK,EAAE,GAAGU,IAAI,CAAC,GAAGD,MAAM;IAC/B,IAAIV,0BAA0B,CAACC,KAAK,CAAC,EAAE;MACnC,OAAOO,SAAS,CAACP,KAAK,EAAE,GAAGU,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":["_handlerGraphql","require","_constants","_createFolderType","filterEntriesByFolderFactory","context","permissions","model","entries","folders","aco","folder","listAll","where","type","createFolderType","results","Promise","all","map","entry","folderId","location","ROOT_FOLDER","find","id","NotFoundError","result","canAccessFolderContent","rwd","filter","exports"],"sources":["filterEntriesByFolderFactory.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { ROOT_FOLDER } from \"./constants\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n\nimport { createFolderType } from \"./createFolderType\";\n\nexport const filterEntriesByFolderFactory = (\n context: Context,\n permissions: FolderLevelPermissions\n) => {\n return async (model: CmsModel, entries: CmsEntry[]) => {\n const [folders] = await context.aco.folder.listAll({\n where: {\n type: createFolderType(model)\n }\n });\n\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 folder = folders.find(folder => folder.id === folderId);\n if (!folder) {\n throw new NotFoundError(`Folder \"${folderId}\" not found.`);\n }\n const result = await permissions.canAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return result ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,4BAA4B,GAAGA,CACxCC,OAAgB,EAChBC,WAAmC,KAClC;EACD,OAAO,OAAOC,KAAe,EAAEC,OAAmB,KAAK;IACnD,MAAM,CAACC,OAAO,CAAC,GAAG,MAAMJ,OAAO,CAACK,GAAG,CAACC,MAAM,CAACC,OAAO,CAAC;MAC/CC,KAAK,EAAE;QACHC,IAAI,EAAE,IAAAC,kCAAgB,EAACR,KAAK;MAChC;IACJ,CAAC,CAAC;IAEF,MAAMS,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BV,OAAO,CAACW,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,MAAMT,MAAM,GAAGF,OAAO,CAACe,IAAI,CAACb,MAAM,IAAIA,MAAM,CAACc,EAAE,KAAKJ,QAAQ,CAAC;MAC7D,IAAI,CAACV,MAAM,EAAE;QACT,MAAM,IAAIe,6BAAa,CAAE,WAAUL,QAAS,cAAa,CAAC;MAC9D;MACA,MAAMM,MAAM,GAAG,MAAMrB,WAAW,CAACsB,sBAAsB,CAAC;QACpDjB,MAAM;QACNkB,GAAG,EAAE;MACT,CAAC,CAAC;MACF,OAAOF,MAAM,GAAGP,KAAK,GAAG,IAAI;IAChC,CAAC,CACL,CAAC;IAED,OAAOJ,OAAO,CAACc,MAAM,CAAEV,KAAK,IAAwB,CAAC,CAACA,KAAK,CAAC;EAChE,CAAC;AACL,CAAC;AAACW,OAAA,CAAA3B,4BAAA,GAAAA,4BAAA"}
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_constants","_createFolderType","filterEntriesByFolderFactory","context","permissions","model","entries","folders","aco","folder","listAll","where","type","createFolderType","results","Promise","all","map","entry","folderId","location","ROOT_FOLDER","find","id","NotFoundError","result","canAccessFolderContent","rwd","filter","exports"],"sources":["filterEntriesByFolderFactory.ts"],"sourcesContent":["import { AcoContext } from \"~/types\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { ROOT_FOLDER } from \"./constants\";\n\ntype Context = Pick<AcoContext, \"aco\" | \"cms\">;\n\nimport { createFolderType } from \"./createFolderType\";\n\nexport const filterEntriesByFolderFactory = (\n context: Context,\n permissions: FolderLevelPermissions\n) => {\n return async (model: CmsModel, entries: CmsEntry[]) => {\n const [folders] = await context.aco.folder.listAll({\n where: {\n type: createFolderType(model)\n }\n });\n\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 folder = folders.find(folder => folder.id === folderId);\n if (!folder) {\n throw new NotFoundError(`Folder \"${folderId}\" not found.`);\n }\n const result = await permissions.canAccessFolderContent({\n folder,\n rwd: \"r\"\n });\n return result ? entry : null;\n })\n );\n\n return results.filter((entry): entry is CmsEntry => !!entry);\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,4BAA4B,GAAGA,CACxCC,OAAgB,EAChBC,WAAmC,KAClC;EACD,OAAO,OAAOC,KAAe,EAAEC,OAAmB,KAAK;IACnD,MAAM,CAACC,OAAO,CAAC,GAAG,MAAMJ,OAAO,CAACK,GAAG,CAACC,MAAM,CAACC,OAAO,CAAC;MAC/CC,KAAK,EAAE;QACHC,IAAI,EAAE,IAAAC,kCAAgB,EAACR,KAAK;MAChC;IACJ,CAAC,CAAC;IAEF,MAAMS,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BV,OAAO,CAACW,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,MAAMT,MAAM,GAAGF,OAAO,CAACe,IAAI,CAACb,MAAM,IAAIA,MAAM,CAACc,EAAE,KAAKJ,QAAQ,CAAC;MAC7D,IAAI,CAACV,MAAM,EAAE;QACT,MAAM,IAAIe,6BAAa,CAAE,WAAUL,QAAS,cAAa,CAAC;MAC9D;MACA,MAAMM,MAAM,GAAG,MAAMrB,WAAW,CAACsB,sBAAsB,CAAC;QACpDjB,MAAM;QACNkB,GAAG,EAAE;MACT,CAAC,CAAC;MACF,OAAOF,MAAM,GAAGP,KAAK,GAAG,IAAI;IAChC,CAAC,CACL,CAAC;IAED,OAAOJ,OAAO,CAACc,MAAM,CAAEV,KAAK,IAAwB,CAAC,CAACA,KAAK,CAAC;EAChE,CAAC;AACL,CAAC;AAACW,OAAA,CAAA3B,4BAAA,GAAAA,4BAAA","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"}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","_isPageModel","createWhere","params","model","where","folders","locationFieldName","isPageModel","whereLocation","folderId_in","ROOT_FOLDER","map","folder","id","whereAnd","AND","exports"],"sources":["where.ts"],"sourcesContent":["import { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Folder } from \"~/folder/folder.types\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { isPageModel } from \"~/utils/decorators/isPageModel\";\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere | undefined;\n folders: Folder[];\n}\n\n/**\n * There are multiple cases that we need to handle:\n * * existing location with no AND conditional\n * * existing location with AND conditional\n * * no existing location with no AND conditional + with AND conditional\n */\nexport const createWhere = (params: Params): CmsEntryListWhere | undefined => {\n const { model, where, folders } = params;\n\n // Once we migrate PB to HCMS, we can remove this check and always use `wbAco_location`.\n const locationFieldName = isPageModel(model) ? \"location\" : \"wbyAco_location\";\n\n const whereLocation = {\n [locationFieldName]: {\n // At the moment, all users can access entries in the root folder.\n // Root folder level permissions cannot be set yet.\n folderId_in: [ROOT_FOLDER, ...folders.map(folder => folder.id)]\n }\n };\n\n if (!where) {\n // If no `where` condition is present, that means we're performing a query\n // across all folders. Still, with FLP enabled, we need to filter out\n // folders to which the user does not have access.\n return whereLocation;\n }\n\n const whereAnd = where.AND;\n if (where[locationFieldName] && !whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n }\n ]\n };\n } else if (where[locationFieldName] && whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n },\n ...whereAnd\n ]\n };\n }\n\n return {\n ...where,\n ...whereLocation\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;;EAExC;EACA,MAAMI,iBAAiB,GAAG,IAAAC,wBAAW,EAACJ,KAAK,CAAC,GAAG,UAAU,GAAG,iBAAiB;EAE7E,MAAMK,aAAa,GAAG;IAClB,CAACF,iBAAiB,GAAG;MACjB;MACA;MACAG,WAAW,EAAE,CAACC,sBAAW,EAAE,GAAGL,OAAO,CAACM,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,EAAE,CAAC;IAClE;EACJ,CAAC;EAED,IAAI,CAACT,KAAK,EAAE;IACR;IACA;IACA;IACA,OAAOI,aAAa;EACxB;EAEA,MAAMM,QAAQ,GAAGV,KAAK,CAACW,GAAG;EAC1B,IAAIX,KAAK,CAACE,iBAAiB,CAAC,IAAI,CAACQ,QAAQ,EAAE;IACvC,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC;IAET,CAAC;EACL,CAAC,MAAM,IAAIJ,KAAK,CAACE,iBAAiB,CAAC,IAAIQ,QAAQ,EAAE;IAC7C,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC,EACD,GAAGM,QAAQ;IAEnB,CAAC;EACL;EAEA,OAAO;IACH,GAAGV,KAAK;IACR,GAAGI;EACP,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAf,WAAA,GAAAA,WAAA"}
|
|
1
|
+
{"version":3,"names":["_constants","require","_isPageModel","createWhere","params","model","where","folders","locationFieldName","isPageModel","whereLocation","folderId_in","ROOT_FOLDER","map","folder","id","whereAnd","AND","exports"],"sources":["where.ts"],"sourcesContent":["import { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Folder } from \"~/folder/folder.types\";\nimport { ROOT_FOLDER } from \"./constants\";\nimport { isPageModel } from \"~/utils/decorators/isPageModel\";\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere | undefined;\n folders: Folder[];\n}\n\n/**\n * There are multiple cases that we need to handle:\n * * existing location with no AND conditional\n * * existing location with AND conditional\n * * no existing location with no AND conditional + with AND conditional\n */\nexport const createWhere = (params: Params): CmsEntryListWhere | undefined => {\n const { model, where, folders } = params;\n\n // Once we migrate PB to HCMS, we can remove this check and always use `wbAco_location`.\n const locationFieldName = isPageModel(model) ? \"location\" : \"wbyAco_location\";\n\n const whereLocation = {\n [locationFieldName]: {\n // At the moment, all users can access entries in the root folder.\n // Root folder level permissions cannot be set yet.\n folderId_in: [ROOT_FOLDER, ...folders.map(folder => folder.id)]\n }\n };\n\n if (!where) {\n // If no `where` condition is present, that means we're performing a query\n // across all folders. Still, with FLP enabled, we need to filter out\n // folders to which the user does not have access.\n return whereLocation;\n }\n\n const whereAnd = where.AND;\n if (where[locationFieldName] && !whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n }\n ]\n };\n } else if (where[locationFieldName] && whereAnd) {\n return {\n ...where,\n AND: [\n {\n ...whereLocation\n },\n ...whereAnd\n ]\n };\n }\n\n return {\n ...where,\n ...whereLocation\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,WAAW,GAAIC,MAAc,IAAoC;EAC1E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;;EAExC;EACA,MAAMI,iBAAiB,GAAG,IAAAC,wBAAW,EAACJ,KAAK,CAAC,GAAG,UAAU,GAAG,iBAAiB;EAE7E,MAAMK,aAAa,GAAG;IAClB,CAACF,iBAAiB,GAAG;MACjB;MACA;MACAG,WAAW,EAAE,CAACC,sBAAW,EAAE,GAAGL,OAAO,CAACM,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,EAAE,CAAC;IAClE;EACJ,CAAC;EAED,IAAI,CAACT,KAAK,EAAE;IACR;IACA;IACA;IACA,OAAOI,aAAa;EACxB;EAEA,MAAMM,QAAQ,GAAGV,KAAK,CAACW,GAAG;EAC1B,IAAIX,KAAK,CAACE,iBAAiB,CAAC,IAAI,CAACQ,QAAQ,EAAE;IACvC,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC;IAET,CAAC;EACL,CAAC,MAAM,IAAIJ,KAAK,CAACE,iBAAiB,CAAC,IAAIQ,QAAQ,EAAE;IAC7C,OAAO;MACH,GAAGV,KAAK;MACRW,GAAG,EAAE,CACD;QACI,GAAGP;MACP,CAAC,EACD,GAAGM,QAAQ;IAEnB,CAAC;EACL;EAEA,OAAO;IACH,GAAGV,KAAK;IACR,GAAGI;EACP,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAf,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -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"}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFolderAndItsAncestors","folder","folders","folderMap","Map","forEach","set","id","findParents","next","current","push","parentId","parent","get","exports"],"sources":["getFolderAndItsAncestors.ts"],"sourcesContent":["import { Folder } from \"~/folder/folder.types\";\n\ninterface GetFolderAndItsAncestorsParams {\n folder: Folder;\n folders: Folder[];\n}\n\nexport const getFolderAndItsAncestors = ({\n folder,\n folders\n}: GetFolderAndItsAncestorsParams): Folder[] => {\n // Create a Map with folders, using folder.id as key\n const folderMap = new Map<string, Folder>();\n folders.forEach(folder => folderMap.set(folder.id, folder));\n\n const findParents = (next: Folder[], current: Folder): Folder[] => {\n // No folder found: return the result\n if (!current) {\n return next;\n }\n\n // Push the current folder into the accumulator array\n next.push(current);\n\n // No parentId found: return the result\n if (!current.parentId) {\n return next;\n }\n\n const parent = folderMap.get(current.parentId);\n\n // No parent found: return the result\n if (!parent) {\n return next;\n }\n\n // Go ahead and find parent for the current parent\n return findParents(next, parent);\n };\n\n // No folder found: return an empty array\n if (!folder) {\n return [];\n }\n\n // The folder has no parent (it's at root level): return an array with the folder\n if (!folder.parentId) {\n return [folder];\n }\n\n // Recursively find parents for a given folder id\n return findParents([], folder);\n};\n"],"mappings":";;;;;;AAOO,MAAMA,wBAAwB,GAAGA,CAAC;EACrCC,MAAM;EACNC;AAC4B,CAAC,KAAe;EAC5C;EACA,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAC3CF,OAAO,CAACG,OAAO,CAACJ,MAAM,IAAIE,SAAS,CAACG,GAAG,CAACL,MAAM,CAACM,EAAE,EAAEN,MAAM,CAAC,CAAC;EAE3D,MAAMO,WAAW,GAAGA,CAACC,IAAc,EAAEC,OAAe,KAAe;IAC/D;IACA,IAAI,CAACA,OAAO,EAAE;MACV,OAAOD,IAAI;IACf;;IAEA;IACAA,IAAI,CAACE,IAAI,CAACD,OAAO,CAAC;;IAElB;IACA,IAAI,CAACA,OAAO,CAACE,QAAQ,EAAE;MACnB,OAAOH,IAAI;IACf;IAEA,MAAMI,MAAM,GAAGV,SAAS,CAACW,GAAG,CAACJ,OAAO,CAACE,QAAQ,CAAC;;IAE9C;IACA,IAAI,CAACC,MAAM,EAAE;MACT,OAAOJ,IAAI;IACf;;IAEA;IACA,OAAOD,WAAW,CAACC,IAAI,EAAEI,MAAM,CAAC;EACpC,CAAC;;EAED;EACA,IAAI,CAACZ,MAAM,EAAE;IACT,OAAO,EAAE;EACb;;EAEA;EACA,IAAI,CAACA,MAAM,CAACW,QAAQ,EAAE;IAClB,OAAO,CAACX,MAAM,CAAC;EACnB;;EAEA;EACA,OAAOO,WAAW,CAAC,EAAE,EAAEP,MAAM,CAAC;AAClC,CAAC;AAACc,OAAA,CAAAf,wBAAA,GAAAA,wBAAA"}
|
|
1
|
+
{"version":3,"names":["getFolderAndItsAncestors","folder","folders","folderMap","Map","forEach","set","id","findParents","next","current","push","parentId","parent","get","exports"],"sources":["getFolderAndItsAncestors.ts"],"sourcesContent":["import { Folder } from \"~/folder/folder.types\";\n\ninterface GetFolderAndItsAncestorsParams {\n folder: Folder;\n folders: Folder[];\n}\n\nexport const getFolderAndItsAncestors = ({\n folder,\n folders\n}: GetFolderAndItsAncestorsParams): Folder[] => {\n // Create a Map with folders, using folder.id as key\n const folderMap = new Map<string, Folder>();\n folders.forEach(folder => folderMap.set(folder.id, folder));\n\n const findParents = (next: Folder[], current: Folder): Folder[] => {\n // No folder found: return the result\n if (!current) {\n return next;\n }\n\n // Push the current folder into the accumulator array\n next.push(current);\n\n // No parentId found: return the result\n if (!current.parentId) {\n return next;\n }\n\n const parent = folderMap.get(current.parentId);\n\n // No parent found: return the result\n if (!parent) {\n return next;\n }\n\n // Go ahead and find parent for the current parent\n return findParents(next, parent);\n };\n\n // No folder found: return an empty array\n if (!folder) {\n return [];\n }\n\n // The folder has no parent (it's at root level): return an array with the folder\n if (!folder.parentId) {\n return [folder];\n }\n\n // Recursively find parents for a given folder id\n return findParents([], folder);\n};\n"],"mappings":";;;;;;AAOO,MAAMA,wBAAwB,GAAGA,CAAC;EACrCC,MAAM;EACNC;AAC4B,CAAC,KAAe;EAC5C;EACA,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAC3CF,OAAO,CAACG,OAAO,CAACJ,MAAM,IAAIE,SAAS,CAACG,GAAG,CAACL,MAAM,CAACM,EAAE,EAAEN,MAAM,CAAC,CAAC;EAE3D,MAAMO,WAAW,GAAGA,CAACC,IAAc,EAAEC,OAAe,KAAe;IAC/D;IACA,IAAI,CAACA,OAAO,EAAE;MACV,OAAOD,IAAI;IACf;;IAEA;IACAA,IAAI,CAACE,IAAI,CAACD,OAAO,CAAC;;IAElB;IACA,IAAI,CAACA,OAAO,CAACE,QAAQ,EAAE;MACnB,OAAOH,IAAI;IACf;IAEA,MAAMI,MAAM,GAAGV,SAAS,CAACW,GAAG,CAACJ,OAAO,CAACE,QAAQ,CAAC;;IAE9C;IACA,IAAI,CAACC,MAAM,EAAE;MACT,OAAOJ,IAAI;IACf;;IAEA;IACA,OAAOD,WAAW,CAACC,IAAI,EAAEI,MAAM,CAAC;EACpC,CAAC;;EAED;EACA,IAAI,CAACZ,MAAM,EAAE;IACT,OAAO,EAAE;EACb;;EAEA;EACA,IAAI,CAACA,MAAM,CAACW,QAAQ,EAAE;IAClB,OAAO,CAACX,MAAM,CAAC;EACnB;;EAEA;EACA,OAAOO,WAAW,CAAC,EAAE,EAAEP,MAAM,CAAC;AAClC,CAAC;AAACc,OAAA,CAAAf,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","locale","tenant","modelDefinition","createCmsModel","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, 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":";;;;;;AAAA,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"}
|
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","modelFactory","params","locale","tenant","modelDefinition","createCmsModel","exports"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, 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":";;;;;;AAAA,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":[]}
|
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.baseFields = void 0;
|
|
7
7
|
exports.pickEntryFieldValues = pickEntryFieldValues;
|
|
8
|
-
const baseFields = [
|
|
8
|
+
const baseFields = exports.baseFields = [
|
|
9
9
|
// Entry ID is mapped to "id" (we don't use revisions with ACO entities).
|
|
10
10
|
"id", "createdOn", "modifiedOn", "savedOn", "createdBy", "modifiedBy", "savedBy"];
|
|
11
|
-
exports.baseFields = baseFields;
|
|
12
11
|
const pickBaseEntryFieldValues = entry => {
|
|
13
12
|
const pickedValues = {};
|
|
14
13
|
for (const fieldName of baseFields) {
|
|
@@ -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\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,GAAG;AACtB;AACA,IAAI,EAEJ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,CACZ;
|
|
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\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,EAEJ,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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","resolve","fn","Response","e","ErrorResponse","exports","resolveList","items","meta","ListResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql\";\n\nexport const resolve = async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\nexport const resolveList = async (fn: () => Promise<any>) => {\n try {\n const [items, meta] = await fn();\n return new ListResponse(items, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,OAAO,GAAG,MAAOC,EAAsB,IAAK;EACrD,IAAI;IACA,OAAO,IAAIC,wBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAACE,OAAA,CAAAL,OAAA,GAAAA,OAAA;AACK,MAAMM,WAAW,GAAG,MAAOL,EAAsB,IAAK;EACzD,IAAI;IACA,MAAM,CAACM,KAAK,EAAEC,IAAI,CAAC,GAAG,MAAMP,EAAE,CAAC,CAAC;IAChC,OAAO,IAAIQ,4BAAY,CAACF,KAAK,EAAEC,IAAI,CAAC;EACxC,CAAC,CAAC,OAAOL,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAACE,OAAA,CAAAC,WAAA,GAAAA,WAAA"}
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","resolve","fn","Response","e","ErrorResponse","exports","resolveList","items","meta","ListResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql\";\n\nexport const resolve = async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\nexport const resolveList = async (fn: () => Promise<any>) => {\n try {\n const [items, meta] = await fn();\n return new ListResponse(items, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,OAAO,GAAG,MAAOC,EAAsB,IAAK;EACrD,IAAI;IACA,OAAO,IAAIC,wBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAACE,OAAA,CAAAL,OAAA,GAAAA,OAAA;AACK,MAAMM,WAAW,GAAG,MAAOL,EAAsB,IAAK;EACzD,IAAI;IACA,MAAM,CAACM,KAAK,EAAEC,IAAI,CAAC,GAAG,MAAMP,EAAE,CAAC,CAAC;IAChC,OAAO,IAAIQ,4BAAY,CAACF,KAAK,EAAEC,IAAI,CAAC;EACxC,CAAC,CAAC,OAAOL,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAACE,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|