@webiny/api-page-builder-import-export 0.0.0-unstable.da99e0b846 → 0.0.0-unstable.de38392959
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/client.js +12 -21
- package/client.js.map +1 -1
- package/export/combine/blocksHandler.js +4 -2
- package/export/combine/blocksHandler.js.map +1 -1
- package/export/combine/formsHandler.js +4 -2
- package/export/combine/formsHandler.js.map +1 -1
- package/export/combine/index.js +23 -19
- package/export/combine/index.js.map +1 -1
- package/export/combine/pagesHandler.js +4 -2
- package/export/combine/pagesHandler.js.map +1 -1
- package/export/combine/templatesHandler.js +4 -2
- package/export/combine/templatesHandler.js.map +1 -1
- package/export/process/blocksHandler.js +13 -6
- package/export/process/blocksHandler.js.map +1 -1
- package/export/process/exporters/BlockExporter.d.ts +12 -0
- package/export/process/exporters/BlockExporter.js +57 -0
- package/export/process/exporters/BlockExporter.js.map +1 -0
- package/export/process/exporters/FormExporter.d.ts +9 -0
- package/export/process/exporters/FormExporter.js +36 -0
- package/export/process/exporters/FormExporter.js.map +1 -0
- package/export/process/exporters/PageExporter.d.ts +11 -0
- package/export/process/exporters/PageExporter.js +58 -0
- package/export/process/exporters/PageExporter.js.map +1 -0
- package/export/process/exporters/PageTemplateExporter.d.ts +11 -0
- package/export/process/exporters/PageTemplateExporter.js +56 -0
- package/export/process/exporters/PageTemplateExporter.js.map +1 -0
- package/export/process/formsHandler.js +8 -6
- package/export/process/formsHandler.js.map +1 -1
- package/export/process/index.js +23 -19
- package/export/process/index.js.map +1 -1
- package/export/process/pagesHandler.js +8 -6
- package/export/process/pagesHandler.js.map +1 -1
- package/export/process/templatesHandler.js +8 -6
- package/export/process/templatesHandler.js.map +1 -1
- package/export/s3Stream.d.ts +8 -8
- package/export/s3Stream.js +27 -22
- package/export/s3Stream.js.map +1 -1
- package/export/utils.d.ts +8 -13
- package/export/utils.js +20 -37
- package/export/utils.js.map +1 -1
- package/export/zipper.d.ts +5 -5
- package/export/zipper.js +18 -22
- package/export/zipper.js.map +1 -1
- package/graphql/crud/blocks.crud.js +49 -26
- package/graphql/crud/blocks.crud.js.map +1 -1
- package/graphql/crud/forms.crud.js +51 -17
- package/graphql/crud/forms.crud.js.map +1 -1
- package/graphql/crud/importExportTasks.crud.js +81 -63
- package/graphql/crud/importExportTasks.crud.js.map +1 -1
- package/graphql/crud/pages.crud.d.ts +1 -0
- package/graphql/crud/pages.crud.js +58 -24
- package/graphql/crud/pages.crud.js.map +1 -1
- package/graphql/crud/templates.crud.js +48 -15
- package/graphql/crud/templates.crud.js.map +1 -1
- package/graphql/crud.js +3 -1
- package/graphql/crud.js.map +1 -1
- package/graphql/graphql/blocks.gql.js +4 -2
- package/graphql/graphql/blocks.gql.js.map +1 -1
- package/graphql/graphql/forms.gql.js +3 -1
- package/graphql/graphql/forms.gql.js.map +1 -1
- package/graphql/graphql/importExportTasks.gql.js +3 -1
- package/graphql/graphql/importExportTasks.gql.js.map +1 -1
- package/graphql/graphql/pages.gql.js +3 -1
- package/graphql/graphql/pages.gql.js.map +1 -1
- package/graphql/graphql/templates.gql.js +3 -1
- package/graphql/graphql/templates.gql.js.map +1 -1
- package/graphql/graphql/utils/resolve.d.ts +1 -1
- package/graphql/graphql/utils/resolve.js +3 -1
- package/graphql/graphql/utils/resolve.js.map +1 -1
- package/graphql/graphql.js +3 -1
- package/graphql/graphql.js.map +1 -1
- package/graphql/index.js +3 -1
- package/graphql/index.js.map +1 -1
- package/graphql/types.d.ts +113 -1
- package/graphql/types.js +3 -1
- package/graphql/types.js.map +1 -1
- package/import/constants.js +3 -1
- package/import/constants.js.map +1 -1
- package/import/create/blocksHandler.js +3 -3
- package/import/create/blocksHandler.js.map +1 -1
- package/import/create/formsHandler.js +3 -1
- package/import/create/formsHandler.js.map +1 -1
- package/import/create/index.js +23 -19
- package/import/create/index.js.map +1 -1
- package/import/create/pagesHandler.js +3 -1
- package/import/create/pagesHandler.js.map +1 -1
- package/import/create/templatesHandler.js +3 -1
- package/import/create/templatesHandler.js.map +1 -1
- package/import/process/blocks/blocksHandler.js +6 -6
- package/import/process/blocks/blocksHandler.js.map +1 -1
- package/import/process/blocks/importBlock.d.ts +2 -2
- package/import/process/blocks/importBlock.js +33 -27
- package/import/process/blocks/importBlock.js.map +1 -1
- package/import/process/forms/formsHandler.js +4 -2
- package/import/process/forms/formsHandler.js.map +1 -1
- package/import/process/forms/importForm.d.ts +1 -1
- package/import/process/forms/importForm.js +6 -2
- package/import/process/forms/importForm.js.map +1 -1
- package/import/process/index.js +23 -19
- package/import/process/index.js.map +1 -1
- package/import/process/pages/importPage.d.ts +1 -1
- package/import/process/pages/importPage.js +8 -6
- package/import/process/pages/importPage.js.map +1 -1
- package/import/process/pages/pagesHandler.js +3 -1
- package/import/process/pages/pagesHandler.js.map +1 -1
- package/import/process/templates/importTemplate.d.ts +1 -1
- package/import/process/templates/importTemplate.js +6 -2
- package/import/process/templates/importTemplate.js.map +1 -1
- package/import/process/templates/templatesHandler.js +3 -1
- package/import/process/templates/templatesHandler.js.map +1 -1
- package/import/utils/deleteS3Folder.js +3 -1
- package/import/utils/deleteS3Folder.js.map +1 -1
- package/import/utils/extractAndUploadZipFileContents.js +3 -2
- package/import/utils/extractAndUploadZipFileContents.js.map +1 -1
- package/import/utils/extractZipAndUploadToS3.js +3 -1
- package/import/utils/extractZipAndUploadToS3.js.map +1 -1
- package/import/utils/getFileNameWithoutExt.js +3 -1
- package/import/utils/getFileNameWithoutExt.js.map +1 -1
- package/import/utils/index.js +3 -1
- package/import/utils/index.js.map +1 -1
- package/import/utils/initialStats.js +3 -1
- package/import/utils/initialStats.js.map +1 -1
- package/import/utils/prepareDataDirMap.js +3 -1
- package/import/utils/prepareDataDirMap.js.map +1 -1
- package/import/utils/updateFilesInData.js +5 -2
- package/import/utils/updateFilesInData.js.map +1 -1
- package/import/utils/uploadAssets.js +56 -15
- package/import/utils/uploadAssets.js.map +1 -1
- package/import/utils/uploadFilesFromS3.d.ts +1 -1
- package/import/utils/uploadFilesFromS3.js +4 -2
- package/import/utils/uploadFilesFromS3.js.map +1 -1
- package/mockSecurity.js +3 -2
- package/mockSecurity.js.map +1 -1
- package/package.json +35 -44
- package/types.js +62 -8
- package/types.js.map +1 -1
- package/import/process/blocksHandler.d.ts +0 -3
- package/import/process/blocksHandler.js +0 -175
- package/import/process/blocksHandler.js.map +0 -1
- package/import/process/pagesHandler.d.ts +0 -3
- package/import/process/pagesHandler.js +0 -180
- package/import/process/pagesHandler.js.map +0 -1
- package/import/utils.d.ts +0 -49
- package/import/utils.js +0 -641
- package/import/utils.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PERMISSION_NAME","EXPORT_PAGES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_PAGES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","ContextPlugin","context","importExportCrud","importPages","category","categorySlug","zipFileUrl","meta","checkBasePermissions","rwd","pageBuilder","getCategory","NotFoundError","task","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","invokeHandlerClient","name","payload","type","identity","security","getIdentity","description","exportPages","ids","initialPageIds","revisionType","where","sort","search","pageIds","Array","isArray","length","pages","hasMoreItems","cursor","totalCount","listLatestPages","after","forEach","page","push","id","WebinyError","exportPagesDataKey","EXPORT_PAGES_FOLDER_KEY","i","pageId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex"],"sources":["pages.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport checkBasePermissions from \"@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions\";\nimport { ImportExportTaskStatus, PagesImportExportCrud, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportPagesProcessHandlerPayload } from \"~/export/process\";\nimport { EXPORT_PAGES_FOLDER_KEY } from \"~/export/utils\";\nimport { MetaResponse } from \"@webiny/api-page-builder/types\";\nimport { zeroPad } from \"@webiny/utils\";\n\nconst PERMISSION_NAME = \"pb.page\";\nconst EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const importExportCrud: PagesImportExportCrud = {\n async importPages({ category: categorySlug, zipFileUrl, meta }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n\n // Bail out early if category not found\n const category = await context.pageBuilder.getCategory(categorySlug);\n if (!category) {\n throw new NotFoundError(`Category with slug \"${categorySlug}\" not found.`);\n }\n\n // Create a task for import page\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n category: categorySlug,\n zipFileUrl\n }\n });\n /**\n * Import Pages\n * ImportPages\n * importPages\n */\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_PAGES_CREATE_HANDLER,\n payload: {\n category: categorySlug,\n zipFileUrl,\n task,\n type: \"page\",\n identity: context.security.getIdentity(),\n meta\n },\n description: \"Import Pages - create\"\n });\n\n return {\n task\n };\n },\n\n async exportPages({ ids: initialPageIds, revisionType, where, sort, search }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n let pageIds: string[] = initialPageIds || [];\n // If no ids are provided then it means we want to export all pages\n if (!initialPageIds || (Array.isArray(initialPageIds) && initialPageIds.length === 0)) {\n pageIds = [];\n let pages = [];\n let meta: MetaResponse = {\n hasMoreItems: true,\n cursor: null,\n totalCount: 0\n };\n // Paginate pages\n while (meta.hasMoreItems) {\n [pages, meta] = await context.pageBuilder.listLatestPages({\n after: meta.cursor,\n where: where,\n sort: sort,\n search: search\n });\n // Save page ids\n pages.forEach(page => pageIds.push(page.id));\n }\n }\n\n if (pageIds.length === 0) {\n throw new WebinyError(\n \"Cannot export pages - no pages found for provided inputs.\",\n \"EMPTY_EXPORT_NO_PAGES_FOUND\"\n );\n }\n\n // Create the main task for page export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportPagesDataKey = `${EXPORT_PAGES_FOLDER_KEY}/${task.id}`;\n // For each page create a sub task and invoke the process handler.\n for (let i = 0; i < pageIds.length; i++) {\n const pageId = pageIds[i];\n // Create sub task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n pageId,\n exportPagesDataKey,\n revisionType\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(pageIds.length),\n input: {\n exportPagesDataKey,\n revisionType\n }\n });\n\n /**\n * Export Pages\n * ExportPages\n * exportPages\n */\n // Invoke handler.\n await invokeHandlerClient<ExportPagesProcessHandlerPayload>({\n context,\n name: EXPORT_PAGES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"page\",\n identity: context.security.getIdentity()\n },\n description: \"Export pages - process\"\n });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.pages = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AAEA,MAAMA,eAAe,GAAG,SAAS;AACjC,MAAMC,4BAA4B,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAgC;AACjF,MAAMC,2BAA2B,GAAGH,OAAO,CAACC,GAAG,CAACG,qBAA+B;AAAC,eAEjE,IAAIC,kBAAa,CAAwBC,OAAO,IAAI;EAC/D,MAAMC,gBAAuC,GAAG;IAC5C,MAAMC,WAAW,CAAC;MAAEC,QAAQ,EAAEC,YAAY;MAAEC,UAAU;MAAE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,6BAAsB,CAACC,OAAO;UACtCC,KAAK,EAAE;YACHkC,MAAM;YACNH,kBAAkB;YAClBnB;UACJ;QACJ,CAAC,CACJ;MACL;MACA;MACA,MAAM9B,OAAO,CAACS,WAAW,CAACI,gBAAgB,CAAC0C,UAAU,CAAC3C,IAAI,CAACmC,EAAE,EAAE;QAC3DhC,MAAM,EAAEC,6BAAsB,CAACwC,UAAU;QACzCC,KAAK,EAAE,IAAAC,mBAAY,EAACxB,OAAO,CAACG,MAAM,CAAC;QACnCnB,KAAK,EAAE;UACH+B,kBAAkB;UAClBnB;QACJ;MACJ,CAAC,CAAC;;MAEF;AACZ;AACA;AACA;AACA;MACY;MACA,MAAM,IAAAX,2BAAmB,EAAmC;QACxDnB,OAAO;QACPoB,IAAI,EAAE3B,4BAA4B;QAClC4B,OAAO,EAAE;UACLsC,MAAM,EAAE/C,IAAI,CAACmC,EAAE;UACfa,YAAY,EAAE,CAAC;UACftC,IAAI,EAAE,MAAM;UACZC,QAAQ,EAAEvB,OAAO,CAACwB,QAAQ,CAACC,WAAW;QAC1C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,OAAO;QAAEd;MAAK,CAAC;IACnB;EACJ,CAAC;EACD;EACAZ,OAAO,CAACS,WAAW,CAAC6B,KAAK,GAAGrC,gBAAgB;AAChD,CAAC,CAAC;AAAA"}
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_pubsub","_handlerGraphql","_api","_types","_client","_utils","_utils2","_PagesPermissions","EXPORT_PAGES_FOLDER_KEY","exports","EXPORT_PAGES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_PAGES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","_default","ContextPlugin","context","pagesPermissions","PagesPermissions","getPermissions","security","getIdentity","fullAccessPermissionName","onPagesBeforeExport","createTopic","onPagesAfterExport","onPagesBeforeImport","onPagesAfterImport","importExportCrud","importPages","params","category","categorySlug","zipFileUrl","meta","ensure","rwd","pageBuilder","getCategory","NotFoundError","task","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","publish","invokeHandlerClient","name","payload","type","identity","description","exportPages","ids","initialPageIds","revisionType","where","sort","search","pageIds","Array","isArray","length","pages","hasMoreItems","cursor","totalCount","listLatestPages","after","forEach","page","push","id","WebinyError","exportPagesDataKey","i","pageId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex","default"],"sources":["pages.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport {\n ImportExportTaskStatus,\n PagesImportExportCrud,\n PbImportExportContext,\n OnPagesBeforeExportTopicParams,\n OnPagesAfterExportTopicParams,\n OnPagesBeforeImportTopicParams,\n OnPagesAfterImportTopicParams\n} from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportPagesProcessHandlerPayload } from \"~/export/process\";\nimport { MetaResponse } from \"@webiny/api-page-builder/types\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { PagesPermissions } from \"@webiny/api-page-builder/graphql/crud/permissions/PagesPermissions\";\n\nexport const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\nconst EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const pagesPermissions = new PagesPermissions({\n getPermissions: () => context.security.getPermissions(\"pb.page\"),\n getIdentity: context.security.getIdentity,\n fullAccessPermissionName: \"pb.*\"\n });\n\n // Export\n const onPagesBeforeExport = createTopic<OnPagesBeforeExportTopicParams>(\n \"PageBuilder.onPagesBeforeExport\"\n );\n const onPagesAfterExport = createTopic<OnPagesAfterExportTopicParams>(\n \"PageBuilder.onPagesAfterExport\"\n );\n\n // Import\n const onPagesBeforeImport = createTopic<OnPagesBeforeImportTopicParams>(\n \"PageBuilder.onPagesBeforeImport\"\n );\n const onPagesAfterImport = createTopic<OnPagesAfterImportTopicParams>(\n \"PageBuilder.onPagesAfterImport\"\n );\n\n const importExportCrud: PagesImportExportCrud = {\n onPagesBeforeExport,\n onPagesAfterExport,\n onPagesBeforeImport,\n onPagesAfterImport,\n async importPages(params) {\n const { category: categorySlug, zipFileUrl, meta } = params;\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n // Bail out early if category not found\n const category = await context.pageBuilder.getCategory(categorySlug);\n if (!category) {\n throw new NotFoundError(`Category with slug \"${categorySlug}\" not found.`);\n }\n\n // Create a task for import page\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n category: categorySlug,\n zipFileUrl\n }\n });\n /**\n * Import Pages\n * ImportPages\n * importPages\n */\n await onPagesBeforeImport.publish({ params });\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_PAGES_CREATE_HANDLER,\n payload: {\n category: categorySlug,\n zipFileUrl,\n task,\n type: \"page\",\n identity: context.security.getIdentity(),\n meta\n },\n description: \"Import Pages - create\"\n });\n await onPagesAfterImport.publish({ params });\n\n return {\n task\n };\n },\n\n async exportPages(params) {\n const { ids: initialPageIds, revisionType, where, sort, search } = params;\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n let pageIds: string[] = initialPageIds || [];\n // If no ids are provided then it means we want to export all pages\n if (!initialPageIds || (Array.isArray(initialPageIds) && initialPageIds.length === 0)) {\n pageIds = [];\n let pages = [];\n let meta: MetaResponse = {\n hasMoreItems: true,\n cursor: null,\n totalCount: 0\n };\n // Paginate pages\n while (meta.hasMoreItems) {\n [pages, meta] = await context.pageBuilder.listLatestPages({\n after: meta.cursor,\n where: where,\n sort: sort,\n search: search\n });\n // Save page ids\n pages.forEach(page => pageIds.push(page.id));\n }\n }\n\n if (pageIds.length === 0) {\n throw new WebinyError(\n \"Cannot export pages - no pages found for provided inputs.\",\n \"EMPTY_EXPORT_NO_PAGES_FOUND\"\n );\n }\n\n // Create the main task for page export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportPagesDataKey = `${EXPORT_PAGES_FOLDER_KEY}/${task.id}`;\n // For each page create a sub-task and invoke the process handler.\n for (let i = 0; i < pageIds.length; i++) {\n const pageId = pageIds[i];\n // Create sub-task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n pageId,\n exportPagesDataKey,\n revisionType\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(pageIds.length),\n input: {\n exportPagesDataKey,\n revisionType\n }\n });\n\n /**\n * Export Pages\n * ExportPages\n * exportPages\n */\n await onPagesBeforeExport.publish({ params });\n // Invoke handler.\n await invokeHandlerClient<ExportPagesProcessHandlerPayload>({\n context,\n name: EXPORT_PAGES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"page\",\n identity: context.security.getIdentity()\n },\n description: \"Export pages - process\"\n });\n await onPagesAfterExport.publish({ params });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.pages = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AASA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAGA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,iBA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O,CAACqB,WAAW,CAACI,gBAAgB,CAACwC,UAAU,CAACzC,IAAI,CAACkC,EAAE,EAAE;QAC3D/B,MAAM,EAAEC,6BAAsB,CAACsC,UAAU;QACzCC,KAAK,EAAE,IAAAC,mBAAY,EAACvB,OAAO,CAACG,MAAM,CAAC;QACnClB,KAAK,EAAE;UACH8B,kBAAkB;UAClBnB;QACJ;MACJ,CAAC,CAAC;;MAEF;AACZ;AACA;AACA;AACA;MACY,MAAMlC,mBAAmB,CAACwB,OAAO,CAAC;QAAEjB;MAAO,CAAC,CAAC;MAC7C;MACA,MAAM,IAAAkB,2BAAmB,EAAmC;QACxDhC,OAAO;QACPiC,IAAI,EAAEzC,4BAA4B;QAClC0C,OAAO,EAAE;UACLmC,MAAM,EAAE7C,IAAI,CAACkC,EAAE;UACfY,YAAY,EAAE,CAAC;UACfnC,IAAI,EAAE,MAAM;UACZC,QAAQ,EAAEpC,OAAO,CAACI,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDgC,WAAW,EAAE;MACjB,CAAC,CAAC;MACF,MAAM5B,kBAAkB,CAACsB,OAAO,CAAC;QAAEjB;MAAO,CAAC,CAAC;MAE5C,OAAO;QAAEU;MAAK,CAAC;IACnB;EACJ,CAAC;EACD;EACAxB,OAAO,CAACqB,WAAW,CAAC4B,KAAK,GAAGrC,gBAAgB;AAChD,CAAC,CAAC;AAAArB,OAAA,CAAAgF,OAAA,GAAAzE,QAAA"}
|
@@ -6,22 +6,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.default = void 0;
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
9
|
+
var _pubsub = require("@webiny/pubsub");
|
9
10
|
var _api = require("@webiny/api");
|
10
|
-
var _checkBasePermissions = _interopRequireDefault(require("@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions"));
|
11
11
|
var _types = require("../../types");
|
12
12
|
var _client = require("../../client");
|
13
13
|
var _utils = require("../../import/utils");
|
14
|
-
var _utils2 = require("
|
15
|
-
var
|
16
|
-
const
|
14
|
+
var _utils2 = require("@webiny/utils");
|
15
|
+
var _PageTemplatesPermissions = require("@webiny/api-page-builder/graphql/crud/permissions/PageTemplatesPermissions");
|
16
|
+
const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
|
17
17
|
const EXPORT_TEMPLATES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER;
|
18
18
|
const IMPORT_TEMPLATES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER;
|
19
19
|
var _default = new _api.ContextPlugin(context => {
|
20
|
+
const pagesPermissions = new _PageTemplatesPermissions.PageTemplatesPermissions({
|
21
|
+
getPermissions: () => context.security.getPermissions("pb.template"),
|
22
|
+
getIdentity: context.security.getIdentity,
|
23
|
+
fullAccessPermissionName: "pb.*"
|
24
|
+
});
|
25
|
+
|
26
|
+
// Export
|
27
|
+
const onTemplatesBeforeExport = (0, _pubsub.createTopic)("PageBuilder.onTemplatesBeforeExport");
|
28
|
+
const onTemplatesAfterExport = (0, _pubsub.createTopic)("PageBuilder.onTemplatesAfterExport");
|
29
|
+
|
30
|
+
// Import
|
31
|
+
const onTemplatesBeforeImport = (0, _pubsub.createTopic)("PageBuilder.onTemplatesBeforeImport");
|
32
|
+
const onTemplatesAfterImport = (0, _pubsub.createTopic)("PageBuilder.onTemplatesAfterImport");
|
20
33
|
const importExportCrud = {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
34
|
+
onTemplatesBeforeExport,
|
35
|
+
onTemplatesAfterExport,
|
36
|
+
onTemplatesBeforeImport,
|
37
|
+
onTemplatesAfterImport,
|
38
|
+
async importTemplates(params) {
|
39
|
+
const {
|
40
|
+
zipFileUrl
|
41
|
+
} = params;
|
42
|
+
await pagesPermissions.ensure({
|
25
43
|
rwd: "w"
|
26
44
|
});
|
27
45
|
|
@@ -37,6 +55,9 @@ var _default = new _api.ContextPlugin(context => {
|
|
37
55
|
* ImportTemplates
|
38
56
|
* importTemplates
|
39
57
|
*/
|
58
|
+
await onTemplatesBeforeImport.publish({
|
59
|
+
params
|
60
|
+
});
|
40
61
|
await (0, _client.invokeHandlerClient)({
|
41
62
|
context,
|
42
63
|
name: IMPORT_TEMPLATES_CREATE_HANDLER,
|
@@ -48,14 +69,18 @@ var _default = new _api.ContextPlugin(context => {
|
|
48
69
|
},
|
49
70
|
description: "Import Templates - create"
|
50
71
|
});
|
72
|
+
await onTemplatesAfterImport.publish({
|
73
|
+
params
|
74
|
+
});
|
51
75
|
return {
|
52
76
|
task
|
53
77
|
};
|
54
78
|
},
|
55
|
-
async exportTemplates({
|
56
|
-
|
57
|
-
|
58
|
-
|
79
|
+
async exportTemplates(params) {
|
80
|
+
const {
|
81
|
+
ids: initialTemplateIds
|
82
|
+
} = params;
|
83
|
+
await pagesPermissions.ensure({
|
59
84
|
rwd: "w"
|
60
85
|
});
|
61
86
|
let templateIds = initialTemplateIds || [];
|
@@ -74,12 +99,12 @@ var _default = new _api.ContextPlugin(context => {
|
|
74
99
|
const task = await context.pageBuilder.importExportTask.createTask({
|
75
100
|
status: _types.ImportExportTaskStatus.PENDING
|
76
101
|
});
|
77
|
-
const exportTemplatesDataKey = `${
|
102
|
+
const exportTemplatesDataKey = `${EXPORT_TEMPLATES_FOLDER_KEY}/${task.id}`;
|
78
103
|
// For each template create a sub task and invoke the process handler.
|
79
104
|
for (let i = 0; i < templateIds.length; i++) {
|
80
105
|
const templateId = templateIds[i];
|
81
106
|
// Create sub task.
|
82
|
-
await context.pageBuilder.importExportTask.createSubTask(task.id, (0,
|
107
|
+
await context.pageBuilder.importExportTask.createSubTask(task.id, (0, _utils2.zeroPad)(i + 1, 5), {
|
83
108
|
status: _types.ImportExportTaskStatus.PENDING,
|
84
109
|
input: {
|
85
110
|
templateId,
|
@@ -101,6 +126,9 @@ var _default = new _api.ContextPlugin(context => {
|
|
101
126
|
* ExportTemplates
|
102
127
|
* exportTemplates
|
103
128
|
*/
|
129
|
+
await onTemplatesBeforeExport.publish({
|
130
|
+
params
|
131
|
+
});
|
104
132
|
// Invoke handler.
|
105
133
|
await (0, _client.invokeHandlerClient)({
|
106
134
|
context,
|
@@ -113,6 +141,9 @@ var _default = new _api.ContextPlugin(context => {
|
|
113
141
|
},
|
114
142
|
description: "Export templates - process"
|
115
143
|
});
|
144
|
+
await onTemplatesAfterExport.publish({
|
145
|
+
params
|
146
|
+
});
|
116
147
|
return {
|
117
148
|
task
|
118
149
|
};
|
@@ -121,4 +152,6 @@ var _default = new _api.ContextPlugin(context => {
|
|
121
152
|
// Modify context
|
122
153
|
context.pageBuilder.templates = importExportCrud;
|
123
154
|
});
|
124
|
-
exports.default = _default;
|
155
|
+
exports.default = _default;
|
156
|
+
|
157
|
+
//# sourceMappingURL=templates.crud.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PERMISSION_NAME","EXPORT_TEMPLATES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_TEMPLATES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","ContextPlugin","context","importExportCrud","importTemplates","zipFileUrl","checkBasePermissions","rwd","task","pageBuilder","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","invokeHandlerClient","name","payload","type","identity","security","getIdentity","description","exportTemplates","ids","initialTemplateIds","templateIds","Array","isArray","length","templates","listPageTemplates","forEach","template","push","id","WebinyError","exportTemplatesDataKey","EXPORT_TEMPLATES_FOLDER_KEY","i","templateId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex"],"sources":["templates.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport checkBasePermissions from \"@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions\";\nimport { ImportExportTaskStatus, TemplatesImportExportCrud, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportTemplatesProcessHandlerPayload } from \"~/export/process\";\nimport { EXPORT_TEMPLATES_FOLDER_KEY } from \"~/export/utils\";\nimport { zeroPad } from \"@webiny/utils\";\n\nconst PERMISSION_NAME = \"pb.template\";\nconst EXPORT_TEMPLATES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_TEMPLATES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const importExportCrud: TemplatesImportExportCrud = {\n async importTemplates({ zipFileUrl }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n\n // Create a task for import template\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n zipFileUrl\n }\n });\n /**\n * Import Templates\n * ImportTemplates\n * importTemplates\n */\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_TEMPLATES_CREATE_HANDLER,\n payload: {\n zipFileUrl,\n task,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Import Templates - create\"\n });\n\n return {\n task\n };\n },\n\n async exportTemplates({ ids: initialTemplateIds }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n let templateIds: string[] = initialTemplateIds || [];\n // If no ids are provided then it means we want to export all templates\n if (\n !initialTemplateIds ||\n (Array.isArray(initialTemplateIds) && initialTemplateIds.length === 0)\n ) {\n templateIds = [];\n const templates = await context.pageBuilder.listPageTemplates();\n // Save template ids\n templates.forEach(template => templateIds.push(template.id));\n }\n\n if (templateIds.length === 0) {\n throw new WebinyError(\n \"Cannot export templates - no templates found for provided inputs.\",\n \"EMPTY_EXPORT_NO_TEMPLATES_FOUND\"\n );\n }\n\n // Create the main task for templates export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportTemplatesDataKey = `${EXPORT_TEMPLATES_FOLDER_KEY}/${task.id}`;\n // For each template create a sub task and invoke the process handler.\n for (let i = 0; i < templateIds.length; i++) {\n const templateId = templateIds[i];\n // Create sub task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n templateId,\n exportTemplatesDataKey\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(templateIds.length),\n input: {\n exportTemplatesDataKey\n }\n });\n\n /**\n * Export Templates\n * ExportTemplates\n * exportTemplates\n */\n // Invoke handler.\n await invokeHandlerClient<ExportTemplatesProcessHandlerPayload>({\n context,\n name: EXPORT_TEMPLATES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Export templates - process\"\n });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.templates = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA,MAAMA,eAAe,GAAG,aAAa;AACrC,MAAMC,gCAAgC,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAgC;AACrF,MAAMC,+BAA+B,GAAGH,OAAO,CAACC,GAAG,CAACG,qBAA+B;AAAC,eAErE,IAAIC,kBAAa,CAAwBC,OAAO,IAAI;EAC/D,MAAMC,gBAA2C,GAAG;IAChD,MAAMC,eAAe,CAAC;MAAEC;IAAW,CAAC,EAAE;MAClC,MAAM,IAAAC,6BAAoB,EAACJ,OAAO,EAAER,eAAe,EAAE;QACjDa,GAAG,EAAE;MACT,CAAC,CAAC;;MAEF;MACA,MAAMC,IAAI,GAAG,MAAMN,OAAO,CAACO,WAAW,CAACC,gBAAgB,CAACC,UAAU,CAAC;QAC/DC,MAAM,EAAEC,6BAAsB,CAACC,OAAO;QACtCC,KAAK,EAAE;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;MACA,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGb,WAAW,CAACG,MAAM,EAAEU,CAAC,EAAE,EAAE;QACzC,MAAMC,UAAU,GAAGd,WAAW,CAACa,CAAC,CAAC;QACjC;QACA,MAAMtC,OAAO,CAACO,WAAW,CAACC,gBAAgB,CAACgC,aAAa,CACpDlC,IAAI,CAAC4B,EAAE,EACP,IAAAO,eAAO,EAACH,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EACjB;UACI5B,MAAM,EAAEC,6BAAsB,CAACC,OAAO;UACtCC,KAAK,EAAE;YACH0B,UAAU;YACVH;UACJ;QACJ,CAAC,CACJ;MACL;MACA;MACA,MAAMpC,OAAO,CAACO,WAAW,CAACC,gBAAgB,CAACkC,UAAU,CAACpC,IAAI,CAAC4B,EAAE,EAAE;QAC3DxB,MAAM,EAAEC,6BAAsB,CAACgC,UAAU;QACzCC,KAAK,EAAE,IAAAC,mBAAY,EAACpB,WAAW,CAACG,MAAM,CAAC;QACvCf,KAAK,EAAE;UACHuB;QACJ;MACJ,CAAC,CAAC;;MAEF;AACZ;AACA;AACA;AACA;MACY;MACA,MAAM,IAAAtB,2BAAmB,EAAuC;QAC5Dd,OAAO;QACPe,IAAI,EAAEtB,gCAAgC;QACtCuB,OAAO,EAAE;UACL8B,MAAM,EAAExC,IAAI,CAAC4B,EAAE;UACfa,YAAY,EAAE,CAAC;UACf9B,IAAI,EAAE,UAAU;UAChBC,QAAQ,EAAElB,OAAO,CAACmB,QAAQ,CAACC,WAAW;QAC1C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,OAAO;QAAEf;MAAK,CAAC;IACnB;EACJ,CAAC;EACD;EACAN,OAAO,CAACO,WAAW,CAACsB,SAAS,GAAG5B,gBAAgB;AACpD,CAAC,CAAC;AAAA"}
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_pubsub","_api","_types","_client","_utils","_utils2","_PageTemplatesPermissions","EXPORT_TEMPLATES_FOLDER_KEY","EXPORT_TEMPLATES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_TEMPLATES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","_default","ContextPlugin","context","pagesPermissions","PageTemplatesPermissions","getPermissions","security","getIdentity","fullAccessPermissionName","onTemplatesBeforeExport","createTopic","onTemplatesAfterExport","onTemplatesBeforeImport","onTemplatesAfterImport","importExportCrud","importTemplates","params","zipFileUrl","ensure","rwd","task","pageBuilder","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","publish","invokeHandlerClient","name","payload","type","identity","description","exportTemplates","ids","initialTemplateIds","templateIds","Array","isArray","length","templates","listPageTemplates","forEach","template","push","id","WebinyError","exportTemplatesDataKey","i","templateId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex","exports","default"],"sources":["templates.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport {\n ImportExportTaskStatus,\n TemplatesImportExportCrud,\n PbImportExportContext,\n OnTemplatesBeforeExportTopicParams,\n OnTemplatesAfterExportTopicParams,\n OnTemplatesBeforeImportTopicParams,\n OnTemplatesAfterImportTopicParams\n} from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportTemplatesProcessHandlerPayload } from \"~/export/process\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { PageTemplatesPermissions } from \"@webiny/api-page-builder/graphql/crud/permissions/PageTemplatesPermissions\";\n\nconst EXPORT_TEMPLATES_FOLDER_KEY = \"WEBINY_PB_EXPORT_TEMPLATE\";\nconst EXPORT_TEMPLATES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_TEMPLATES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const pagesPermissions = new PageTemplatesPermissions({\n getPermissions: () => context.security.getPermissions(\"pb.template\"),\n getIdentity: context.security.getIdentity,\n fullAccessPermissionName: \"pb.*\"\n });\n\n // Export\n const onTemplatesBeforeExport = createTopic<OnTemplatesBeforeExportTopicParams>(\n \"PageBuilder.onTemplatesBeforeExport\"\n );\n const onTemplatesAfterExport = createTopic<OnTemplatesAfterExportTopicParams>(\n \"PageBuilder.onTemplatesAfterExport\"\n );\n\n // Import\n const onTemplatesBeforeImport = createTopic<OnTemplatesBeforeImportTopicParams>(\n \"PageBuilder.onTemplatesBeforeImport\"\n );\n const onTemplatesAfterImport = createTopic<OnTemplatesAfterImportTopicParams>(\n \"PageBuilder.onTemplatesAfterImport\"\n );\n\n const importExportCrud: TemplatesImportExportCrud = {\n onTemplatesBeforeExport,\n onTemplatesAfterExport,\n onTemplatesBeforeImport,\n onTemplatesAfterImport,\n async importTemplates(params) {\n const { zipFileUrl } = params;\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n // Create a task for import template\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n zipFileUrl\n }\n });\n /**\n * Import Templates\n * ImportTemplates\n * importTemplates\n */\n await onTemplatesBeforeImport.publish({ params });\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_TEMPLATES_CREATE_HANDLER,\n payload: {\n zipFileUrl,\n task,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Import Templates - create\"\n });\n await onTemplatesAfterImport.publish({ params });\n\n return {\n task\n };\n },\n\n async exportTemplates(params) {\n const { ids: initialTemplateIds } = params;\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n let templateIds: string[] = initialTemplateIds || [];\n // If no ids are provided then it means we want to export all templates\n if (\n !initialTemplateIds ||\n (Array.isArray(initialTemplateIds) && initialTemplateIds.length === 0)\n ) {\n templateIds = [];\n const templates = await context.pageBuilder.listPageTemplates();\n // Save template ids\n templates.forEach(template => templateIds.push(template.id));\n }\n\n if (templateIds.length === 0) {\n throw new WebinyError(\n \"Cannot export templates - no templates found for provided inputs.\",\n \"EMPTY_EXPORT_NO_TEMPLATES_FOUND\"\n );\n }\n\n // Create the main task for templates export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportTemplatesDataKey = `${EXPORT_TEMPLATES_FOLDER_KEY}/${task.id}`;\n // For each template create a sub task and invoke the process handler.\n for (let i = 0; i < templateIds.length; i++) {\n const templateId = templateIds[i];\n // Create sub task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n templateId,\n exportTemplatesDataKey\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(templateIds.length),\n input: {\n exportTemplatesDataKey\n }\n });\n\n /**\n * Export Templates\n * ExportTemplates\n * exportTemplates\n */\n await onTemplatesBeforeExport.publish({ params });\n // Invoke handler.\n await invokeHandlerClient<ExportTemplatesProcessHandlerPayload>({\n context,\n name: EXPORT_TEMPLATES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Export templates - process\"\n });\n await onTemplatesAfterExport.publish({ params });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.templates = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AASA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,yBAAA,GAAAP,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C;IACnB;EACJ,CAAC;EACD;EACAlB,OAAO,CAACmB,WAAW,CAACqB,SAAS,GAAG5B,gBAAgB;AACpD,CAAC,CAAC;AAAA8C,OAAA,CAAAC,OAAA,GAAA7D,QAAA"}
|
package/graphql/crud.js
CHANGED
@@ -11,4 +11,6 @@ var _pages = _interopRequireDefault(require("./crud/pages.crud"));
|
|
11
11
|
var _templates = _interopRequireDefault(require("./crud/templates.crud"));
|
12
12
|
var _importExportTasks = _interopRequireDefault(require("./crud/importExportTasks.crud"));
|
13
13
|
var _default = params => [_blocks.default, _forms.default, _pages.default, _templates.default, (0, _importExportTasks.default)(params)];
|
14
|
-
exports.default = _default;
|
14
|
+
exports.default = _default;
|
15
|
+
|
16
|
+
//# sourceMappingURL=crud.js.map
|
package/graphql/crud.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["params","blocks","forms","pages","templates","importExportTask"],"sources":["crud.ts"],"sourcesContent":["import blocks from \"./crud/blocks.crud\";\nimport forms from \"./crud/forms.crud\";\nimport pages from \"./crud/pages.crud\";\nimport templates from \"./crud/templates.crud\";\nimport importExportTask from \"./crud/importExportTasks.crud\";\nimport { ImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: ImportExportPluginsParams) => [\n blocks,\n forms,\n pages,\n templates,\n importExportTask(params as ImportExportPluginsParams)\n];\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAA6D,
|
1
|
+
{"version":3,"names":["_blocks","_interopRequireDefault","require","_forms","_pages","_templates","_importExportTasks","_default","params","blocks","forms","pages","templates","importExportTask","exports","default"],"sources":["crud.ts"],"sourcesContent":["import blocks from \"./crud/blocks.crud\";\nimport forms from \"./crud/forms.crud\";\nimport pages from \"./crud/pages.crud\";\nimport templates from \"./crud/templates.crud\";\nimport importExportTask from \"./crud/importExportTasks.crud\";\nimport { ImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: ImportExportPluginsParams) => [\n blocks,\n forms,\n pages,\n templates,\n importExportTask(params as ImportExportPluginsParams)\n];\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,kBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAA6D,IAAAK,QAAA,GAG7CC,MAAiC,IAAK,CAClDC,eAAM,EACNC,cAAK,EACLC,cAAK,EACLC,kBAAS,EACT,IAAAC,0BAAgB,EAACL,MAAmC,CAAC,CACxD;AAAAM,OAAA,CAAAC,OAAA,GAAAR,QAAA"}
|
@@ -33,7 +33,7 @@ const plugin = {
|
|
33
33
|
exportBlocks(ids: [ID!], where: PbListPageBlocksWhereInput): PbExportBlockResponse
|
34
34
|
|
35
35
|
# Import blocks
|
36
|
-
importBlocks(
|
36
|
+
importBlocks(zipFileUrl: String): PbImportBlockResponse
|
37
37
|
}
|
38
38
|
`,
|
39
39
|
resolvers: {
|
@@ -49,4 +49,6 @@ const plugin = {
|
|
49
49
|
}
|
50
50
|
};
|
51
51
|
var _default = plugin;
|
52
|
-
exports.default = _default;
|
52
|
+
exports.default = _default;
|
53
|
+
|
54
|
+
//# sourceMappingURL=blocks.gql.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["plugin","type","schema","typeDefs","resolvers","PbMutation","exportBlocks","_","args","context","resolve","pageBuilder","blocks","importBlocks"],"sources":["blocks.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportBlockData {\n task: PbImportExportTask\n }\n\n type PbExportBlockResponse {\n data: PbExportBlockData\n error: PbError\n }\n\n type PbImportBlockData {\n task: PbImportExportTask\n }\n\n type PbImportBlockResponse {\n data: PbImportBlockData\n error: PbError\n }\n\n extend type PbMutation {\n # Export blocks\n exportBlocks(ids: [ID!], where: PbListPageBlocksWhereInput): PbExportBlockResponse\n\n # Import blocks\n importBlocks(
|
1
|
+
{"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","PbMutation","exportBlocks","_","args","context","resolve","pageBuilder","blocks","importBlocks","_default","exports","default"],"sources":["blocks.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportBlockData {\n task: PbImportExportTask\n }\n\n type PbExportBlockResponse {\n data: PbExportBlockData\n error: PbError\n }\n\n type PbImportBlockData {\n task: PbImportExportTask\n }\n\n type PbImportBlockResponse {\n data: PbImportBlockData\n error: PbError\n }\n\n extend type PbMutation {\n # Export blocks\n exportBlocks(ids: [ID!], where: PbListPageBlocksWhereInput): PbExportBlockResponse\n\n # Import blocks\n importBlocks(zipFileUrl: String): PbImportBlockResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportBlocks: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.blocks.exportBlocks(args));\n },\n\n importBlocks: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.blocks.importBlocks(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,YAAY,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC3C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,MAAM,CAACN,YAAY,CAACE,IAAI,CAAC,CAAC;QACvE,CAAC;QAEDK,YAAY,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC3C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,MAAM,CAACC,YAAY,CAACL,IAAI,CAAC,CAAC;QACvE;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["plugin","type","schema","typeDefs","resolvers","FbMutation","exportForms","_","args","context","resolve","formBuilder","forms","importForms"],"sources":["forms.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type FbExportFormData {\n task: PbImportExportTask\n }\n\n type FbExportFormResponse {\n data: FbExportFormData\n error: FbError\n }\n\n type FbImportFormData {\n task: PbImportExportTask\n }\n\n type FbImportFormResponse {\n data: FbImportFormData\n error: FbError\n }\n\n enum FbExportFormRevisionType {\n published\n latest\n }\n\n extend type FbMutation {\n # Export forms\n exportForms(\n ids: [ID!]\n revisionType: FbExportFormRevisionType!\n ): FbExportFormResponse\n\n # Import forms\n importForms(zipFileUrl: String, meta: JSON): FbImportFormResponse\n }\n `,\n resolvers: {\n FbMutation: {\n exportForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.exportForms(args));\n },\n\n importForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.importForms(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA;AAEA,
|
1
|
+
{"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","FbMutation","exportForms","_","args","context","resolve","formBuilder","forms","importForms","_default","exports","default"],"sources":["forms.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type FbExportFormData {\n task: PbImportExportTask\n }\n\n type FbExportFormResponse {\n data: FbExportFormData\n error: FbError\n }\n\n type FbImportFormData {\n task: PbImportExportTask\n }\n\n type FbImportFormResponse {\n data: FbImportFormData\n error: FbError\n }\n\n enum FbExportFormRevisionType {\n published\n latest\n }\n\n extend type FbMutation {\n # Export forms\n exportForms(\n ids: [ID!]\n revisionType: FbExportFormRevisionType!\n ): FbExportFormResponse\n\n # Import forms\n importForms(zipFileUrl: String, meta: JSON): FbImportFormResponse\n }\n `,\n resolvers: {\n FbMutation: {\n exportForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.exportForms(args));\n },\n\n importForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.importForms(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,WAAW,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACN,WAAW,CAACE,IAAI,CAAC,CAAC;QACrE,CAAC;QAEDK,WAAW,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACC,WAAW,CAACL,IAAI,CAAC,CAAC;QACrE;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["plugin","type","schema","typeDefs","resolvers","PbQuery","getImportExportTask","_","args","context","resolve","pageBuilder","importExportTask","getTask","id","listImportExportSubTask","listSubTasks","status","limit"],"sources":["importExportTasks.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport resolve from \"./utils/resolve\";\nimport { PbImportExportContext } from \"../types\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n enum PbImportExportTaskStatus {\n pending\n processing\n completed\n failed\n }\n\n type PbImportExportTaskStats {\n pending: Int\n processing: Int\n completed: Int\n failed: Int\n total: Int\n }\n\n type PbImportExportTask {\n id: ID\n createdOn: DateTime\n createdBy: PbCreatedBy\n status: PbImportExportTaskStatus\n data: JSON\n stats: PbImportExportTaskStats\n error: JSON\n }\n\n # Response types\n type PbImportExportTaskResponse {\n data: PbImportExportTask\n error: PbError\n }\n\n type PbImportExportTaskListResponse {\n data: [PbImportExportTask]\n error: PbError\n }\n\n extend type PbQuery {\n getImportExportTask(id: ID!): PbImportExportTaskResponse\n listImportExportSubTask(\n id: ID!\n status: PbImportExportTaskStatus\n limit: Int\n ): PbImportExportTaskListResponse\n }\n `,\n resolvers: {\n PbQuery: {\n getImportExportTask: async (_, args: any, context) => {\n return resolve(() => {\n return context.pageBuilder.importExportTask.getTask(args.id);\n });\n },\n listImportExportSubTask: async (_, args: any, context) => {\n return resolve(() => {\n return context.pageBuilder.importExportTask.listSubTasks(\n args.id,\n args.status,\n args.limit\n );\n });\n }\n }\n }\n }\n};\nexport default plugin;\n"],"mappings":";;;;;;;AACA;AAGA,
|
1
|
+
{"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","PbQuery","getImportExportTask","_","args","context","resolve","pageBuilder","importExportTask","getTask","id","listImportExportSubTask","listSubTasks","status","limit","_default","exports","default"],"sources":["importExportTasks.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport resolve from \"./utils/resolve\";\nimport { PbImportExportContext } from \"../types\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n enum PbImportExportTaskStatus {\n pending\n processing\n completed\n failed\n }\n\n type PbImportExportTaskStats {\n pending: Int\n processing: Int\n completed: Int\n failed: Int\n total: Int\n }\n\n type PbImportExportTask {\n id: ID\n createdOn: DateTime\n createdBy: PbCreatedBy\n status: PbImportExportTaskStatus\n data: JSON\n stats: PbImportExportTaskStats\n error: JSON\n }\n\n # Response types\n type PbImportExportTaskResponse {\n data: PbImportExportTask\n error: PbError\n }\n\n type PbImportExportTaskListResponse {\n data: [PbImportExportTask]\n error: PbError\n }\n\n extend type PbQuery {\n getImportExportTask(id: ID!): PbImportExportTaskResponse\n listImportExportSubTask(\n id: ID!\n status: PbImportExportTaskStatus\n limit: Int\n ): PbImportExportTaskListResponse\n }\n `,\n resolvers: {\n PbQuery: {\n getImportExportTask: async (_, args: any, context) => {\n return resolve(() => {\n return context.pageBuilder.importExportTask.getTask(args.id);\n });\n },\n listImportExportSubTask: async (_, args: any, context) => {\n return resolve(() => {\n return context.pageBuilder.importExportTask.listSubTasks(\n args.id,\n args.status,\n args.limit\n );\n });\n }\n }\n }\n }\n};\nexport default plugin;\n"],"mappings":";;;;;;;AACA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,OAAO,EAAE;QACLC,mBAAmB,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAClD,OAAO,IAAAC,gBAAO,EAAC,MAAM;YACjB,OAAOD,OAAO,CAACE,WAAW,CAACC,gBAAgB,CAACC,OAAO,CAACL,IAAI,CAACM,EAAE,CAAC;UAChE,CAAC,CAAC;QACN,CAAC;QACDC,uBAAuB,EAAE,MAAAA,CAAOR,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UACtD,OAAO,IAAAC,gBAAO,EAAC,MAAM;YACjB,OAAOD,OAAO,CAACE,WAAW,CAACC,gBAAgB,CAACI,YAAY,CACpDR,IAAI,CAACM,EAAE,EACPN,IAAI,CAACS,MAAM,EACXT,IAAI,CAACU,KACT,CAAC;UACL,CAAC,CAAC;QACN;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAC,QAAA,GACanB,MAAM;AAAAoB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["plugin","type","schema","typeDefs","resolvers","PbMutation","exportPages","_","args","context","resolve","pageBuilder","pages","importPages"],"sources":["pages.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportPageData {\n task: PbImportExportTask\n }\n\n type PbExportPageResponse {\n data: PbExportPageData\n error: PbError\n }\n\n type PbImportPageData {\n task: PbImportExportTask\n }\n\n type PbImportPageResponse {\n data: PbImportPageData\n error: PbError\n }\n\n enum PbExportPageRevisionType {\n published\n latest\n }\n\n extend type PbMutation {\n # Export pages\n exportPages(\n ids: [ID!]\n revisionType: PbExportPageRevisionType!\n where: PbListPagesWhereInput\n sort: [PbListPagesSort!]\n search: PbListPagesSearchInput\n ): PbExportPageResponse\n\n # Import pages\n importPages(category: String!, zipFileUrl: String, meta: JSON): PbImportPageResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportPages: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.pages.exportPages(args));\n },\n\n importPages: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.pages.importPages(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA;AAEA,
|
1
|
+
{"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","PbMutation","exportPages","_","args","context","resolve","pageBuilder","pages","importPages","_default","exports","default"],"sources":["pages.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportPageData {\n task: PbImportExportTask\n }\n\n type PbExportPageResponse {\n data: PbExportPageData\n error: PbError\n }\n\n type PbImportPageData {\n task: PbImportExportTask\n }\n\n type PbImportPageResponse {\n data: PbImportPageData\n error: PbError\n }\n\n enum PbExportPageRevisionType {\n published\n latest\n }\n\n extend type PbMutation {\n # Export pages\n exportPages(\n ids: [ID!]\n revisionType: PbExportPageRevisionType!\n where: PbListPagesWhereInput\n sort: [PbListPagesSort!]\n search: PbListPagesSearchInput\n ): PbExportPageResponse\n\n # Import pages\n importPages(category: String!, zipFileUrl: String, meta: JSON): PbImportPageResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportPages: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.pages.exportPages(args));\n },\n\n importPages: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.pages.importPages(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,WAAW,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACN,WAAW,CAACE,IAAI,CAAC,CAAC;QACrE,CAAC;QAEDK,WAAW,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACC,WAAW,CAACL,IAAI,CAAC,CAAC;QACrE;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["plugin","type","schema","typeDefs","resolvers","PbMutation","exportTemplates","_","args","context","resolve","pageBuilder","templates","importTemplates"],"sources":["templates.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportTemplateData {\n task: PbImportExportTask\n }\n\n type PbExportTemplateResponse {\n data: PbExportTemplateData\n error: PbError\n }\n\n type PbImportTemplateData {\n task: PbImportExportTask\n }\n\n type PbImportTemplateResponse {\n data: PbImportTemplateData\n error: PbError\n }\n\n extend type PbMutation {\n # Export templates\n exportTemplates(ids: [ID!]): PbExportTemplateResponse\n\n # Import templates\n importTemplates(zipFileUrl: String): PbImportTemplateResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportTemplates: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.templates.exportTemplates(args));\n },\n\n importTemplates: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.templates.importTemplates(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA;AAEA,
|
1
|
+
{"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","PbMutation","exportTemplates","_","args","context","resolve","pageBuilder","templates","importTemplates","_default","exports","default"],"sources":["templates.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportTemplateData {\n task: PbImportExportTask\n }\n\n type PbExportTemplateResponse {\n data: PbExportTemplateData\n error: PbError\n }\n\n type PbImportTemplateData {\n task: PbImportExportTask\n }\n\n type PbImportTemplateResponse {\n data: PbImportTemplateData\n error: PbError\n }\n\n extend type PbMutation {\n # Export templates\n exportTemplates(ids: [ID!]): PbExportTemplateResponse\n\n # Import templates\n importTemplates(zipFileUrl: String): PbImportTemplateResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportTemplates: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.templates.exportTemplates(args));\n },\n\n importTemplates: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.templates.importTemplates(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,eAAe,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,SAAS,CAACN,eAAe,CAACE,IAAI,CAAC,CAAC;QAC7E,CAAC;QAEDK,eAAe,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,SAAS,CAACC,eAAe,CAACL,IAAI,CAAC,CAAC;QAC7E;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Response, ErrorResponse } from "@webiny/handler-graphql";
|
2
|
-
declare const _default: (fn: () => Promise<any>) => Promise<Response<any
|
2
|
+
declare const _default: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
|
3
3
|
export default _default;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["fn","Response","e","ErrorResponse"],"sources":["resolve.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql\";\n\nexport default async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":";;;;;;AAAA;AAAkE,
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_default","fn","Response","e","ErrorResponse","exports","default"],"sources":["resolve.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql\";\n\nexport default async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAkE,IAAAC,QAAA,GAEnD,MAAOC,EAAsB,IAAK;EAC7C,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;AAAAE,OAAA,CAAAC,OAAA,GAAAN,QAAA"}
|
package/graphql/graphql.js
CHANGED
@@ -11,4 +11,6 @@ var _pages = _interopRequireDefault(require("./graphql/pages.gql"));
|
|
11
11
|
var _templates = _interopRequireDefault(require("./graphql/templates.gql"));
|
12
12
|
var _importExportTasks = _interopRequireDefault(require("./graphql/importExportTasks.gql"));
|
13
13
|
var _default = [_blocks.default, _forms.default, _pages.default, _templates.default, _importExportTasks.default];
|
14
|
-
exports.default = _default;
|
14
|
+
exports.default = _default;
|
15
|
+
|
16
|
+
//# sourceMappingURL=graphql.js.map
|
package/graphql/graphql.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["blocks","forms","pages","templates","importExportTask"],"sources":["graphql.ts"],"sourcesContent":["import blocks from \"./graphql/blocks.gql\";\nimport forms from \"./graphql/forms.gql\";\nimport pages from \"./graphql/pages.gql\";\nimport templates from \"./graphql/templates.gql\";\nimport importExportTask from \"./graphql/importExportTasks.gql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\n\nexport default [blocks, forms, pages, templates, importExportTask] as GraphQLSchemaPlugin[];\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAA+D,
|
1
|
+
{"version":3,"names":["_blocks","_interopRequireDefault","require","_forms","_pages","_templates","_importExportTasks","_default","blocks","forms","pages","templates","importExportTask","exports","default"],"sources":["graphql.ts"],"sourcesContent":["import blocks from \"./graphql/blocks.gql\";\nimport forms from \"./graphql/forms.gql\";\nimport pages from \"./graphql/pages.gql\";\nimport templates from \"./graphql/templates.gql\";\nimport importExportTask from \"./graphql/importExportTasks.gql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\n\nexport default [blocks, forms, pages, templates, importExportTask] as GraphQLSchemaPlugin[];\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,kBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAA+D,IAAAK,QAAA,GAGhD,CAACC,eAAM,EAAEC,cAAK,EAAEC,cAAK,EAAEC,kBAAS,EAAEC,0BAAgB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAP,QAAA"}
|
package/graphql/index.js
CHANGED
@@ -8,4 +8,6 @@ exports.default = void 0;
|
|
8
8
|
var _crud = _interopRequireDefault(require("./crud"));
|
9
9
|
var _graphql = _interopRequireDefault(require("./graphql"));
|
10
10
|
var _default = params => [(0, _crud.default)(params), _graphql.default];
|
11
|
-
exports.default = _default;
|
11
|
+
exports.default = _default;
|
12
|
+
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/graphql/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["params","crud","graphql"],"sources":["index.ts"],"sourcesContent":["import crud from \"./crud\";\nimport graphql from \"./graphql\";\nimport { ImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: ImportExportPluginsParams) => [crud(params), graphql];\n"],"mappings":";;;;;;;AAAA;AACA;AAAgC,
|
1
|
+
{"version":3,"names":["_crud","_interopRequireDefault","require","_graphql","_default","params","crud","graphql","exports","default"],"sources":["index.ts"],"sourcesContent":["import crud from \"./crud\";\nimport graphql from \"./graphql\";\nimport { ImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: ImportExportPluginsParams) => [crud(params), graphql];\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAgC,IAAAE,QAAA,GAGhBC,MAAiC,IAAK,CAAC,IAAAC,aAAI,EAACD,MAAM,CAAC,EAAEE,gBAAO,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAL,QAAA"}
|
package/graphql/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
1
2
|
import { PbContext } from "@webiny/api-page-builder/types";
|
2
3
|
import { FormBuilderContext } from "@webiny/api-form-builder/types";
|
3
4
|
import { ExportRevisionType, ImportExportTask, ImportExportTaskStatus, ImportExportTaskStorageOperations, ImportExportTaskStorageOperationsListParams } from "../types";
|
@@ -23,6 +24,30 @@ export interface ImportPagesParams {
|
|
23
24
|
zipFileUrl: string;
|
24
25
|
meta?: Record<string, any>;
|
25
26
|
}
|
27
|
+
/**
|
28
|
+
* @category Lifecycle events
|
29
|
+
*/
|
30
|
+
export interface OnPagesBeforeExportTopicParams {
|
31
|
+
params: ExportPagesParams;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* @category Lifecycle events
|
35
|
+
*/
|
36
|
+
export interface OnPagesAfterExportTopicParams {
|
37
|
+
params: ExportPagesParams;
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* @category Lifecycle events
|
41
|
+
*/
|
42
|
+
export interface OnPagesBeforeImportTopicParams {
|
43
|
+
params: ImportPagesParams;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* @category Lifecycle events
|
47
|
+
*/
|
48
|
+
export interface OnPagesAfterImportTopicParams {
|
49
|
+
params: ImportPagesParams;
|
50
|
+
}
|
26
51
|
export declare type PagesImportExportCrud = {
|
27
52
|
exportPages(params: ExportPagesParams): Promise<{
|
28
53
|
task: ImportExportTask;
|
@@ -30,6 +55,10 @@ export declare type PagesImportExportCrud = {
|
|
30
55
|
importPages(params: ImportPagesParams): Promise<{
|
31
56
|
task: ImportExportTask;
|
32
57
|
}>;
|
58
|
+
onPagesBeforeExport: Topic<OnPagesBeforeExportTopicParams>;
|
59
|
+
onPagesAfterExport: Topic<OnPagesAfterExportTopicParams>;
|
60
|
+
onPagesBeforeImport: Topic<OnPagesBeforeImportTopicParams>;
|
61
|
+
onPagesAfterImport: Topic<OnPagesAfterImportTopicParams>;
|
33
62
|
};
|
34
63
|
export interface ExportBlocksParams {
|
35
64
|
ids?: string[];
|
@@ -39,9 +68,32 @@ export interface ExportBlocksParams {
|
|
39
68
|
};
|
40
69
|
}
|
41
70
|
export interface ImportBlocksParams {
|
42
|
-
category: string;
|
43
71
|
zipFileUrl: string;
|
44
72
|
}
|
73
|
+
/**
|
74
|
+
* @category Lifecycle events
|
75
|
+
*/
|
76
|
+
export interface OnBlocksBeforeExportTopicParams {
|
77
|
+
params: ExportBlocksParams;
|
78
|
+
}
|
79
|
+
/**
|
80
|
+
* @category Lifecycle events
|
81
|
+
*/
|
82
|
+
export interface OnBlocksAfterExportTopicParams {
|
83
|
+
params: ExportBlocksParams;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* @category Lifecycle events
|
87
|
+
*/
|
88
|
+
export interface OnBlocksBeforeImportTopicParams {
|
89
|
+
params: ImportBlocksParams;
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* @category Lifecycle events
|
93
|
+
*/
|
94
|
+
export interface OnBlocksAfterImportTopicParams {
|
95
|
+
params: ImportBlocksParams;
|
96
|
+
}
|
45
97
|
export declare type BlocksImportExportCrud = {
|
46
98
|
exportBlocks(params: ExportBlocksParams): Promise<{
|
47
99
|
task: ImportExportTask;
|
@@ -49,6 +101,10 @@ export declare type BlocksImportExportCrud = {
|
|
49
101
|
importBlocks(params: ImportBlocksParams): Promise<{
|
50
102
|
task: ImportExportTask;
|
51
103
|
}>;
|
104
|
+
onBlocksBeforeExport: Topic<OnBlocksBeforeExportTopicParams>;
|
105
|
+
onBlocksAfterExport: Topic<OnBlocksAfterExportTopicParams>;
|
106
|
+
onBlocksBeforeImport: Topic<OnBlocksBeforeImportTopicParams>;
|
107
|
+
onBlocksAfterImport: Topic<OnBlocksAfterImportTopicParams>;
|
52
108
|
};
|
53
109
|
export interface ExportTemplatesParams {
|
54
110
|
ids?: string[];
|
@@ -57,6 +113,30 @@ export interface ExportTemplatesParams {
|
|
57
113
|
export interface ImportTemplatesParams {
|
58
114
|
zipFileUrl: string;
|
59
115
|
}
|
116
|
+
/**
|
117
|
+
* @category Lifecycle events
|
118
|
+
*/
|
119
|
+
export interface OnTemplatesBeforeExportTopicParams {
|
120
|
+
params: ExportTemplatesParams;
|
121
|
+
}
|
122
|
+
/**
|
123
|
+
* @category Lifecycle events
|
124
|
+
*/
|
125
|
+
export interface OnTemplatesAfterExportTopicParams {
|
126
|
+
params: ExportTemplatesParams;
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* @category Lifecycle events
|
130
|
+
*/
|
131
|
+
export interface OnTemplatesBeforeImportTopicParams {
|
132
|
+
params: ImportTemplatesParams;
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* @category Lifecycle events
|
136
|
+
*/
|
137
|
+
export interface OnTemplatesAfterImportTopicParams {
|
138
|
+
params: ImportTemplatesParams;
|
139
|
+
}
|
60
140
|
export declare type TemplatesImportExportCrud = {
|
61
141
|
exportTemplates(params: ExportTemplatesParams): Promise<{
|
62
142
|
task: ImportExportTask;
|
@@ -64,6 +144,10 @@ export declare type TemplatesImportExportCrud = {
|
|
64
144
|
importTemplates(params: ImportTemplatesParams): Promise<{
|
65
145
|
task: ImportExportTask;
|
66
146
|
}>;
|
147
|
+
onTemplatesBeforeExport: Topic<OnTemplatesBeforeExportTopicParams>;
|
148
|
+
onTemplatesAfterExport: Topic<OnTemplatesAfterExportTopicParams>;
|
149
|
+
onTemplatesBeforeImport: Topic<OnTemplatesBeforeImportTopicParams>;
|
150
|
+
onTemplatesAfterImport: Topic<OnTemplatesAfterImportTopicParams>;
|
67
151
|
};
|
68
152
|
export interface ExportFormsParams {
|
69
153
|
ids?: string[];
|
@@ -76,6 +160,30 @@ export interface ExportFormsParams {
|
|
76
160
|
export interface ImportFormsParams {
|
77
161
|
zipFileUrl: string;
|
78
162
|
}
|
163
|
+
/**
|
164
|
+
* @category Lifecycle events
|
165
|
+
*/
|
166
|
+
export interface OnFormsBeforeExportTopicParams {
|
167
|
+
params: ExportFormsParams;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* @category Lifecycle events
|
171
|
+
*/
|
172
|
+
export interface OnFormsAfterExportTopicParams {
|
173
|
+
params: ExportFormsParams;
|
174
|
+
}
|
175
|
+
/**
|
176
|
+
* @category Lifecycle events
|
177
|
+
*/
|
178
|
+
export interface OnFormsBeforeImportTopicParams {
|
179
|
+
params: ImportFormsParams;
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* @category Lifecycle events
|
183
|
+
*/
|
184
|
+
export interface OnFormsAfterImportTopicParams {
|
185
|
+
params: ImportFormsParams;
|
186
|
+
}
|
79
187
|
export declare type FormsImportExportCrud = {
|
80
188
|
exportForms(params: ExportFormsParams): Promise<{
|
81
189
|
task: ImportExportTask;
|
@@ -83,6 +191,10 @@ export declare type FormsImportExportCrud = {
|
|
83
191
|
importForms(params: ImportFormsParams): Promise<{
|
84
192
|
task: ImportExportTask;
|
85
193
|
}>;
|
194
|
+
onFormsBeforeExport: Topic<OnFormsBeforeExportTopicParams>;
|
195
|
+
onFormsAfterExport: Topic<OnFormsAfterExportTopicParams>;
|
196
|
+
onFormsBeforeImport: Topic<OnFormsBeforeImportTopicParams>;
|
197
|
+
onFormsAfterImport: Topic<OnFormsAfterImportTopicParams>;
|
86
198
|
};
|
87
199
|
declare type ImportExportTaskCreateData = Omit<ImportExportTask, "id" | "createdOn" | "createdBy">;
|
88
200
|
export declare type ImportExportTaskCrud = {
|