import{r,p as i,q as c,w as a,z as e,t,R as s}from"./vendor.8ed37afc.js";const d={class:"markdown-body"},u=e("div",{class:"two-up"},[e("div",{class:"left"},[e("blockquote",null,[e("p",null,"Utilities are the various helper endpoints located within the API.")])]),e("div",{class:"right"},[e("p",null,[e("div",{class:"table-of-contents"},[e("ul",null,[e("li",null,[e("a",{href:"#generate-a-hash"},"Generate a Hash")]),e("li",null,[e("a",{href:"#verify-a-hash"},"Verify a Hash")]),e("li",null,[e("a",{href:"#manually-sort-items-in-collection"},"Manually Sort Items in Collection")]),e("li",null,[e("a",{href:"#import-data-from-file"},"Import Data from File")]),e("li",null,[e("a",{href:"#clear-the-internal-cache"},"Clear the Internal Cache")])])])])])],-1),p=e("hr",null,null,-1),_=e("h2",{id:"generate-a-hash"},[s("Generate a Hash "),e("a",{class:"header-anchor",href:"#generate-a-hash"},"#")],-1),f=e("p",null,"Generate a hash for a given string.",-1),m=e("div",{class:"two-up"},[e("div",{class:"left"},[e("h3",{id:"request-body"},[s("Request Body "),e("a",{class:"header-anchor",href:"#request-body"},"#")]),e("div",{class:"definitions"},[e("p",null,[e("code",null,"string"),s(),e("strong",null,"Required"),e("br"),s(" String to hash.")])]),e("h3",{id:"returns"},[s("Returns "),e("a",{class:"header-anchor",href:"#returns"},"#")]),e("p",null,"Hashed string.")]),e("div",{class:"right"},[e("h3",{id:"rest-api"},[s("REST API "),e("a",{class:"header-anchor",href:"#rest-api"},"#")]),e("pre",null,[e("code",null,`POST /utils/hash/generate
`)]),e("h5",{id:"example"},[s("Example "),e("a",{class:"header-anchor",href:"#example"},"#")]),e("pre",null,[e("code",{class:"language-json"},[e("span",{class:"hljs-comment"},"// POST /utils/hash/generate"),s(`

{
	`),e("span",{class:"hljs-attr"},'"string"'),s(": "),e("span",{class:"hljs-string"},'"Hello World!"'),s(`
}
`)])]),e("h3",{id:"graphql"},[s("GraphQL "),e("a",{class:"header-anchor",href:"#graphql"},"#")]),e("pre",null,[e("code",null,`POST /graphql/system
`)]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"type"),e("span",{class:"hljs-type"}," Mutation"),s(` {
	utils_hash_generate(string:`),e("span",{class:"hljs-type"}," String"),s("!):"),e("span",{class:"hljs-type"}," String"),s(`
}
`)])]),e("h5",{id:"example-2"},[s("Example "),e("a",{class:"header-anchor",href:"#example-2"},"#")]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"mutation"),s(` {
	utils_hash_generate(string: `),e("span",{class:"hljs-string"},'"Hello World!"'),s(`)
}
`)])])])],-1),g=e("hr",null,null,-1),y=e("h2",{id:"verify-a-hash"},[s("Verify a Hash "),e("a",{class:"header-anchor",href:"#verify-a-hash"},"#")],-1),q=e("p",null,"Verify a string with a hash.",-1),j=e("div",{class:"two-up"},[e("div",{class:"left"},[e("h3",{id:"request-body-2"},[s("Request Body "),e("a",{class:"header-anchor",href:"#request-body-2"},"#")]),e("div",{class:"definitions"},[e("p",null,[e("code",null,"string"),s(),e("strong",null,"Required"),e("br"),s(" Source string.")]),e("p",null,[e("code",null,"hash"),s(),e("strong",null,"Required"),e("br"),s(" Hash you want to verify against.")])]),e("h3",{id:"returns-2"},[s("Returns "),e("a",{class:"header-anchor",href:"#returns-2"},"#")]),e("p",null,"Boolean.")]),e("div",{class:"right"},[e("h3",{id:"rest-api-2"},[s("REST API "),e("a",{class:"header-anchor",href:"#rest-api-2"},"#")]),e("pre",null,[e("code",null,`POST /utils/hash/verify
`)]),e("h5",{id:"example-3"},[s("Example "),e("a",{class:"header-anchor",href:"#example-3"},"#")]),e("pre",null,[e("code",{class:"language-json"},[e("span",{class:"hljs-comment"},"// POST /utils/hash/verify"),s(`

{
	`),e("span",{class:"hljs-attr"},'"string"'),s(": "),e("span",{class:"hljs-string"},'"Hello World!"'),s(`,
	`),e("span",{class:"hljs-attr"},'"hash"'),s(": "),e("span",{class:"hljs-string"},'"$arg...fEfM"'),s(`
}
`)])]),e("h3",{id:"graphql-2"},[s("GraphQL "),e("a",{class:"header-anchor",href:"#graphql-2"},"#")]),e("pre",null,[e("code",null,`POST /graphql/system
`)]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"type"),e("span",{class:"hljs-type"}," Mutation"),s(` {
	utils_hash_verify(hash:`),e("span",{class:"hljs-type"}," String"),s("!, string:"),e("span",{class:"hljs-type"}," String"),s("!):"),e("span",{class:"hljs-type"}," Boolean"),s(`
}
`)])])])],-1),v=e("hr",null,null,-1),b=e("h2",{id:"manually-sort-items-in-collection"},[s("Manually Sort Items in Collection "),e("a",{class:"header-anchor",href:"#manually-sort-items-in-collection"},"#")],-1),A=e("p",null,"If a collection has a sort field, this util can be used to move items in that manual order.",-1),S=e("div",{class:"two-up"},[e("div",{class:"left"},[e("h3",{id:"request-body-3"},[s("Request Body "),e("a",{class:"header-anchor",href:"#request-body-3"},"#")]),e("div",{class:"definitions"},[e("p",null,[e("code",null,"item"),s(),e("strong",null,"Required"),e("br"),s(" Primary key of the item you\u2019re moving in the collection.")]),e("p",null,[e("code",null,"to"),s(),e("strong",null,"Required"),e("br"),s(" Primary key of the item you\u2019re moving the source item too.")])]),e("h3",{id:"returns-3"},[s("Returns "),e("a",{class:"header-anchor",href:"#returns-3"},"#")]),e("p",null,"Empty body.")]),e("div",{class:"right"},[e("h3",{id:"rest-api-3"},[s("REST API "),e("a",{class:"header-anchor",href:"#rest-api-3"},"#")]),e("pre",null,[e("code",null,`POST /utils/sort/:collection
`)]),e("h5",{id:"example-4"},[s("Example "),e("a",{class:"header-anchor",href:"#example-4"},"#")]),e("pre",null,[e("code",{class:"language-json"},[e("span",{class:"hljs-comment"},"// POST /utils/sort/articles"),s(`

{
	`),e("span",{class:"hljs-attr"},'"item"'),s(": "),e("span",{class:"hljs-number"},"16"),s(`,
	`),e("span",{class:"hljs-attr"},'"to"'),s(": "),e("span",{class:"hljs-number"},"51"),s(`
}
`)])]),e("h3",{id:"graphql-3"},[s("GraphQL "),e("a",{class:"header-anchor",href:"#graphql-3"},"#")]),e("pre",null,[e("code",null,`POST /graphql/system
`)]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"type"),e("span",{class:"hljs-type"}," Mutation"),s(` {
	utils_sort(collection:`),e("span",{class:"hljs-type"}," String"),s("!, item:"),e("span",{class:"hljs-literal"}," ID"),s("!, to:"),e("span",{class:"hljs-literal"}," ID"),s("!):"),e("span",{class:"hljs-type"}," Boolean"),s(`
}
`)])]),e("h5",{id:"example-5"},[s("Example "),e("a",{class:"header-anchor",href:"#example-5"},"#")]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"mutation"),s(` {
	utils_sort(collection: `),e("span",{class:"hljs-string"},'"articles"'),s(", item: "),e("span",{class:"hljs-number"},"16"),s(", to: "),e("span",{class:"hljs-number"},"51"),s(`)
}
`)])])])],-1),x=e("hr",null,null,-1),E=e("h2",{id:"import-data-from-file"},[s("Import Data from File "),e("a",{class:"header-anchor",href:"#import-data-from-file"},"#")],-1),R=s("Import multiple records from a JSON or CSV file into a collection. Relies on a "),T=e("code",null,"multipart/form-data",-1),C=s(" encoded request, just like regular file uploads. Check "),P=s("Upload a File"),w=s(" for more information."),k=s("The import endpoint expects the file structure to match "),I=s("the export query parameter"),O=s(". For JSON, this is an array of objects, where every object is an item. For CSV, the first line has to be the columns header."),F={class:"two-up"},B={class:"left"},M=e("h3",{id:"request-body-4"},[s("Request Body "),e("a",{class:"header-anchor",href:"#request-body-4"},"#")],-1),D=s("Send the file in a "),H=e("code",null,"multipart/form-data",-1),G=s(" request. See "),V=s("Upload a File"),N=s(" for more information."),U=e("h3",{id:"returns-4"},[s("Returns "),e("a",{class:"header-anchor",href:"#returns-4"},"#")],-1),L=e("p",null,"Empty body.",-1),Q=e("div",{class:"right"},[e("h3",{id:"rest-api-4"},[s("REST API "),e("a",{class:"header-anchor",href:"#rest-api-4"},"#")]),e("pre",null,[e("code",null,`POST /utils/import/:collection
`)]),e("h5",{id:"example-6"},[s("Example "),e("a",{class:"header-anchor",href:"#example-6"},"#")]),e("pre",null,[e("code",null,`POST /utils/import/articles

Content-Type: multipart/form-data; charset=utf-8; boundary=__X_BOUNDARY__
Content-Length: 3442422

--__X_BOUNDARY__
Content-Disposition: form-data; name="file"; filename="articles.csv"
Content-Type: text/csv

"id","title","another","created_by"
1,"My First Articled","abc","506385A2-E444-4AE2-A860-F00957A62C8A"
2,"My Second Article","abc","506385A2-E444-4AE2-A860-F00957A62C8A"
3,"My Updated Third Article","abc","506385A2-E444-4AE2-A860-F00957A62C8A"
4,"My Fourth Article","abc","506385A2-E444-4AE2-A860-F00957A62C8A"
5,"My Fifth Article","abc","506385A2-E444-4AE2-A860-F00957A62C8A"
...
`)]),e("h3",{id:"graphql-4"},[s("GraphQL "),e("a",{class:"header-anchor",href:"#graphql-4"},"#")]),e("p",null,"n/a")],-1),W=e("hr",null,null,-1),J=e("h2",{id:"clear-the-internal-cache"},[s("Clear the Internal Cache "),e("a",{class:"header-anchor",href:"#clear-the-internal-cache"},"#")],-1),X=e("p",null,"Resets both the data and schema cache of Directus. This endpoint is only available to admin users.",-1),Y=e("div",{class:"two-up"},[e("div",{class:"left"},[e("h3",{id:"request-body-5"},[s("Request Body "),e("a",{class:"header-anchor",href:"#request-body-5"},"#")]),e("p",null,"n/a"),e("h3",{id:"returns-5"},[s("Returns "),e("a",{class:"header-anchor",href:"#returns-5"},"#")]),e("p",null,"Empty body")]),e("div",{class:"right"},[e("h3",{id:"rest-api-5"},[s("REST API "),e("a",{class:"header-anchor",href:"#rest-api-5"},"#")]),e("pre",null,[e("code",null,`POST /utils/cache/clear
`)]),e("h3",{id:"graphql-5"},[s("GraphQL "),e("a",{class:"header-anchor",href:"#graphql-5"},"#")]),e("pre",null,[e("code",{class:"language-graphql"},[e("span",{class:"hljs-keyword"},"mutation"),s(` {
	utils_cache_clear
}
`)])])])],-1),ee={setup(z,{expose:o}){const n={title:"Utilities",modularExtension:!1,pageClass:"page-reference"};return o({frontmatter:n}),($,K)=>{const l=r("router-link"),h=r("DocsWrapper");return i(),c(h,{frontmatter:n},{default:a(()=>[e("div",d,[u,p,_,f,m,g,y,q,j,v,b,A,S,x,E,e("p",null,[R,T,C,t(l,{to:"/docs/reference/files/#upload-a-file"},{default:a(()=>[P]),_:1}),w]),e("p",null,[k,t(l,{to:"/docs/reference/query/#export"},{default:a(()=>[I]),_:1}),O]),e("div",F,[e("div",B,[M,e("p",null,[D,H,G,t(l,{to:"/docs/reference/files/#upload-a-file"},{default:a(()=>[V]),_:1}),N]),U,L]),Q]),W,J,X,Y])]),_:1})}}};export{ee as default};
