mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-04-09 09:23:57 +02:00
91 lines
16 KiB
JavaScript
91 lines
16 KiB
JavaScript
import{S as $t,i as qt,s as St,U as Tt,I as ee,W as ue,V as Ct,f as s,y as _,h as p,c as $e,j as w,l as r,n as i,m as qe,G as oe,X as Ve,Y as pt,D as Ot,Z as Mt,E as Pt,t as ye,a as ve,u as d,d as Se,p as Ft,k as Te,o as Ht,H as we,K as Lt}from"./index-CnS8PnB7.js";import{F as Rt}from"./FieldsQueryParam-Du9lakni.js";function mt(a,e,t){const l=a.slice();return l[10]=e[t],l}function bt(a,e,t){const l=a.slice();return l[10]=e[t],l}function _t(a,e,t){const l=a.slice();return l[15]=e[t],l}function kt(a){let e;return{c(){e=s("p"),e.innerHTML="Requires superuser <code>Authorization:TOKEN</code> header",w(e,"class","txt-hint txt-sm txt-right")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function ht(a){let e,t,l,u,c,f,b,m,$,h,g,A,T,O,R,M,U,J,S,Q,P,q,k,F,te,Y,I,re,z,G,X;function fe(y,C){var V,W,L;return C&1&&(f=null),f==null&&(f=!!((L=(W=(V=y[0])==null?void 0:V.fields)==null?void 0:W.find(Gt))!=null&&L.required)),f?At:jt}let le=fe(a,-1),E=le(a);function Z(y,C){var V,W,L;return C&1&&(U=null),U==null&&(U=!!((L=(W=(V=y[0])==null?void 0:V.fields)==null?void 0:W.find(zt))!=null&&L.required)),U?Vt:Bt}let x=Z(a,-1),H=x(a);return{c(){e=s("tr"),e.innerHTML='<td colspan="3" class="txt-hint txt-bold">Auth specific fields</td>',t=p(),l=s("tr"),u=s("td"),c=s("div"),E.c(),b=p(),m=s("span"),m.textContent="email",$=p(),h=s("td"),h.innerHTML='<span class="label">String</span>',g=p(),A=s("td"),A.textContent="Auth record email address.",T=p(),O=s("tr"),R=s("td"),M=s("div"),H.c(),J=p(),S=s("span"),S.textContent="emailVisibility",Q=p(),P=s("td"),P.innerHTML='<span class="label">Boolean</span>',q=p(),k=s("td"),k.textContent="Whether to show/hide the auth record email when fetching the record data.",F=p(),te=s("tr"),te.innerHTML='<td><div class="inline-flex"><span class="label label-success">Required</span> <span>password</span></div></td> <td><span class="label">String</span></td> <td>Auth record password.</td>',Y=p(),I=s("tr"),I.innerHTML='<td><div class="inline-flex"><span class="label label-success">Required</span> <span>passwordConfirm</span></div></td> <td><span class="label">String</span></td> <td>Auth record password confirmation.</td>',re=p(),z=s("tr"),z.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span> <span>verified</span></div></td> <td><span class="label">Boolean</span></td> <td>Indicates whether the auth record is verified or not.
|
|
<br/>
|
|
This field can be set only by superusers or auth records with "Manage" access.</td>`,G=p(),X=s("tr"),X.innerHTML='<td colspan="3" class="txt-hint txt-bold">Other fields</td>',w(c,"class","inline-flex"),w(M,"class","inline-flex")},m(y,C){r(y,e,C),r(y,t,C),r(y,l,C),i(l,u),i(u,c),E.m(c,null),i(c,b),i(c,m),i(l,$),i(l,h),i(l,g),i(l,A),r(y,T,C),r(y,O,C),i(O,R),i(R,M),H.m(M,null),i(M,J),i(M,S),i(O,Q),i(O,P),i(O,q),i(O,k),r(y,F,C),r(y,te,C),r(y,Y,C),r(y,I,C),r(y,re,C),r(y,z,C),r(y,G,C),r(y,X,C)},p(y,C){le!==(le=fe(y,C))&&(E.d(1),E=le(y),E&&(E.c(),E.m(c,b))),x!==(x=Z(y,C))&&(H.d(1),H=x(y),H&&(H.c(),H.m(M,J)))},d(y){y&&(d(e),d(t),d(l),d(T),d(O),d(F),d(te),d(Y),d(I),d(re),d(z),d(G),d(X)),E.d(),H.d()}}}function jt(a){let e;return{c(){e=s("span"),e.textContent="Optional",w(e,"class","label label-warning")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function At(a){let e;return{c(){e=s("span"),e.textContent="Required",w(e,"class","label label-success")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function Bt(a){let e;return{c(){e=s("span"),e.textContent="Optional",w(e,"class","label label-warning")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function Vt(a){let e;return{c(){e=s("span"),e.textContent="Required",w(e,"class","label label-success")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function Dt(a){let e;return{c(){e=s("span"),e.textContent="Required",w(e,"class","label label-success")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function Nt(a){let e;return{c(){e=s("span"),e.textContent="Optional",w(e,"class","label label-warning")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function Jt(a){let e,t=a[15].maxSelect===1?"id":"ids",l,u;return{c(){e=_("Relation record "),l=_(t),u=_(".")},m(c,f){r(c,e,f),r(c,l,f),r(c,u,f)},p(c,f){f&64&&t!==(t=c[15].maxSelect===1?"id":"ids")&&oe(l,t)},d(c){c&&(d(e),d(l),d(u))}}}function Et(a){let e,t,l,u,c,f,b,m,$;return{c(){e=_("File object."),t=s("br"),l=_(`
|
|
Set to empty value (`),u=s("code"),u.textContent="null",c=_(", "),f=s("code"),f.textContent='""',b=_(" or "),m=s("code"),m.textContent="[]",$=_(`) to delete
|
|
already uploaded file(s).`)},m(h,g){r(h,e,g),r(h,t,g),r(h,l,g),r(h,u,g),r(h,c,g),r(h,f,g),r(h,b,g),r(h,m,g),r(h,$,g)},p:we,d(h){h&&(d(e),d(t),d(l),d(u),d(c),d(f),d(b),d(m),d($))}}}function Ut(a){let e;return{c(){e=_("URL address.")},m(t,l){r(t,e,l)},p:we,d(t){t&&d(e)}}}function It(a){let e;return{c(){e=_("Email address.")},m(t,l){r(t,e,l)},p:we,d(t){t&&d(e)}}}function Kt(a){let e;return{c(){e=_("JSON array or object.")},m(t,l){r(t,e,l)},p:we,d(t){t&&d(e)}}}function Qt(a){let e;return{c(){e=_("Number value.")},m(t,l){r(t,e,l)},p:we,d(t){t&&d(e)}}}function Wt(a){let e,t,l=a[15].autogeneratePattern&&yt();return{c(){e=_(`Plain text value.
|
|
`),l&&l.c(),t=Lt()},m(u,c){r(u,e,c),l&&l.m(u,c),r(u,t,c)},p(u,c){u[15].autogeneratePattern?l||(l=yt(),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null)},d(u){u&&(d(e),d(t)),l&&l.d(u)}}}function yt(a){let e;return{c(){e=_("It is autogenerated if not set.")},m(t,l){r(t,e,l)},d(t){t&&d(e)}}}function vt(a,e){let t,l,u,c,f,b=e[15].name+"",m,$,h,g,A=ee.getFieldValueType(e[15])+"",T,O,R,M;function U(k,F){return!k[15].required||k[15].type=="text"&&k[15].autogeneratePattern?Nt:Dt}let J=U(e),S=J(e);function Q(k,F){if(k[15].type==="text")return Wt;if(k[15].type==="number")return Qt;if(k[15].type==="json")return Kt;if(k[15].type==="email")return It;if(k[15].type==="url")return Ut;if(k[15].type==="file")return Et;if(k[15].type==="relation")return Jt}let P=Q(e),q=P&&P(e);return{key:a,first:null,c(){t=s("tr"),l=s("td"),u=s("div"),S.c(),c=p(),f=s("span"),m=_(b),$=p(),h=s("td"),g=s("span"),T=_(A),O=p(),R=s("td"),q&&q.c(),M=p(),w(u,"class","inline-flex"),w(g,"class","label"),this.first=t},m(k,F){r(k,t,F),i(t,l),i(l,u),S.m(u,null),i(u,c),i(u,f),i(f,m),i(t,$),i(t,h),i(h,g),i(g,T),i(t,O),i(t,R),q&&q.m(R,null),i(t,M)},p(k,F){e=k,J!==(J=U(e))&&(S.d(1),S=J(e),S&&(S.c(),S.m(u,c))),F&64&&b!==(b=e[15].name+"")&&oe(m,b),F&64&&A!==(A=ee.getFieldValueType(e[15])+"")&&oe(T,A),P===(P=Q(e))&&q?q.p(e,F):(q&&q.d(1),q=P&&P(e),q&&(q.c(),q.m(R,null)))},d(k){k&&d(t),S.d(),q&&q.d()}}}function wt(a,e){let t,l=e[10].code+"",u,c,f,b;function m(){return e[9](e[10])}return{key:a,first:null,c(){t=s("button"),u=_(l),c=p(),w(t,"class","tab-item"),Te(t,"active",e[2]===e[10].code),this.first=t},m($,h){r($,t,h),i(t,u),i(t,c),f||(b=Ht(t,"click",m),f=!0)},p($,h){e=$,h&8&&l!==(l=e[10].code+"")&&oe(u,l),h&12&&Te(t,"active",e[2]===e[10].code)},d($){$&&d(t),f=!1,b()}}}function gt(a,e){let t,l,u,c;return l=new Ct({props:{content:e[10].body}}),{key:a,first:null,c(){t=s("div"),$e(l.$$.fragment),u=p(),w(t,"class","tab-item"),Te(t,"active",e[2]===e[10].code),this.first=t},m(f,b){r(f,t,b),qe(l,t,null),i(t,u),c=!0},p(f,b){e=f;const m={};b&8&&(m.content=e[10].body),l.$set(m),(!c||b&12)&&Te(t,"active",e[2]===e[10].code)},i(f){c||(ye(l.$$.fragment,f),c=!0)},o(f){ve(l.$$.fragment,f),c=!1},d(f){f&&d(t),Se(l)}}}function Yt(a){var at,st,ot,rt;let e,t,l=a[0].name+"",u,c,f,b,m,$,h,g=a[0].name+"",A,T,O,R,M,U,J,S,Q,P,q,k,F,te,Y,I,re,z,G=a[0].name+"",X,fe,le,E,Z,x,H,y,C,V,W,L=[],De=new Map,Oe,pe,Me,ne,Pe,Ne,me,ie,Fe,Je,He,Ee,j,Ue,de,Ie,Ke,Qe,Le,We,Re,Ye,ze,Ge,je,Xe,Ze,ce,Ae,be,Be,ae,_e,K=[],xe=new Map,et,ke,D=[],tt=new Map,se;S=new Tt({props:{js:`
|
|
import PocketBase from 'pocketbase';
|
|
|
|
const pb = new PocketBase('${a[5]}');
|
|
|
|
...
|
|
|
|
// example create data
|
|
const data = ${JSON.stringify(Object.assign({},a[4],ee.dummyCollectionSchemaData(a[0],!0)),null,4)};
|
|
|
|
const record = await pb.collection('${(at=a[0])==null?void 0:at.name}').create(data);
|
|
`+(a[1]?`
|
|
// (optional) send an email verification request
|
|
await pb.collection('${(st=a[0])==null?void 0:st.name}').requestVerification('test@example.com');
|
|
`:""),dart:`
|
|
import 'package:pocketbase/pocketbase.dart';
|
|
|
|
final pb = PocketBase('${a[5]}');
|
|
|
|
...
|
|
|
|
// example create body
|
|
final body = <String, dynamic>${JSON.stringify(Object.assign({},a[4],ee.dummyCollectionSchemaData(a[0],!0)),null,2)};
|
|
|
|
final record = await pb.collection('${(ot=a[0])==null?void 0:ot.name}').create(body: body);
|
|
`+(a[1]?`
|
|
// (optional) send an email verification request
|
|
await pb.collection('${(rt=a[0])==null?void 0:rt.name}').requestVerification('test@example.com');
|
|
`:"")}});let N=a[7]&&kt(),B=a[1]&&ht(a),ge=ue(a[6]);const lt=n=>n[15].name;for(let n=0;n<ge.length;n+=1){let o=_t(a,ge,n),v=lt(o);De.set(v,L[n]=vt(v,o))}de=new Ct({props:{content:"?expand=relField1,relField2.subRelField"}}),ce=new Rt({});let Ce=ue(a[3]);const nt=n=>n[10].code;for(let n=0;n<Ce.length;n+=1){let o=bt(a,Ce,n),v=nt(o);xe.set(v,K[n]=wt(v,o))}let he=ue(a[3]);const it=n=>n[10].code;for(let n=0;n<he.length;n+=1){let o=mt(a,he,n),v=it(o);tt.set(v,D[n]=gt(v,o))}return{c(){e=s("h3"),t=_("Create ("),u=_(l),c=_(")"),f=p(),b=s("div"),m=s("p"),$=_("Create a new "),h=s("strong"),A=_(g),T=_(" record."),O=p(),R=s("p"),R.innerHTML=`Body parameters could be sent as <code>application/json</code> or
|
|
<code>multipart/form-data</code>.`,M=p(),U=s("p"),U.innerHTML=`File upload is supported only via <code>multipart/form-data</code>.
|
|
<br/>
|
|
For more info and examples you could check the detailed
|
|
<a href="https://pocketbase.io/docs/files-handling/" target="_blank" rel="noopener noreferrer">Files upload and handling docs
|
|
</a>.`,J=p(),$e(S.$$.fragment),Q=p(),P=s("h6"),P.textContent="API details",q=p(),k=s("div"),F=s("strong"),F.textContent="POST",te=p(),Y=s("div"),I=s("p"),re=_("/api/collections/"),z=s("strong"),X=_(G),fe=_("/records"),le=p(),N&&N.c(),E=p(),Z=s("div"),Z.textContent="Body Parameters",x=p(),H=s("table"),y=s("thead"),y.innerHTML='<tr><th>Param</th> <th>Type</th> <th width="50%">Description</th></tr>',C=p(),V=s("tbody"),B&&B.c(),W=p();for(let n=0;n<L.length;n+=1)L[n].c();Oe=p(),pe=s("div"),pe.textContent="Query parameters",Me=p(),ne=s("table"),Pe=s("thead"),Pe.innerHTML='<tr><th>Param</th> <th>Type</th> <th width="60%">Description</th></tr>',Ne=p(),me=s("tbody"),ie=s("tr"),Fe=s("td"),Fe.textContent="expand",Je=p(),He=s("td"),He.innerHTML='<span class="label">String</span>',Ee=p(),j=s("td"),Ue=_(`Auto expand relations when returning the created record. Ex.:
|
|
`),$e(de.$$.fragment),Ie=_(`
|
|
Supports up to 6-levels depth nested relations expansion. `),Ke=s("br"),Qe=_(`
|
|
The expanded relations will be appended to the record under the
|
|
`),Le=s("code"),Le.textContent="expand",We=_(" property (eg. "),Re=s("code"),Re.textContent='"expand": {"relField1": {...}, ...}',Ye=_(`).
|
|
`),ze=s("br"),Ge=_(`
|
|
Only the relations to which the request user has permissions to `),je=s("strong"),je.textContent="view",Xe=_(" will be expanded."),Ze=p(),$e(ce.$$.fragment),Ae=p(),be=s("div"),be.textContent="Responses",Be=p(),ae=s("div"),_e=s("div");for(let n=0;n<K.length;n+=1)K[n].c();et=p(),ke=s("div");for(let n=0;n<D.length;n+=1)D[n].c();w(e,"class","m-b-sm"),w(b,"class","content txt-lg m-b-sm"),w(P,"class","m-b-xs"),w(F,"class","label label-primary"),w(Y,"class","content"),w(k,"class","alert alert-success"),w(Z,"class","section-title"),w(H,"class","table-compact table-border m-b-base"),w(pe,"class","section-title"),w(ne,"class","table-compact table-border m-b-base"),w(be,"class","section-title"),w(_e,"class","tabs-header compact combined left"),w(ke,"class","tabs-content"),w(ae,"class","tabs")},m(n,o){r(n,e,o),i(e,t),i(e,u),i(e,c),r(n,f,o),r(n,b,o),i(b,m),i(m,$),i(m,h),i(h,A),i(m,T),i(b,O),i(b,R),i(b,M),i(b,U),r(n,J,o),qe(S,n,o),r(n,Q,o),r(n,P,o),r(n,q,o),r(n,k,o),i(k,F),i(k,te),i(k,Y),i(Y,I),i(I,re),i(I,z),i(z,X),i(I,fe),i(k,le),N&&N.m(k,null),r(n,E,o),r(n,Z,o),r(n,x,o),r(n,H,o),i(H,y),i(H,C),i(H,V),B&&B.m(V,null),i(V,W);for(let v=0;v<L.length;v+=1)L[v]&&L[v].m(V,null);r(n,Oe,o),r(n,pe,o),r(n,Me,o),r(n,ne,o),i(ne,Pe),i(ne,Ne),i(ne,me),i(me,ie),i(ie,Fe),i(ie,Je),i(ie,He),i(ie,Ee),i(ie,j),i(j,Ue),qe(de,j,null),i(j,Ie),i(j,Ke),i(j,Qe),i(j,Le),i(j,We),i(j,Re),i(j,Ye),i(j,ze),i(j,Ge),i(j,je),i(j,Xe),i(me,Ze),qe(ce,me,null),r(n,Ae,o),r(n,be,o),r(n,Be,o),r(n,ae,o),i(ae,_e);for(let v=0;v<K.length;v+=1)K[v]&&K[v].m(_e,null);i(ae,et),i(ae,ke);for(let v=0;v<D.length;v+=1)D[v]&&D[v].m(ke,null);se=!0},p(n,[o]){var dt,ct,ut,ft;(!se||o&1)&&l!==(l=n[0].name+"")&&oe(u,l),(!se||o&1)&&g!==(g=n[0].name+"")&&oe(A,g);const v={};o&51&&(v.js=`
|
|
import PocketBase from 'pocketbase';
|
|
|
|
const pb = new PocketBase('${n[5]}');
|
|
|
|
...
|
|
|
|
// example create data
|
|
const data = ${JSON.stringify(Object.assign({},n[4],ee.dummyCollectionSchemaData(n[0],!0)),null,4)};
|
|
|
|
const record = await pb.collection('${(dt=n[0])==null?void 0:dt.name}').create(data);
|
|
`+(n[1]?`
|
|
// (optional) send an email verification request
|
|
await pb.collection('${(ct=n[0])==null?void 0:ct.name}').requestVerification('test@example.com');
|
|
`:"")),o&51&&(v.dart=`
|
|
import 'package:pocketbase/pocketbase.dart';
|
|
|
|
final pb = PocketBase('${n[5]}');
|
|
|
|
...
|
|
|
|
// example create body
|
|
final body = <String, dynamic>${JSON.stringify(Object.assign({},n[4],ee.dummyCollectionSchemaData(n[0],!0)),null,2)};
|
|
|
|
final record = await pb.collection('${(ut=n[0])==null?void 0:ut.name}').create(body: body);
|
|
`+(n[1]?`
|
|
// (optional) send an email verification request
|
|
await pb.collection('${(ft=n[0])==null?void 0:ft.name}').requestVerification('test@example.com');
|
|
`:"")),S.$set(v),(!se||o&1)&&G!==(G=n[0].name+"")&&oe(X,G),n[7]?N||(N=kt(),N.c(),N.m(k,null)):N&&(N.d(1),N=null),n[1]?B?B.p(n,o):(B=ht(n),B.c(),B.m(V,W)):B&&(B.d(1),B=null),o&64&&(ge=ue(n[6]),L=Ve(L,o,lt,1,n,ge,De,V,pt,vt,null,_t)),o&12&&(Ce=ue(n[3]),K=Ve(K,o,nt,1,n,Ce,xe,_e,pt,wt,null,bt)),o&12&&(he=ue(n[3]),Ot(),D=Ve(D,o,it,1,n,he,tt,ke,Mt,gt,null,mt),Pt())},i(n){if(!se){ye(S.$$.fragment,n),ye(de.$$.fragment,n),ye(ce.$$.fragment,n);for(let o=0;o<he.length;o+=1)ye(D[o]);se=!0}},o(n){ve(S.$$.fragment,n),ve(de.$$.fragment,n),ve(ce.$$.fragment,n);for(let o=0;o<D.length;o+=1)ve(D[o]);se=!1},d(n){n&&(d(e),d(f),d(b),d(J),d(Q),d(P),d(q),d(k),d(E),d(Z),d(x),d(H),d(Oe),d(pe),d(Me),d(ne),d(Ae),d(be),d(Be),d(ae)),Se(S,n),N&&N.d(),B&&B.d();for(let o=0;o<L.length;o+=1)L[o].d();Se(de),Se(ce);for(let o=0;o<K.length;o+=1)K[o].d();for(let o=0;o<D.length;o+=1)D[o].d()}}}const zt=a=>a.name=="emailVisibility",Gt=a=>a.name=="email";function Xt(a,e,t){let l,u,c,f,b,{collection:m}=e,$=200,h=[],g={};const A=T=>t(2,$=T.code);return a.$$set=T=>{"collection"in T&&t(0,m=T.collection)},a.$$.update=()=>{var T,O,R;a.$$.dirty&1&&t(1,l=m.type==="auth"),a.$$.dirty&1&&t(7,u=(m==null?void 0:m.createRule)===null),a.$$.dirty&2&&t(8,c=l?["password","verified","email","emailVisibility"]:[]),a.$$.dirty&257&&t(6,f=((T=m==null?void 0:m.fields)==null?void 0:T.filter(M=>!M.hidden&&M.type!="autodate"&&!c.includes(M.name)))||[]),a.$$.dirty&1&&t(3,h=[{code:200,body:JSON.stringify(ee.dummyCollectionRecord(m),null,2)},{code:400,body:`
|
|
{
|
|
"code": 400,
|
|
"message": "Failed to create record.",
|
|
"data": {
|
|
"${(R=(O=m==null?void 0:m.fields)==null?void 0:O[0])==null?void 0:R.name}": {
|
|
"code": "validation_required",
|
|
"message": "Missing required value."
|
|
}
|
|
}
|
|
}
|
|
`},{code:403,body:`
|
|
{
|
|
"code": 403,
|
|
"message": "You are not allowed to perform this request.",
|
|
"data": {}
|
|
}
|
|
`}]),a.$$.dirty&2&&(l?t(4,g={password:"12345678",passwordConfirm:"12345678"}):t(4,g={}))},t(5,b=ee.getApiExampleUrl(Ft.baseURL)),[m,l,$,h,g,b,f,u,c,A]}class el extends $t{constructor(e){super(),qt(this,e,Xt,Yt,St,{collection:0})}}export{el as default};
|