import{d as u,a as m}from"./dataSchema-VwIQYPJL.js";import"./locale-wDcg0qDg.js";import{C as h}from"./collection-nnUjKAuT.js";import"./manifest--hA2W8VB.js";const f=`The CRUD Export client is a business-logic web component that handles exporting an entire collection from a backend Mia-Platform CRUD Service resource. It functions as an ndjson fetcher and a native file downloader using the browser's native download API. An export route is available at <collection-name>/export and supports mongoDB queries and STATE filtering according to CRUD Service specifications. The component listens to any filtering applied in the plugin where it is mounted by monitoring change-query events and maintaining an internal representation of all filters. When it detects an export-data event, it initiates the data export process.
`,g=`Il client CRUD Export è un componente web business-logic che gestisce l'esportazione di un'intera collezione dal CRUD Service. Funziona come un fetcher ndjson e un downloader nativo di file utilizzando l'API di download nativa del browser. Una rotta di esportazione è disponibile all'indirizzo <nome collezione>/export e supporta le query mongoDB e il filtraggio STATE secondo le specifiche del CRUD Service. Il componente ascolta qualsiasi filtro applicato nel plugin in cui è montato, monitorando gli eventi change-query e mantenendo una rappresentazione interna di tutti i filtri. Quando rileva un evento export-data, avvia il processo di esportazione dei dati.
`,b={docLink:"https://docs.mia-platform.eu/docs/microfrontend-composer/back-kit/components/crud_export",description:{en:"Client for Mia-Platform CRUD service export route",it:"Client per la rotta di export del servizio CRUD di Mia-Platform "},descriptionLong:{en:f,it:g},example:JSON.stringify({tag:"bk-export",properties:{basePath:"/orders/export",dataSchema:{type:"object",properties:{_id:{type:"string"},__STATE__:{type:"string"},name:{type:"string"}}}}}),label:"CRUD Export",mocks:{fetch:o=>{const{basePath:t,dataSchema:a}=o,r=new h(a);if(t){const{pathname:s,origin:c}=new URL(t,window.document.baseURI);return[{handler:async d=>new Response(new ReadableStream({start(i){const l=`
`,p=new TextEncoder;async function n(e){if(e.length===0){i.close();return}i.enqueue(p.encode(JSON.stringify(e.shift()).concat(l))),n(e)}n(r.export(d))}}),{status:200,statusText:"OK",headers:new Headers({"Content-Type":"application/x-ndjson","Transfer-Encoding":"chunked"})}),method:"GET",url:{pathname:s,origin:c}}]}return[]}},definitions:{...u,dataSchema:m},properties:{dataSchema:{$ref:"#/definitions/dataSchema",__mia_configuration:{"shared-key":"back-kit/data-schema",attribute:!1,label:"Data schema",priority:"high",group:"content"}},streamSaverIFrameSrc:{type:"string",__mia_configuration:{attribute:"stream-saver-iframe-src",label:"Streamsaver IFrame source",description:"When downloading this component may use the `streamsaver` service worker. This property sets the location where the relevant iframe can be found"}},nativeDownload:{type:"boolean",__mia_configuration:{priority:"high",attribute:"native-download",label:"Native download mode",description:"When `true` it skips frontend blob parsing and uses browser native download API"}},basePath:{type:"string",__mia_configuration:{description:"The URL base path used to reach the CRUD service",label:"CRUD Service base path",attribute:!0,priority:"high"}},shouldIncludeProjections:{type:"boolean",default:!0,__mia_configuration:{description:"should append projection when exporting from CRUD service",attribute:"should-include-projection",label:"Include projections"}},userConfig:{type:"boolean",default:!1,__mia_configuration:{description:"Whether to listen to `awaiting-for-export-configuration` or not. It must be true to use it with bk-export-modal.",attribute:"user-config",label:"Export with user config"}},primaryKey:{type:"string",default:"_id",__mia_configuration:{attribute:"primary-key",label:"Primary Key",description:"primary key to filter selected data when `selected only export` option is enabled"}}},type:"connector"};var x=b;export{x as default};
