directus-extension-okam-typesense
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
import{defineOperationApp as e}from"@directus/extensions-sdk";const t=[],i=[],n=[],o=[],l=[],s=[],r=[e({id:"okam-typesense-upsert",name:"Typesense Upsert Document Operation",icon:"box",description:"Upsert a document(s) in typesense, using env TYPESENSE_HOST and TYPESENSE_APIKEY_WRITE",overview:({collection:e})=>[{label:"Collection",text:e}],options:[{field:"collection",name:"Collection",type:"string",meta:{width:"full",interface:"input"}},{field:"item",name:"Item",type:"json",meta:{width:"full",interface:"input-code",options:{languages:"json"}}},{field:"host_override",name:"Host Override",type:"string",meta:{width:"full",interface:"input"}},{field:"apikey_override",name:"API Key Override",type:"string",meta:{width:"full",interface:"input"}}]}),e({id:"okam-typesense-delete",name:"Typesense Delete Document Operation",icon:"box",description:"Delete a document(s) in typesense",overview:({collection:e})=>[{label:"Collection",text:e}],options:[{field:"collection",name:"Collection",type:"string",meta:{width:"full",interface:"input"}},{field:"key",name:"Key",type:"string",meta:{width:"full",interface:"input"}},{field:"item",name:"Item",type:"json",meta:{width:"full",interface:"input-code",options:{languages:"json"}}},{field:"host_override",name:"Host Override",type:"string",meta:{width:"full",interface:"input"}},{field:"apikey_override",name:"API Key Override",type:"string",meta:{width:"full",interface:"input"}}]})];export{i as displays,t as interfaces,n as layouts,o as modules,r as operations,l as panels,s as themes}; | ||
import{defineOperationApp as e,defineModule as t}from"@directus/extensions-sdk";import{defineComponent as n,resolveComponent as i,openBlock as a,createBlock as s,withCtx as o,createElementVNode as l,withDirectives as r,vModelText as c,createElementBlock as p,Fragment as u,renderList as d,toDisplayString as h,vModelSelect as y,createTextVNode as f,createVNode as m,pushScopeId as g,popScopeId as _}from"vue";var v=e({id:"okam-typesense-upsert",name:"Typesense Upsert Document Operation",icon:"box",description:"Upsert a document(s) in typesense, using env TYPESENSE_HOST and TYPESENSE_APIKEY_WRITE",overview:({collection:e})=>[{label:"Collection",text:e}],options:[{field:"collection",name:"Collection",type:"string",meta:{width:"full",interface:"input"}},{field:"item",name:"Item",type:"json",meta:{width:"full",interface:"input-code",options:{languages:"json"}}},{field:"host_override",name:"Host Override",type:"string",meta:{width:"full",interface:"input"}},{field:"apikey_override",name:"API Key Override",type:"string",meta:{width:"full",interface:"input"}}]}),b=e({id:"okam-typesense-delete",name:"Typesense Delete Document Operation",icon:"box",description:"Delete a document(s) in typesense",overview:({collection:e})=>[{label:"Collection",text:e}],options:[{field:"collection",name:"Collection",type:"string",meta:{width:"full",interface:"input"}},{field:"key",name:"Key",type:"string",meta:{width:"full",interface:"input"}},{field:"item",name:"Item",type:"json",meta:{width:"full",interface:"input-code",options:{languages:"json"}}},{field:"host_override",name:"Host Override",type:"string",meta:{width:"full",interface:"input"}},{field:"apikey_override",name:"API Key Override",type:"string",meta:{width:"full",interface:"input"}}]});class w{constructor(e){this.client=e}async retrieve(){return this.client.get("/health")}}const S={Client:class{constructor(e){this.apiKey=e.apiKey,this.nodes=e.nodes,this.health=new w(this)}getUrl(e){var t;if(!(null==(t=null==this?void 0:this.nodes)?void 0:t[0]))return null;const{host:n,port:i,protocol:a}=this.nodes[0];return`${a}://${n}:${i}${e}`}async get(e,t="GET",n="json"){const i=this.getUrl(e);if(!i)return null;return(await fetch(i,{method:t||"GET",headers:{"X-TYPESENSE-API-KEY":this.apiKey}}))[n||"json"]().catch((()=>null))}async delete(e){return this.get(e,"DELETE")}async patch(e,t){return this.post(e,t,"PATCH")}async post(e,t,n="POST"){const i=this.getUrl(e);if(!i)return null;return(await fetch(i,{method:n,headers:{"X-TYPESENSE-API-KEY":this.apiKey},body:JSON.stringify(t)})).json()}collections(e=void 0){return{retrieve:async()=>this.get("/collections"),create:async e=>this.post("/collections",e),delete:async()=>this.delete(`/collections/${e}`),alter:async t=>this.patch(`/collections/${e}`,t),export:async()=>this.get(`/collections/${e}/documents/export`,"GET","text"),search:async t=>{const n=function(e){return new URLSearchParams(e).toString()}(t);return this.get(`/collections/${e}/documents/search?${n}`)}}}}};async function k(e,t){return e&&t?async function({host:e,apiKey:t}){try{const n=new URL(e);return new S.Client({nodes:[{host:n.hostname,port:C(n),protocol:n.protocol.replace(/:/,"")}],apiKey:t})}catch(e){return null}}({host:e,apiKey:t}):null}function C(e){const t=e.protocol.replace(/:/,"").toLowerCase(),n=Number(e.port);if(n>0)return n;return new Map([["http",80],["https",443]]).get(t)||8108}var E={programs:{name:"programs",enable_nested_fields:!0,fields:[{name:"id",type:"string"},{name:"lang",type:"string"},{name:"title",type:"string"},{name:"code",type:"string"},{name:"tag",type:"int64",facet:!0},{name:"pa_.*",type:"int64[]",facet:!0},{name:"image",type:"object"}]},pages:{name:"pages",enable_nested_fields:!0,fields:[{name:"id",type:"string"},{name:"lang",type:"string"},{name:"title",type:"string"},{name:"image",type:"object"}]},news:{name:"news",enable_nested_fields:!0,fields:[{name:"id",type:"string"},{name:"lang",type:"string"},{name:"title",type:"string"},{name:"image",type:"object"}]},events:{name:"events",enable_nested_fields:!0,fields:[{name:"id",type:"string"},{name:"lang",type:"string"},{name:"title",type:"string"}]},staff_members:{name:"staff_members",enable_nested_fields:!0,fields:[{name:"id",type:"string"},{name:"lang",type:"string"},{name:"title",type:"string"},{name:"alphacategory",type:"string",facet:!0}]}},x=n({name:"okam-typesense-form",props:{host:{type:String,required:!0},apikey:{type:String,required:!0},collection:{type:String,required:!0},alter:{type:String,required:!1},search_q:{type:String,required:!0},search_query_by:{type:String,required:!0},search_facet_by:{type:String,required:!0},search_filter_by:{type:String,required:!0},response:{type:String}},data:()=>({host:"",apikey:"",collection:"programs",alter:"",search_q:"",search_query_by:"code,title",search_facet_by:"tag",search_filter_by:"",response:"",collectionlist:Object.keys(E).map((e=>({name:e})))}),methods:{async onHealth(){const e=await k(this.host,this.apikey);if(!e)return;const t=await async function(e){return e.health.retrieve()}(e);this.outputResponse(t)},async onCollectionList(){const e=await k(this.host,this.apikey);if(!e)return;const t=await async function(e){return e.collections().retrieve()}(e);this.outputResponse(t)},async onCreateSchema(){const e=await k(this.host,this.apikey);if(!e||!this.collection)return;const t=E[this.collection],n=await async function(e,t){return e.collections().create(t)}(e,t);this.outputResponse(n)},async onDeleteSchema(){const e=await k(this.host,this.apikey);if(!e||!this.collection)return;const t=await async function(e,t){return e.collections(t).delete()}(e,this.collection);this.outputResponse(t)},async onAlterSchema(){const e=await k(this.host,this.apikey);if(e&&this.collection&&this.alter)try{const t=JSON.parse(this.alter),n=await async function(e,t,n){return e.collections(t).alter(n)}(e,this.collection,t);this.outputResponse(n)}catch(e){}},async onExportDocuments(){const e=await k(this.host,this.apikey);if(!e||!this.collection)return;const t=await async function(e,t){return e.collections(t).export()}(e,this.collection);this.response=t},async onSearchDocuments(){const e=await k(this.host,this.apikey);if(!e||!this.collection)return;const t={q:this.search_q,query_by:this.search_query_by,facet_by:this.search_facet_by,filter_by:this.search_filter_by},n=await async function(e,t,n){return e.collections(t).search(n)}(e,this.collection,t);this.outputResponse(n)},outputResponse(e){this.response=JSON.stringify(e,null," ")}}}),q=[],T=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,i=!0===t.prepend?"prepend":"append",a=!0===t.singleTag,s="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(a){var o=q.indexOf(s);-1===o&&(o=q.push(s)-1,T[o]={}),n=T[o]&&T[o][i]?T[o][i]:T[o][i]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),a=0;a<n.length;a++)e.setAttribute(n[a],t.attributes[n[a]]);var o="prepend"===i?"afterbegin":"beforeend";return s.insertAdjacentElement(o,e),e}}("\n/* @import '@/styles/mixins/form-grid'; */\n.v-form[data-v-f3d3893a] {\n\t/*\n\t@include form-grid\n\thttps://github.com/directus/directus/blob/e18182010239df89168aea49fc651c01808a279a/app/src/components/v-form/v-form.vue\n\t*/\n\tdisplay: grid;\n\tgrid-template-columns: [start] minmax(0,1fr) [half] minmax(0,1fr) [full];\n\tgap: var(--theme--form--row-gap) var(--theme--form--column-gap);\n\tpadding-top: calc(var(--theme--form--row-gap) / 2);\n}\n.field_full[data-v-f3d3893a] {\n\tgrid-column: start/full;\n}\ntextarea[data-v-f3d3893a] {\n\twidth: 95%;\n}\n",{});var O=(e,t)=>{const n=e.__vccOpts||e;for(const[e,i]of t)n[e]=i;return n};const U=e=>(g("data-v-f3d3893a"),e=e(),_(),e),A={class:"v-form"},K={class:"field_half"},j=U((()=>l("label",null,"Host",-1))),D={class:"field_half"},P=U((()=>l("label",null,"Key",-1))),R={class:"field_hakf"},N=U((()=>l("label",null,"Collection",-1))),I=["value"],V={class:"field_half"},$=U((()=>l("label",null,"Alter",-1))),H={class:"field_full"},L=U((()=>l("label",null,"Search",-1))),Y={class:"v-button field_full"},G={class:"field_full"},J=U((()=>l("label",null,"Response",-1)));const M=[],X=[],B=[],W=[t({id:"okam-typesense",name:"Okam Typesense",icon:"box",routes:[{path:"",component:O(x,[["render",function(e,t,n,g,_,v){const b=i("v-button"),w=i("private-view");return a(),s(w,{title:"OKAM Typesense"},{default:o((()=>[l("div",A,[l("div",K,[j,r(l("input",{"onUpdate:modelValue":t[0]||(t[0]=t=>e.host=t),placeholder:"http://host:port"},null,512),[[c,e.host]])]),l("div",D,[P,r(l("input",{"onUpdate:modelValue":t[1]||(t[1]=t=>e.apikey=t),placeholder:""},null,512),[[c,e.apikey]])]),l("div",R,[N,r(l("select",{"onUpdate:modelValue":t[2]||(t[2]=t=>e.collection=t),placeholder:""},[(a(!0),p(u,null,d(e.collectionlist,(e=>(a(),p("option",{key:e.name,value:e.name},h(e.name),9,I)))),128))],512),[[y,e.collection]])]),l("div",V,[$,r(l("textarea",{"onUpdate:modelValue":t[3]||(t[3]=t=>e.alter=t),placeholder:'{"fields": [{name:"abc","type":"string"}]}'},null,512),[[c,e.alter]])]),l("div",H,[L,f(" q: "),r(l("input",{"onUpdate:modelValue":t[4]||(t[4]=t=>e.search_q=t)},null,512),[[c,e.search_q]]),f(" query_by: "),r(l("input",{"onUpdate:modelValue":t[5]||(t[5]=t=>e.search_query_by=t)},null,512),[[c,e.search_query_by]]),f(" facet_by: "),r(l("input",{"onUpdate:modelValue":t[6]||(t[6]=t=>e.search_facet_by=t)},null,512),[[c,e.search_facet_by]]),f(" filter_by: "),r(l("input",{"onUpdate:modelValue":t[7]||(t[7]=t=>e.search_filter_by=t)},null,512),[[c,e.search_filter_by]])]),l("div",Y,[m(b,{onClick:e.onHealth},{default:o((()=>[f("Health")])),_:1},8,["onClick"]),m(b,{onClick:e.onCollectionList},{default:o((()=>[f("Collection List")])),_:1},8,["onClick"]),m(b,{onClick:e.onCreateSchema},{default:o((()=>[f("Create Schema")])),_:1},8,["onClick"]),m(b,{onClick:e.onDeleteSchema},{default:o((()=>[f("Delete Schema")])),_:1},8,["onClick"]),m(b,{onClick:e.onAlterSchema},{default:o((()=>[f("Alter Schema")])),_:1},8,["onClick"]),m(b,{onClick:e.onExportDocuments},{default:o((()=>[f("Export")])),_:1},8,["onClick"]),m(b,{onClick:e.onSearchDocuments},{default:o((()=>[f("Search")])),_:1},8,["onClick"])]),l("div",G,[J,r(l("textarea",{"onUpdate:modelValue":t[8]||(t[8]=t=>e.response=t),cols:"100",rows:"20"},null,512),[[c,e.response]])])])])),_:1})}],["__scopeId","data-v-f3d3893a"],["__file","module.vue"]])}]})],z=[],F=[],Q=[v,b];export{X as displays,M as interfaces,B as layouts,W as modules,Q as operations,z as panels,F as themes}; |
@@ -5,3 +5,3 @@ { | ||
"icon": "extension", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"keywords": [ | ||
@@ -35,2 +35,7 @@ "directus", | ||
} | ||
}, | ||
{ | ||
"type": "module", | ||
"name": "okam-typesense-admin", | ||
"source": "src/okam-typesense-admin/index.ts" | ||
} | ||
@@ -49,5 +54,5 @@ ], | ||
"@directus/extensions-sdk": "10.3.0", | ||
"@types/node": "^20.11.4", | ||
"@types/node": "^20.11.17", | ||
"typescript": "^5.3.3", | ||
"vue": "^3.4.14" | ||
"vue": "^3.4.19" | ||
}, | ||
@@ -54,0 +59,0 @@ "files": [ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
68983
256
4