'use strict'; var api = require('@flatfile/api'); var pluginJobHandler = require('@flatfile/plugin-job-handler'); var n=new api.FlatfileClient;function b(t,s){return function(c){c.use(pluginJobHandler.jobHandler("space:configure",async(r,f)=>{let{spaceId:a,environmentId:p}=r.context,e=typeof t=="function"?await t(r):t,o=await Promise.all(e.workbooks.map(async i=>(await n.workbooks.create({spaceId:a,environmentId:p,name:"Workbook",...i})).data.id));if(await f(50,"Workbook created"),e.config?.maintainWorkbookOrder&&(e.space||(e.space={}),e.space.settings={sidebarConfig:{workbookSidebarOrder:o}}),await n.spaces.update(a,{environmentId:p,primaryWorkbookId:o&&o.length>0?o[0]:"",...e.space}),e.documents)for(let i of e.documents)await n.documents.create(a,i);return s&&await s(r,o,f),{info:"Space configured"}}));}} exports.configureSpace = b; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map