initial v0.8 pre-release

This commit is contained in:
Gani Georgiev
2022-10-30 10:28:14 +02:00
parent 9cbb2e750e
commit 90dba45d7c
388 changed files with 21580 additions and 13603 deletions
+9 -6
View File
@@ -1,7 +1,10 @@
# all environments should start with 'PB_' prefix
PB_BACKEND_URL = "../"
PB_PROFILE_COLLECTION = "profiles"
PB_INSTALLER_PARAM = "installer"
PB_RULES_SYNTAX_DOCS = "https://pocketbase.io/docs/manage-collections#rules-filters-syntax"
PB_RELEASES = "https://github.com/pocketbase/pocketbase/releases"
PB_VERSION = "v0.7.9"
PB_BACKEND_URL = "../"
PB_INSTALLER_PARAM = "installer"
PB_OAUTH2_EXAMPLE = "https://pocketbase.io/docs/manage-users/#auth-via-oauth2"
PB_RULES_SYNTAX_DOCS = "https://pocketbase.io/docs/manage-collections#rules-filters-syntax"
PB_FILE_UPLOAD_DOCS = "https://pocketbase.io/docs/files-handling/#uploading-files"
PB_JS_SDK_URL = "https://github.com/pocketbase/js-sdk/tree/rc"
PB_DART_SDK_URL = "https://github.com/pocketbase/dart-sdk/tree/rc"
PB_RELEASES = "https://github.com/pocketbase/pocketbase/releases"
PB_VERSION = "v0.8.0-rc1"
+64
View File
@@ -0,0 +1,64 @@
import{S as ke,i as be,s as ge,e as r,w as b,b as g,c as _e,f as k,g as h,h as n,m as me,x as G,P as re,Q as we,k as ve,R as Ce,n as Pe,t as J,a as Y,o as _,d as pe,L as Me,C as Se,p as $e,r as H,u as je,O as Ae}from"./index.97f016a1.js";import{S as Be}from"./SdkTabs.88269ae0.js";function ue(a,l,o){const s=a.slice();return s[5]=l[o],s}function de(a,l,o){const s=a.slice();return s[5]=l[o],s}function fe(a,l){let o,s=l[5].code+"",m,f,i,u;function d(){return l[4](l[5])}return{key:a,first:null,c(){o=r("button"),m=b(s),f=g(),k(o,"class","tab-item"),H(o,"active",l[1]===l[5].code),this.first=o},m(v,C){h(v,o,C),n(o,m),n(o,f),i||(u=je(o,"click",d),i=!0)},p(v,C){l=v,C&4&&s!==(s=l[5].code+"")&&G(m,s),C&6&&H(o,"active",l[1]===l[5].code)},d(v){v&&_(o),i=!1,u()}}}function he(a,l){let o,s,m,f;return s=new Ae({props:{content:l[5].body}}),{key:a,first:null,c(){o=r("div"),_e(s.$$.fragment),m=g(),k(o,"class","tab-item"),H(o,"active",l[1]===l[5].code),this.first=o},m(i,u){h(i,o,u),me(s,o,null),n(o,m),f=!0},p(i,u){l=i;const d={};u&4&&(d.content=l[5].body),s.$set(d),(!f||u&6)&&H(o,"active",l[1]===l[5].code)},i(i){f||(J(s.$$.fragment,i),f=!0)},o(i){Y(s.$$.fragment,i),f=!1},d(i){i&&_(o),pe(s)}}}function Oe(a){var ae,ne;let l,o,s=a[0].name+"",m,f,i,u,d,v,C,K=a[0].name+"",U,R,q,P,D,j,W,M,N,X,Q,A,Z,V,y=a[0].name+"",I,x,L,B,E,S,O,w=[],ee=new Map,te,T,p=[],le=new Map,$;P=new Be({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${a[3]}');
...
const result = await pb.collection('${(ae=a[0])==null?void 0:ae.name}').listAuthMethods();
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${a[3]}');
...
final result = await pb.collection('${(ne=a[0])==null?void 0:ne.name}').listAuthMethods();
`}});let z=a[2];const oe=e=>e[5].code;for(let e=0;e<z.length;e+=1){let t=de(a,z,e),c=oe(t);ee.set(c,w[e]=fe(c,t))}let F=a[2];const se=e=>e[5].code;for(let e=0;e<F.length;e+=1){let t=ue(a,F,e),c=se(t);le.set(c,p[e]=he(c,t))}return{c(){l=r("h3"),o=b("List auth methods ("),m=b(s),f=b(")"),i=g(),u=r("div"),d=r("p"),v=b("Returns a public list with all allowed "),C=r("strong"),U=b(K),R=b(" authentication methods."),q=g(),_e(P.$$.fragment),D=g(),j=r("h6"),j.textContent="API details",W=g(),M=r("div"),N=r("strong"),N.textContent="GET",X=g(),Q=r("div"),A=r("p"),Z=b("/api/collections/"),V=r("strong"),I=b(y),x=b("/auth-methods"),L=g(),B=r("div"),B.textContent="Responses",E=g(),S=r("div"),O=r("div");for(let e=0;e<w.length;e+=1)w[e].c();te=g(),T=r("div");for(let e=0;e<p.length;e+=1)p[e].c();k(l,"class","m-b-sm"),k(u,"class","content txt-lg m-b-sm"),k(j,"class","m-b-xs"),k(N,"class","label label-primary"),k(Q,"class","content"),k(M,"class","alert alert-info"),k(B,"class","section-title"),k(O,"class","tabs-header compact left"),k(T,"class","tabs-content"),k(S,"class","tabs")},m(e,t){h(e,l,t),n(l,o),n(l,m),n(l,f),h(e,i,t),h(e,u,t),n(u,d),n(d,v),n(d,C),n(C,U),n(d,R),h(e,q,t),me(P,e,t),h(e,D,t),h(e,j,t),h(e,W,t),h(e,M,t),n(M,N),n(M,X),n(M,Q),n(Q,A),n(A,Z),n(A,V),n(V,I),n(A,x),h(e,L,t),h(e,B,t),h(e,E,t),h(e,S,t),n(S,O);for(let c=0;c<w.length;c+=1)w[c].m(O,null);n(S,te),n(S,T);for(let c=0;c<p.length;c+=1)p[c].m(T,null);$=!0},p(e,[t]){var ie,ce;(!$||t&1)&&s!==(s=e[0].name+"")&&G(m,s),(!$||t&1)&&K!==(K=e[0].name+"")&&G(U,K);const c={};t&9&&(c.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const result = await pb.collection('${(ie=e[0])==null?void 0:ie.name}').listAuthMethods();
`),t&9&&(c.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final result = await pb.collection('${(ce=e[0])==null?void 0:ce.name}').listAuthMethods();
`),P.$set(c),(!$||t&1)&&y!==(y=e[0].name+"")&&G(I,y),t&6&&(z=e[2],w=re(w,t,oe,1,e,z,ee,O,we,fe,null,de)),t&6&&(F=e[2],ve(),p=re(p,t,se,1,e,F,le,T,Ce,he,null,ue),Pe())},i(e){if(!$){J(P.$$.fragment,e);for(let t=0;t<F.length;t+=1)J(p[t]);$=!0}},o(e){Y(P.$$.fragment,e);for(let t=0;t<p.length;t+=1)Y(p[t]);$=!1},d(e){e&&_(l),e&&_(i),e&&_(u),e&&_(q),pe(P,e),e&&_(D),e&&_(j),e&&_(W),e&&_(M),e&&_(L),e&&_(B),e&&_(E),e&&_(S);for(let t=0;t<w.length;t+=1)w[t].d();for(let t=0;t<p.length;t+=1)p[t].d()}}}function Te(a,l,o){let s,{collection:m=new Me}=l,f=200,i=[];const u=d=>o(1,f=d.code);return a.$$set=d=>{"collection"in d&&o(0,m=d.collection)},o(3,s=Se.getApiExampleUrl($e.baseUrl)),o(2,i=[{code:200,body:`
{
"usernamePassword": true,
"emailPassword": true,
"authProviders": [
{
"name": "github",
"state": "3Yd8jNkK_6PJG6hPWwBjLqKwse6Ejd",
"codeVerifier": "KxFDWz1B3fxscCDJ_9gHQhLuh__ie7",
"codeChallenge": "NM1oVexB6Q6QH8uPtOUfK7tq4pmu4Jz6lNDIwoxHZNE=",
"codeChallengeMethod": "S256",
"authUrl": "https://github.com/login/oauth/authorize?client_id=demo&code_challenge=NM1oVexB6Q6QH8uPtOUfK7tq4pmu4Jz6lNDIwoxHZNE%3D&code_challenge_method=S256&response_type=code&scope=user&state=3Yd8jNkK_6PJG6hPWwBjLqKwse6Ejd&redirect_uri="
},
{
"name": "gitlab",
"state": "NeQSbtO5cShr_mk5__3CUukiMnymeb",
"codeVerifier": "ahTFHOgua8mkvPAlIBGwCUJbWKR_xi",
"codeChallenge": "O-GATkTj4eXDCnfonsqGLCd6njvTixlpCMvy5kjgOOg=",
"codeChallengeMethod": "S256",
"authUrl": "https://gitlab.com/oauth/authorize?client_id=demo&code_challenge=O-GATkTj4eXDCnfonsqGLCd6njvTixlpCMvy5kjgOOg%3D&code_challenge_method=S256&response_type=code&scope=read_user&state=NeQSbtO5cShr_mk5__3CUukiMnymeb&redirect_uri="
},
{
"name": "google",
"state": "zB3ZPifV1TW2GMuvuFkamSXfSNkHPQ",
"codeVerifier": "t3CmO5VObGzdXqieakvR_fpjiW0zdO",
"codeChallenge": "KChwoQPKYlz2anAdqtgsSTdIo8hdwtc1fh2wHMwW2Yk=",
"codeChallengeMethod": "S256",
"authUrl": "https://accounts.google.com/o/oauth2/auth?client_id=demo&code_challenge=KChwoQPKYlz2anAdqtgsSTdIo8hdwtc1fh2wHMwW2Yk%3D&code_challenge_method=S256&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&state=zB3ZPifV1TW2GMuvuFkamSXfSNkHPQ&redirect_uri="
}
]
}
`}]),[m,f,i,s,u]}class Ne extends ke{constructor(l){super(),be(this,l,Te,Oe,ge,{collection:0})}}export{Ne as default};
+87
View File
@@ -0,0 +1,87 @@
import{S as Ne,i as Ue,s as je,O as ze,e as s,w as k,b as p,c as se,f as b,g as c,h as o,m as ne,x as re,P as Oe,Q as Ie,k as Je,R as Ke,n as Qe,t as U,a as j,o as d,d as ie,L as xe,C as Fe,p as We,r as I,u as Ge}from"./index.97f016a1.js";import{S as Xe}from"./SdkTabs.88269ae0.js";function He(r,l,a){const n=r.slice();return n[5]=l[a],n}function Le(r,l,a){const n=r.slice();return n[5]=l[a],n}function Ee(r,l){let a,n=l[5].code+"",m,_,i,f;function v(){return l[4](l[5])}return{key:r,first:null,c(){a=s("button"),m=k(n),_=p(),b(a,"class","tab-item"),I(a,"active",l[1]===l[5].code),this.first=a},m(g,w){c(g,a,w),o(a,m),o(a,_),i||(f=Ge(a,"click",v),i=!0)},p(g,w){l=g,w&4&&n!==(n=l[5].code+"")&&re(m,n),w&6&&I(a,"active",l[1]===l[5].code)},d(g){g&&d(a),i=!1,f()}}}function Ve(r,l){let a,n,m,_;return n=new ze({props:{content:l[5].body}}),{key:r,first:null,c(){a=s("div"),se(n.$$.fragment),m=p(),b(a,"class","tab-item"),I(a,"active",l[1]===l[5].code),this.first=a},m(i,f){c(i,a,f),ne(n,a,null),o(a,m),_=!0},p(i,f){l=i;const v={};f&4&&(v.content=l[5].body),n.$set(v),(!_||f&6)&&I(a,"active",l[1]===l[5].code)},i(i){_||(U(n.$$.fragment,i),_=!0)},o(i){j(n.$$.fragment,i),_=!1},d(i){i&&d(a),ie(n)}}}function Ye(r){var Be,Me;let l,a,n=r[0].name+"",m,_,i,f,v,g,w,B,J,S,L,ce,E,M,de,K,V=r[0].name+"",Q,ue,pe,z,x,q,W,T,G,fe,X,C,Y,he,Z,be,h,me,P,_e,ke,ve,ee,ge,te,ye,Se,$e,oe,we,le,D,ae,R,O,$=[],Te=new Map,Ce,F,y=[],Re=new Map,A;g=new Xe({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${r[3]}');
...
const authData = await pb.collection('${(Be=r[0])==null?void 0:Be.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${r[3]}');
...
final authData = await pb.collection('${(Me=r[0])==null?void 0:Me.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
`}}),P=new ze({props:{content:"?expand=relField1,relField2.subRelField"}});let N=r[2];const Pe=e=>e[5].code;for(let e=0;e<N.length;e+=1){let t=Le(r,N,e),u=Pe(t);Te.set(u,$[e]=Ee(u,t))}let H=r[2];const Ae=e=>e[5].code;for(let e=0;e<H.length;e+=1){let t=He(r,H,e),u=Ae(t);Re.set(u,y[e]=Ve(u,t))}return{c(){l=s("h3"),a=k("Auth refresh ("),m=k(n),_=k(")"),i=p(),f=s("div"),f.innerHTML=`<p>Returns a new auth response (token and account data) for an
<strong>already authenticated record</strong>.</p>
<p><em>This method is usually called by users on page/screen reload to ensure that the previously stored
data in <code>pb.authStore</code> is still valid and up-to-date.</em></p>`,v=p(),se(g.$$.fragment),w=p(),B=s("h6"),B.textContent="API details",J=p(),S=s("div"),L=s("strong"),L.textContent="POST",ce=p(),E=s("div"),M=s("p"),de=k("/api/collections/"),K=s("strong"),Q=k(V),ue=k("/auth-refresh"),pe=p(),z=s("p"),z.innerHTML="Requires record <code>Authorization:TOKEN</code> header",x=p(),q=s("div"),q.textContent="Query parameters",W=p(),T=s("table"),G=s("thead"),G.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,fe=p(),X=s("tbody"),C=s("tr"),Y=s("td"),Y.textContent="expand",he=p(),Z=s("td"),Z.innerHTML='<span class="label">String</span>',be=p(),h=s("td"),me=k(`Auto expand record relations. Ex.:
`),se(P.$$.fragment),_e=k(`
Supports up to 6-levels depth nested relations expansion. `),ke=s("br"),ve=k(`
The expanded relations will be appended to the record under the
`),ee=s("code"),ee.textContent="expand",ge=k(" property (eg. "),te=s("code"),te.textContent='"expand": {"relField1": {...}, ...}',ye=k(`).
`),Se=s("br"),$e=k(`
Only the relations to which the account has permissions to `),oe=s("strong"),oe.textContent="view",we=k(" will be expanded."),le=p(),D=s("div"),D.textContent="Responses",ae=p(),R=s("div"),O=s("div");for(let e=0;e<$.length;e+=1)$[e].c();Ce=p(),F=s("div");for(let e=0;e<y.length;e+=1)y[e].c();b(l,"class","m-b-sm"),b(f,"class","content txt-lg m-b-sm"),b(B,"class","m-b-xs"),b(L,"class","label label-primary"),b(E,"class","content"),b(z,"class","txt-hint txt-sm txt-right"),b(S,"class","alert alert-success"),b(q,"class","section-title"),b(T,"class","table-compact table-border m-b-base"),b(D,"class","section-title"),b(O,"class","tabs-header compact left"),b(F,"class","tabs-content"),b(R,"class","tabs")},m(e,t){c(e,l,t),o(l,a),o(l,m),o(l,_),c(e,i,t),c(e,f,t),c(e,v,t),ne(g,e,t),c(e,w,t),c(e,B,t),c(e,J,t),c(e,S,t),o(S,L),o(S,ce),o(S,E),o(E,M),o(M,de),o(M,K),o(K,Q),o(M,ue),o(S,pe),o(S,z),c(e,x,t),c(e,q,t),c(e,W,t),c(e,T,t),o(T,G),o(T,fe),o(T,X),o(X,C),o(C,Y),o(C,he),o(C,Z),o(C,be),o(C,h),o(h,me),ne(P,h,null),o(h,_e),o(h,ke),o(h,ve),o(h,ee),o(h,ge),o(h,te),o(h,ye),o(h,Se),o(h,$e),o(h,oe),o(h,we),c(e,le,t),c(e,D,t),c(e,ae,t),c(e,R,t),o(R,O);for(let u=0;u<$.length;u+=1)$[u].m(O,null);o(R,Ce),o(R,F);for(let u=0;u<y.length;u+=1)y[u].m(F,null);A=!0},p(e,[t]){var qe,De;(!A||t&1)&&n!==(n=e[0].name+"")&&re(m,n);const u={};t&9&&(u.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const authData = await pb.collection('${(qe=e[0])==null?void 0:qe.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),t&9&&(u.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final authData = await pb.collection('${(De=e[0])==null?void 0:De.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
`),g.$set(u),(!A||t&1)&&V!==(V=e[0].name+"")&&re(Q,V),t&6&&(N=e[2],$=Oe($,t,Pe,1,e,N,Te,O,Ie,Ee,null,Le)),t&6&&(H=e[2],Je(),y=Oe(y,t,Ae,1,e,H,Re,F,Ke,Ve,null,He),Qe())},i(e){if(!A){U(g.$$.fragment,e),U(P.$$.fragment,e);for(let t=0;t<H.length;t+=1)U(y[t]);A=!0}},o(e){j(g.$$.fragment,e),j(P.$$.fragment,e);for(let t=0;t<y.length;t+=1)j(y[t]);A=!1},d(e){e&&d(l),e&&d(i),e&&d(f),e&&d(v),ie(g,e),e&&d(w),e&&d(B),e&&d(J),e&&d(S),e&&d(x),e&&d(q),e&&d(W),e&&d(T),ie(P),e&&d(le),e&&d(D),e&&d(ae),e&&d(R);for(let t=0;t<$.length;t+=1)$[t].d();for(let t=0;t<y.length;t+=1)y[t].d()}}}function Ze(r,l,a){let n,{collection:m=new xe}=l,_=200,i=[];const f=v=>a(1,_=v.code);return r.$$set=v=>{"collection"in v&&a(0,m=v.collection)},r.$$.update=()=>{r.$$.dirty&1&&a(2,i=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:Fe.dummyCollectionRecord(m)},null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"identity": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`},{code:401,body:`
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`},{code:403,body:`
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`}])},a(3,n=Fe.getApiExampleUrl(We.baseUrl)),[m,_,i,n,f]}class ot extends Ne{constructor(l){super(),Ue(this,l,Ze,Ye,je,{collection:0})}}export{ot as default};
+151
View File
@@ -0,0 +1,151 @@
import{S as je,i as He,s as Je,O as We,e as s,w as v,b as p,c as re,f as h,g as r,h as a,m as ce,x as de,P as Ue,Q as Ne,k as Qe,R as ze,n as Ke,t as j,a as H,o as c,d as ue,L as Ye,C as Ve,p as Ge,r as J,u as Xe}from"./index.97f016a1.js";import{S as Ze}from"./SdkTabs.88269ae0.js";function Be(i,l,o){const n=i.slice();return n[5]=l[o],n}function Fe(i,l,o){const n=i.slice();return n[5]=l[o],n}function xe(i,l){let o,n=l[5].code+"",m,_,d,b;function g(){return l[4](l[5])}return{key:i,first:null,c(){o=s("button"),m=v(n),_=p(),h(o,"class","tab-item"),J(o,"active",l[1]===l[5].code),this.first=o},m(k,R){r(k,o,R),a(o,m),a(o,_),d||(b=Xe(o,"click",g),d=!0)},p(k,R){l=k,R&4&&n!==(n=l[5].code+"")&&de(m,n),R&6&&J(o,"active",l[1]===l[5].code)},d(k){k&&c(o),d=!1,b()}}}function Me(i,l){let o,n,m,_;return n=new We({props:{content:l[5].body}}),{key:i,first:null,c(){o=s("div"),re(n.$$.fragment),m=p(),h(o,"class","tab-item"),J(o,"active",l[1]===l[5].code),this.first=o},m(d,b){r(d,o,b),ce(n,o,null),a(o,m),_=!0},p(d,b){l=d;const g={};b&4&&(g.content=l[5].body),n.$set(g),(!_||b&6)&&J(o,"active",l[1]===l[5].code)},i(d){_||(j(n.$$.fragment,d),_=!0)},o(d){H(n.$$.fragment,d),_=!1},d(d){d&&c(o),ue(n)}}}function et(i){var Ie,qe;let l,o,n=i[0].name+"",m,_,d,b,g,k,R,C,N,y,F,pe,x,D,he,Q,M=i[0].name+"",z,be,K,I,Y,q,G,P,X,O,Z,fe,ee,$,te,me,ae,_e,f,ve,E,ge,ke,we,le,Se,oe,Re,ye,Oe,se,$e,ne,L,ie,A,U,S=[],Ae=new Map,Ee,V,w=[],Te=new Map,T;k=new Ze({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${i[3]}');
...
const authData = await pb.collection('${(Ie=i[0])==null?void 0:Ie.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
{
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${i[3]}');
...
final authData = await pb.collection('${(qe=i[0])==null?void 0:qe.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
createData: {
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}}),E=new We({props:{content:"?expand=relField1,relField2.subRelField"}});let W=i[2];const Ce=e=>e[5].code;for(let e=0;e<W.length;e+=1){let t=Fe(i,W,e),u=Ce(t);Ae.set(u,S[e]=xe(u,t))}let B=i[2];const De=e=>e[5].code;for(let e=0;e<B.length;e+=1){let t=Be(i,B,e),u=De(t);Te.set(u,w[e]=Me(u,t))}return{c(){l=s("h3"),o=v("Auth with OAuth2 ("),m=v(n),_=v(")"),d=p(),b=s("div"),b.innerHTML=`<p>Authenticate with an OAuth2 provider and returns a new auth token and account data.</p>
<p>This action usually should be called right after the provider login page redirect.</p>
<p>You could also check the
<a href="https://pocketbase.io/docs/manage-users/#auth-via-oauth2" target="_blank" rel="noopener noreferrer">OAuth2 web integration example
</a>.</p>`,g=p(),re(k.$$.fragment),R=p(),C=s("h6"),C.textContent="API details",N=p(),y=s("div"),F=s("strong"),F.textContent="POST",pe=p(),x=s("div"),D=s("p"),he=v("/api/collections/"),Q=s("strong"),z=v(M),be=v("/auth-with-oauth2"),K=p(),I=s("div"),I.textContent="Body Parameters",Y=p(),q=s("table"),q.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>provider</span></div></td>
<td><span class="label">String</span></td>
<td>The name of the OAuth2 client provider (eg. &quot;google&quot;).</td></tr>
<tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>code</span></div></td>
<td><span class="label">String</span></td>
<td>The authorization code returned from the initial request.</td></tr>
<tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>codeVerifier</span></div></td>
<td><span class="label">String</span></td>
<td>The code verifier sent with the initial request as part of the code_challenge.</td></tr>
<tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>redirectUrl</span></div></td>
<td><span class="label">String</span></td>
<td>The redirect url sent with the initial request.</td></tr>
<tr><td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>createData</span></div></td>
<td><span class="label">Object</span></td>
<td><p>Optional data that will be used when creating the auth record on OAuth2 sign-up.</p>
<p>The created auth record must comply with the same requirements and validations in the
regular <strong>create</strong> action.
<br/>
<em>The data can only be in <code>json</code>, aka. <code>multipart/form-data</code> and files
upload currently are not supported during OAuth2 sign-ups.</em></p></td></tr></tbody>`,G=p(),P=s("div"),P.textContent="Query parameters",X=p(),O=s("table"),Z=s("thead"),Z.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,fe=p(),ee=s("tbody"),$=s("tr"),te=s("td"),te.textContent="expand",me=p(),ae=s("td"),ae.innerHTML='<span class="label">String</span>',_e=p(),f=s("td"),ve=v(`Auto expand record relations. Ex.:
`),re(E.$$.fragment),ge=v(`
Supports up to 6-levels depth nested relations expansion. `),ke=s("br"),we=v(`
The expanded relations will be appended to the record under the
`),le=s("code"),le.textContent="expand",Se=v(" property (eg. "),oe=s("code"),oe.textContent='"expand": {"relField1": {...}, ...}',Re=v(`).
`),ye=s("br"),Oe=v(`
Only the relations to which the account has permissions to `),se=s("strong"),se.textContent="view",$e=v(" will be expanded."),ne=p(),L=s("div"),L.textContent="Responses",ie=p(),A=s("div"),U=s("div");for(let e=0;e<S.length;e+=1)S[e].c();Ee=p(),V=s("div");for(let e=0;e<w.length;e+=1)w[e].c();h(l,"class","m-b-sm"),h(b,"class","content txt-lg m-b-sm"),h(C,"class","m-b-xs"),h(F,"class","label label-primary"),h(x,"class","content"),h(y,"class","alert alert-success"),h(I,"class","section-title"),h(q,"class","table-compact table-border m-b-base"),h(P,"class","section-title"),h(O,"class","table-compact table-border m-b-base"),h(L,"class","section-title"),h(U,"class","tabs-header compact left"),h(V,"class","tabs-content"),h(A,"class","tabs")},m(e,t){r(e,l,t),a(l,o),a(l,m),a(l,_),r(e,d,t),r(e,b,t),r(e,g,t),ce(k,e,t),r(e,R,t),r(e,C,t),r(e,N,t),r(e,y,t),a(y,F),a(y,pe),a(y,x),a(x,D),a(D,he),a(D,Q),a(Q,z),a(D,be),r(e,K,t),r(e,I,t),r(e,Y,t),r(e,q,t),r(e,G,t),r(e,P,t),r(e,X,t),r(e,O,t),a(O,Z),a(O,fe),a(O,ee),a(ee,$),a($,te),a($,me),a($,ae),a($,_e),a($,f),a(f,ve),ce(E,f,null),a(f,ge),a(f,ke),a(f,we),a(f,le),a(f,Se),a(f,oe),a(f,Re),a(f,ye),a(f,Oe),a(f,se),a(f,$e),r(e,ne,t),r(e,L,t),r(e,ie,t),r(e,A,t),a(A,U);for(let u=0;u<S.length;u+=1)S[u].m(U,null);a(A,Ee),a(A,V);for(let u=0;u<w.length;u+=1)w[u].m(V,null);T=!0},p(e,[t]){var Pe,Le;(!T||t&1)&&n!==(n=e[0].name+"")&&de(m,n);const u={};t&9&&(u.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const authData = await pb.collection('${(Pe=e[0])==null?void 0:Pe.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
{
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`),t&9&&(u.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final authData = await pb.collection('${(Le=e[0])==null?void 0:Le.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
createData: {
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`),k.$set(u),(!T||t&1)&&M!==(M=e[0].name+"")&&de(z,M),t&6&&(W=e[2],S=Ue(S,t,Ce,1,e,W,Ae,U,Ne,xe,null,Fe)),t&6&&(B=e[2],Qe(),w=Ue(w,t,De,1,e,B,Te,V,ze,Me,null,Be),Ke())},i(e){if(!T){j(k.$$.fragment,e),j(E.$$.fragment,e);for(let t=0;t<B.length;t+=1)j(w[t]);T=!0}},o(e){H(k.$$.fragment,e),H(E.$$.fragment,e);for(let t=0;t<w.length;t+=1)H(w[t]);T=!1},d(e){e&&c(l),e&&c(d),e&&c(b),e&&c(g),ue(k,e),e&&c(R),e&&c(C),e&&c(N),e&&c(y),e&&c(K),e&&c(I),e&&c(Y),e&&c(q),e&&c(G),e&&c(P),e&&c(X),e&&c(O),ue(E),e&&c(ne),e&&c(L),e&&c(ie),e&&c(A);for(let t=0;t<S.length;t+=1)S[t].d();for(let t=0;t<w.length;t+=1)w[t].d()}}}function tt(i,l,o){let n,{collection:m=new Ye}=l,_=200,d=[];const b=g=>o(1,_=g.code);return i.$$set=g=>{"collection"in g&&o(0,m=g.collection)},i.$$.update=()=>{i.$$.dirty&1&&o(2,d=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:Ve.dummyCollectionRecord(m),meta:{id:"abc123",name:"John Doe",username:"john.doe",email:"test@example.com",avatarUrl:"https://example.com/avatar.png"}},null,2)},{code:400,body:`
{
"code": 400,
"message": "An error occurred while submitting the form.",
"data": {
"provider": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}])},o(3,n=Ve.getApiExampleUrl(Ge.baseUrl)),[m,_,d,n,b]}class ot extends je{constructor(l){super(),He(this,l,tt,et,Je,{collection:0})}}export{ot as default};
+106
View File
@@ -0,0 +1,106 @@
import{S as Se,i as ve,s as we,O as ke,e as s,w as f,b as u,c as Ot,f as h,g as r,h as o,m as At,x as Tt,P as ce,Q as ye,k as ge,R as Pe,n as Re,t as tt,a as et,o as c,d as Ut,L as $e,C as de,p as Ce,r as lt,u as Oe}from"./index.97f016a1.js";import{S as Ae}from"./SdkTabs.88269ae0.js";function ue(n,e,l){const i=n.slice();return i[8]=e[l],i}function fe(n,e,l){const i=n.slice();return i[8]=e[l],i}function Te(n){let e;return{c(){e=f("email")},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function Ue(n){let e;return{c(){e=f("username")},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function Me(n){let e;return{c(){e=f("username/email")},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function pe(n){let e;return{c(){e=s("strong"),e.textContent="username"},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function be(n){let e;return{c(){e=f("or")},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function me(n){let e;return{c(){e=s("strong"),e.textContent="email"},m(l,i){r(l,e,i)},d(l){l&&c(e)}}}function he(n,e){let l,i=e[8].code+"",S,m,p,d;function _(){return e[7](e[8])}return{key:n,first:null,c(){l=s("button"),S=f(i),m=u(),h(l,"class","tab-item"),lt(l,"active",e[3]===e[8].code),this.first=l},m($,C){r($,l,C),o(l,S),o(l,m),p||(d=Oe(l,"click",_),p=!0)},p($,C){e=$,C&16&&i!==(i=e[8].code+"")&&Tt(S,i),C&24&&lt(l,"active",e[3]===e[8].code)},d($){$&&c(l),p=!1,d()}}}function _e(n,e){let l,i,S,m;return i=new ke({props:{content:e[8].body}}),{key:n,first:null,c(){l=s("div"),Ot(i.$$.fragment),S=u(),h(l,"class","tab-item"),lt(l,"active",e[3]===e[8].code),this.first=l},m(p,d){r(p,l,d),At(i,l,null),o(l,S),m=!0},p(p,d){e=p;const _={};d&16&&(_.content=e[8].body),i.$set(_),(!m||d&24)&&lt(l,"active",e[3]===e[8].code)},i(p){m||(tt(i.$$.fragment,p),m=!0)},o(p){et(i.$$.fragment,p),m=!1},d(p){p&&c(l),Ut(i)}}}function De(n){var se,ne;let e,l,i=n[0].name+"",S,m,p,d,_,$,C,O,B,Mt,ot,T,at,F,st,U,G,Dt,X,I,Et,nt,Z=n[0].name+"",it,Lt,rt,N,ct,M,dt,Wt,V,D,ut,Bt,ft,Ht,g,Yt,pt,bt,mt,qt,ht,_t,j,kt,E,St,Ft,vt,L,wt,It,yt,Nt,k,Vt,H,jt,Jt,Qt,gt,Kt,Pt,zt,Gt,Xt,Rt,Zt,$t,J,Ct,W,Q,A=[],xt=new Map,te,K,P=[],ee=new Map,Y;function le(t,a){if(t[1]&&t[2])return Me;if(t[1])return Ue;if(t[2])return Te}let q=le(n),R=q&&q(n);T=new Ae({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${n[6]}');
...
const authData = await pb.collection('${(se=n[0])==null?void 0:se.name}').authWithPassword(
'${n[5]}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${n[6]}');
...
final authData = await pb.collection('${(ne=n[0])==null?void 0:ne.name}').authWithPassword(
'${n[5]}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}});let v=n[1]&&pe(),w=n[1]&&n[2]&&be(),y=n[2]&&me();H=new ke({props:{content:"?expand=relField1,relField2.subRelField"}});let x=n[4];const oe=t=>t[8].code;for(let t=0;t<x.length;t+=1){let a=fe(n,x,t),b=oe(a);xt.set(b,A[t]=he(b,a))}let z=n[4];const ae=t=>t[8].code;for(let t=0;t<z.length;t+=1){let a=ue(n,z,t),b=ae(a);ee.set(b,P[t]=_e(b,a))}return{c(){e=s("h3"),l=f("Auth with password ("),S=f(i),m=f(")"),p=u(),d=s("div"),_=s("p"),$=f(`Returns new auth token and account data by a combination of
`),C=s("strong"),R&&R.c(),O=f(`
and `),B=s("strong"),B.textContent="password",Mt=f("."),ot=u(),Ot(T.$$.fragment),at=u(),F=s("h6"),F.textContent="API details",st=u(),U=s("div"),G=s("strong"),G.textContent="POST",Dt=u(),X=s("div"),I=s("p"),Et=f("/api/collections/"),nt=s("strong"),it=f(Z),Lt=f("/auth-with-password"),rt=u(),N=s("div"),N.textContent="Body Parameters",ct=u(),M=s("table"),dt=s("thead"),dt.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr>`,Wt=u(),V=s("tbody"),D=s("tr"),ut=s("td"),ut.innerHTML=`<div class="inline-flex"><span class="label label-success">Required</span>
<span>identity</span></div>`,Bt=u(),ft=s("td"),ft.innerHTML='<span class="label">String</span>',Ht=u(),g=s("td"),Yt=f(`The
`),v&&v.c(),pt=u(),w&&w.c(),bt=u(),y&&y.c(),mt=f(`
of the record to authenticate.`),qt=u(),ht=s("tr"),ht.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>The auth record password.</td>`,_t=u(),j=s("div"),j.textContent="Query parameters",kt=u(),E=s("table"),St=s("thead"),St.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Ft=u(),vt=s("tbody"),L=s("tr"),wt=s("td"),wt.textContent="expand",It=u(),yt=s("td"),yt.innerHTML='<span class="label">String</span>',Nt=u(),k=s("td"),Vt=f(`Auto expand record relations. Ex.:
`),Ot(H.$$.fragment),jt=f(`
Supports up to 6-levels depth nested relations expansion. `),Jt=s("br"),Qt=f(`
The expanded relations will be appended to the record under the
`),gt=s("code"),gt.textContent="expand",Kt=f(" property (eg. "),Pt=s("code"),Pt.textContent='"expand": {"relField1": {...}, ...}',zt=f(`).
`),Gt=s("br"),Xt=f(`
Only the relations to which the account has permissions to `),Rt=s("strong"),Rt.textContent="view",Zt=f(" will be expanded."),$t=u(),J=s("div"),J.textContent="Responses",Ct=u(),W=s("div"),Q=s("div");for(let t=0;t<A.length;t+=1)A[t].c();te=u(),K=s("div");for(let t=0;t<P.length;t+=1)P[t].c();h(e,"class","m-b-sm"),h(d,"class","content txt-lg m-b-sm"),h(F,"class","m-b-xs"),h(G,"class","label label-primary"),h(X,"class","content"),h(U,"class","alert alert-success"),h(N,"class","section-title"),h(M,"class","table-compact table-border m-b-base"),h(j,"class","section-title"),h(E,"class","table-compact table-border m-b-base"),h(J,"class","section-title"),h(Q,"class","tabs-header compact left"),h(K,"class","tabs-content"),h(W,"class","tabs")},m(t,a){r(t,e,a),o(e,l),o(e,S),o(e,m),r(t,p,a),r(t,d,a),o(d,_),o(_,$),o(_,C),R&&R.m(C,null),o(_,O),o(_,B),o(_,Mt),r(t,ot,a),At(T,t,a),r(t,at,a),r(t,F,a),r(t,st,a),r(t,U,a),o(U,G),o(U,Dt),o(U,X),o(X,I),o(I,Et),o(I,nt),o(nt,it),o(I,Lt),r(t,rt,a),r(t,N,a),r(t,ct,a),r(t,M,a),o(M,dt),o(M,Wt),o(M,V),o(V,D),o(D,ut),o(D,Bt),o(D,ft),o(D,Ht),o(D,g),o(g,Yt),v&&v.m(g,null),o(g,pt),w&&w.m(g,null),o(g,bt),y&&y.m(g,null),o(g,mt),o(V,qt),o(V,ht),r(t,_t,a),r(t,j,a),r(t,kt,a),r(t,E,a),o(E,St),o(E,Ft),o(E,vt),o(vt,L),o(L,wt),o(L,It),o(L,yt),o(L,Nt),o(L,k),o(k,Vt),At(H,k,null),o(k,jt),o(k,Jt),o(k,Qt),o(k,gt),o(k,Kt),o(k,Pt),o(k,zt),o(k,Gt),o(k,Xt),o(k,Rt),o(k,Zt),r(t,$t,a),r(t,J,a),r(t,Ct,a),r(t,W,a),o(W,Q);for(let b=0;b<A.length;b+=1)A[b].m(Q,null);o(W,te),o(W,K);for(let b=0;b<P.length;b+=1)P[b].m(K,null);Y=!0},p(t,[a]){var ie,re;(!Y||a&1)&&i!==(i=t[0].name+"")&&Tt(S,i),q!==(q=le(t))&&(R&&R.d(1),R=q&&q(t),R&&(R.c(),R.m(C,null)));const b={};a&97&&(b.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${t[6]}');
...
const authData = await pb.collection('${(ie=t[0])==null?void 0:ie.name}').authWithPassword(
'${t[5]}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`),a&97&&(b.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${t[6]}');
...
final authData = await pb.collection('${(re=t[0])==null?void 0:re.name}').authWithPassword(
'${t[5]}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`),T.$set(b),(!Y||a&1)&&Z!==(Z=t[0].name+"")&&Tt(it,Z),t[1]?v||(v=pe(),v.c(),v.m(g,pt)):v&&(v.d(1),v=null),t[1]&&t[2]?w||(w=be(),w.c(),w.m(g,bt)):w&&(w.d(1),w=null),t[2]?y||(y=me(),y.c(),y.m(g,mt)):y&&(y.d(1),y=null),a&24&&(x=t[4],A=ce(A,a,oe,1,t,x,xt,Q,ye,he,null,fe)),a&24&&(z=t[4],ge(),P=ce(P,a,ae,1,t,z,ee,K,Pe,_e,null,ue),Re())},i(t){if(!Y){tt(T.$$.fragment,t),tt(H.$$.fragment,t);for(let a=0;a<z.length;a+=1)tt(P[a]);Y=!0}},o(t){et(T.$$.fragment,t),et(H.$$.fragment,t);for(let a=0;a<P.length;a+=1)et(P[a]);Y=!1},d(t){t&&c(e),t&&c(p),t&&c(d),R&&R.d(),t&&c(ot),Ut(T,t),t&&c(at),t&&c(F),t&&c(st),t&&c(U),t&&c(rt),t&&c(N),t&&c(ct),t&&c(M),v&&v.d(),w&&w.d(),y&&y.d(),t&&c(_t),t&&c(j),t&&c(kt),t&&c(E),Ut(H),t&&c($t),t&&c(J),t&&c(Ct),t&&c(W);for(let a=0;a<A.length;a+=1)A[a].d();for(let a=0;a<P.length;a+=1)P[a].d()}}}function Ee(n,e,l){let i,S,m,p,{collection:d=new $e}=e,_=200,$=[];const C=O=>l(3,_=O.code);return n.$$set=O=>{"collection"in O&&l(0,d=O.collection)},n.$$.update=()=>{var O,B;n.$$.dirty&1&&l(2,S=(O=d==null?void 0:d.options)==null?void 0:O.allowEmailAuth),n.$$.dirty&1&&l(1,m=(B=d==null?void 0:d.options)==null?void 0:B.allowUsernameAuth),n.$$.dirty&6&&l(5,p=m&&S?"YOUR_USERNAME_OR_EMAIL":m?"YOUR_USERNAME":"YOUR_EMAIL"),n.$$.dirty&1&&l(4,$=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:de.dummyCollectionRecord(d)},null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"identity": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}])},l(6,i=de.getApiExampleUrl(Ce.baseUrl)),[d,m,S,_,$,p,i,C]}class Be extends Se{constructor(e){super(),ve(this,e,Ee,De,we,{collection:0})}}export{Be as default};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+94
View File
@@ -0,0 +1,94 @@
import{S as Ge,i as Xe,s as Ze,O as ze,e as s,w as m,b as p,c as be,f as b,g as r,h as l,m as he,x as j,P as Ye,Q as et,k as tt,R as lt,n as ot,t as I,a as J,o as c,d as _e,L as at,C as je,p as st,r as Q,u as nt}from"./index.97f016a1.js";import{S as it}from"./SdkTabs.88269ae0.js";function Ie(i,o,a){const n=i.slice();return n[5]=o[a],n}function Je(i,o,a){const n=i.slice();return n[5]=o[a],n}function Qe(i,o){let a,n=o[5].code+"",k,v,d,u;function h(){return o[4](o[5])}return{key:i,first:null,c(){a=s("button"),k=m(n),v=p(),b(a,"class","tab-item"),Q(a,"active",o[1]===o[5].code),this.first=a},m(C,$){r(C,a,$),l(a,k),l(a,v),d||(u=nt(a,"click",h),d=!0)},p(C,$){o=C,$&4&&n!==(n=o[5].code+"")&&j(k,n),$&6&&Q(a,"active",o[1]===o[5].code)},d(C){C&&c(a),d=!1,u()}}}function xe(i,o){let a,n,k,v;return n=new ze({props:{content:o[5].body}}),{key:i,first:null,c(){a=s("div"),be(n.$$.fragment),k=p(),b(a,"class","tab-item"),Q(a,"active",o[1]===o[5].code),this.first=a},m(d,u){r(d,a,u),he(n,a,null),l(a,k),v=!0},p(d,u){o=d;const h={};u&4&&(h.content=o[5].body),n.$set(h),(!v||u&6)&&Q(a,"active",o[1]===o[5].code)},i(d){v||(I(n.$$.fragment,d),v=!0)},o(d){J(n.$$.fragment,d),v=!1},d(d){d&&c(a),_e(n)}}}function rt(i){var We,He;let o,a,n=i[0].name+"",k,v,d,u,h,C,$,W=i[0].name+"",x,ke,ve,z,G,y,X,D,Z,w,H,Se,L,A,ge,ee,V=i[0].name+"",te,Ce,le,B,oe,q,ae,U,se,O,ne,$e,ie,T,re,ye,ce,we,_,Oe,E,Te,Pe,Re,de,Ee,pe,De,Ae,Be,ue,qe,fe,M,me,P,N,g=[],Ue=new Map,Me,F,S=[],Ne=new Map,R;y=new it({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${i[3]}');
...
const authData = await pb.collection('${(We=i[0])==null?void 0:We.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${i[3]}');
...
final authData = await pb.collection('${(He=i[0])==null?void 0:He.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}}),E=new ze({props:{content:"?expand=relField1,relField2.subRelField"}});let Y=i[2];const Fe=e=>e[5].code;for(let e=0;e<Y.length;e+=1){let t=Je(i,Y,e),f=Fe(t);Ue.set(f,g[e]=Qe(f,t))}let K=i[2];const Ke=e=>e[5].code;for(let e=0;e<K.length;e+=1){let t=Ie(i,K,e),f=Ke(t);Ne.set(f,S[e]=xe(f,t))}return{c(){o=s("h3"),a=m("Confirm email change ("),k=m(n),v=m(")"),d=p(),u=s("div"),h=s("p"),C=m("Confirms "),$=s("strong"),x=m(W),ke=m(" email change request."),ve=p(),z=s("p"),z.textContent="Returns the refreshed auth data.",G=p(),be(y.$$.fragment),X=p(),D=s("h6"),D.textContent="API details",Z=p(),w=s("div"),H=s("strong"),H.textContent="POST",Se=p(),L=s("div"),A=s("p"),ge=m("/api/collections/"),ee=s("strong"),te=m(V),Ce=m("/confirm-email-change"),le=p(),B=s("div"),B.textContent="Body Parameters",oe=p(),q=s("table"),q.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>token</span></div></td>
<td><span class="label">String</span></td>
<td>The token from the change email request email.</td></tr>
<tr><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>The account password to confirm the email change.</td></tr></tbody>`,ae=p(),U=s("div"),U.textContent="Query parameters",se=p(),O=s("table"),ne=s("thead"),ne.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,$e=p(),ie=s("tbody"),T=s("tr"),re=s("td"),re.textContent="expand",ye=p(),ce=s("td"),ce.innerHTML='<span class="label">String</span>',we=p(),_=s("td"),Oe=m(`Auto expand record relations. Ex.:
`),be(E.$$.fragment),Te=m(`
Supports up to 6-levels depth nested relations expansion. `),Pe=s("br"),Re=m(`
The expanded relations will be appended to the record under the
`),de=s("code"),de.textContent="expand",Ee=m(" property (eg. "),pe=s("code"),pe.textContent='"expand": {"relField1": {...}, ...}',De=m(`).
`),Ae=s("br"),Be=m(`
Only the relations to which the account has permissions to `),ue=s("strong"),ue.textContent="view",qe=m(" will be expanded."),fe=p(),M=s("div"),M.textContent="Responses",me=p(),P=s("div"),N=s("div");for(let e=0;e<g.length;e+=1)g[e].c();Me=p(),F=s("div");for(let e=0;e<S.length;e+=1)S[e].c();b(o,"class","m-b-sm"),b(u,"class","content txt-lg m-b-sm"),b(D,"class","m-b-xs"),b(H,"class","label label-primary"),b(L,"class","content"),b(w,"class","alert alert-success"),b(B,"class","section-title"),b(q,"class","table-compact table-border m-b-base"),b(U,"class","section-title"),b(O,"class","table-compact table-border m-b-base"),b(M,"class","section-title"),b(N,"class","tabs-header compact left"),b(F,"class","tabs-content"),b(P,"class","tabs")},m(e,t){r(e,o,t),l(o,a),l(o,k),l(o,v),r(e,d,t),r(e,u,t),l(u,h),l(h,C),l(h,$),l($,x),l(h,ke),l(u,ve),l(u,z),r(e,G,t),he(y,e,t),r(e,X,t),r(e,D,t),r(e,Z,t),r(e,w,t),l(w,H),l(w,Se),l(w,L),l(L,A),l(A,ge),l(A,ee),l(ee,te),l(A,Ce),r(e,le,t),r(e,B,t),r(e,oe,t),r(e,q,t),r(e,ae,t),r(e,U,t),r(e,se,t),r(e,O,t),l(O,ne),l(O,$e),l(O,ie),l(ie,T),l(T,re),l(T,ye),l(T,ce),l(T,we),l(T,_),l(_,Oe),he(E,_,null),l(_,Te),l(_,Pe),l(_,Re),l(_,de),l(_,Ee),l(_,pe),l(_,De),l(_,Ae),l(_,Be),l(_,ue),l(_,qe),r(e,fe,t),r(e,M,t),r(e,me,t),r(e,P,t),l(P,N);for(let f=0;f<g.length;f+=1)g[f].m(N,null);l(P,Me),l(P,F);for(let f=0;f<S.length;f+=1)S[f].m(F,null);R=!0},p(e,[t]){var Le,Ve;(!R||t&1)&&n!==(n=e[0].name+"")&&j(k,n),(!R||t&1)&&W!==(W=e[0].name+"")&&j(x,W);const f={};t&9&&(f.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const authData = await pb.collection('${(Le=e[0])==null?void 0:Le.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),t&9&&(f.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final authData = await pb.collection('${(Ve=e[0])==null?void 0:Ve.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),y.$set(f),(!R||t&1)&&V!==(V=e[0].name+"")&&j(te,V),t&6&&(Y=e[2],g=Ye(g,t,Fe,1,e,Y,Ue,N,et,Qe,null,Je)),t&6&&(K=e[2],tt(),S=Ye(S,t,Ke,1,e,K,Ne,F,lt,xe,null,Ie),ot())},i(e){if(!R){I(y.$$.fragment,e),I(E.$$.fragment,e);for(let t=0;t<K.length;t+=1)I(S[t]);R=!0}},o(e){J(y.$$.fragment,e),J(E.$$.fragment,e);for(let t=0;t<S.length;t+=1)J(S[t]);R=!1},d(e){e&&c(o),e&&c(d),e&&c(u),e&&c(G),_e(y,e),e&&c(X),e&&c(D),e&&c(Z),e&&c(w),e&&c(le),e&&c(B),e&&c(oe),e&&c(q),e&&c(ae),e&&c(U),e&&c(se),e&&c(O),_e(E),e&&c(fe),e&&c(M),e&&c(me),e&&c(P);for(let t=0;t<g.length;t+=1)g[t].d();for(let t=0;t<S.length;t+=1)S[t].d()}}}function ct(i,o,a){let n,{collection:k=new at}=o,v=200,d=[];const u=h=>a(1,v=h.code);return i.$$set=h=>{"collection"in h&&a(0,k=h.collection)},i.$$.update=()=>{i.$$.dirty&1&&a(2,d=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:je.dummyCollectionRecord(k)},null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}])},a(3,n=je.getApiExampleUrl(st.baseUrl)),[k,v,d,n,u]}class ut extends Ge{constructor(o){super(),Xe(this,o,ct,rt,Ze,{collection:0})}}export{ut as default};
+102
View File
@@ -0,0 +1,102 @@
import{S as Xe,i as Ye,s as Ze,O as Ge,e as a,w as b,b as p,c as me,f as m,g as r,h as l,m as he,x as j,P as Ue,Q as et,k as tt,R as lt,n as st,t as J,a as Q,o as d,d as _e,L as ot,C as je,p as at,r as x,u as nt}from"./index.97f016a1.js";import{S as it}from"./SdkTabs.88269ae0.js";function Je(i,s,o){const n=i.slice();return n[5]=s[o],n}function Qe(i,s,o){const n=i.slice();return n[5]=s[o],n}function xe(i,s){let o,n=s[5].code+"",k,S,c,f;function h(){return s[4](s[5])}return{key:i,first:null,c(){o=a("button"),k=b(n),S=p(),m(o,"class","tab-item"),x(o,"active",s[1]===s[5].code),this.first=o},m(P,R){r(P,o,R),l(o,k),l(o,S),c||(f=nt(o,"click",h),c=!0)},p(P,R){s=P,R&4&&n!==(n=s[5].code+"")&&j(k,n),R&6&&x(o,"active",s[1]===s[5].code)},d(P){P&&d(o),c=!1,f()}}}function ze(i,s){let o,n,k,S;return n=new Ge({props:{content:s[5].body}}),{key:i,first:null,c(){o=a("div"),me(n.$$.fragment),k=p(),m(o,"class","tab-item"),x(o,"active",s[1]===s[5].code),this.first=o},m(c,f){r(c,o,f),he(n,o,null),l(o,k),S=!0},p(c,f){s=c;const h={};f&4&&(h.content=s[5].body),n.$set(h),(!S||f&6)&&x(o,"active",s[1]===s[5].code)},i(c){S||(J(n.$$.fragment,c),S=!0)},o(c){Q(n.$$.fragment,c),S=!1},d(c){c&&d(o),_e(n)}}}function rt(i){var Ke,He;let s,o,n=i[0].name+"",k,S,c,f,h,P,R,K=i[0].name+"",z,ke,Se,G,X,g,Y,W,Z,C,H,ve,L,D,we,ee,V=i[0].name+"",te,Pe,le,E,se,A,oe,M,ae,$,ne,Re,ie,y,re,ge,de,Ce,_,$e,T,ye,Oe,Ne,ce,Te,pe,We,De,Ee,fe,Ae,ue,F,be,O,q,w=[],Me=new Map,Fe,B,v=[],qe=new Map,N;g=new it({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${i[3]}');
...
const authData = await pb.collection('${(Ke=i[0])==null?void 0:Ke.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${i[3]}');
...
final authData = await pb.collection('${(He=i[0])==null?void 0:He.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}}),T=new Ge({props:{content:"?expand=relField1,relField2.subRelField"}});let U=i[2];const Be=e=>e[5].code;for(let e=0;e<U.length;e+=1){let t=Qe(i,U,e),u=Be(t);Me.set(u,w[e]=xe(u,t))}let I=i[2];const Ie=e=>e[5].code;for(let e=0;e<I.length;e+=1){let t=Je(i,I,e),u=Ie(t);qe.set(u,v[e]=ze(u,t))}return{c(){s=a("h3"),o=b("Confirm password reset ("),k=b(n),S=b(")"),c=p(),f=a("div"),h=a("p"),P=b("Confirms "),R=a("strong"),z=b(K),ke=b(" password reset request."),Se=p(),G=a("p"),G.textContent="Returns the refreshed auth data.",X=p(),me(g.$$.fragment),Y=p(),W=a("h6"),W.textContent="API details",Z=p(),C=a("div"),H=a("strong"),H.textContent="POST",ve=p(),L=a("div"),D=a("p"),we=b("/api/collections/"),ee=a("strong"),te=b(V),Pe=b("/confirm-password-reset"),le=p(),E=a("div"),E.textContent="Body Parameters",se=p(),A=a("table"),A.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>token</span></div></td>
<td><span class="label">String</span></td>
<td>The token from the password reset request email.</td></tr>
<tr><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>The new password to set.</td></tr>
<tr><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>The new password confirmation.</td></tr></tbody>`,oe=p(),M=a("div"),M.textContent="Query parameters",ae=p(),$=a("table"),ne=a("thead"),ne.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Re=p(),ie=a("tbody"),y=a("tr"),re=a("td"),re.textContent="expand",ge=p(),de=a("td"),de.innerHTML='<span class="label">String</span>',Ce=p(),_=a("td"),$e=b(`Auto expand record relations. Ex.:
`),me(T.$$.fragment),ye=b(`
Supports up to 6-levels depth nested relations expansion. `),Oe=a("br"),Ne=b(`
The expanded relations will be appended to the record under the
`),ce=a("code"),ce.textContent="expand",Te=b(" property (eg. "),pe=a("code"),pe.textContent='"expand": {"relField1": {...}, ...}',We=b(`).
`),De=a("br"),Ee=b(`
Only the relations to which the account has permissions to `),fe=a("strong"),fe.textContent="view",Ae=b(" will be expanded."),ue=p(),F=a("div"),F.textContent="Responses",be=p(),O=a("div"),q=a("div");for(let e=0;e<w.length;e+=1)w[e].c();Fe=p(),B=a("div");for(let e=0;e<v.length;e+=1)v[e].c();m(s,"class","m-b-sm"),m(f,"class","content txt-lg m-b-sm"),m(W,"class","m-b-xs"),m(H,"class","label label-primary"),m(L,"class","content"),m(C,"class","alert alert-success"),m(E,"class","section-title"),m(A,"class","table-compact table-border m-b-base"),m(M,"class","section-title"),m($,"class","table-compact table-border m-b-base"),m(F,"class","section-title"),m(q,"class","tabs-header compact left"),m(B,"class","tabs-content"),m(O,"class","tabs")},m(e,t){r(e,s,t),l(s,o),l(s,k),l(s,S),r(e,c,t),r(e,f,t),l(f,h),l(h,P),l(h,R),l(R,z),l(h,ke),l(f,Se),l(f,G),r(e,X,t),he(g,e,t),r(e,Y,t),r(e,W,t),r(e,Z,t),r(e,C,t),l(C,H),l(C,ve),l(C,L),l(L,D),l(D,we),l(D,ee),l(ee,te),l(D,Pe),r(e,le,t),r(e,E,t),r(e,se,t),r(e,A,t),r(e,oe,t),r(e,M,t),r(e,ae,t),r(e,$,t),l($,ne),l($,Re),l($,ie),l(ie,y),l(y,re),l(y,ge),l(y,de),l(y,Ce),l(y,_),l(_,$e),he(T,_,null),l(_,ye),l(_,Oe),l(_,Ne),l(_,ce),l(_,Te),l(_,pe),l(_,We),l(_,De),l(_,Ee),l(_,fe),l(_,Ae),r(e,ue,t),r(e,F,t),r(e,be,t),r(e,O,t),l(O,q);for(let u=0;u<w.length;u+=1)w[u].m(q,null);l(O,Fe),l(O,B);for(let u=0;u<v.length;u+=1)v[u].m(B,null);N=!0},p(e,[t]){var Le,Ve;(!N||t&1)&&n!==(n=e[0].name+"")&&j(k,n),(!N||t&1)&&K!==(K=e[0].name+"")&&j(z,K);const u={};t&9&&(u.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const authData = await pb.collection('${(Le=e[0])==null?void 0:Le.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),t&9&&(u.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final authData = await pb.collection('${(Ve=e[0])==null?void 0:Ve.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),g.$set(u),(!N||t&1)&&V!==(V=e[0].name+"")&&j(te,V),t&6&&(U=e[2],w=Ue(w,t,Be,1,e,U,Me,q,et,xe,null,Qe)),t&6&&(I=e[2],tt(),v=Ue(v,t,Ie,1,e,I,qe,B,lt,ze,null,Je),st())},i(e){if(!N){J(g.$$.fragment,e),J(T.$$.fragment,e);for(let t=0;t<I.length;t+=1)J(v[t]);N=!0}},o(e){Q(g.$$.fragment,e),Q(T.$$.fragment,e);for(let t=0;t<v.length;t+=1)Q(v[t]);N=!1},d(e){e&&d(s),e&&d(c),e&&d(f),e&&d(X),_e(g,e),e&&d(Y),e&&d(W),e&&d(Z),e&&d(C),e&&d(le),e&&d(E),e&&d(se),e&&d(A),e&&d(oe),e&&d(M),e&&d(ae),e&&d($),_e(T),e&&d(ue),e&&d(F),e&&d(be),e&&d(O);for(let t=0;t<w.length;t+=1)w[t].d();for(let t=0;t<v.length;t+=1)v[t].d()}}}function dt(i,s,o){let n,{collection:k=new ot}=s,S=200,c=[];const f=h=>o(1,S=h.code);return i.$$set=h=>{"collection"in h&&o(0,k=h.collection)},i.$$.update=()=>{i.$$.dirty&1&&o(2,c=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:je.dummyCollectionRecord(k)},null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}])},o(3,n=je.getApiExampleUrl(at.baseUrl)),[k,S,c,n,f]}class ft extends Xe{constructor(s){super(),Ye(this,s,dt,rt,Ze,{collection:0})}}export{ft as default};
+78
View File
@@ -0,0 +1,78 @@
import{S as Ye,i as Ze,s as xe,O as Xe,e as a,w as b,b as f,c as me,f as m,g as r,h as l,m as he,x as J,P as Ie,Q as et,k as tt,R as lt,n as ot,t as Q,a as W,o as c,d as _e,L as st,C as Je,p as at,r as z,u as nt}from"./index.97f016a1.js";import{S as it}from"./SdkTabs.88269ae0.js";function Qe(i,o,s){const n=i.slice();return n[5]=o[s],n}function We(i,o,s){const n=i.slice();return n[5]=o[s],n}function ze(i,o){let s,n=o[5].code+"",k,v,d,p;function h(){return o[4](o[5])}return{key:i,first:null,c(){s=a("button"),k=b(n),v=f(),m(s,"class","tab-item"),z(s,"active",o[1]===o[5].code),this.first=s},m(y,g){r(y,s,g),l(s,k),l(s,v),d||(p=nt(s,"click",h),d=!0)},p(y,g){o=y,g&4&&n!==(n=o[5].code+"")&&J(k,n),g&6&&z(s,"active",o[1]===o[5].code)},d(y){y&&c(s),d=!1,p()}}}function Ge(i,o){let s,n,k,v;return n=new Xe({props:{content:o[5].body}}),{key:i,first:null,c(){s=a("div"),me(n.$$.fragment),k=f(),m(s,"class","tab-item"),z(s,"active",o[1]===o[5].code),this.first=s},m(d,p){r(d,s,p),he(n,s,null),l(s,k),v=!0},p(d,p){o=d;const h={};p&4&&(h.content=o[5].body),n.$set(h),(!v||p&6)&&z(s,"active",o[1]===o[5].code)},i(d){v||(Q(n.$$.fragment,d),v=!0)},o(d){W(n.$$.fragment,d),v=!1},d(d){d&&c(s),_e(n)}}}function rt(i){var He,Le;let o,s,n=i[0].name+"",k,v,d,p,h,y,g,H=i[0].name+"",G,ke,ve,X,Y,w,Z,D,x,C,L,Se,U,E,$e,ee,j=i[0].name+"",te,ye,le,q,oe,M,se,N,ae,T,ne,ge,ie,P,re,we,ce,Ce,_,Te,B,Pe,Oe,Ve,de,Be,fe,De,Ee,qe,pe,Me,ue,R,be,O,F,$=[],Ne=new Map,Re,K,S=[],Fe=new Map,V;w=new it({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${i[3]}');
...
const authData = await pb.collection('${(He=i[0])==null?void 0:He.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${i[3]}');
...
final authData = await pb.collection('${(Le=i[0])==null?void 0:Le.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}}),B=new Xe({props:{content:"?expand=relField1,relField2.subRelField"}});let I=i[2];const Ke=e=>e[5].code;for(let e=0;e<I.length;e+=1){let t=We(i,I,e),u=Ke(t);Ne.set(u,$[e]=ze(u,t))}let A=i[2];const Ae=e=>e[5].code;for(let e=0;e<A.length;e+=1){let t=Qe(i,A,e),u=Ae(t);Fe.set(u,S[e]=Ge(u,t))}return{c(){o=a("h3"),s=b("Confirm verification ("),k=b(n),v=b(")"),d=f(),p=a("div"),h=a("p"),y=b("Confirms "),g=a("strong"),G=b(H),ke=b(" account verification request."),ve=f(),X=a("p"),X.textContent="Returns the refreshed auth data.",Y=f(),me(w.$$.fragment),Z=f(),D=a("h6"),D.textContent="API details",x=f(),C=a("div"),L=a("strong"),L.textContent="POST",Se=f(),U=a("div"),E=a("p"),$e=b("/api/collections/"),ee=a("strong"),te=b(j),ye=b("/confirm-verification"),le=f(),q=a("div"),q.textContent="Body Parameters",oe=f(),M=a("table"),M.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>token</span></div></td>
<td><span class="label">String</span></td>
<td>The token from the verification request email.</td></tr></tbody>`,se=f(),N=a("div"),N.textContent="Query parameters",ae=f(),T=a("table"),ne=a("thead"),ne.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,ge=f(),ie=a("tbody"),P=a("tr"),re=a("td"),re.textContent="expand",we=f(),ce=a("td"),ce.innerHTML='<span class="label">String</span>',Ce=f(),_=a("td"),Te=b(`Auto expand record relations. Ex.:
`),me(B.$$.fragment),Pe=b(`
Supports up to 6-levels depth nested relations expansion. `),Oe=a("br"),Ve=b(`
The expanded relations will be appended to the record under the
`),de=a("code"),de.textContent="expand",Be=b(" property (eg. "),fe=a("code"),fe.textContent='"expand": {"relField1": {...}, ...}',De=b(`).
`),Ee=a("br"),qe=b(`
Only the relations to which the account has permissions to `),pe=a("strong"),pe.textContent="view",Me=b(" will be expanded."),ue=f(),R=a("div"),R.textContent="Responses",be=f(),O=a("div"),F=a("div");for(let e=0;e<$.length;e+=1)$[e].c();Re=f(),K=a("div");for(let e=0;e<S.length;e+=1)S[e].c();m(o,"class","m-b-sm"),m(p,"class","content txt-lg m-b-sm"),m(D,"class","m-b-xs"),m(L,"class","label label-primary"),m(U,"class","content"),m(C,"class","alert alert-success"),m(q,"class","section-title"),m(M,"class","table-compact table-border m-b-base"),m(N,"class","section-title"),m(T,"class","table-compact table-border m-b-base"),m(R,"class","section-title"),m(F,"class","tabs-header compact left"),m(K,"class","tabs-content"),m(O,"class","tabs")},m(e,t){r(e,o,t),l(o,s),l(o,k),l(o,v),r(e,d,t),r(e,p,t),l(p,h),l(h,y),l(h,g),l(g,G),l(h,ke),l(p,ve),l(p,X),r(e,Y,t),he(w,e,t),r(e,Z,t),r(e,D,t),r(e,x,t),r(e,C,t),l(C,L),l(C,Se),l(C,U),l(U,E),l(E,$e),l(E,ee),l(ee,te),l(E,ye),r(e,le,t),r(e,q,t),r(e,oe,t),r(e,M,t),r(e,se,t),r(e,N,t),r(e,ae,t),r(e,T,t),l(T,ne),l(T,ge),l(T,ie),l(ie,P),l(P,re),l(P,we),l(P,ce),l(P,Ce),l(P,_),l(_,Te),he(B,_,null),l(_,Pe),l(_,Oe),l(_,Ve),l(_,de),l(_,Be),l(_,fe),l(_,De),l(_,Ee),l(_,qe),l(_,pe),l(_,Me),r(e,ue,t),r(e,R,t),r(e,be,t),r(e,O,t),l(O,F);for(let u=0;u<$.length;u+=1)$[u].m(F,null);l(O,Re),l(O,K);for(let u=0;u<S.length;u+=1)S[u].m(K,null);V=!0},p(e,[t]){var Ue,je;(!V||t&1)&&n!==(n=e[0].name+"")&&J(k,n),(!V||t&1)&&H!==(H=e[0].name+"")&&J(G,H);const u={};t&9&&(u.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const authData = await pb.collection('${(Ue=e[0])==null?void 0:Ue.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),t&9&&(u.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final authData = await pb.collection('${(je=e[0])==null?void 0:je.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`),w.$set(u),(!V||t&1)&&j!==(j=e[0].name+"")&&J(te,j),t&6&&(I=e[2],$=Ie($,t,Ke,1,e,I,Ne,F,et,ze,null,We)),t&6&&(A=e[2],tt(),S=Ie(S,t,Ae,1,e,A,Fe,K,lt,Ge,null,Qe),ot())},i(e){if(!V){Q(w.$$.fragment,e),Q(B.$$.fragment,e);for(let t=0;t<A.length;t+=1)Q(S[t]);V=!0}},o(e){W(w.$$.fragment,e),W(B.$$.fragment,e);for(let t=0;t<S.length;t+=1)W(S[t]);V=!1},d(e){e&&c(o),e&&c(d),e&&c(p),e&&c(Y),_e(w,e),e&&c(Z),e&&c(D),e&&c(x),e&&c(C),e&&c(le),e&&c(q),e&&c(oe),e&&c(M),e&&c(se),e&&c(N),e&&c(ae),e&&c(T),_e(B),e&&c(ue),e&&c(R),e&&c(be),e&&c(O);for(let t=0;t<$.length;t+=1)$[t].d();for(let t=0;t<S.length;t+=1)S[t].d()}}}function ct(i,o,s){let n,{collection:k=new st}=o,v=200,d=[];const p=h=>s(1,v=h.code);return i.$$set=h=>{"collection"in h&&s(0,k=h.collection)},i.$$.update=()=>{i.$$.dirty&1&&s(2,d=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:Je.dummyCollectionRecord(k)},null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}])},s(3,n=Je.getApiExampleUrl(at.baseUrl)),[k,v,d,n,p]}class pt extends Ye{constructor(o){super(),Ze(this,o,ct,rt,xe,{collection:0})}}export{pt as default};
+102
View File
@@ -0,0 +1,102 @@
import{S as Ct,i as St,s as Tt,C as Q,O as wt,e as a,w as k,b,c as Pe,f as h,g as o,h as n,m as Re,x as Z,P as Ae,Q as pt,k as $t,R as Ot,n as Mt,t as fe,a as pe,o as r,d as ge,L as Lt,p as Ht,r as ue,u as qt,y as le}from"./index.97f016a1.js";import{S as At}from"./SdkTabs.88269ae0.js";function ut(d,e,l){const s=d.slice();return s[7]=e[l],s}function bt(d,e,l){const s=d.slice();return s[7]=e[l],s}function mt(d,e,l){const s=d.slice();return s[12]=e[l],s}function _t(d){let e;return{c(){e=a("p"),e.innerHTML="Requires admin <code>Authorization:TOKEN</code> header",h(e,"class","txt-hint txt-sm txt-right")},m(l,s){o(l,e,s)},d(l){l&&r(e)}}}function kt(d){let e,l,s,m,p,c,f,y,$,w,M,F,D,I,A,J,j,g,S,N,O,C,_;function L(u,T){var ee,z;return(z=(ee=u[0])==null?void 0:ee.options)!=null&&z.requireEmail?Rt:Pt}let x=L(d),P=x(d);return{c(){e=a("tr"),e.innerHTML='<td colspan="3" class="txt-hint">Auth fields</td>',l=b(),s=a("tr"),s.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>username</span></div></td>
<td><span class="label">String</span></td>
<td>The username of the auth record.
<br/>
If not set, it will be auto generated.</td>`,m=b(),p=a("tr"),c=a("td"),f=a("div"),P.c(),y=b(),$=a("span"),$.textContent="email",w=b(),M=a("td"),M.innerHTML='<span class="label">String</span>',F=b(),D=a("td"),D.textContent="Auth record email address.",I=b(),A=a("tr"),A.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>emailVisibility</span></div></td>
<td><span class="label">Boolean</span></td>
<td>Whether to show/hide the auth record email when fetching the record data.</td>`,J=b(),j=a("tr"),j.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>`,g=b(),S=a("tr"),S.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>`,N=b(),O=a("tr"),O.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 admins or auth records with &quot;Manage&quot; access.</td>`,C=b(),_=a("tr"),_.innerHTML='<td colspan="3" class="txt-hint">Schema fields</td>',h(f,"class","inline-flex")},m(u,T){o(u,e,T),o(u,l,T),o(u,s,T),o(u,m,T),o(u,p,T),n(p,c),n(c,f),P.m(f,null),n(f,y),n(f,$),n(p,w),n(p,M),n(p,F),n(p,D),o(u,I,T),o(u,A,T),o(u,J,T),o(u,j,T),o(u,g,T),o(u,S,T),o(u,N,T),o(u,O,T),o(u,C,T),o(u,_,T)},p(u,T){x!==(x=L(u))&&(P.d(1),P=x(u),P&&(P.c(),P.m(f,y)))},d(u){u&&r(e),u&&r(l),u&&r(s),u&&r(m),u&&r(p),P.d(),u&&r(I),u&&r(A),u&&r(J),u&&r(j),u&&r(g),u&&r(S),u&&r(N),u&&r(O),u&&r(C),u&&r(_)}}}function Pt(d){let e;return{c(){e=a("span"),e.textContent="Optional",h(e,"class","label label-warning")},m(l,s){o(l,e,s)},d(l){l&&r(e)}}}function Rt(d){let e;return{c(){e=a("span"),e.textContent="Required",h(e,"class","label label-success")},m(l,s){o(l,e,s)},d(l){l&&r(e)}}}function gt(d){let e;return{c(){e=a("span"),e.textContent="Optional",h(e,"class","label label-warning")},m(l,s){o(l,e,s)},d(l){l&&r(e)}}}function Bt(d){let e;return{c(){e=a("span"),e.textContent="Required",h(e,"class","label label-success")},m(l,s){o(l,e,s)},d(l){l&&r(e)}}}function Ft(d){var p;let e,l=((p=d[12].options)==null?void 0:p.maxSelect)===1?"id":"ids",s,m;return{c(){e=k("Relation record "),s=k(l),m=k(".")},m(c,f){o(c,e,f),o(c,s,f),o(c,m,f)},p(c,f){var y;f&1&&l!==(l=((y=c[12].options)==null?void 0:y.maxSelect)===1?"id":"ids")&&Z(s,l)},d(c){c&&r(e),c&&r(s),c&&r(m)}}}function jt(d){let e,l,s,m,p;return{c(){e=k("File object."),l=a("br"),s=k(`
Set to `),m=a("code"),m.textContent="null",p=k(" to delete already uploaded file(s).")},m(c,f){o(c,e,f),o(c,l,f),o(c,s,f),o(c,m,f),o(c,p,f)},p:le,d(c){c&&r(e),c&&r(l),c&&r(s),c&&r(m),c&&r(p)}}}function Dt(d){let e;return{c(){e=k("URL address.")},m(l,s){o(l,e,s)},p:le,d(l){l&&r(e)}}}function Nt(d){let e;return{c(){e=k("Email address.")},m(l,s){o(l,e,s)},p:le,d(l){l&&r(e)}}}function It(d){let e;return{c(){e=k("JSON array or object.")},m(l,s){o(l,e,s)},p:le,d(l){l&&r(e)}}}function Jt(d){let e;return{c(){e=k("Number value.")},m(l,s){o(l,e,s)},p:le,d(l){l&&r(e)}}}function Et(d){let e;return{c(){e=k("Plain text value.")},m(l,s){o(l,e,s)},p:le,d(l){l&&r(e)}}}function yt(d,e){let l,s,m,p,c,f=e[12].name+"",y,$,w,M,F=Q.getFieldValueType(e[12])+"",D,I,A,J;function j(_,L){return _[12].required?Bt:gt}let g=j(e),S=g(e);function N(_,L){if(_[12].type==="text")return Et;if(_[12].type==="number")return Jt;if(_[12].type==="json")return It;if(_[12].type==="email")return Nt;if(_[12].type==="url")return Dt;if(_[12].type==="file")return jt;if(_[12].type==="relation")return Ft}let O=N(e),C=O&&O(e);return{key:d,first:null,c(){l=a("tr"),s=a("td"),m=a("div"),S.c(),p=b(),c=a("span"),y=k(f),$=b(),w=a("td"),M=a("span"),D=k(F),I=b(),A=a("td"),C&&C.c(),J=b(),h(m,"class","inline-flex"),h(M,"class","label"),this.first=l},m(_,L){o(_,l,L),n(l,s),n(s,m),S.m(m,null),n(m,p),n(m,c),n(c,y),n(l,$),n(l,w),n(w,M),n(M,D),n(l,I),n(l,A),C&&C.m(A,null),n(l,J)},p(_,L){e=_,g!==(g=j(e))&&(S.d(1),S=g(e),S&&(S.c(),S.m(m,p))),L&1&&f!==(f=e[12].name+"")&&Z(y,f),L&1&&F!==(F=Q.getFieldValueType(e[12])+"")&&Z(D,F),O===(O=N(e))&&C?C.p(e,L):(C&&C.d(1),C=O&&O(e),C&&(C.c(),C.m(A,null)))},d(_){_&&r(l),S.d(),C&&C.d()}}}function vt(d,e){let l,s=e[7].code+"",m,p,c,f;function y(){return e[6](e[7])}return{key:d,first:null,c(){l=a("button"),m=k(s),p=b(),h(l,"class","tab-item"),ue(l,"active",e[1]===e[7].code),this.first=l},m($,w){o($,l,w),n(l,m),n(l,p),c||(f=qt(l,"click",y),c=!0)},p($,w){e=$,w&4&&s!==(s=e[7].code+"")&&Z(m,s),w&6&&ue(l,"active",e[1]===e[7].code)},d($){$&&r(l),c=!1,f()}}}function ht(d,e){let l,s,m,p;return s=new wt({props:{content:e[7].body}}),{key:d,first:null,c(){l=a("div"),Pe(s.$$.fragment),m=b(),h(l,"class","tab-item"),ue(l,"active",e[1]===e[7].code),this.first=l},m(c,f){o(c,l,f),Re(s,l,null),n(l,m),p=!0},p(c,f){e=c;const y={};f&4&&(y.content=e[7].body),s.$set(y),(!p||f&6)&&ue(l,"active",e[1]===e[7].code)},i(c){p||(fe(s.$$.fragment,c),p=!0)},o(c){pe(s.$$.fragment,c),p=!1},d(c){c&&r(l),ge(s)}}}function Ut(d){var st,it,at,ot;let e,l,s=d[0].name+"",m,p,c,f,y,$,w,M=d[0].name+"",F,D,I,A,J,j,g,S,N,O,C,_,L,x,P,u,T,ee,z=d[0].name+"",be,Be,Fe,me,ne,_e,K,ke,je,E,ye,De,ve,U=[],Ne=new Map,he,se,we,W,Ce,Ie,Se,Y,Te,Je,$e,Ee,H,Ue,te,Ve,Qe,xe,Oe,ze,Me,Ke,We,Ye,Le,Ge,He,ie,qe,G,ae,V=[],Xe=new Map,Ze,oe,B=[],et=new Map,X;S=new At({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${d[4]}');
...
// example create data
const data = ${JSON.stringify(Object.assign({},d[3],Q.dummyCollectionSchemaData(d[0])),null,4)};
const record = await pb.collection('${(st=d[0])==null?void 0:st.name}').create(data);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${d[4]}');
...
// example create body
final body = <String, dynamic>${JSON.stringify(Object.assign({},d[3],Q.dummyCollectionSchemaData(d[0])),null,2)};
final record = await pb.collection('${(it=d[0])==null?void 0:it.name}').create(body: body);
`}});let R=d[5]&&_t(),q=((at=d[0])==null?void 0:at.isAuth)&&kt(d),de=(ot=d[0])==null?void 0:ot.schema;const tt=t=>t[12].name;for(let t=0;t<de.length;t+=1){let i=mt(d,de,t),v=tt(i);Ne.set(v,U[t]=yt(v,i))}te=new wt({props:{content:"?expand=relField1,relField2.subRelField"}});let ce=d[2];const lt=t=>t[7].code;for(let t=0;t<ce.length;t+=1){let i=bt(d,ce,t),v=lt(i);Xe.set(v,V[t]=vt(v,i))}let re=d[2];const nt=t=>t[7].code;for(let t=0;t<re.length;t+=1){let i=ut(d,re,t),v=nt(i);et.set(v,B[t]=ht(v,i))}return{c(){e=a("h3"),l=k("Create ("),m=k(s),p=k(")"),c=b(),f=a("div"),y=a("p"),$=k("Create a new "),w=a("strong"),F=k(M),D=k(" record."),I=b(),A=a("p"),A.innerHTML=`Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.`,J=b(),j=a("p"),j.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/#uploading-files" target="_blank" rel="noopener noreferrer">Files upload and handling docs
</a>.`,g=b(),Pe(S.$$.fragment),N=b(),O=a("h6"),O.textContent="API details",C=b(),_=a("div"),L=a("strong"),L.textContent="POST",x=b(),P=a("div"),u=a("p"),T=k("/api/collections/"),ee=a("strong"),be=k(z),Be=k("/records"),Fe=b(),R&&R.c(),me=b(),ne=a("div"),ne.textContent="Body Parameters",_e=b(),K=a("table"),ke=a("thead"),ke.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr>`,je=b(),E=a("tbody"),ye=a("tr"),ye.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>id</span></div></td>
<td><span class="label">String</span></td>
<td><strong>15 characters string</strong> to store as record ID.
<br/>
If not set, it will be auto generated.</td>`,De=b(),q&&q.c(),ve=b();for(let t=0;t<U.length;t+=1)U[t].c();he=b(),se=a("div"),se.textContent="Query parameters",we=b(),W=a("table"),Ce=a("thead"),Ce.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Ie=b(),Se=a("tbody"),Y=a("tr"),Te=a("td"),Te.textContent="expand",Je=b(),$e=a("td"),$e.innerHTML='<span class="label">String</span>',Ee=b(),H=a("td"),Ue=k(`Auto expand relations when returning the created record. Ex.:
`),Pe(te.$$.fragment),Ve=k(`
Supports up to 6-levels depth nested relations expansion. `),Qe=a("br"),xe=k(`
The expanded relations will be appended to the record under the
`),Oe=a("code"),Oe.textContent="expand",ze=k(" property (eg. "),Me=a("code"),Me.textContent='"expand": {"relField1": {...}, ...}',Ke=k(`).
`),We=a("br"),Ye=k(`
Only the relations to which the account has permissions to `),Le=a("strong"),Le.textContent="view",Ge=k(" will be expanded."),He=b(),ie=a("div"),ie.textContent="Responses",qe=b(),G=a("div"),ae=a("div");for(let t=0;t<V.length;t+=1)V[t].c();Ze=b(),oe=a("div");for(let t=0;t<B.length;t+=1)B[t].c();h(e,"class","m-b-sm"),h(f,"class","content txt-lg m-b-sm"),h(O,"class","m-b-xs"),h(L,"class","label label-primary"),h(P,"class","content"),h(_,"class","alert alert-success"),h(ne,"class","section-title"),h(K,"class","table-compact table-border m-b-base"),h(se,"class","section-title"),h(W,"class","table-compact table-border m-b-base"),h(ie,"class","section-title"),h(ae,"class","tabs-header compact left"),h(oe,"class","tabs-content"),h(G,"class","tabs")},m(t,i){o(t,e,i),n(e,l),n(e,m),n(e,p),o(t,c,i),o(t,f,i),n(f,y),n(y,$),n(y,w),n(w,F),n(y,D),n(f,I),n(f,A),n(f,J),n(f,j),o(t,g,i),Re(S,t,i),o(t,N,i),o(t,O,i),o(t,C,i),o(t,_,i),n(_,L),n(_,x),n(_,P),n(P,u),n(u,T),n(u,ee),n(ee,be),n(u,Be),n(_,Fe),R&&R.m(_,null),o(t,me,i),o(t,ne,i),o(t,_e,i),o(t,K,i),n(K,ke),n(K,je),n(K,E),n(E,ye),n(E,De),q&&q.m(E,null),n(E,ve);for(let v=0;v<U.length;v+=1)U[v].m(E,null);o(t,he,i),o(t,se,i),o(t,we,i),o(t,W,i),n(W,Ce),n(W,Ie),n(W,Se),n(Se,Y),n(Y,Te),n(Y,Je),n(Y,$e),n(Y,Ee),n(Y,H),n(H,Ue),Re(te,H,null),n(H,Ve),n(H,Qe),n(H,xe),n(H,Oe),n(H,ze),n(H,Me),n(H,Ke),n(H,We),n(H,Ye),n(H,Le),n(H,Ge),o(t,He,i),o(t,ie,i),o(t,qe,i),o(t,G,i),n(G,ae);for(let v=0;v<V.length;v+=1)V[v].m(ae,null);n(G,Ze),n(G,oe);for(let v=0;v<B.length;v+=1)B[v].m(oe,null);X=!0},p(t,[i]){var rt,dt,ct,ft;(!X||i&1)&&s!==(s=t[0].name+"")&&Z(m,s),(!X||i&1)&&M!==(M=t[0].name+"")&&Z(F,M);const v={};i&25&&(v.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${t[4]}');
...
// example create data
const data = ${JSON.stringify(Object.assign({},t[3],Q.dummyCollectionSchemaData(t[0])),null,4)};
const record = await pb.collection('${(rt=t[0])==null?void 0:rt.name}').create(data);
`),i&25&&(v.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${t[4]}');
...
// example create body
final body = <String, dynamic>${JSON.stringify(Object.assign({},t[3],Q.dummyCollectionSchemaData(t[0])),null,2)};
final record = await pb.collection('${(dt=t[0])==null?void 0:dt.name}').create(body: body);
`),S.$set(v),(!X||i&1)&&z!==(z=t[0].name+"")&&Z(be,z),t[5]?R||(R=_t(),R.c(),R.m(_,null)):R&&(R.d(1),R=null),(ct=t[0])!=null&&ct.isAuth?q?q.p(t,i):(q=kt(t),q.c(),q.m(E,ve)):q&&(q.d(1),q=null),i&1&&(de=(ft=t[0])==null?void 0:ft.schema,U=Ae(U,i,tt,1,t,de,Ne,E,pt,yt,null,mt)),i&6&&(ce=t[2],V=Ae(V,i,lt,1,t,ce,Xe,ae,pt,vt,null,bt)),i&6&&(re=t[2],$t(),B=Ae(B,i,nt,1,t,re,et,oe,Ot,ht,null,ut),Mt())},i(t){if(!X){fe(S.$$.fragment,t),fe(te.$$.fragment,t);for(let i=0;i<re.length;i+=1)fe(B[i]);X=!0}},o(t){pe(S.$$.fragment,t),pe(te.$$.fragment,t);for(let i=0;i<B.length;i+=1)pe(B[i]);X=!1},d(t){t&&r(e),t&&r(c),t&&r(f),t&&r(g),ge(S,t),t&&r(N),t&&r(O),t&&r(C),t&&r(_),R&&R.d(),t&&r(me),t&&r(ne),t&&r(_e),t&&r(K),q&&q.d();for(let i=0;i<U.length;i+=1)U[i].d();t&&r(he),t&&r(se),t&&r(we),t&&r(W),ge(te),t&&r(He),t&&r(ie),t&&r(qe),t&&r(G);for(let i=0;i<V.length;i+=1)V[i].d();for(let i=0;i<B.length;i+=1)B[i].d()}}}function Vt(d,e,l){let s,m,{collection:p=new Lt}=e,c=200,f=[],y={};const $=w=>l(1,c=w.code);return d.$$set=w=>{"collection"in w&&l(0,p=w.collection)},d.$$.update=()=>{var w,M;d.$$.dirty&1&&l(5,s=(p==null?void 0:p.createRule)===null),d.$$.dirty&1&&l(2,f=[{code:200,body:JSON.stringify(Q.dummyCollectionRecord(p),null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to create record.",
"data": {
"${(M=(w=p==null?void 0:p.schema)==null?void 0:w[0])==null?void 0:M.name}": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`},{code:403,body:`
{
"code": 403,
"message": "You are not allowed to perform this request.",
"data": {}
}
`}]),d.$$.dirty&1&&(p.isAuth?l(3,y={username:"test_username",email:"test@exampe.com",emailVisibility:!0,password:"12345678",passwordConfirm:"12345678"}):l(3,y={}))},l(4,m=Q.getApiExampleUrl(Ht.baseUrl)),[p,c,f,y,m,s,$]}class zt extends Ct{constructor(e){super(),St(this,e,Vt,Ut,Tt,{collection:0})}}export{zt as default};
+58
View File
@@ -0,0 +1,58 @@
import{S as Ce,i as Re,s as Pe,e as c,w as D,b as k,c as $e,f as m,g as d,h as n,m as we,x,P as _e,Q as Ee,k as Oe,R as Te,n as Be,t as ee,a as te,o as f,d as ge,L as Ie,C as Ae,p as Me,r as z,u as Se,O as qe}from"./index.97f016a1.js";import{S as Le}from"./SdkTabs.88269ae0.js";function ke(o,l,s){const a=o.slice();return a[6]=l[s],a}function he(o,l,s){const a=o.slice();return a[6]=l[s],a}function ve(o){let l;return{c(){l=c("p"),l.innerHTML="Requires admin <code>Authorization:TOKEN</code> header",m(l,"class","txt-hint txt-sm txt-right")},m(s,a){d(s,l,a)},d(s){s&&f(l)}}}function ye(o,l){let s,a=l[6].code+"",h,i,r,u;function $(){return l[5](l[6])}return{key:o,first:null,c(){s=c("button"),h=D(a),i=k(),m(s,"class","tab-item"),z(s,"active",l[2]===l[6].code),this.first=s},m(b,g){d(b,s,g),n(s,h),n(s,i),r||(u=Se(s,"click",$),r=!0)},p(b,g){l=b,g&20&&z(s,"active",l[2]===l[6].code)},d(b){b&&f(s),r=!1,u()}}}function De(o,l){let s,a,h,i;return a=new qe({props:{content:l[6].body}}),{key:o,first:null,c(){s=c("div"),$e(a.$$.fragment),h=k(),m(s,"class","tab-item"),z(s,"active",l[2]===l[6].code),this.first=s},m(r,u){d(r,s,u),we(a,s,null),n(s,h),i=!0},p(r,u){l=r,(!i||u&20)&&z(s,"active",l[2]===l[6].code)},i(r){i||(ee(a.$$.fragment,r),i=!0)},o(r){te(a.$$.fragment,r),i=!1},d(r){r&&f(s),ge(a)}}}function He(o){var ue,pe;let l,s,a=o[0].name+"",h,i,r,u,$,b,g,q=o[0].name+"",F,le,K,C,N,O,Q,y,L,se,H,E,oe,G,U=o[0].name+"",J,ae,V,ne,W,T,X,B,Y,I,Z,R,A,w=[],ie=new Map,re,M,v=[],ce=new Map,P;C=new Le({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${o[3]}');
...
await pb.collection('${(ue=o[0])==null?void 0:ue.name}').delete('RECORD_ID');
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${o[3]}');
...
await pb.collection('${(pe=o[0])==null?void 0:pe.name}').delete('RECORD_ID');
`}});let _=o[1]&&ve(),j=o[4];const de=e=>e[6].code;for(let e=0;e<j.length;e+=1){let t=he(o,j,e),p=de(t);ie.set(p,w[e]=ye(p,t))}let S=o[4];const fe=e=>e[6].code;for(let e=0;e<S.length;e+=1){let t=ke(o,S,e),p=fe(t);ce.set(p,v[e]=De(p,t))}return{c(){l=c("h3"),s=D("Delete ("),h=D(a),i=D(")"),r=k(),u=c("div"),$=c("p"),b=D("Delete a single "),g=c("strong"),F=D(q),le=D(" record."),K=k(),$e(C.$$.fragment),N=k(),O=c("h6"),O.textContent="API details",Q=k(),y=c("div"),L=c("strong"),L.textContent="DELETE",se=k(),H=c("div"),E=c("p"),oe=D("/api/collections/"),G=c("strong"),J=D(U),ae=D("/records/"),V=c("strong"),V.textContent=":id",ne=k(),_&&_.c(),W=k(),T=c("div"),T.textContent="Path parameters",X=k(),B=c("table"),B.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr></thead>
<tbody><tr><td>id</td>
<td><span class="label">String</span></td>
<td>ID of the record to delete.</td></tr></tbody>`,Y=k(),I=c("div"),I.textContent="Responses",Z=k(),R=c("div"),A=c("div");for(let e=0;e<w.length;e+=1)w[e].c();re=k(),M=c("div");for(let e=0;e<v.length;e+=1)v[e].c();m(l,"class","m-b-sm"),m(u,"class","content txt-lg m-b-sm"),m(O,"class","m-b-xs"),m(L,"class","label label-primary"),m(H,"class","content"),m(y,"class","alert alert-danger"),m(T,"class","section-title"),m(B,"class","table-compact table-border m-b-base"),m(I,"class","section-title"),m(A,"class","tabs-header compact left"),m(M,"class","tabs-content"),m(R,"class","tabs")},m(e,t){d(e,l,t),n(l,s),n(l,h),n(l,i),d(e,r,t),d(e,u,t),n(u,$),n($,b),n($,g),n(g,F),n($,le),d(e,K,t),we(C,e,t),d(e,N,t),d(e,O,t),d(e,Q,t),d(e,y,t),n(y,L),n(y,se),n(y,H),n(H,E),n(E,oe),n(E,G),n(G,J),n(E,ae),n(E,V),n(y,ne),_&&_.m(y,null),d(e,W,t),d(e,T,t),d(e,X,t),d(e,B,t),d(e,Y,t),d(e,I,t),d(e,Z,t),d(e,R,t),n(R,A);for(let p=0;p<w.length;p+=1)w[p].m(A,null);n(R,re),n(R,M);for(let p=0;p<v.length;p+=1)v[p].m(M,null);P=!0},p(e,[t]){var me,be;(!P||t&1)&&a!==(a=e[0].name+"")&&x(h,a),(!P||t&1)&&q!==(q=e[0].name+"")&&x(F,q);const p={};t&9&&(p.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(me=e[0])==null?void 0:me.name}').delete('RECORD_ID');
`),t&9&&(p.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${(be=e[0])==null?void 0:be.name}').delete('RECORD_ID');
`),C.$set(p),(!P||t&1)&&U!==(U=e[0].name+"")&&x(J,U),e[1]?_||(_=ve(),_.c(),_.m(y,null)):_&&(_.d(1),_=null),t&20&&(j=e[4],w=_e(w,t,de,1,e,j,ie,A,Ee,ye,null,he)),t&20&&(S=e[4],Oe(),v=_e(v,t,fe,1,e,S,ce,M,Te,De,null,ke),Be())},i(e){if(!P){ee(C.$$.fragment,e);for(let t=0;t<S.length;t+=1)ee(v[t]);P=!0}},o(e){te(C.$$.fragment,e);for(let t=0;t<v.length;t+=1)te(v[t]);P=!1},d(e){e&&f(l),e&&f(r),e&&f(u),e&&f(K),ge(C,e),e&&f(N),e&&f(O),e&&f(Q),e&&f(y),_&&_.d(),e&&f(W),e&&f(T),e&&f(X),e&&f(B),e&&f(Y),e&&f(I),e&&f(Z),e&&f(R);for(let t=0;t<w.length;t+=1)w[t].d();for(let t=0;t<v.length;t+=1)v[t].d()}}}function Ue(o,l,s){let a,h,{collection:i=new Ie}=l,r=204,u=[];const $=b=>s(2,r=b.code);return o.$$set=b=>{"collection"in b&&s(0,i=b.collection)},o.$$.update=()=>{o.$$.dirty&1&&s(1,a=(i==null?void 0:i.deleteRule)===null),o.$$.dirty&3&&i!=null&&i.id&&(u.push({code:204,body:`
null
`}),u.push({code:400,body:`
{
"code": 400,
"message": "Failed to delete record. Make sure that the record is not part of a required relation reference.",
"data": {}
}
`}),a&&u.push({code:403,body:`
{
"code": 403,
"message": "Only admins can access this action.",
"data": {}
}
`}),u.push({code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}))},s(3,h=Ae.getApiExampleUrl(Me.baseUrl)),[i,a,r,h,u,$]}class Fe extends Ce{constructor(l){super(),Re(this,l,Ue,He,Pe,{collection:0})}}export{Fe as default};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+140
View File
@@ -0,0 +1,140 @@
import{S as Et,i as Nt,s as Ht,e as l,b as a,E as qt,f as d,g as p,u as Mt,y as xt,o as u,w as k,h as e,O as Ae,c as ge,m as ye,x as Ue,P as Lt,Q as Dt,k as It,R as Bt,n as zt,t as ce,a as de,d as ve,L as Gt,C as je,p as Ut,r as Ee}from"./index.97f016a1.js";import{S as jt}from"./SdkTabs.88269ae0.js";function Qt(r){let s,n,i;return{c(){s=l("span"),s.textContent="Show details",n=a(),i=l("i"),d(s,"class","txt"),d(i,"class","ri-arrow-down-s-line")},m(c,f){p(c,s,f),p(c,n,f),p(c,i,f)},d(c){c&&u(s),c&&u(n),c&&u(i)}}}function Jt(r){let s,n,i;return{c(){s=l("span"),s.textContent="Hide details",n=a(),i=l("i"),d(s,"class","txt"),d(i,"class","ri-arrow-up-s-line")},m(c,f){p(c,s,f),p(c,n,f),p(c,i,f)},d(c){c&&u(s),c&&u(n),c&&u(i)}}}function Tt(r){let s,n,i,c,f,m,_,w,b,$,h,H,W,fe,T,pe,O,G,C,M,Fe,A,E,Ce,U,X,q,Y,xe,j,Q,D,P,ue,Z,v,I,ee,me,te,N,B,le,be,se,x,J,ne,Le,K,he,V;return{c(){s=l("p"),s.innerHTML=`The syntax basically follows the format
<code><span class="txt-success">OPERAND</span>
<span class="txt-danger">OPERATOR</span>
<span class="txt-success">OPERAND</span></code>, where:`,n=a(),i=l("ul"),c=l("li"),c.innerHTML=`<code class="txt-success">OPERAND</code> - could be any of the above field literal, string (single
or double quoted), number, null, true, false`,f=a(),m=l("li"),_=l("code"),_.textContent="OPERATOR",w=k(` - is one of:
`),b=l("br"),$=a(),h=l("ul"),H=l("li"),W=l("code"),W.textContent="=",fe=a(),T=l("span"),T.textContent="Equal",pe=a(),O=l("li"),G=l("code"),G.textContent="!=",C=a(),M=l("span"),M.textContent="NOT equal",Fe=a(),A=l("li"),E=l("code"),E.textContent=">",Ce=a(),U=l("span"),U.textContent="Greater than",X=a(),q=l("li"),Y=l("code"),Y.textContent=">=",xe=a(),j=l("span"),j.textContent="Greater than or equal",Q=a(),D=l("li"),P=l("code"),P.textContent="<",ue=a(),Z=l("span"),Z.textContent="Less than or equal",v=a(),I=l("li"),ee=l("code"),ee.textContent="<=",me=a(),te=l("span"),te.textContent="Less than or equal",N=a(),B=l("li"),le=l("code"),le.textContent="~",be=a(),se=l("span"),se.textContent=`Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for
wildcard match)`,x=a(),J=l("li"),ne=l("code"),ne.textContent="!~",Le=a(),K=l("span"),K.textContent=`NOT Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for
wildcard match)`,he=a(),V=l("p"),V.innerHTML=`To group and combine several expressions you could use brackets
<code>(...)</code>, <code>&amp;&amp;</code> (AND) and <code>||</code> (OR) tokens.`,d(_,"class","txt-danger"),d(W,"class","filter-op svelte-1w7s5nw"),d(T,"class","txt-hint"),d(G,"class","filter-op svelte-1w7s5nw"),d(M,"class","txt-hint"),d(E,"class","filter-op svelte-1w7s5nw"),d(U,"class","txt-hint"),d(Y,"class","filter-op svelte-1w7s5nw"),d(j,"class","txt-hint"),d(P,"class","filter-op svelte-1w7s5nw"),d(Z,"class","txt-hint"),d(ee,"class","filter-op svelte-1w7s5nw"),d(te,"class","txt-hint"),d(le,"class","filter-op svelte-1w7s5nw"),d(se,"class","txt-hint"),d(ne,"class","filter-op svelte-1w7s5nw"),d(K,"class","txt-hint")},m(F,R){p(F,s,R),p(F,n,R),p(F,i,R),e(i,c),e(i,f),e(i,m),e(m,_),e(m,w),e(m,b),e(m,$),e(m,h),e(h,H),e(H,W),e(H,fe),e(H,T),e(h,pe),e(h,O),e(O,G),e(O,C),e(O,M),e(h,Fe),e(h,A),e(A,E),e(A,Ce),e(A,U),e(h,X),e(h,q),e(q,Y),e(q,xe),e(q,j),e(h,Q),e(h,D),e(D,P),e(D,ue),e(D,Z),e(h,v),e(h,I),e(I,ee),e(I,me),e(I,te),e(h,N),e(h,B),e(B,le),e(B,be),e(B,se),e(h,x),e(h,J),e(J,ne),e(J,Le),e(J,K),p(F,he,R),p(F,V,R)},d(F){F&&u(s),F&&u(n),F&&u(i),F&&u(he),F&&u(V)}}}function Kt(r){let s,n,i,c,f;function m($,h){return $[0]?Jt:Qt}let _=m(r),w=_(r),b=r[0]&&Tt();return{c(){s=l("button"),w.c(),n=a(),b&&b.c(),i=qt(),d(s,"class","btn btn-sm btn-secondary m-t-5")},m($,h){p($,s,h),w.m(s,null),p($,n,h),b&&b.m($,h),p($,i,h),c||(f=Mt(s,"click",r[1]),c=!0)},p($,[h]){_!==(_=m($))&&(w.d(1),w=_($),w&&(w.c(),w.m(s,null))),$[0]?b||(b=Tt(),b.c(),b.m(i.parentNode,i)):b&&(b.d(1),b=null)},i:xt,o:xt,d($){$&&u(s),w.d(),$&&u(n),b&&b.d($),$&&u(i),c=!1,f()}}}function Vt(r,s,n){let i=!1;function c(){n(0,i=!i)}return[i,c]}class Wt extends Et{constructor(s){super(),Nt(this,s,Vt,Kt,Ht,{})}}function Pt(r,s,n){const i=r.slice();return i[6]=s[n],i}function Rt(r,s,n){const i=r.slice();return i[6]=s[n],i}function St(r){let s;return{c(){s=l("p"),s.innerHTML="Requires admin <code>Authorization:TOKEN</code> header",d(s,"class","txt-hint txt-sm txt-right")},m(n,i){p(n,s,i)},d(n){n&&u(s)}}}function Ot(r,s){let n,i=s[6].code+"",c,f,m,_;function w(){return s[5](s[6])}return{key:r,first:null,c(){n=l("div"),c=k(i),f=a(),d(n,"class","tab-item"),Ee(n,"active",s[2]===s[6].code),this.first=n},m(b,$){p(b,n,$),e(n,c),e(n,f),m||(_=Mt(n,"click",w),m=!0)},p(b,$){s=b,$&20&&Ee(n,"active",s[2]===s[6].code)},d(b){b&&u(n),m=!1,_()}}}function At(r,s){let n,i,c,f;return i=new Ae({props:{content:s[6].body}}),{key:r,first:null,c(){n=l("div"),ge(i.$$.fragment),c=a(),d(n,"class","tab-item"),Ee(n,"active",s[2]===s[6].code),this.first=n},m(m,_){p(m,n,_),ye(i,n,null),e(n,c),f=!0},p(m,_){s=m,(!f||_&20)&&Ee(n,"active",s[2]===s[6].code)},i(m){f||(ce(i.$$.fragment,m),f=!0)},o(m){de(i.$$.fragment,m),f=!1},d(m){m&&u(n),ve(i)}}}function Xt(r){var mt,bt,ht,_t,$t,kt;let s,n,i=r[0].name+"",c,f,m,_,w,b,$,h=r[0].name+"",H,W,fe,T,pe,O,G,C,M,Fe,A,E,Ce,U,X=r[0].name+"",q,Y,xe,j,Q,D,P,ue,Z,v,I,ee,me,te,N,B,le,be,se,x,J,ne,Le,K,he,V,F,R,Qe,ie,Ne,Je,He,Ke,_e,Ve,$e,We,ke,Xe,oe,Me,Ye,qe,Ze,y,et,we,tt,lt,st,De,nt,Ie,it,ot,at,Be,rt,ze,Te,Ge,ae,Pe,z=[],ct=new Map,dt,Re,S=[],ft=new Map,re;T=new jt({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${r[3]}');
...
// fetch a paginated records list
const resultList = await pb.collection('${(mt=r[0])==null?void 0:mt.name}').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
});
// you can also fetch all records at once via getFullList:
const records = await pb.collection('${(bt=r[0])==null?void 0:bt.name}').getFullList(200 /* batch size */, {
sort: '-created'
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('${(ht=r[0])==null?void 0:ht.name}').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${r[3]}');
...
// fetch a paginated records list
final result = await pb.collection('${(_t=r[0])==null?void 0:_t.name}').getList(
page: 1,
perPage: 50,
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
);
// alternatively you can also fetch all records at once via getFullList:
final records = await pb.collection('${($t=r[0])==null?void 0:$t.name}').getFullList(
batch: 200,
sort: '-created',
);
// or fetch only the first record that matches the specified filter
final record2 = await pb.collection('${(kt=r[0])==null?void 0:kt.name}').getFirstListItem(
'someField="test"',
expand: 'relField1,relField2.subRelField',
);
`}});let L=r[1]&&St();R=new Ae({props:{content:`
// DESC by created and ASC by id
?sort=-created,id
`}}),$e=new Ae({props:{content:`
?filter=(id='abc' && created>'2022-01-01')
`}}),ke=new Wt({}),we=new Ae({props:{content:"?expand=relField1,relField2.subRelField"}});let Oe=r[4];const pt=t=>t[6].code;for(let t=0;t<Oe.length;t+=1){let o=Rt(r,Oe,t),g=pt(o);ct.set(g,z[t]=Ot(g,o))}let Se=r[4];const ut=t=>t[6].code;for(let t=0;t<Se.length;t+=1){let o=Pt(r,Se,t),g=ut(o);ft.set(g,S[t]=At(g,o))}return{c(){s=l("h3"),n=k("List/Search ("),c=k(i),f=k(")"),m=a(),_=l("div"),w=l("p"),b=k("Fetch a paginated "),$=l("strong"),H=k(h),W=k(" records list, supporting sorting and filtering."),fe=a(),ge(T.$$.fragment),pe=a(),O=l("h6"),O.textContent="API details",G=a(),C=l("div"),M=l("strong"),M.textContent="GET",Fe=a(),A=l("div"),E=l("p"),Ce=k("/api/collections/"),U=l("strong"),q=k(X),Y=k("/records"),xe=a(),L&&L.c(),j=a(),Q=l("div"),Q.textContent="Query parameters",D=a(),P=l("table"),ue=l("thead"),ue.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Z=a(),v=l("tbody"),I=l("tr"),I.innerHTML=`<td>page</td>
<td><span class="label">Number</span></td>
<td>The page (aka. offset) of the paginated list (default to 1).</td>`,ee=a(),me=l("tr"),me.innerHTML=`<td>perPage</td>
<td><span class="label">Number</span></td>
<td>Specify the max returned records per page (default to 30).</td>`,te=a(),N=l("tr"),B=l("td"),B.textContent="sort",le=a(),be=l("td"),be.innerHTML='<span class="label">String</span>',se=a(),x=l("td"),J=k("Specify the records order attribute(s). "),ne=l("br"),Le=k(`
Add `),K=l("code"),K.textContent="-",he=k(" / "),V=l("code"),V.textContent="+",F=k(` (default) in front of the attribute for DESC / ASC order.
Ex.:
`),ge(R.$$.fragment),Qe=a(),ie=l("tr"),Ne=l("td"),Ne.textContent="filter",Je=a(),He=l("td"),He.innerHTML='<span class="label">String</span>',Ke=a(),_e=l("td"),Ve=k(`Filter the returned records. Ex.:
`),ge($e.$$.fragment),We=a(),ge(ke.$$.fragment),Xe=a(),oe=l("tr"),Me=l("td"),Me.textContent="expand",Ye=a(),qe=l("td"),qe.innerHTML='<span class="label">String</span>',Ze=a(),y=l("td"),et=k(`Auto expand record relations. Ex.:
`),ge(we.$$.fragment),tt=k(`
Supports up to 6-levels depth nested relations expansion. `),lt=l("br"),st=k(`
The expanded relations will be appended to each individual record under the
`),De=l("code"),De.textContent="expand",nt=k(" property (eg. "),Ie=l("code"),Ie.textContent='"expand": {"relField1": {...}, ...}',it=k(`).
`),ot=l("br"),at=k(`
Only the relations to which the account has permissions to `),Be=l("strong"),Be.textContent="view",rt=k(" will be expanded."),ze=a(),Te=l("div"),Te.textContent="Responses",Ge=a(),ae=l("div"),Pe=l("div");for(let t=0;t<z.length;t+=1)z[t].c();dt=a(),Re=l("div");for(let t=0;t<S.length;t+=1)S[t].c();d(s,"class","m-b-sm"),d(_,"class","content txt-lg m-b-sm"),d(O,"class","m-b-xs"),d(M,"class","label label-primary"),d(A,"class","content"),d(C,"class","alert alert-info"),d(Q,"class","section-title"),d(P,"class","table-compact table-border m-b-base"),d(Te,"class","section-title"),d(Pe,"class","tabs-header compact left"),d(Re,"class","tabs-content"),d(ae,"class","tabs")},m(t,o){p(t,s,o),e(s,n),e(s,c),e(s,f),p(t,m,o),p(t,_,o),e(_,w),e(w,b),e(w,$),e($,H),e(w,W),p(t,fe,o),ye(T,t,o),p(t,pe,o),p(t,O,o),p(t,G,o),p(t,C,o),e(C,M),e(C,Fe),e(C,A),e(A,E),e(E,Ce),e(E,U),e(U,q),e(E,Y),e(C,xe),L&&L.m(C,null),p(t,j,o),p(t,Q,o),p(t,D,o),p(t,P,o),e(P,ue),e(P,Z),e(P,v),e(v,I),e(v,ee),e(v,me),e(v,te),e(v,N),e(N,B),e(N,le),e(N,be),e(N,se),e(N,x),e(x,J),e(x,ne),e(x,Le),e(x,K),e(x,he),e(x,V),e(x,F),ye(R,x,null),e(v,Qe),e(v,ie),e(ie,Ne),e(ie,Je),e(ie,He),e(ie,Ke),e(ie,_e),e(_e,Ve),ye($e,_e,null),e(_e,We),ye(ke,_e,null),e(v,Xe),e(v,oe),e(oe,Me),e(oe,Ye),e(oe,qe),e(oe,Ze),e(oe,y),e(y,et),ye(we,y,null),e(y,tt),e(y,lt),e(y,st),e(y,De),e(y,nt),e(y,Ie),e(y,it),e(y,ot),e(y,at),e(y,Be),e(y,rt),p(t,ze,o),p(t,Te,o),p(t,Ge,o),p(t,ae,o),e(ae,Pe);for(let g=0;g<z.length;g+=1)z[g].m(Pe,null);e(ae,dt),e(ae,Re);for(let g=0;g<S.length;g+=1)S[g].m(Re,null);re=!0},p(t,[o]){var wt,gt,yt,vt,Ft,Ct;(!re||o&1)&&i!==(i=t[0].name+"")&&Ue(c,i),(!re||o&1)&&h!==(h=t[0].name+"")&&Ue(H,h);const g={};o&9&&(g.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${t[3]}');
...
// fetch a paginated records list
const resultList = await pb.collection('${(wt=t[0])==null?void 0:wt.name}').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
});
// you can also fetch all records at once via getFullList:
const records = await pb.collection('${(gt=t[0])==null?void 0:gt.name}').getFullList(200 /* batch size */, {
sort: '-created'
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('${(yt=t[0])==null?void 0:yt.name}').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});
`),o&9&&(g.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${t[3]}');
...
// fetch a paginated records list
final result = await pb.collection('${(vt=t[0])==null?void 0:vt.name}').getList(
page: 1,
perPage: 50,
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
);
// alternatively you can also fetch all records at once via getFullList:
final records = await pb.collection('${(Ft=t[0])==null?void 0:Ft.name}').getFullList(
batch: 200,
sort: '-created',
);
// or fetch only the first record that matches the specified filter
final record2 = await pb.collection('${(Ct=t[0])==null?void 0:Ct.name}').getFirstListItem(
'someField="test"',
expand: 'relField1,relField2.subRelField',
);
`),T.$set(g),(!re||o&1)&&X!==(X=t[0].name+"")&&Ue(q,X),t[1]?L||(L=St(),L.c(),L.m(C,null)):L&&(L.d(1),L=null),o&20&&(Oe=t[4],z=Lt(z,o,pt,1,t,Oe,ct,Pe,Dt,Ot,null,Rt)),o&20&&(Se=t[4],It(),S=Lt(S,o,ut,1,t,Se,ft,Re,Bt,At,null,Pt),zt())},i(t){if(!re){ce(T.$$.fragment,t),ce(R.$$.fragment,t),ce($e.$$.fragment,t),ce(ke.$$.fragment,t),ce(we.$$.fragment,t);for(let o=0;o<Se.length;o+=1)ce(S[o]);re=!0}},o(t){de(T.$$.fragment,t),de(R.$$.fragment,t),de($e.$$.fragment,t),de(ke.$$.fragment,t),de(we.$$.fragment,t);for(let o=0;o<S.length;o+=1)de(S[o]);re=!1},d(t){t&&u(s),t&&u(m),t&&u(_),t&&u(fe),ve(T,t),t&&u(pe),t&&u(O),t&&u(G),t&&u(C),L&&L.d(),t&&u(j),t&&u(Q),t&&u(D),t&&u(P),ve(R),ve($e),ve(ke),ve(we),t&&u(ze),t&&u(Te),t&&u(Ge),t&&u(ae);for(let o=0;o<z.length;o+=1)z[o].d();for(let o=0;o<S.length;o+=1)S[o].d()}}}function Yt(r,s,n){let i,c,{collection:f=new Gt}=s,m=200,_=[];const w=b=>n(2,m=b.code);return r.$$set=b=>{"collection"in b&&n(0,f=b.collection)},r.$$.update=()=>{r.$$.dirty&1&&n(1,i=(f==null?void 0:f.listRule)===null),r.$$.dirty&3&&f!=null&&f.id&&(_.push({code:200,body:JSON.stringify({page:1,perPage:30,totalPages:1,totalItems:2,items:[je.dummyCollectionRecord(f),je.dummyCollectionRecord(f)]},null,2)}),_.push({code:400,body:`
{
"code": 400,
"message": "Something went wrong while processing your request. Invalid filter.",
"data": {}
}
`}),i&&_.push({code:403,body:`
{
"code": 403,
"message": "Only admins can access this action.",
"data": {}
}
`}),_.push({code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}))},n(3,c=je.getApiExampleUrl(Ut.baseUrl)),[f,i,m,c,_,w]}class tl extends Et{constructor(s){super(),Nt(this,s,Yt,Xt,Ht,{collection:0})}}export{tl as default};
+1
View File
@@ -0,0 +1 @@
.filter-op.svelte-1w7s5nw{display:inline-block;vertical-align:top;margin-right:5px;width:30px;text-align:center;padding-left:0;padding-right:0}
+93
View File
@@ -0,0 +1,93 @@
import{S as Be,i as qe,s as Le,e as n,w as v,b as h,c as Te,f as b,g as r,h as s,m as Ie,x as U,P as ye,Q as Oe,k as Me,R as Re,n as Ve,t as te,a as le,o as d,d as Se,L as ze,C as De,p as He,r as j,u as Ue,O as je}from"./index.97f016a1.js";import{S as Ge}from"./SdkTabs.88269ae0.js";function Ee(a,l,o){const i=a.slice();return i[5]=l[o],i}function Ae(a,l,o){const i=a.slice();return i[5]=l[o],i}function Pe(a,l){let o,i=l[5].code+"",m,_,c,u;function f(){return l[4](l[5])}return{key:a,first:null,c(){o=n("button"),m=v(i),_=h(),b(o,"class","tab-item"),j(o,"active",l[1]===l[5].code),this.first=o},m(g,y){r(g,o,y),s(o,m),s(o,_),c||(u=Ue(o,"click",f),c=!0)},p(g,y){l=g,y&4&&i!==(i=l[5].code+"")&&U(m,i),y&6&&j(o,"active",l[1]===l[5].code)},d(g){g&&d(o),c=!1,u()}}}function Ce(a,l){let o,i,m,_;return i=new je({props:{content:l[5].body}}),{key:a,first:null,c(){o=n("div"),Te(i.$$.fragment),m=h(),b(o,"class","tab-item"),j(o,"active",l[1]===l[5].code),this.first=o},m(c,u){r(c,o,u),Ie(i,o,null),s(o,m),_=!0},p(c,u){l=c;const f={};u&4&&(f.content=l[5].body),i.$set(f),(!_||u&6)&&j(o,"active",l[1]===l[5].code)},i(c){_||(te(i.$$.fragment,c),_=!0)},o(c){le(i.$$.fragment,c),_=!1},d(c){c&&d(o),Se(i)}}}function Ke(a){var be,_e,he,ke;let l,o,i=a[0].name+"",m,_,c,u,f,g,y,M=a[0].name+"",G,oe,se,K,N,E,Q,T,F,w,R,ae,V,A,ie,J,z=a[0].name+"",W,ne,X,ce,re,D,Y,I,Z,S,x,B,ee,P,q,$=[],de=new Map,ue,L,k=[],pe=new Map,C;E=new Ge({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${a[3]}');
...
await pb.collection('${(be=a[0])==null?void 0:be.name}').authViaEmail('test@example.com', '123456');
const result = await pb.collection('${(_e=a[0])==null?void 0:_e.name}').listExternalAuths(
pb.authStore.model.id
);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${a[3]}');
...
await pb.collection('${(he=a[0])==null?void 0:he.name}').authViaEmail('test@example.com', '123456');
final result = await pb.collection('${(ke=a[0])==null?void 0:ke.name}').listExternalAuths(
pb.authStore.model.id,
);
`}});let H=a[2];const me=e=>e[5].code;for(let e=0;e<H.length;e+=1){let t=Ae(a,H,e),p=me(t);de.set(p,$[e]=Pe(p,t))}let O=a[2];const fe=e=>e[5].code;for(let e=0;e<O.length;e+=1){let t=Ee(a,O,e),p=fe(t);pe.set(p,k[e]=Ce(p,t))}return{c(){l=n("h3"),o=v("List OAuth2 accounts ("),m=v(i),_=v(")"),c=h(),u=n("div"),f=n("p"),g=v("Returns a list with all OAuth2 providers linked to a single "),y=n("strong"),G=v(M),oe=v("."),se=h(),K=n("p"),K.textContent="Only admins and the account owner can access this action.",N=h(),Te(E.$$.fragment),Q=h(),T=n("h6"),T.textContent="API details",F=h(),w=n("div"),R=n("strong"),R.textContent="GET",ae=h(),V=n("div"),A=n("p"),ie=v("/api/collections/"),J=n("strong"),W=v(z),ne=v("/records/"),X=n("strong"),X.textContent=":id",ce=v("/external-auths"),re=h(),D=n("p"),D.innerHTML="Requires <code>Authorization:TOKEN</code> header",Y=h(),I=n("div"),I.textContent="Path Parameters",Z=h(),S=n("table"),S.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr></thead>
<tbody><tr><td>id</td>
<td><span class="label">String</span></td>
<td>ID of the auth record.</td></tr></tbody>`,x=h(),B=n("div"),B.textContent="Responses",ee=h(),P=n("div"),q=n("div");for(let e=0;e<$.length;e+=1)$[e].c();ue=h(),L=n("div");for(let e=0;e<k.length;e+=1)k[e].c();b(l,"class","m-b-sm"),b(u,"class","content txt-lg m-b-sm"),b(T,"class","m-b-xs"),b(R,"class","label label-primary"),b(V,"class","content"),b(D,"class","txt-hint txt-sm txt-right"),b(w,"class","alert alert-info"),b(I,"class","section-title"),b(S,"class","table-compact table-border m-b-base"),b(B,"class","section-title"),b(q,"class","tabs-header compact left"),b(L,"class","tabs-content"),b(P,"class","tabs")},m(e,t){r(e,l,t),s(l,o),s(l,m),s(l,_),r(e,c,t),r(e,u,t),s(u,f),s(f,g),s(f,y),s(y,G),s(f,oe),s(u,se),s(u,K),r(e,N,t),Ie(E,e,t),r(e,Q,t),r(e,T,t),r(e,F,t),r(e,w,t),s(w,R),s(w,ae),s(w,V),s(V,A),s(A,ie),s(A,J),s(J,W),s(A,ne),s(A,X),s(A,ce),s(w,re),s(w,D),r(e,Y,t),r(e,I,t),r(e,Z,t),r(e,S,t),r(e,x,t),r(e,B,t),r(e,ee,t),r(e,P,t),s(P,q);for(let p=0;p<$.length;p+=1)$[p].m(q,null);s(P,ue),s(P,L);for(let p=0;p<k.length;p+=1)k[p].m(L,null);C=!0},p(e,[t]){var ve,we,$e,ge;(!C||t&1)&&i!==(i=e[0].name+"")&&U(m,i),(!C||t&1)&&M!==(M=e[0].name+"")&&U(G,M);const p={};t&9&&(p.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(ve=e[0])==null?void 0:ve.name}').authViaEmail('test@example.com', '123456');
const result = await pb.collection('${(we=e[0])==null?void 0:we.name}').listExternalAuths(
pb.authStore.model.id
);
`),t&9&&(p.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${($e=e[0])==null?void 0:$e.name}').authViaEmail('test@example.com', '123456');
final result = await pb.collection('${(ge=e[0])==null?void 0:ge.name}').listExternalAuths(
pb.authStore.model.id,
);
`),E.$set(p),(!C||t&1)&&z!==(z=e[0].name+"")&&U(W,z),t&6&&(H=e[2],$=ye($,t,me,1,e,H,de,q,Oe,Pe,null,Ae)),t&6&&(O=e[2],Me(),k=ye(k,t,fe,1,e,O,pe,L,Re,Ce,null,Ee),Ve())},i(e){if(!C){te(E.$$.fragment,e);for(let t=0;t<O.length;t+=1)te(k[t]);C=!0}},o(e){le(E.$$.fragment,e);for(let t=0;t<k.length;t+=1)le(k[t]);C=!1},d(e){e&&d(l),e&&d(c),e&&d(u),e&&d(N),Se(E,e),e&&d(Q),e&&d(T),e&&d(F),e&&d(w),e&&d(Y),e&&d(I),e&&d(Z),e&&d(S),e&&d(x),e&&d(B),e&&d(ee),e&&d(P);for(let t=0;t<$.length;t+=1)$[t].d();for(let t=0;t<k.length;t+=1)k[t].d()}}}function Ne(a,l,o){let i,{collection:m=new ze}=l,_=200,c=[];const u=f=>o(1,_=f.code);return a.$$set=f=>{"collection"in f&&o(0,m=f.collection)},a.$$.update=()=>{a.$$.dirty&1&&o(2,c=[{code:200,body:`
[
{
"id": "8171022dc95a4e8",
"created": "2022-09-01 10:24:18.434",
"updated": "2022-09-01 10:24:18.889",
"recordId": "e22581b6f1d44ea",
"collectionId": "${m.id}",
"provider": "google",
"providerId": "2da15468800514p",
},
{
"id": "171022dc895a4e8",
"created": "2022-09-01 10:24:18.434",
"updated": "2022-09-01 10:24:18.889",
"recordId": "e22581b6f1d44ea",
"collectionId": "${m.id}",
"provider": "twitter",
"providerId": "720688005140514",
}
]
`},{code:401,body:`
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`},{code:403,body:`
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`},{code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}])},o(3,i=De.getApiExampleUrl(He.baseUrl)),[m,_,c,i,u]}class Je extends Be{constructor(l){super(),qe(this,l,Ne,Ke,Le,{collection:0})}}export{Je as default};
@@ -1,2 +1,2 @@
import{S as E,i as G,s as I,F as K,c as A,m as B,t as H,a as N,d as T,C as M,q as J,e as c,w as q,b as C,f as u,r as L,g as b,h as _,u as h,v as O,j as Q,l as U,o as w,A as V,p as W,B as X,D as Y,x as Z,z as S}from"./index.e13041a6.js";function y(f){let e,o,s;return{c(){e=q("for "),o=c("strong"),s=q(f[3]),u(o,"class","txt-nowrap")},m(l,t){b(l,e,t),b(l,o,t),_(o,s)},p(l,t){t&8&&Z(s,l[3])},d(l){l&&w(e),l&&w(o)}}}function x(f){let e,o,s,l,t,r,p,d;return{c(){e=c("label"),o=q("New password"),l=C(),t=c("input"),u(e,"for",s=f[8]),u(t,"type","password"),u(t,"id",r=f[8]),t.required=!0,t.autofocus=!0},m(n,i){b(n,e,i),_(e,o),b(n,l,i),b(n,t,i),S(t,f[0]),t.focus(),p||(d=h(t,"input",f[6]),p=!0)},p(n,i){i&256&&s!==(s=n[8])&&u(e,"for",s),i&256&&r!==(r=n[8])&&u(t,"id",r),i&1&&t.value!==n[0]&&S(t,n[0])},d(n){n&&w(e),n&&w(l),n&&w(t),p=!1,d()}}}function ee(f){let e,o,s,l,t,r,p,d;return{c(){e=c("label"),o=q("New password confirm"),l=C(),t=c("input"),u(e,"for",s=f[8]),u(t,"type","password"),u(t,"id",r=f[8]),t.required=!0},m(n,i){b(n,e,i),_(e,o),b(n,l,i),b(n,t,i),S(t,f[1]),p||(d=h(t,"input",f[7]),p=!0)},p(n,i){i&256&&s!==(s=n[8])&&u(e,"for",s),i&256&&r!==(r=n[8])&&u(t,"id",r),i&2&&t.value!==n[1]&&S(t,n[1])},d(n){n&&w(e),n&&w(l),n&&w(t),p=!1,d()}}}function te(f){let e,o,s,l,t,r,p,d,n,i,g,R,P,v,k,F,j,m=f[3]&&y(f);return r=new J({props:{class:"form-field required",name:"password",$$slots:{default:[x,({uniqueId:a})=>({8:a}),({uniqueId:a})=>a?256:0]},$$scope:{ctx:f}}}),d=new J({props:{class:"form-field required",name:"passwordConfirm",$$slots:{default:[ee,({uniqueId:a})=>({8:a}),({uniqueId:a})=>a?256:0]},$$scope:{ctx:f}}}),{c(){e=c("form"),o=c("div"),s=c("h4"),l=q(`Reset your admin password
import{S as E,i as G,s as I,F as K,c as A,m as B,t as H,a as N,d as T,C as M,q as J,e as c,w as q,b as C,f as u,r as L,g as b,h as _,u as h,v as O,j as Q,l as U,o as w,A as V,p as W,B as X,D as Y,x as Z,z as S}from"./index.97f016a1.js";function y(f){let e,o,s;return{c(){e=q("for "),o=c("strong"),s=q(f[3]),u(o,"class","txt-nowrap")},m(l,t){b(l,e,t),b(l,o,t),_(o,s)},p(l,t){t&8&&Z(s,l[3])},d(l){l&&w(e),l&&w(o)}}}function x(f){let e,o,s,l,t,r,p,d;return{c(){e=c("label"),o=q("New password"),l=C(),t=c("input"),u(e,"for",s=f[8]),u(t,"type","password"),u(t,"id",r=f[8]),t.required=!0,t.autofocus=!0},m(n,i){b(n,e,i),_(e,o),b(n,l,i),b(n,t,i),S(t,f[0]),t.focus(),p||(d=h(t,"input",f[6]),p=!0)},p(n,i){i&256&&s!==(s=n[8])&&u(e,"for",s),i&256&&r!==(r=n[8])&&u(t,"id",r),i&1&&t.value!==n[0]&&S(t,n[0])},d(n){n&&w(e),n&&w(l),n&&w(t),p=!1,d()}}}function ee(f){let e,o,s,l,t,r,p,d;return{c(){e=c("label"),o=q("New password confirm"),l=C(),t=c("input"),u(e,"for",s=f[8]),u(t,"type","password"),u(t,"id",r=f[8]),t.required=!0},m(n,i){b(n,e,i),_(e,o),b(n,l,i),b(n,t,i),S(t,f[1]),p||(d=h(t,"input",f[7]),p=!0)},p(n,i){i&256&&s!==(s=n[8])&&u(e,"for",s),i&256&&r!==(r=n[8])&&u(t,"id",r),i&2&&t.value!==n[1]&&S(t,n[1])},d(n){n&&w(e),n&&w(l),n&&w(t),p=!1,d()}}}function te(f){let e,o,s,l,t,r,p,d,n,i,g,R,P,v,k,F,j,m=f[3]&&y(f);return r=new J({props:{class:"form-field required",name:"password",$$slots:{default:[x,({uniqueId:a})=>({8:a}),({uniqueId:a})=>a?256:0]},$$scope:{ctx:f}}}),d=new J({props:{class:"form-field required",name:"passwordConfirm",$$slots:{default:[ee,({uniqueId:a})=>({8:a}),({uniqueId:a})=>a?256:0]},$$scope:{ctx:f}}}),{c(){e=c("form"),o=c("div"),s=c("h4"),l=q(`Reset your admin password
`),m&&m.c(),t=C(),A(r.$$.fragment),p=C(),A(d.$$.fragment),n=C(),i=c("button"),g=c("span"),g.textContent="Set new password",R=C(),P=c("div"),v=c("a"),v.textContent="Back to login",u(s,"class","m-b-xs"),u(o,"class","content txt-center m-b-sm"),u(g,"class","txt"),u(i,"type","submit"),u(i,"class","btn btn-lg btn-block"),i.disabled=f[2],L(i,"btn-loading",f[2]),u(e,"class","m-b-base"),u(v,"href","/login"),u(v,"class","link-hint"),u(P,"class","content txt-center")},m(a,$){b(a,e,$),_(e,o),_(o,s),_(s,l),m&&m.m(s,null),_(e,t),B(r,e,null),_(e,p),B(d,e,null),_(e,n),_(e,i),_(i,g),b(a,R,$),b(a,P,$),_(P,v),k=!0,F||(j=[h(e,"submit",O(f[4])),Q(U.call(null,v))],F=!0)},p(a,$){a[3]?m?m.p(a,$):(m=y(a),m.c(),m.m(s,null)):m&&(m.d(1),m=null);const z={};$&769&&(z.$$scope={dirty:$,ctx:a}),r.$set(z);const D={};$&770&&(D.$$scope={dirty:$,ctx:a}),d.$set(D),(!k||$&4)&&(i.disabled=a[2]),(!k||$&4)&&L(i,"btn-loading",a[2])},i(a){k||(H(r.$$.fragment,a),H(d.$$.fragment,a),k=!0)},o(a){N(r.$$.fragment,a),N(d.$$.fragment,a),k=!1},d(a){a&&w(e),m&&m.d(),T(r),T(d),a&&w(R),a&&w(P),F=!1,V(j)}}}function se(f){let e,o;return e=new K({props:{$$slots:{default:[te]},$$scope:{ctx:f}}}),{c(){A(e.$$.fragment)},m(s,l){B(e,s,l),o=!0},p(s,[l]){const t={};l&527&&(t.$$scope={dirty:l,ctx:s}),e.$set(t)},i(s){o||(H(e.$$.fragment,s),o=!0)},o(s){N(e.$$.fragment,s),o=!1},d(s){T(e,s)}}}function le(f,e,o){let s,{params:l}=e,t="",r="",p=!1;async function d(){if(!p){o(2,p=!0);try{await W.admins.confirmPasswordReset(l==null?void 0:l.token,t,r),X("Successfully set a new admin password."),Y("/")}catch(g){W.errorResponseHandler(g)}o(2,p=!1)}}function n(){t=this.value,o(0,t)}function i(){r=this.value,o(1,r)}return f.$$set=g=>{"params"in g&&o(5,l=g.params)},f.$$.update=()=>{f.$$.dirty&32&&o(3,s=M.getJWTPayload(l==null?void 0:l.token).email||"")},[t,r,p,s,d,l,n,i]}class ae extends E{constructor(e){super(),G(this,e,le,se,I,{params:5})}}export{ae as default};
@@ -1,2 +1,2 @@
import{S as M,i as T,s as j,F as z,c as H,m as L,t as w,a as y,d as S,b as g,e as _,f as p,g as k,h as d,j as A,l as B,k as N,n as D,o as v,p as C,q as G,r as F,u as E,v as I,w as h,x as J,y as P,z as R}from"./index.e13041a6.js";function K(c){let e,s,n,l,t,o,f,m,i,a,b,u;return l=new G({props:{class:"form-field required",name:"email",$$slots:{default:[Q,({uniqueId:r})=>({5:r}),({uniqueId:r})=>r?32:0]},$$scope:{ctx:c}}}),{c(){e=_("form"),s=_("div"),s.innerHTML=`<h4 class="m-b-xs">Forgotten admin password</h4>
import{S as M,i as T,s as j,F as z,c as H,m as L,t as w,a as y,d as S,b as g,e as _,f as p,g as k,h as d,j as A,l as B,k as N,n as D,o as v,p as C,q as G,r as F,u as E,v as I,w as h,x as J,y as P,z as R}from"./index.97f016a1.js";function K(c){let e,s,n,l,t,o,f,m,i,a,b,u;return l=new G({props:{class:"form-field required",name:"email",$$slots:{default:[Q,({uniqueId:r})=>({5:r}),({uniqueId:r})=>r?32:0]},$$scope:{ctx:c}}}),{c(){e=_("form"),s=_("div"),s.innerHTML=`<h4 class="m-b-xs">Forgotten admin password</h4>
<p>Enter the email associated with your account and we\u2019ll send you a recovery link:</p>`,n=g(),H(l.$$.fragment),t=g(),o=_("button"),f=_("i"),m=g(),i=_("span"),i.textContent="Send recovery link",p(s,"class","content txt-center m-b-sm"),p(f,"class","ri-mail-send-line"),p(i,"class","txt"),p(o,"type","submit"),p(o,"class","btn btn-lg btn-block"),o.disabled=c[1],F(o,"btn-loading",c[1]),p(e,"class","m-b-base")},m(r,$){k(r,e,$),d(e,s),d(e,n),L(l,e,null),d(e,t),d(e,o),d(o,f),d(o,m),d(o,i),a=!0,b||(u=E(e,"submit",I(c[3])),b=!0)},p(r,$){const q={};$&97&&(q.$$scope={dirty:$,ctx:r}),l.$set(q),(!a||$&2)&&(o.disabled=r[1]),(!a||$&2)&&F(o,"btn-loading",r[1])},i(r){a||(w(l.$$.fragment,r),a=!0)},o(r){y(l.$$.fragment,r),a=!1},d(r){r&&v(e),S(l),b=!1,u()}}}function O(c){let e,s,n,l,t,o,f,m,i;return{c(){e=_("div"),s=_("div"),s.innerHTML='<i class="ri-checkbox-circle-line"></i>',n=g(),l=_("div"),t=_("p"),o=h("Check "),f=_("strong"),m=h(c[0]),i=h(" for the recovery link."),p(s,"class","icon"),p(f,"class","txt-nowrap"),p(l,"class","content"),p(e,"class","alert alert-success")},m(a,b){k(a,e,b),d(e,s),d(e,n),d(e,l),d(l,t),d(t,o),d(t,f),d(f,m),d(t,i)},p(a,b){b&1&&J(m,a[0])},i:P,o:P,d(a){a&&v(e)}}}function Q(c){let e,s,n,l,t,o,f,m;return{c(){e=_("label"),s=h("Email"),l=g(),t=_("input"),p(e,"for",n=c[5]),p(t,"type","email"),p(t,"id",o=c[5]),t.required=!0,t.autofocus=!0},m(i,a){k(i,e,a),d(e,s),k(i,l,a),k(i,t,a),R(t,c[0]),t.focus(),f||(m=E(t,"input",c[4]),f=!0)},p(i,a){a&32&&n!==(n=i[5])&&p(e,"for",n),a&32&&o!==(o=i[5])&&p(t,"id",o),a&1&&t.value!==i[0]&&R(t,i[0])},d(i){i&&v(e),i&&v(l),i&&v(t),f=!1,m()}}}function U(c){let e,s,n,l,t,o,f,m;const i=[O,K],a=[];function b(u,r){return u[2]?0:1}return e=b(c),s=a[e]=i[e](c),{c(){s.c(),n=g(),l=_("div"),t=_("a"),t.textContent="Back to login",p(t,"href","/login"),p(t,"class","link-hint"),p(l,"class","content txt-center")},m(u,r){a[e].m(u,r),k(u,n,r),k(u,l,r),d(l,t),o=!0,f||(m=A(B.call(null,t)),f=!0)},p(u,r){let $=e;e=b(u),e===$?a[e].p(u,r):(N(),y(a[$],1,1,()=>{a[$]=null}),D(),s=a[e],s?s.p(u,r):(s=a[e]=i[e](u),s.c()),w(s,1),s.m(n.parentNode,n))},i(u){o||(w(s),o=!0)},o(u){y(s),o=!1},d(u){a[e].d(u),u&&v(n),u&&v(l),f=!1,m()}}}function V(c){let e,s;return e=new z({props:{$$slots:{default:[U]},$$scope:{ctx:c}}}),{c(){H(e.$$.fragment)},m(n,l){L(e,n,l),s=!0},p(n,[l]){const t={};l&71&&(t.$$scope={dirty:l,ctx:n}),e.$set(t)},i(n){s||(w(e.$$.fragment,n),s=!0)},o(n){y(e.$$.fragment,n),s=!1},d(n){S(e,n)}}}function W(c,e,s){let n="",l=!1,t=!1;async function o(){if(!l){s(1,l=!0);try{await C.admins.requestPasswordReset(n),s(2,t=!0)}catch(m){C.errorResponseHandler(m)}s(1,l=!1)}}function f(){n=this.value,s(0,n)}return[n,l,t,o,f]}class Y extends M{constructor(e){super(),T(this,e,W,V,j,{})}}export{Y as default};
@@ -0,0 +1,4 @@
import{S as z,i as G,s as I,F as J,c as T,m as L,t as v,a as y,d as R,C as M,E as N,g as _,k as W,n as Y,o as b,G as j,H as A,p as B,q as D,e as m,w as C,b as h,f as d,r as P,h as k,u as q,v as K,y as E,x as O,z as F}from"./index.97f016a1.js";function Q(r){let e,t,s,l,n,o,c,i,a,u,g,$,p=r[3]&&S(r);return o=new D({props:{class:"form-field required",name:"password",$$slots:{default:[V,({uniqueId:f})=>({8:f}),({uniqueId:f})=>f?256:0]},$$scope:{ctx:r}}}),{c(){e=m("form"),t=m("div"),s=m("h5"),l=C(`Type your password to confirm changing your email address
`),p&&p.c(),n=h(),T(o.$$.fragment),c=h(),i=m("button"),a=m("span"),a.textContent="Confirm new email",d(t,"class","content txt-center m-b-base"),d(a,"class","txt"),d(i,"type","submit"),d(i,"class","btn btn-lg btn-block"),i.disabled=r[1],P(i,"btn-loading",r[1])},m(f,w){_(f,e,w),k(e,t),k(t,s),k(s,l),p&&p.m(s,null),k(e,n),L(o,e,null),k(e,c),k(e,i),k(i,a),u=!0,g||($=q(e,"submit",K(r[4])),g=!0)},p(f,w){f[3]?p?p.p(f,w):(p=S(f),p.c(),p.m(s,null)):p&&(p.d(1),p=null);const H={};w&769&&(H.$$scope={dirty:w,ctx:f}),o.$set(H),(!u||w&2)&&(i.disabled=f[1]),(!u||w&2)&&P(i,"btn-loading",f[1])},i(f){u||(v(o.$$.fragment,f),u=!0)},o(f){y(o.$$.fragment,f),u=!1},d(f){f&&b(e),p&&p.d(),R(o),g=!1,$()}}}function U(r){let e,t,s,l,n;return{c(){e=m("div"),e.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully changed the user email address.</p>
<p>You can now sign in with your new email address.</p></div>`,t=h(),s=m("button"),s.textContent="Close",d(e,"class","alert alert-success"),d(s,"type","button"),d(s,"class","btn btn-secondary btn-block")},m(o,c){_(o,e,c),_(o,t,c),_(o,s,c),l||(n=q(s,"click",r[6]),l=!0)},p:E,i:E,o:E,d(o){o&&b(e),o&&b(t),o&&b(s),l=!1,n()}}}function S(r){let e,t,s;return{c(){e=C("to "),t=m("strong"),s=C(r[3]),d(t,"class","txt-nowrap")},m(l,n){_(l,e,n),_(l,t,n),k(t,s)},p(l,n){n&8&&O(s,l[3])},d(l){l&&b(e),l&&b(t)}}}function V(r){let e,t,s,l,n,o,c,i;return{c(){e=m("label"),t=C("Password"),l=h(),n=m("input"),d(e,"for",s=r[8]),d(n,"type","password"),d(n,"id",o=r[8]),n.required=!0,n.autofocus=!0},m(a,u){_(a,e,u),k(e,t),_(a,l,u),_(a,n,u),F(n,r[0]),n.focus(),c||(i=q(n,"input",r[7]),c=!0)},p(a,u){u&256&&s!==(s=a[8])&&d(e,"for",s),u&256&&o!==(o=a[8])&&d(n,"id",o),u&1&&n.value!==a[0]&&F(n,a[0])},d(a){a&&b(e),a&&b(l),a&&b(n),c=!1,i()}}}function X(r){let e,t,s,l;const n=[U,Q],o=[];function c(i,a){return i[2]?0:1}return e=c(r),t=o[e]=n[e](r),{c(){t.c(),s=N()},m(i,a){o[e].m(i,a),_(i,s,a),l=!0},p(i,a){let u=e;e=c(i),e===u?o[e].p(i,a):(W(),y(o[u],1,1,()=>{o[u]=null}),Y(),t=o[e],t?t.p(i,a):(t=o[e]=n[e](i),t.c()),v(t,1),t.m(s.parentNode,s))},i(i){l||(v(t),l=!0)},o(i){y(t),l=!1},d(i){o[e].d(i),i&&b(s)}}}function Z(r){let e,t;return e=new J({props:{nobranding:!0,$$slots:{default:[X]},$$scope:{ctx:r}}}),{c(){T(e.$$.fragment)},m(s,l){L(e,s,l),t=!0},p(s,[l]){const n={};l&527&&(n.$$scope={dirty:l,ctx:s}),e.$set(n)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){y(e.$$.fragment,s),t=!1},d(s){R(e,s)}}}function x(r,e,t){let s,{params:l}=e,n="",o=!1,c=!1;async function i(){if(o)return;t(1,o=!0);const g=new j("../");try{const $=A(l==null?void 0:l.token);await g.collection($.collectionId).confirmEmailChange(l==null?void 0:l.token,n),t(2,c=!0)}catch($){B.errorResponseHandler($)}t(1,o=!1)}const a=()=>window.close();function u(){n=this.value,t(0,n)}return r.$$set=g=>{"params"in g&&t(5,l=g.params)},r.$$.update=()=>{r.$$.dirty&32&&t(3,s=M.getJWTPayload(l==null?void 0:l.token).newEmail||"")},[n,o,c,s,i,l,a,u]}class te extends z{constructor(e){super(),G(this,e,x,Z,I,{params:5})}}export{te as default};
@@ -0,0 +1,4 @@
import{S as J,i as M,s as W,F as Y,c as F,m as N,t as P,a as q,d as E,C as j,E as A,g as _,k as B,n as D,o as m,G as K,H as O,p as Q,q as z,e as b,w as R,b as y,f as p,r as G,h as w,u as H,v as U,y as S,x as V,z as h}from"./index.97f016a1.js";function X(r){let e,l,s,n,t,o,c,u,i,a,v,k,g,C,d=r[4]&&I(r);return o=new z({props:{class:"form-field required",name:"password",$$slots:{default:[x,({uniqueId:f})=>({10:f}),({uniqueId:f})=>f?1024:0]},$$scope:{ctx:r}}}),u=new z({props:{class:"form-field required",name:"passwordConfirm",$$slots:{default:[ee,({uniqueId:f})=>({10:f}),({uniqueId:f})=>f?1024:0]},$$scope:{ctx:r}}}),{c(){e=b("form"),l=b("div"),s=b("h5"),n=R(`Reset your user password
`),d&&d.c(),t=y(),F(o.$$.fragment),c=y(),F(u.$$.fragment),i=y(),a=b("button"),v=b("span"),v.textContent="Set new password",p(l,"class","content txt-center m-b-base"),p(v,"class","txt"),p(a,"type","submit"),p(a,"class","btn btn-lg btn-block"),a.disabled=r[2],G(a,"btn-loading",r[2])},m(f,$){_(f,e,$),w(e,l),w(l,s),w(s,n),d&&d.m(s,null),w(e,t),N(o,e,null),w(e,c),N(u,e,null),w(e,i),w(e,a),w(a,v),k=!0,g||(C=H(e,"submit",U(r[5])),g=!0)},p(f,$){f[4]?d?d.p(f,$):(d=I(f),d.c(),d.m(s,null)):d&&(d.d(1),d=null);const L={};$&3073&&(L.$$scope={dirty:$,ctx:f}),o.$set(L);const T={};$&3074&&(T.$$scope={dirty:$,ctx:f}),u.$set(T),(!k||$&4)&&(a.disabled=f[2]),(!k||$&4)&&G(a,"btn-loading",f[2])},i(f){k||(P(o.$$.fragment,f),P(u.$$.fragment,f),k=!0)},o(f){q(o.$$.fragment,f),q(u.$$.fragment,f),k=!1},d(f){f&&m(e),d&&d.d(),E(o),E(u),g=!1,C()}}}function Z(r){let e,l,s,n,t;return{c(){e=b("div"),e.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully changed the user password.</p>
<p>You can now sign in with your new password.</p></div>`,l=y(),s=b("button"),s.textContent="Close",p(e,"class","alert alert-success"),p(s,"type","button"),p(s,"class","btn btn-secondary btn-block")},m(o,c){_(o,e,c),_(o,l,c),_(o,s,c),n||(t=H(s,"click",r[7]),n=!0)},p:S,i:S,o:S,d(o){o&&m(e),o&&m(l),o&&m(s),n=!1,t()}}}function I(r){let e,l,s;return{c(){e=R("for "),l=b("strong"),s=R(r[4])},m(n,t){_(n,e,t),_(n,l,t),w(l,s)},p(n,t){t&16&&V(s,n[4])},d(n){n&&m(e),n&&m(l)}}}function x(r){let e,l,s,n,t,o,c,u;return{c(){e=b("label"),l=R("New password"),n=y(),t=b("input"),p(e,"for",s=r[10]),p(t,"type","password"),p(t,"id",o=r[10]),t.required=!0,t.autofocus=!0},m(i,a){_(i,e,a),w(e,l),_(i,n,a),_(i,t,a),h(t,r[0]),t.focus(),c||(u=H(t,"input",r[8]),c=!0)},p(i,a){a&1024&&s!==(s=i[10])&&p(e,"for",s),a&1024&&o!==(o=i[10])&&p(t,"id",o),a&1&&t.value!==i[0]&&h(t,i[0])},d(i){i&&m(e),i&&m(n),i&&m(t),c=!1,u()}}}function ee(r){let e,l,s,n,t,o,c,u;return{c(){e=b("label"),l=R("New password confirm"),n=y(),t=b("input"),p(e,"for",s=r[10]),p(t,"type","password"),p(t,"id",o=r[10]),t.required=!0},m(i,a){_(i,e,a),w(e,l),_(i,n,a),_(i,t,a),h(t,r[1]),c||(u=H(t,"input",r[9]),c=!0)},p(i,a){a&1024&&s!==(s=i[10])&&p(e,"for",s),a&1024&&o!==(o=i[10])&&p(t,"id",o),a&2&&t.value!==i[1]&&h(t,i[1])},d(i){i&&m(e),i&&m(n),i&&m(t),c=!1,u()}}}function te(r){let e,l,s,n;const t=[Z,X],o=[];function c(u,i){return u[3]?0:1}return e=c(r),l=o[e]=t[e](r),{c(){l.c(),s=A()},m(u,i){o[e].m(u,i),_(u,s,i),n=!0},p(u,i){let a=e;e=c(u),e===a?o[e].p(u,i):(B(),q(o[a],1,1,()=>{o[a]=null}),D(),l=o[e],l?l.p(u,i):(l=o[e]=t[e](u),l.c()),P(l,1),l.m(s.parentNode,s))},i(u){n||(P(l),n=!0)},o(u){q(l),n=!1},d(u){o[e].d(u),u&&m(s)}}}function se(r){let e,l;return e=new Y({props:{nobranding:!0,$$slots:{default:[te]},$$scope:{ctx:r}}}),{c(){F(e.$$.fragment)},m(s,n){N(e,s,n),l=!0},p(s,[n]){const t={};n&2079&&(t.$$scope={dirty:n,ctx:s}),e.$set(t)},i(s){l||(P(e.$$.fragment,s),l=!0)},o(s){q(e.$$.fragment,s),l=!1},d(s){E(e,s)}}}function le(r,e,l){let s,{params:n}=e,t="",o="",c=!1,u=!1;async function i(){if(c)return;l(2,c=!0);const g=new K("../");try{const C=O(n==null?void 0:n.token);await g.collection(C.collectionId).confirmPasswordReset(n==null?void 0:n.token,t,o),l(3,u=!0)}catch(C){Q.errorResponseHandler(C)}l(2,c=!1)}const a=()=>window.close();function v(){t=this.value,l(0,t)}function k(){o=this.value,l(1,o)}return r.$$set=g=>{"params"in g&&l(6,n=g.params)},r.$$.update=()=>{r.$$.dirty&64&&l(4,s=j.getJWTPayload(n==null?void 0:n.token).email||"")},[t,o,c,u,s,i,n,a,v,k]}class oe extends J{constructor(e){super(),M(this,e,le,se,W,{params:6})}}export{oe as default};
@@ -0,0 +1,3 @@
import{S as v,i as y,s as w,F as x,c as C,m as g,t as $,a as H,d as L,G as M,H as P,E as S,g as r,o as a,e as u,b as _,f,u as b,y as p}from"./index.97f016a1.js";function T(o){let t,s,e,n,l;return{c(){t=u("div"),t.innerHTML=`<div class="icon"><i class="ri-error-warning-line"></i></div>
<div class="content txt-bold"><p>Invalid or expired verification token.</p></div>`,s=_(),e=u("button"),e.textContent="Close",f(t,"class","alert alert-danger"),f(e,"type","button"),f(e,"class","btn btn-secondary btn-block")},m(i,c){r(i,t,c),r(i,s,c),r(i,e,c),n||(l=b(e,"click",o[4]),n=!0)},p,d(i){i&&a(t),i&&a(s),i&&a(e),n=!1,l()}}}function E(o){let t,s,e,n,l;return{c(){t=u("div"),t.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully verified email address.</p></div>`,s=_(),e=u("button"),e.textContent="Close",f(t,"class","alert alert-success"),f(e,"type","button"),f(e,"class","btn btn-secondary btn-block")},m(i,c){r(i,t,c),r(i,s,c),r(i,e,c),n||(l=b(e,"click",o[3]),n=!0)},p,d(i){i&&a(t),i&&a(s),i&&a(e),n=!1,l()}}}function F(o){let t;return{c(){t=u("div"),t.innerHTML='<div class="loader loader-lg"><em>Please wait...</em></div>',f(t,"class","txt-center")},m(s,e){r(s,t,e)},p,d(s){s&&a(t)}}}function I(o){let t;function s(l,i){return l[1]?F:l[0]?E:T}let e=s(o),n=e(o);return{c(){n.c(),t=S()},m(l,i){n.m(l,i),r(l,t,i)},p(l,i){e===(e=s(l))&&n?n.p(l,i):(n.d(1),n=e(l),n&&(n.c(),n.m(t.parentNode,t)))},d(l){n.d(l),l&&a(t)}}}function V(o){let t,s;return t=new x({props:{nobranding:!0,$$slots:{default:[I]},$$scope:{ctx:o}}}),{c(){C(t.$$.fragment)},m(e,n){g(t,e,n),s=!0},p(e,[n]){const l={};n&67&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){s||($(t.$$.fragment,e),s=!0)},o(e){H(t.$$.fragment,e),s=!1},d(e){L(t,e)}}}function q(o,t,s){let{params:e}=t,n=!1,l=!1;i();async function i(){s(1,l=!0);const d=new M("../");try{const m=P(e==null?void 0:e.token);await d.collection(m.collectionId).confirmVerification(e==null?void 0:e.token),s(0,n=!0)}catch{s(0,n=!1)}s(1,l=!1)}const c=()=>window.close(),k=()=>window.close();return o.$$set=d=>{"params"in d&&s(2,e=d.params)},[n,l,e,c,k]}class N extends v{constructor(t){super(),y(this,t,q,V,w,{params:2})}}export{N as default};
-4
View File
@@ -1,4 +0,0 @@
import{S as G,i as J,s as M,F as N,c as T,m as L,t as v,a as y,d as z,C as R,E as U,g as _,k as W,n as Y,o as b,G as j,p as A,q as B,e as m,w as C,b as h,f as d,r as F,h as k,u as q,v as D,y as E,x as I,z as H}from"./index.e13041a6.js";function K(r){let e,t,s,l,n,o,c,a,i,u,g,$,p=r[3]&&S(r);return o=new B({props:{class:"form-field required",name:"password",$$slots:{default:[Q,({uniqueId:f})=>({8:f}),({uniqueId:f})=>f?256:0]},$$scope:{ctx:r}}}),{c(){e=m("form"),t=m("div"),s=m("h5"),l=C(`Type your password to confirm changing your email address
`),p&&p.c(),n=h(),T(o.$$.fragment),c=h(),a=m("button"),i=m("span"),i.textContent="Confirm new email",d(t,"class","content txt-center m-b-base"),d(i,"class","txt"),d(a,"type","submit"),d(a,"class","btn btn-lg btn-block"),a.disabled=r[1],F(a,"btn-loading",r[1])},m(f,w){_(f,e,w),k(e,t),k(t,s),k(s,l),p&&p.m(s,null),k(e,n),L(o,e,null),k(e,c),k(e,a),k(a,i),u=!0,g||($=q(e,"submit",D(r[4])),g=!0)},p(f,w){f[3]?p?p.p(f,w):(p=S(f),p.c(),p.m(s,null)):p&&(p.d(1),p=null);const P={};w&769&&(P.$$scope={dirty:w,ctx:f}),o.$set(P),(!u||w&2)&&(a.disabled=f[1]),(!u||w&2)&&F(a,"btn-loading",f[1])},i(f){u||(v(o.$$.fragment,f),u=!0)},o(f){y(o.$$.fragment,f),u=!1},d(f){f&&b(e),p&&p.d(),z(o),g=!1,$()}}}function O(r){let e,t,s,l,n;return{c(){e=m("div"),e.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully changed the user email address.</p>
<p>You can now sign in with your new email address.</p></div>`,t=h(),s=m("button"),s.textContent="Close",d(e,"class","alert alert-success"),d(s,"type","button"),d(s,"class","btn btn-secondary btn-block")},m(o,c){_(o,e,c),_(o,t,c),_(o,s,c),l||(n=q(s,"click",r[6]),l=!0)},p:E,i:E,o:E,d(o){o&&b(e),o&&b(t),o&&b(s),l=!1,n()}}}function S(r){let e,t,s;return{c(){e=C("to "),t=m("strong"),s=C(r[3]),d(t,"class","txt-nowrap")},m(l,n){_(l,e,n),_(l,t,n),k(t,s)},p(l,n){n&8&&I(s,l[3])},d(l){l&&b(e),l&&b(t)}}}function Q(r){let e,t,s,l,n,o,c,a;return{c(){e=m("label"),t=C("Password"),l=h(),n=m("input"),d(e,"for",s=r[8]),d(n,"type","password"),d(n,"id",o=r[8]),n.required=!0,n.autofocus=!0},m(i,u){_(i,e,u),k(e,t),_(i,l,u),_(i,n,u),H(n,r[0]),n.focus(),c||(a=q(n,"input",r[7]),c=!0)},p(i,u){u&256&&s!==(s=i[8])&&d(e,"for",s),u&256&&o!==(o=i[8])&&d(n,"id",o),u&1&&n.value!==i[0]&&H(n,i[0])},d(i){i&&b(e),i&&b(l),i&&b(n),c=!1,a()}}}function V(r){let e,t,s,l;const n=[O,K],o=[];function c(a,i){return a[2]?0:1}return e=c(r),t=o[e]=n[e](r),{c(){t.c(),s=U()},m(a,i){o[e].m(a,i),_(a,s,i),l=!0},p(a,i){let u=e;e=c(a),e===u?o[e].p(a,i):(W(),y(o[u],1,1,()=>{o[u]=null}),Y(),t=o[e],t?t.p(a,i):(t=o[e]=n[e](a),t.c()),v(t,1),t.m(s.parentNode,s))},i(a){l||(v(t),l=!0)},o(a){y(t),l=!1},d(a){o[e].d(a),a&&b(s)}}}function X(r){let e,t;return e=new N({props:{nobranding:!0,$$slots:{default:[V]},$$scope:{ctx:r}}}),{c(){T(e.$$.fragment)},m(s,l){L(e,s,l),t=!0},p(s,[l]){const n={};l&527&&(n.$$scope={dirty:l,ctx:s}),e.$set(n)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){y(e.$$.fragment,s),t=!1},d(s){z(e,s)}}}function Z(r,e,t){let s,{params:l}=e,n="",o=!1,c=!1;async function a(){if(o)return;t(1,o=!0);const g=new j("../");try{await g.users.confirmEmailChange(l==null?void 0:l.token,n),t(2,c=!0)}catch($){A.errorResponseHandler($)}t(1,o=!1)}const i=()=>window.close();function u(){n=this.value,t(0,n)}return r.$$set=g=>{"params"in g&&t(5,l=g.params)},r.$$.update=()=>{r.$$.dirty&32&&t(3,s=R.getJWTPayload(l==null?void 0:l.token).newEmail||"")},[n,o,c,s,a,l,i,u]}class ee extends G{constructor(e){super(),J(this,e,Z,X,M,{params:5})}}export{ee as default};
@@ -1,4 +0,0 @@
import{S as M,i as U,s as W,F as Y,c as H,m as N,t as P,a as q,d as L,C as j,E as A,g as _,k as B,n as D,o as m,G as I,p as K,q as E,e as b,w as y,b as C,f as c,r as G,h as w,u as S,v as O,y as F,x as Q,z as R}from"./index.e13041a6.js";function V(i){let e,l,s,n,t,o,p,u,r,a,v,k,g,h,d=i[4]&&J(i);return o=new E({props:{class:"form-field required",name:"password",$$slots:{default:[Z,({uniqueId:f})=>({10:f}),({uniqueId:f})=>f?1024:0]},$$scope:{ctx:i}}}),u=new E({props:{class:"form-field required",name:"passwordConfirm",$$slots:{default:[x,({uniqueId:f})=>({10:f}),({uniqueId:f})=>f?1024:0]},$$scope:{ctx:i}}}),{c(){e=b("form"),l=b("div"),s=b("h5"),n=y(`Reset your user password
`),d&&d.c(),t=C(),H(o.$$.fragment),p=C(),H(u.$$.fragment),r=C(),a=b("button"),v=b("span"),v.textContent="Set new password",c(l,"class","content txt-center m-b-base"),c(v,"class","txt"),c(a,"type","submit"),c(a,"class","btn btn-lg btn-block"),a.disabled=i[2],G(a,"btn-loading",i[2])},m(f,$){_(f,e,$),w(e,l),w(l,s),w(s,n),d&&d.m(s,null),w(e,t),N(o,e,null),w(e,p),N(u,e,null),w(e,r),w(e,a),w(a,v),k=!0,g||(h=S(e,"submit",O(i[5])),g=!0)},p(f,$){f[4]?d?d.p(f,$):(d=J(f),d.c(),d.m(s,null)):d&&(d.d(1),d=null);const T={};$&3073&&(T.$$scope={dirty:$,ctx:f}),o.$set(T);const z={};$&3074&&(z.$$scope={dirty:$,ctx:f}),u.$set(z),(!k||$&4)&&(a.disabled=f[2]),(!k||$&4)&&G(a,"btn-loading",f[2])},i(f){k||(P(o.$$.fragment,f),P(u.$$.fragment,f),k=!0)},o(f){q(o.$$.fragment,f),q(u.$$.fragment,f),k=!1},d(f){f&&m(e),d&&d.d(),L(o),L(u),g=!1,h()}}}function X(i){let e,l,s,n,t;return{c(){e=b("div"),e.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully changed the user password.</p>
<p>You can now sign in with your new password.</p></div>`,l=C(),s=b("button"),s.textContent="Close",c(e,"class","alert alert-success"),c(s,"type","button"),c(s,"class","btn btn-secondary btn-block")},m(o,p){_(o,e,p),_(o,l,p),_(o,s,p),n||(t=S(s,"click",i[7]),n=!0)},p:F,i:F,o:F,d(o){o&&m(e),o&&m(l),o&&m(s),n=!1,t()}}}function J(i){let e,l,s;return{c(){e=y("for "),l=b("strong"),s=y(i[4])},m(n,t){_(n,e,t),_(n,l,t),w(l,s)},p(n,t){t&16&&Q(s,n[4])},d(n){n&&m(e),n&&m(l)}}}function Z(i){let e,l,s,n,t,o,p,u;return{c(){e=b("label"),l=y("New password"),n=C(),t=b("input"),c(e,"for",s=i[10]),c(t,"type","password"),c(t,"id",o=i[10]),t.required=!0,t.autofocus=!0},m(r,a){_(r,e,a),w(e,l),_(r,n,a),_(r,t,a),R(t,i[0]),t.focus(),p||(u=S(t,"input",i[8]),p=!0)},p(r,a){a&1024&&s!==(s=r[10])&&c(e,"for",s),a&1024&&o!==(o=r[10])&&c(t,"id",o),a&1&&t.value!==r[0]&&R(t,r[0])},d(r){r&&m(e),r&&m(n),r&&m(t),p=!1,u()}}}function x(i){let e,l,s,n,t,o,p,u;return{c(){e=b("label"),l=y("New password confirm"),n=C(),t=b("input"),c(e,"for",s=i[10]),c(t,"type","password"),c(t,"id",o=i[10]),t.required=!0},m(r,a){_(r,e,a),w(e,l),_(r,n,a),_(r,t,a),R(t,i[1]),p||(u=S(t,"input",i[9]),p=!0)},p(r,a){a&1024&&s!==(s=r[10])&&c(e,"for",s),a&1024&&o!==(o=r[10])&&c(t,"id",o),a&2&&t.value!==r[1]&&R(t,r[1])},d(r){r&&m(e),r&&m(n),r&&m(t),p=!1,u()}}}function ee(i){let e,l,s,n;const t=[X,V],o=[];function p(u,r){return u[3]?0:1}return e=p(i),l=o[e]=t[e](i),{c(){l.c(),s=A()},m(u,r){o[e].m(u,r),_(u,s,r),n=!0},p(u,r){let a=e;e=p(u),e===a?o[e].p(u,r):(B(),q(o[a],1,1,()=>{o[a]=null}),D(),l=o[e],l?l.p(u,r):(l=o[e]=t[e](u),l.c()),P(l,1),l.m(s.parentNode,s))},i(u){n||(P(l),n=!0)},o(u){q(l),n=!1},d(u){o[e].d(u),u&&m(s)}}}function te(i){let e,l;return e=new Y({props:{nobranding:!0,$$slots:{default:[ee]},$$scope:{ctx:i}}}),{c(){H(e.$$.fragment)},m(s,n){N(e,s,n),l=!0},p(s,[n]){const t={};n&2079&&(t.$$scope={dirty:n,ctx:s}),e.$set(t)},i(s){l||(P(e.$$.fragment,s),l=!0)},o(s){q(e.$$.fragment,s),l=!1},d(s){L(e,s)}}}function se(i,e,l){let s,{params:n}=e,t="",o="",p=!1,u=!1;async function r(){if(p)return;l(2,p=!0);const g=new I("../");try{await g.users.confirmPasswordReset(n==null?void 0:n.token,t,o),l(3,u=!0)}catch(h){K.errorResponseHandler(h)}l(2,p=!1)}const a=()=>window.close();function v(){t=this.value,l(0,t)}function k(){o=this.value,l(1,o)}return i.$$set=g=>{"params"in g&&l(6,n=g.params)},i.$$.update=()=>{i.$$.dirty&64&&l(4,s=j.getJWTPayload(n==null?void 0:n.token).email||"")},[t,o,p,u,s,r,n,a,v,k]}class ne extends M{constructor(e){super(),U(this,e,se,te,W,{params:6})}}export{ne as default};
@@ -1,3 +0,0 @@
import{S as k,i as v,s as y,F as w,c as x,m as C,t as g,a as $,d as L,G as H,E as M,g as r,o as a,e as u,b as m,f,u as _,y as p}from"./index.e13041a6.js";function P(c){let t,s,e,n,i;return{c(){t=u("div"),t.innerHTML=`<div class="icon"><i class="ri-error-warning-line"></i></div>
<div class="content txt-bold"><p>Invalid or expired verification token.</p></div>`,s=m(),e=u("button"),e.textContent="Close",f(t,"class","alert alert-danger"),f(e,"type","button"),f(e,"class","btn btn-secondary btn-block")},m(l,o){r(l,t,o),r(l,s,o),r(l,e,o),n||(i=_(e,"click",c[4]),n=!0)},p,d(l){l&&a(t),l&&a(s),l&&a(e),n=!1,i()}}}function S(c){let t,s,e,n,i;return{c(){t=u("div"),t.innerHTML=`<div class="icon"><i class="ri-checkbox-circle-line"></i></div>
<div class="content txt-bold"><p>Successfully verified email address.</p></div>`,s=m(),e=u("button"),e.textContent="Close",f(t,"class","alert alert-success"),f(e,"type","button"),f(e,"class","btn btn-secondary btn-block")},m(l,o){r(l,t,o),r(l,s,o),r(l,e,o),n||(i=_(e,"click",c[3]),n=!0)},p,d(l){l&&a(t),l&&a(s),l&&a(e),n=!1,i()}}}function T(c){let t;return{c(){t=u("div"),t.innerHTML='<div class="loader loader-lg"><em>Please wait...</em></div>',f(t,"class","txt-center")},m(s,e){r(s,t,e)},p,d(s){s&&a(t)}}}function F(c){let t;function s(i,l){return i[1]?T:i[0]?S:P}let e=s(c),n=e(c);return{c(){n.c(),t=M()},m(i,l){n.m(i,l),r(i,t,l)},p(i,l){e===(e=s(i))&&n?n.p(i,l):(n.d(1),n=e(i),n&&(n.c(),n.m(t.parentNode,t)))},d(i){n.d(i),i&&a(t)}}}function V(c){let t,s;return t=new w({props:{nobranding:!0,$$slots:{default:[F]},$$scope:{ctx:c}}}),{c(){x(t.$$.fragment)},m(e,n){C(t,e,n),s=!0},p(e,[n]){const i={};n&67&&(i.$$scope={dirty:n,ctx:e}),t.$set(i)},i(e){s||(g(t.$$.fragment,e),s=!0)},o(e){$(t.$$.fragment,e),s=!1},d(e){L(t,e)}}}function q(c,t,s){let{params:e}=t,n=!1,i=!1;l();async function l(){s(1,i=!0);const d=new H("../");try{await d.users.confirmVerification(e==null?void 0:e.token),s(0,n=!0)}catch{s(0,n=!1)}s(1,i=!1)}const o=()=>window.close(),b=()=>window.close();return c.$$set=d=>{"params"in d&&s(2,e=d.params)},[n,i,e,o,b]}class I extends k{constructor(t){super(),v(this,t,q,V,y,{params:2})}}export{I as default};
+103
View File
@@ -0,0 +1,103 @@
import{S as ee,i as oe,s as te,O as se,C as I,e as u,w as E,b as a,c as K,f as p,g as s,h as P,m as Q,x as ne,t as X,a as Z,o as n,d as x,L as ie,p as ce}from"./index.97f016a1.js";import{S as re}from"./SdkTabs.88269ae0.js";function le(t){var B,U,W,L,A,H,T,q;let i,m,c=t[0].name+"",b,d,k,f,S,v,w,r,_,$,O,g,y,h,D,l,R;return r=new re({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${t[1]}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${(B=t[0])==null?void 0:B.name}').subscribe(function (e) {
console.log(e.record);
});
// Subscribe to changes in a single record
pb.collection('${(U=t[0])==null?void 0:U.name}').subscribeOne('RECORD_ID', function (e) {
console.log(e.record);
});
// Unsubscribe
pb.collection('${(W=t[0])==null?void 0:W.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${(L=t[0])==null?void 0:L.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${t[1]}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${(A=t[0])==null?void 0:A.name}').subscribe((e) {
print(e.record);
});
// Subscribe to changes in a single record
pb.collection('${(H=t[0])==null?void 0:H.name}').subscribeOne('RECORD_ID', (e) {
print(e.record);
});
// Unsubscribe
pb.collection('${(T=t[0])==null?void 0:T.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${(q=t[0])==null?void 0:q.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`}}),l=new se({props:{content:JSON.stringify({action:"create",record:I.dummyCollectionRecord(t[0])},null,2).replace('"action": "create"','"action": "create" // create, update or delete')}}),{c(){i=u("h3"),m=E("Realtime ("),b=E(c),d=E(")"),k=a(),f=u("div"),f.innerHTML=`<p>Subscribe to realtime changes via Server-Sent Events (SSE).</p>
<p>Events are sent for <strong>create</strong>, <strong>update</strong>
and <strong>delete</strong> record operations (see &quot;Event data format&quot; section below).</p>`,S=a(),v=u("div"),v.innerHTML=`<div class="icon"><i class="ri-information-line"></i></div>
<div class="contet"><p><strong>You could subscribe to a single record or to an entire collection.</strong></p>
<p>When you subscribe to a <strong>single record</strong>, the collection&#39;s
<strong>ViewRule</strong> will be used to determine whether the subscriber has access to receive the
event message.</p>
<p>When you subscribe to an <strong>entire collection</strong>, the collection&#39;s
<strong>ListRule</strong> will be used to determine whether the subscriber has access to receive the
event message.</p></div>`,w=a(),K(r.$$.fragment),_=a(),$=u("h6"),$.textContent="API details",O=a(),g=u("div"),g.innerHTML=`<strong class="label label-primary">SSE</strong>
<div class="content"><p>/api/realtime</p></div>`,y=a(),h=u("div"),h.textContent="Event data format",D=a(),K(l.$$.fragment),p(i,"class","m-b-sm"),p(f,"class","content txt-lg m-b-sm"),p(v,"class","alert alert-info m-t-10 m-b-sm"),p($,"class","m-b-xs"),p(g,"class","alert"),p(h,"class","section-title")},m(e,o){s(e,i,o),P(i,m),P(i,b),P(i,d),s(e,k,o),s(e,f,o),s(e,S,o),s(e,v,o),s(e,w,o),Q(r,e,o),s(e,_,o),s(e,$,o),s(e,O,o),s(e,g,o),s(e,y,o),s(e,h,o),s(e,D,o),Q(l,e,o),R=!0},p(e,[o]){var j,J,N,V,Y,z,F,G;(!R||o&1)&&c!==(c=e[0].name+"")&&ne(b,c);const C={};o&3&&(C.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[1]}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${(j=e[0])==null?void 0:j.name}').subscribe(function (e) {
console.log(e.record);
});
// Subscribe to changes in a single record
pb.collection('${(J=e[0])==null?void 0:J.name}').subscribeOne('RECORD_ID', function (e) {
console.log(e.record);
});
// Unsubscribe
pb.collection('${(N=e[0])==null?void 0:N.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${(V=e[0])==null?void 0:V.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`),o&3&&(C.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[1]}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${(Y=e[0])==null?void 0:Y.name}').subscribe((e) {
print(e.record);
});
// Subscribe to changes in a single record
pb.collection('${(z=e[0])==null?void 0:z.name}').subscribeOne('RECORD_ID', (e) {
print(e.record);
});
// Unsubscribe
pb.collection('${(F=e[0])==null?void 0:F.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${(G=e[0])==null?void 0:G.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`),r.$set(C);const M={};o&1&&(M.content=JSON.stringify({action:"create",record:I.dummyCollectionRecord(e[0])},null,2).replace('"action": "create"','"action": "create" // create, update or delete')),l.$set(M)},i(e){R||(X(r.$$.fragment,e),X(l.$$.fragment,e),R=!0)},o(e){Z(r.$$.fragment,e),Z(l.$$.fragment,e),R=!1},d(e){e&&n(i),e&&n(k),e&&n(f),e&&n(S),e&&n(v),e&&n(w),x(r,e),e&&n(_),e&&n($),e&&n(O),e&&n(g),e&&n(y),e&&n(h),e&&n(D),x(l,e)}}}function ae(t,i,m){let c,{collection:b=new ie}=i;return t.$$set=d=>{"collection"in d&&m(0,b=d.collection)},m(1,c=I.getApiExampleUrl(ce.baseUrl)),[b,c]}class pe extends ee{constructor(i){super(),oe(this,i,ae,le,te,{collection:0})}}export{pe as default};
+70
View File
@@ -0,0 +1,70 @@
import{S as Pe,i as Te,s as Be,e as c,w as v,b as h,c as Ce,f,g as r,h as n,m as Ee,x as D,P as ve,Q as Se,k as Re,R as Me,n as Ae,t as x,a as ee,o as m,d as ye,L as Ve,C as ze,p as He,r as I,u as Le,O as Oe}from"./index.97f016a1.js";import{S as Ue}from"./SdkTabs.88269ae0.js";function we(o,l,s){const a=o.slice();return a[5]=l[s],a}function ge(o,l,s){const a=o.slice();return a[5]=l[s],a}function $e(o,l){let s,a=l[5].code+"",_,b,i,p;function u(){return l[4](l[5])}return{key:o,first:null,c(){s=c("button"),_=v(a),b=h(),f(s,"class","tab-item"),I(s,"active",l[1]===l[5].code),this.first=s},m($,q){r($,s,q),n(s,_),n(s,b),i||(p=Le(s,"click",u),i=!0)},p($,q){l=$,q&4&&a!==(a=l[5].code+"")&&D(_,a),q&6&&I(s,"active",l[1]===l[5].code)},d($){$&&m(s),i=!1,p()}}}function qe(o,l){let s,a,_,b;return a=new Oe({props:{content:l[5].body}}),{key:o,first:null,c(){s=c("div"),Ce(a.$$.fragment),_=h(),f(s,"class","tab-item"),I(s,"active",l[1]===l[5].code),this.first=s},m(i,p){r(i,s,p),Ee(a,s,null),n(s,_),b=!0},p(i,p){l=i;const u={};p&4&&(u.content=l[5].body),a.$set(u),(!b||p&6)&&I(s,"active",l[1]===l[5].code)},i(i){b||(x(a.$$.fragment,i),b=!0)},o(i){ee(a.$$.fragment,i),b=!1},d(i){i&&m(s),ye(a)}}}function je(o){var de,pe,ue,fe;let l,s,a=o[0].name+"",_,b,i,p,u,$,q,z=o[0].name+"",F,te,K,C,N,P,Q,w,H,le,L,T,se,G,O=o[0].name+"",J,ae,oe,U,W,B,X,S,Y,R,Z,E,M,g=[],ne=new Map,ie,A,k=[],ce=new Map,y;C=new Ue({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${o[3]}');
...
await pb.collection('${(de=o[0])==null?void 0:de.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(pe=o[0])==null?void 0:pe.name}').requestEmailChange('new@example.com');
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${o[3]}');
...
await pb.collection('${(ue=o[0])==null?void 0:ue.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(fe=o[0])==null?void 0:fe.name}').requestEmailChange('new@example.com');
`}});let j=o[2];const re=e=>e[5].code;for(let e=0;e<j.length;e+=1){let t=ge(o,j,e),d=re(t);ne.set(d,g[e]=$e(d,t))}let V=o[2];const me=e=>e[5].code;for(let e=0;e<V.length;e+=1){let t=we(o,V,e),d=me(t);ce.set(d,k[e]=qe(d,t))}return{c(){l=c("h3"),s=v("Request email change ("),_=v(a),b=v(")"),i=h(),p=c("div"),u=c("p"),$=v("Sends "),q=c("strong"),F=v(z),te=v(" email change request."),K=h(),Ce(C.$$.fragment),N=h(),P=c("h6"),P.textContent="API details",Q=h(),w=c("div"),H=c("strong"),H.textContent="POST",le=h(),L=c("div"),T=c("p"),se=v("/api/collections/"),G=c("strong"),J=v(O),ae=v("/confirm-email-change"),oe=h(),U=c("p"),U.innerHTML="Requires record <code>Authorization:TOKEN</code> header",W=h(),B=c("div"),B.textContent="Body Parameters",X=h(),S=c("table"),S.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>newEmail</span></div></td>
<td><span class="label">String</span></td>
<td>The new email address to send the change email request.</td></tr></tbody>`,Y=h(),R=c("div"),R.textContent="Responses",Z=h(),E=c("div"),M=c("div");for(let e=0;e<g.length;e+=1)g[e].c();ie=h(),A=c("div");for(let e=0;e<k.length;e+=1)k[e].c();f(l,"class","m-b-sm"),f(p,"class","content txt-lg m-b-sm"),f(P,"class","m-b-xs"),f(H,"class","label label-primary"),f(L,"class","content"),f(U,"class","txt-hint txt-sm txt-right"),f(w,"class","alert alert-success"),f(B,"class","section-title"),f(S,"class","table-compact table-border m-b-base"),f(R,"class","section-title"),f(M,"class","tabs-header compact left"),f(A,"class","tabs-content"),f(E,"class","tabs")},m(e,t){r(e,l,t),n(l,s),n(l,_),n(l,b),r(e,i,t),r(e,p,t),n(p,u),n(u,$),n(u,q),n(q,F),n(u,te),r(e,K,t),Ee(C,e,t),r(e,N,t),r(e,P,t),r(e,Q,t),r(e,w,t),n(w,H),n(w,le),n(w,L),n(L,T),n(T,se),n(T,G),n(G,J),n(T,ae),n(w,oe),n(w,U),r(e,W,t),r(e,B,t),r(e,X,t),r(e,S,t),r(e,Y,t),r(e,R,t),r(e,Z,t),r(e,E,t),n(E,M);for(let d=0;d<g.length;d+=1)g[d].m(M,null);n(E,ie),n(E,A);for(let d=0;d<k.length;d+=1)k[d].m(A,null);y=!0},p(e,[t]){var be,_e,he,ke;(!y||t&1)&&a!==(a=e[0].name+"")&&D(_,a),(!y||t&1)&&z!==(z=e[0].name+"")&&D(F,z);const d={};t&9&&(d.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(be=e[0])==null?void 0:be.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(_e=e[0])==null?void 0:_e.name}').requestEmailChange('new@example.com');
`),t&9&&(d.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${(he=e[0])==null?void 0:he.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(ke=e[0])==null?void 0:ke.name}').requestEmailChange('new@example.com');
`),C.$set(d),(!y||t&1)&&O!==(O=e[0].name+"")&&D(J,O),t&6&&(j=e[2],g=ve(g,t,re,1,e,j,ne,M,Se,$e,null,ge)),t&6&&(V=e[2],Re(),k=ve(k,t,me,1,e,V,ce,A,Me,qe,null,we),Ae())},i(e){if(!y){x(C.$$.fragment,e);for(let t=0;t<V.length;t+=1)x(k[t]);y=!0}},o(e){ee(C.$$.fragment,e);for(let t=0;t<k.length;t+=1)ee(k[t]);y=!1},d(e){e&&m(l),e&&m(i),e&&m(p),e&&m(K),ye(C,e),e&&m(N),e&&m(P),e&&m(Q),e&&m(w),e&&m(W),e&&m(B),e&&m(X),e&&m(S),e&&m(Y),e&&m(R),e&&m(Z),e&&m(E);for(let t=0;t<g.length;t+=1)g[t].d();for(let t=0;t<k.length;t+=1)k[t].d()}}}function De(o,l,s){let a,{collection:_=new Ve}=l,b=204,i=[];const p=u=>s(1,b=u.code);return o.$$set=u=>{"collection"in u&&s(0,_=u.collection)},s(3,a=ze.getApiExampleUrl(He.baseUrl)),s(2,i=[{code:204,body:"null"},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"newEmail": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`},{code:401,body:`
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`},{code:403,body:`
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`}]),[_,b,i,a,p]}class Ke extends Pe{constructor(l){super(),Te(this,l,De,je,Be,{collection:0})}}export{Ke as default};
+50
View File
@@ -0,0 +1,50 @@
import{S as Pe,i as $e,s as qe,e as c,w,b as v,c as ve,f as b,g as r,h as n,m as we,x as E,P as ue,Q as Re,k as ge,R as ye,n as Be,t as Z,a as x,o as d,d as he,L as Ce,C as Se,p as Te,r as F,u as Me,O as Ae}from"./index.97f016a1.js";import{S as Ue}from"./SdkTabs.88269ae0.js";function me(a,s,l){const o=a.slice();return o[5]=s[l],o}function be(a,s,l){const o=a.slice();return o[5]=s[l],o}function _e(a,s){let l,o=s[5].code+"",_,m,i,p;function u(){return s[4](s[5])}return{key:a,first:null,c(){l=c("button"),_=w(o),m=v(),b(l,"class","tab-item"),F(l,"active",s[1]===s[5].code),this.first=l},m(P,$){r(P,l,$),n(l,_),n(l,m),i||(p=Me(l,"click",u),i=!0)},p(P,$){s=P,$&4&&o!==(o=s[5].code+"")&&E(_,o),$&6&&F(l,"active",s[1]===s[5].code)},d(P){P&&d(l),i=!1,p()}}}function ke(a,s){let l,o,_,m;return o=new Ae({props:{content:s[5].body}}),{key:a,first:null,c(){l=c("div"),ve(o.$$.fragment),_=v(),b(l,"class","tab-item"),F(l,"active",s[1]===s[5].code),this.first=l},m(i,p){r(i,l,p),we(o,l,null),n(l,_),m=!0},p(i,p){s=i;const u={};p&4&&(u.content=s[5].body),o.$set(u),(!m||p&6)&&F(l,"active",s[1]===s[5].code)},i(i){m||(Z(o.$$.fragment,i),m=!0)},o(i){x(o.$$.fragment,i),m=!1},d(i){i&&d(l),he(o)}}}function je(a){var re,de;let s,l,o=a[0].name+"",_,m,i,p,u,P,$,D=a[0].name+"",Q,ee,z,q,G,B,J,R,H,te,I,C,se,K,L=a[0].name+"",N,le,V,S,W,T,X,M,Y,g,A,h=[],oe=new Map,ae,U,k=[],ne=new Map,y;q=new Ue({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${a[3]}');
...
await pb.collection('${(re=a[0])==null?void 0:re.name}').requestPasswordReset('test@example.com');
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${a[3]}');
...
await pb.collection('${(de=a[0])==null?void 0:de.name}').requestPasswordReset('test@example.com');
`}});let O=a[2];const ie=e=>e[5].code;for(let e=0;e<O.length;e+=1){let t=be(a,O,e),f=ie(t);oe.set(f,h[e]=_e(f,t))}let j=a[2];const ce=e=>e[5].code;for(let e=0;e<j.length;e+=1){let t=me(a,j,e),f=ce(t);ne.set(f,k[e]=ke(f,t))}return{c(){s=c("h3"),l=w("Request password reset ("),_=w(o),m=w(")"),i=v(),p=c("div"),u=c("p"),P=w("Sends "),$=c("strong"),Q=w(D),ee=w(" password reset email request."),z=v(),ve(q.$$.fragment),G=v(),B=c("h6"),B.textContent="API details",J=v(),R=c("div"),H=c("strong"),H.textContent="POST",te=v(),I=c("div"),C=c("p"),se=w("/api/collections/"),K=c("strong"),N=w(L),le=w("/request-password-reset"),V=v(),S=c("div"),S.textContent="Body Parameters",W=v(),T=c("table"),T.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>email</span></div></td>
<td><span class="label">String</span></td>
<td>The auth record email address to send the password reset request (if exists).</td></tr></tbody>`,X=v(),M=c("div"),M.textContent="Responses",Y=v(),g=c("div"),A=c("div");for(let e=0;e<h.length;e+=1)h[e].c();ae=v(),U=c("div");for(let e=0;e<k.length;e+=1)k[e].c();b(s,"class","m-b-sm"),b(p,"class","content txt-lg m-b-sm"),b(B,"class","m-b-xs"),b(H,"class","label label-primary"),b(I,"class","content"),b(R,"class","alert alert-success"),b(S,"class","section-title"),b(T,"class","table-compact table-border m-b-base"),b(M,"class","section-title"),b(A,"class","tabs-header compact left"),b(U,"class","tabs-content"),b(g,"class","tabs")},m(e,t){r(e,s,t),n(s,l),n(s,_),n(s,m),r(e,i,t),r(e,p,t),n(p,u),n(u,P),n(u,$),n($,Q),n(u,ee),r(e,z,t),we(q,e,t),r(e,G,t),r(e,B,t),r(e,J,t),r(e,R,t),n(R,H),n(R,te),n(R,I),n(I,C),n(C,se),n(C,K),n(K,N),n(C,le),r(e,V,t),r(e,S,t),r(e,W,t),r(e,T,t),r(e,X,t),r(e,M,t),r(e,Y,t),r(e,g,t),n(g,A);for(let f=0;f<h.length;f+=1)h[f].m(A,null);n(g,ae),n(g,U);for(let f=0;f<k.length;f+=1)k[f].m(U,null);y=!0},p(e,[t]){var fe,pe;(!y||t&1)&&o!==(o=e[0].name+"")&&E(_,o),(!y||t&1)&&D!==(D=e[0].name+"")&&E(Q,D);const f={};t&9&&(f.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(fe=e[0])==null?void 0:fe.name}').requestPasswordReset('test@example.com');
`),t&9&&(f.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${(pe=e[0])==null?void 0:pe.name}').requestPasswordReset('test@example.com');
`),q.$set(f),(!y||t&1)&&L!==(L=e[0].name+"")&&E(N,L),t&6&&(O=e[2],h=ue(h,t,ie,1,e,O,oe,A,Re,_e,null,be)),t&6&&(j=e[2],ge(),k=ue(k,t,ce,1,e,j,ne,U,ye,ke,null,me),Be())},i(e){if(!y){Z(q.$$.fragment,e);for(let t=0;t<j.length;t+=1)Z(k[t]);y=!0}},o(e){x(q.$$.fragment,e);for(let t=0;t<k.length;t+=1)x(k[t]);y=!1},d(e){e&&d(s),e&&d(i),e&&d(p),e&&d(z),he(q,e),e&&d(G),e&&d(B),e&&d(J),e&&d(R),e&&d(V),e&&d(S),e&&d(W),e&&d(T),e&&d(X),e&&d(M),e&&d(Y),e&&d(g);for(let t=0;t<h.length;t+=1)h[t].d();for(let t=0;t<k.length;t+=1)k[t].d()}}}function De(a,s,l){let o,{collection:_=new Ce}=s,m=204,i=[];const p=u=>l(1,m=u.code);return a.$$set=u=>{"collection"in u&&l(0,_=u.collection)},l(3,o=Se.getApiExampleUrl(Te.baseUrl)),l(2,i=[{code:204,body:"null"},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"email": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}]),[_,m,i,o,p]}class Le extends Pe{constructor(s){super(),$e(this,s,De,je,qe,{collection:0})}}export{Le as default};
+50
View File
@@ -0,0 +1,50 @@
import{S as we,i as qe,s as Pe,e as c,w as h,b as v,c as ve,f as b,g as r,h as i,m as he,x as O,P as ue,Q as ge,k as ye,R as Be,n as Ce,t as Z,a as x,o as f,d as $e,L as Se,C as Te,p as Re,r as E,u as Ve,O as Me}from"./index.97f016a1.js";import{S as Ae}from"./SdkTabs.88269ae0.js";function me(a,l,s){const o=a.slice();return o[5]=l[s],o}function be(a,l,s){const o=a.slice();return o[5]=l[s],o}function _e(a,l){let s,o=l[5].code+"",_,m,n,p;function u(){return l[4](l[5])}return{key:a,first:null,c(){s=c("button"),_=h(o),m=v(),b(s,"class","tab-item"),E(s,"active",l[1]===l[5].code),this.first=s},m(w,q){r(w,s,q),i(s,_),i(s,m),n||(p=Ve(s,"click",u),n=!0)},p(w,q){l=w,q&4&&o!==(o=l[5].code+"")&&O(_,o),q&6&&E(s,"active",l[1]===l[5].code)},d(w){w&&f(s),n=!1,p()}}}function ke(a,l){let s,o,_,m;return o=new Me({props:{content:l[5].body}}),{key:a,first:null,c(){s=c("div"),ve(o.$$.fragment),_=v(),b(s,"class","tab-item"),E(s,"active",l[1]===l[5].code),this.first=s},m(n,p){r(n,s,p),he(o,s,null),i(s,_),m=!0},p(n,p){l=n;const u={};p&4&&(u.content=l[5].body),o.$set(u),(!m||p&6)&&E(s,"active",l[1]===l[5].code)},i(n){m||(Z(o.$$.fragment,n),m=!0)},o(n){x(o.$$.fragment,n),m=!1},d(n){n&&f(s),$e(o)}}}function Ue(a){var re,fe;let l,s,o=a[0].name+"",_,m,n,p,u,w,q,j=a[0].name+"",F,ee,Q,P,z,C,G,g,D,te,H,S,le,J,I=a[0].name+"",K,se,N,T,W,R,X,V,Y,y,M,$=[],oe=new Map,ae,A,k=[],ie=new Map,B;P=new Ae({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${a[3]}');
...
await pb.collection('${(re=a[0])==null?void 0:re.name}').requestVerification('test@example.com');
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${a[3]}');
...
await pb.collection('${(fe=a[0])==null?void 0:fe.name}').requestVerification('test@example.com');
`}});let L=a[2];const ne=e=>e[5].code;for(let e=0;e<L.length;e+=1){let t=be(a,L,e),d=ne(t);oe.set(d,$[e]=_e(d,t))}let U=a[2];const ce=e=>e[5].code;for(let e=0;e<U.length;e+=1){let t=me(a,U,e),d=ce(t);ie.set(d,k[e]=ke(d,t))}return{c(){l=c("h3"),s=h("Request verification ("),_=h(o),m=h(")"),n=v(),p=c("div"),u=c("p"),w=h("Sends "),q=c("strong"),F=h(j),ee=h(" verification email request."),Q=v(),ve(P.$$.fragment),z=v(),C=c("h6"),C.textContent="API details",G=v(),g=c("div"),D=c("strong"),D.textContent="POST",te=v(),H=c("div"),S=c("p"),le=h("/api/collections/"),J=c("strong"),K=h(I),se=h("/request-password-reset"),N=v(),T=c("div"),T.textContent="Body Parameters",W=v(),R=c("table"),R.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr></thead>
<tbody><tr><td><div class="inline-flex"><span class="label label-success">Required</span>
<span>email</span></div></td>
<td><span class="label">String</span></td>
<td>The auth record email address to send the verification request (if exists).</td></tr></tbody>`,X=v(),V=c("div"),V.textContent="Responses",Y=v(),y=c("div"),M=c("div");for(let e=0;e<$.length;e+=1)$[e].c();ae=v(),A=c("div");for(let e=0;e<k.length;e+=1)k[e].c();b(l,"class","m-b-sm"),b(p,"class","content txt-lg m-b-sm"),b(C,"class","m-b-xs"),b(D,"class","label label-primary"),b(H,"class","content"),b(g,"class","alert alert-success"),b(T,"class","section-title"),b(R,"class","table-compact table-border m-b-base"),b(V,"class","section-title"),b(M,"class","tabs-header compact left"),b(A,"class","tabs-content"),b(y,"class","tabs")},m(e,t){r(e,l,t),i(l,s),i(l,_),i(l,m),r(e,n,t),r(e,p,t),i(p,u),i(u,w),i(u,q),i(q,F),i(u,ee),r(e,Q,t),he(P,e,t),r(e,z,t),r(e,C,t),r(e,G,t),r(e,g,t),i(g,D),i(g,te),i(g,H),i(H,S),i(S,le),i(S,J),i(J,K),i(S,se),r(e,N,t),r(e,T,t),r(e,W,t),r(e,R,t),r(e,X,t),r(e,V,t),r(e,Y,t),r(e,y,t),i(y,M);for(let d=0;d<$.length;d+=1)$[d].m(M,null);i(y,ae),i(y,A);for(let d=0;d<k.length;d+=1)k[d].m(A,null);B=!0},p(e,[t]){var de,pe;(!B||t&1)&&o!==(o=e[0].name+"")&&O(_,o),(!B||t&1)&&j!==(j=e[0].name+"")&&O(F,j);const d={};t&9&&(d.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(de=e[0])==null?void 0:de.name}').requestVerification('test@example.com');
`),t&9&&(d.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${(pe=e[0])==null?void 0:pe.name}').requestVerification('test@example.com');
`),P.$set(d),(!B||t&1)&&I!==(I=e[0].name+"")&&O(K,I),t&6&&(L=e[2],$=ue($,t,ne,1,e,L,oe,M,ge,_e,null,be)),t&6&&(U=e[2],ye(),k=ue(k,t,ce,1,e,U,ie,A,Be,ke,null,me),Ce())},i(e){if(!B){Z(P.$$.fragment,e);for(let t=0;t<U.length;t+=1)Z(k[t]);B=!0}},o(e){x(P.$$.fragment,e);for(let t=0;t<k.length;t+=1)x(k[t]);B=!1},d(e){e&&f(l),e&&f(n),e&&f(p),e&&f(Q),$e(P,e),e&&f(z),e&&f(C),e&&f(G),e&&f(g),e&&f(N),e&&f(T),e&&f(W),e&&f(R),e&&f(X),e&&f(V),e&&f(Y),e&&f(y);for(let t=0;t<$.length;t+=1)$[t].d();for(let t=0;t<k.length;t+=1)k[t].d()}}}function je(a,l,s){let o,{collection:_=new Se}=l,m=204,n=[];const p=u=>s(1,m=u.code);return a.$$set=u=>{"collection"in u&&s(0,_=u.collection)},s(3,o=Te.getApiExampleUrl(Re.baseUrl)),s(2,n=[{code:204,body:"null"},{code:400,body:`
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"email": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`}]),[_,m,n,o,p]}class Ie extends we{constructor(l){super(),qe(this,l,je,Ue,Pe,{collection:0})}}export{Ie as default};
+1
View File
@@ -0,0 +1 @@
import{S as q,i as B,s as F,e as b,b as v,f as h,g as y,h as f,P as w,Q as J,k as N,R as O,n as Q,t as I,a as M,o as E,w as S,r as j,u as Y,x as P,O as z,c as A,m as G,d as H}from"./index.97f016a1.js";function C(o,t,l){const n=o.slice();return n[5]=t[l],n}function D(o,t,l){const n=o.slice();return n[5]=t[l],n}function K(o,t){let l,n,_=t[5].title+"",u,r,s,c;function m(){return t[4](t[5])}return{key:o,first:null,c(){l=b("button"),n=b("div"),u=S(_),r=v(),h(n,"class","txt"),h(l,"class","tab-item svelte-1maocj6"),j(l,"active",t[0]===t[5].language),this.first=l},m(g,d){y(g,l,d),f(l,n),f(n,u),f(l,r),s||(c=Y(l,"click",m),s=!0)},p(g,d){t=g,d&2&&_!==(_=t[5].title+"")&&P(u,_),d&3&&j(l,"active",t[0]===t[5].language)},d(g){g&&E(l),s=!1,c()}}}function R(o,t){let l,n,_,u,r,s,c=t[5].title+"",m,g,d,p,k;return n=new z({props:{language:t[5].language,content:t[5].content}}),{key:o,first:null,c(){l=b("div"),A(n.$$.fragment),_=v(),u=b("div"),r=b("em"),s=b("a"),m=S(c),g=S(" SDK"),p=v(),h(s,"href",d=t[5].url),h(s,"target","_blank"),h(s,"rel","noopener noreferrer"),h(r,"class","txt-sm txt-hint"),h(u,"class","txt-right"),h(l,"class","tab-item svelte-1maocj6"),j(l,"active",t[0]===t[5].language),this.first=l},m(e,a){y(e,l,a),G(n,l,null),f(l,_),f(l,u),f(u,r),f(r,s),f(s,m),f(s,g),f(l,p),k=!0},p(e,a){t=e;const i={};a&2&&(i.language=t[5].language),a&2&&(i.content=t[5].content),n.$set(i),(!k||a&2)&&c!==(c=t[5].title+"")&&P(m,c),(!k||a&2&&d!==(d=t[5].url))&&h(s,"href",d),(!k||a&3)&&j(l,"active",t[0]===t[5].language)},i(e){k||(I(n.$$.fragment,e),k=!0)},o(e){M(n.$$.fragment,e),k=!1},d(e){e&&E(l),H(n)}}}function L(o){let t,l,n=[],_=new Map,u,r,s=[],c=new Map,m,g=o[1];const d=e=>e[5].language;for(let e=0;e<g.length;e+=1){let a=D(o,g,e),i=d(a);_.set(i,n[e]=K(i,a))}let p=o[1];const k=e=>e[5].language;for(let e=0;e<p.length;e+=1){let a=C(o,p,e),i=k(a);c.set(i,s[e]=R(i,a))}return{c(){t=b("div"),l=b("div");for(let e=0;e<n.length;e+=1)n[e].c();u=v(),r=b("div");for(let e=0;e<s.length;e+=1)s[e].c();h(l,"class","tabs-header compact left"),h(r,"class","tabs-content"),h(t,"class","tabs sdk-tabs m-b-base svelte-1maocj6")},m(e,a){y(e,t,a),f(t,l);for(let i=0;i<n.length;i+=1)n[i].m(l,null);f(t,u),f(t,r);for(let i=0;i<s.length;i+=1)s[i].m(r,null);m=!0},p(e,[a]){a&3&&(g=e[1],n=w(n,a,d,1,e,g,_,l,J,K,null,D)),a&3&&(p=e[1],N(),s=w(s,a,k,1,e,p,c,r,O,R,null,C),Q())},i(e){if(!m){for(let a=0;a<p.length;a+=1)I(s[a]);m=!0}},o(e){for(let a=0;a<s.length;a+=1)M(s[a]);m=!1},d(e){e&&E(t);for(let a=0;a<n.length;a+=1)n[a].d();for(let a=0;a<s.length;a+=1)s[a].d()}}}const T="pb_sdk_preference";function U(o,t,l){let n,{js:_=""}=t,{dart:u=""}=t,r=localStorage.getItem(T)||"javascript";const s=c=>l(0,r=c.language);return o.$$set=c=>{"js"in c&&l(2,_=c.js),"dart"in c&&l(3,u=c.dart)},o.$$.update=()=>{o.$$.dirty&1&&r&&localStorage.setItem(T,r),o.$$.dirty&12&&l(1,n=[{title:"JavaScript",language:"javascript",content:_,url:"https://github.com/pocketbase/js-sdk/tree/rc"},{title:"Dart",language:"dart",content:u,url:"https://github.com/pocketbase/dart-sdk/tree/rc"}])},[r,n,_,u,s]}class W extends q{constructor(t){super(),B(this,t,U,L,F,{js:2,dart:3})}}export{W as S};
+1
View File
@@ -0,0 +1 @@
.sdk-tabs.svelte-1maocj6 .tabs-header .tab-item.svelte-1maocj6{min-width:100px}
+80
View File
@@ -0,0 +1,80 @@
import{S as qe,i as Oe,s as De,e as i,w as v,b as h,c as Se,f,g as r,h as s,m as Be,x as R,P as ye,Q as Le,k as Me,R as Ve,n as ze,t as le,a as oe,o as d,d as Ue,L as He,C as Ie,p as Re,r as j,u as je,O as Ke}from"./index.97f016a1.js";import{S as Ne}from"./SdkTabs.88269ae0.js";function Ae(n,l,o){const a=n.slice();return a[5]=l[o],a}function Ce(n,l,o){const a=n.slice();return a[5]=l[o],a}function Pe(n,l){let o,a=l[5].code+"",_,b,c,u;function p(){return l[4](l[5])}return{key:n,first:null,c(){o=i("button"),_=v(a),b=h(),f(o,"class","tab-item"),j(o,"active",l[1]===l[5].code),this.first=o},m($,E){r($,o,E),s(o,_),s(o,b),c||(u=je(o,"click",p),c=!0)},p($,E){l=$,E&4&&a!==(a=l[5].code+"")&&R(_,a),E&6&&j(o,"active",l[1]===l[5].code)},d($){$&&d(o),c=!1,u()}}}function Te(n,l){let o,a,_,b;return a=new Ke({props:{content:l[5].body}}),{key:n,first:null,c(){o=i("div"),Se(a.$$.fragment),_=h(),f(o,"class","tab-item"),j(o,"active",l[1]===l[5].code),this.first=o},m(c,u){r(c,o,u),Be(a,o,null),s(o,_),b=!0},p(c,u){l=c;const p={};u&4&&(p.content=l[5].body),a.$set(p),(!b||u&6)&&j(o,"active",l[1]===l[5].code)},i(c){b||(le(a.$$.fragment,c),b=!0)},o(c){oe(a.$$.fragment,c),b=!1},d(c){c&&d(o),Ue(a)}}}function Qe(n){var he,_e,ke,ve;let l,o,a=n[0].name+"",_,b,c,u,p,$,E,L=n[0].name+"",K,se,ae,N,Q,A,F,T,G,g,M,ne,V,y,ie,J,z=n[0].name+"",W,ce,X,re,Y,de,H,Z,S,x,B,ee,U,te,C,q,w=[],ue=new Map,me,O,k=[],pe=new Map,P;A=new Ne({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${n[3]}');
...
await pb.collection('${(he=n[0])==null?void 0:he.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(_e=n[0])==null?void 0:_e.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google'
);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${n[3]}');
...
await pb.collection('${(ke=n[0])==null?void 0:ke.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(ve=n[0])==null?void 0:ve.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google',
);
`}});let I=n[2];const fe=e=>e[5].code;for(let e=0;e<I.length;e+=1){let t=Ce(n,I,e),m=fe(t);ue.set(m,w[e]=Pe(m,t))}let D=n[2];const be=e=>e[5].code;for(let e=0;e<D.length;e+=1){let t=Ae(n,D,e),m=be(t);pe.set(m,k[e]=Te(m,t))}return{c(){l=i("h3"),o=v("Unlink OAuth2 account ("),_=v(a),b=v(")"),c=h(),u=i("div"),p=i("p"),$=v("Unlink a single external OAuth2 provider from "),E=i("strong"),K=v(L),se=v(" record."),ae=h(),N=i("p"),N.textContent="Only admins and the account owner can access this action.",Q=h(),Se(A.$$.fragment),F=h(),T=i("h6"),T.textContent="API details",G=h(),g=i("div"),M=i("strong"),M.textContent="DELETE",ne=h(),V=i("div"),y=i("p"),ie=v("/api/collections/"),J=i("strong"),W=v(z),ce=v("/records/"),X=i("strong"),X.textContent=":id",re=v("/external-auths/"),Y=i("strong"),Y.textContent=":provider",de=h(),H=i("p"),H.innerHTML="Requires <code>Authorization:TOKEN</code> header",Z=h(),S=i("div"),S.textContent="Path Parameters",x=h(),B=i("table"),B.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr></thead>
<tbody><tr><td>id</td>
<td><span class="label">String</span></td>
<td>ID of the auth record.</td></tr>
<tr><td>provider</td>
<td><span class="label">String</span></td>
<td>The name of the auth provider to unlink, eg. <code>google</code>, <code>twitter</code>,
<code>github</code>, etc.</td></tr></tbody>`,ee=h(),U=i("div"),U.textContent="Responses",te=h(),C=i("div"),q=i("div");for(let e=0;e<w.length;e+=1)w[e].c();me=h(),O=i("div");for(let e=0;e<k.length;e+=1)k[e].c();f(l,"class","m-b-sm"),f(u,"class","content txt-lg m-b-sm"),f(T,"class","m-b-xs"),f(M,"class","label label-primary"),f(V,"class","content"),f(H,"class","txt-hint txt-sm txt-right"),f(g,"class","alert alert-danger"),f(S,"class","section-title"),f(B,"class","table-compact table-border m-b-base"),f(U,"class","section-title"),f(q,"class","tabs-header compact left"),f(O,"class","tabs-content"),f(C,"class","tabs")},m(e,t){r(e,l,t),s(l,o),s(l,_),s(l,b),r(e,c,t),r(e,u,t),s(u,p),s(p,$),s(p,E),s(E,K),s(p,se),s(u,ae),s(u,N),r(e,Q,t),Be(A,e,t),r(e,F,t),r(e,T,t),r(e,G,t),r(e,g,t),s(g,M),s(g,ne),s(g,V),s(V,y),s(y,ie),s(y,J),s(J,W),s(y,ce),s(y,X),s(y,re),s(y,Y),s(g,de),s(g,H),r(e,Z,t),r(e,S,t),r(e,x,t),r(e,B,t),r(e,ee,t),r(e,U,t),r(e,te,t),r(e,C,t),s(C,q);for(let m=0;m<w.length;m+=1)w[m].m(q,null);s(C,me),s(C,O);for(let m=0;m<k.length;m+=1)k[m].m(O,null);P=!0},p(e,[t]){var ge,we,$e,Ee;(!P||t&1)&&a!==(a=e[0].name+"")&&R(_,a),(!P||t&1)&&L!==(L=e[0].name+"")&&R(K,L);const m={};t&9&&(m.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
await pb.collection('${(ge=e[0])==null?void 0:ge.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(we=e[0])==null?void 0:we.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google'
);
`),t&9&&(m.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
await pb.collection('${($e=e[0])==null?void 0:$e.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${(Ee=e[0])==null?void 0:Ee.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google',
);
`),A.$set(m),(!P||t&1)&&z!==(z=e[0].name+"")&&R(W,z),t&6&&(I=e[2],w=ye(w,t,fe,1,e,I,ue,q,Le,Pe,null,Ce)),t&6&&(D=e[2],Me(),k=ye(k,t,be,1,e,D,pe,O,Ve,Te,null,Ae),ze())},i(e){if(!P){le(A.$$.fragment,e);for(let t=0;t<D.length;t+=1)le(k[t]);P=!0}},o(e){oe(A.$$.fragment,e);for(let t=0;t<k.length;t+=1)oe(k[t]);P=!1},d(e){e&&d(l),e&&d(c),e&&d(u),e&&d(Q),Ue(A,e),e&&d(F),e&&d(T),e&&d(G),e&&d(g),e&&d(Z),e&&d(S),e&&d(x),e&&d(B),e&&d(ee),e&&d(U),e&&d(te),e&&d(C);for(let t=0;t<w.length;t+=1)w[t].d();for(let t=0;t<k.length;t+=1)k[t].d()}}}function Fe(n,l,o){let a,{collection:_=new He}=l,b=204,c=[];const u=p=>o(1,b=p.code);return n.$$set=p=>{"collection"in p&&o(0,_=p.collection)},o(3,a=Ie.getApiExampleUrl(Re.baseUrl)),o(2,c=[{code:204,body:"null"},{code:401,body:`
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`},{code:403,body:`
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`},{code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}]),[_,b,c,a,u]}class We extends qe{constructor(l){super(),Oe(this,l,Fe,Qe,De,{collection:0})}}export{We as default};
+118
View File
@@ -0,0 +1,118 @@
import{S as Ct,i as St,s as Ot,C as I,O as Tt,e as r,w as y,b as m,c as Ae,f as T,g as a,h as i,m as Be,x as U,P as Pe,Q as ut,k as Mt,R as $t,n as Rt,t as pe,a as fe,o,d as Fe,L as qt,p as Dt,r as ce,u as Ht,y as G}from"./index.97f016a1.js";import{S as Lt}from"./SdkTabs.88269ae0.js";function bt(p,t,l){const s=p.slice();return s[7]=t[l],s}function mt(p,t,l){const s=p.slice();return s[7]=t[l],s}function _t(p,t,l){const s=p.slice();return s[12]=t[l],s}function yt(p){let t;return{c(){t=r("p"),t.innerHTML="Requires admin <code>Authorization:TOKEN</code> header",T(t,"class","txt-hint txt-sm txt-right")},m(l,s){a(l,t,s)},d(l){l&&o(t)}}}function kt(p){let t,l,s,b,u,d,f,k,C,v,O,D,A,F,M,j,B;return{c(){t=r("tr"),t.innerHTML='<td colspan="3" class="txt-hint">Auth fields</td>',l=m(),s=r("tr"),s.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>username</span></div></td>
<td><span class="label">String</span></td>
<td>The username of the auth record.</td>`,b=m(),u=r("tr"),u.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>email</span></div></td>
<td><span class="label">String</span></td>
<td>The auth record email address.
<br/>
This field can be updated only by admins or auth records with &quot;Manage&quot; access.
<br/>
Regular accounts can update their email by calling &quot;Request email change&quot;.</td>`,d=m(),f=r("tr"),f.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>emailVisibility</span></div></td>
<td><span class="label">Boolean</span></td>
<td>Whether to show/hide the auth record email when fetching the record data.</td>`,k=m(),C=r("tr"),C.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>oldPassword</span></div></td>
<td><span class="label">String</span></td>
<td>Old auth record password.
<br/>
This field is required only when changing the record password. Admins and auth records with
&quot;Manage&quot; access can skip this field.</td>`,v=m(),O=r("tr"),O.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>password</span></div></td>
<td><span class="label">String</span></td>
<td>New auth record password.</td>`,D=m(),A=r("tr"),A.innerHTML=`<td><div class="inline-flex"><span class="label label-warning">Optional</span>
<span>passwordConfirm</span></div></td>
<td><span class="label">String</span></td>
<td>New auth record password confirmation.</td>`,F=m(),M=r("tr"),M.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 admins or auth records with &quot;Manage&quot; access.</td>`,j=m(),B=r("tr"),B.innerHTML='<td colspan="3" class="txt-hint">Schema fields</td>'},m(c,_){a(c,t,_),a(c,l,_),a(c,s,_),a(c,b,_),a(c,u,_),a(c,d,_),a(c,f,_),a(c,k,_),a(c,C,_),a(c,v,_),a(c,O,_),a(c,D,_),a(c,A,_),a(c,F,_),a(c,M,_),a(c,j,_),a(c,B,_)},d(c){c&&o(t),c&&o(l),c&&o(s),c&&o(b),c&&o(u),c&&o(d),c&&o(f),c&&o(k),c&&o(C),c&&o(v),c&&o(O),c&&o(D),c&&o(A),c&&o(F),c&&o(M),c&&o(j),c&&o(B)}}}function Pt(p){let t;return{c(){t=r("span"),t.textContent="Optional",T(t,"class","label label-warning")},m(l,s){a(l,t,s)},d(l){l&&o(t)}}}function At(p){let t;return{c(){t=r("span"),t.textContent="Required",T(t,"class","label label-success")},m(l,s){a(l,t,s)},d(l){l&&o(t)}}}function Bt(p){var u;let t,l=((u=p[12].options)==null?void 0:u.maxSelect)>1?"ids":"id",s,b;return{c(){t=y("User "),s=y(l),b=y(".")},m(d,f){a(d,t,f),a(d,s,f),a(d,b,f)},p(d,f){var k;f&1&&l!==(l=((k=d[12].options)==null?void 0:k.maxSelect)>1?"ids":"id")&&U(s,l)},d(d){d&&o(t),d&&o(s),d&&o(b)}}}function Ft(p){var u;let t,l=((u=p[12].options)==null?void 0:u.maxSelect)>1?"ids":"id",s,b;return{c(){t=y("Relation record "),s=y(l),b=y(".")},m(d,f){a(d,t,f),a(d,s,f),a(d,b,f)},p(d,f){var k;f&1&&l!==(l=((k=d[12].options)==null?void 0:k.maxSelect)>1?"ids":"id")&&U(s,l)},d(d){d&&o(t),d&&o(s),d&&o(b)}}}function jt(p){let t,l,s,b,u;return{c(){t=y("File object."),l=r("br"),s=y(`
Set to `),b=r("code"),b.textContent="null",u=y(" to delete already uploaded file(s).")},m(d,f){a(d,t,f),a(d,l,f),a(d,s,f),a(d,b,f),a(d,u,f)},p:G,d(d){d&&o(t),d&&o(l),d&&o(s),d&&o(b),d&&o(u)}}}function Nt(p){let t;return{c(){t=y("URL address.")},m(l,s){a(l,t,s)},p:G,d(l){l&&o(t)}}}function Et(p){let t;return{c(){t=y("Email address.")},m(l,s){a(l,t,s)},p:G,d(l){l&&o(t)}}}function It(p){let t;return{c(){t=y("JSON array or object.")},m(l,s){a(l,t,s)},p:G,d(l){l&&o(t)}}}function Ut(p){let t;return{c(){t=y("Number value.")},m(l,s){a(l,t,s)},p:G,d(l){l&&o(t)}}}function gt(p){let t;return{c(){t=y("Plain text value.")},m(l,s){a(l,t,s)},p:G,d(l){l&&o(t)}}}function ht(p,t){let l,s,b,u,d,f=t[12].name+"",k,C,v,O,D=I.getFieldValueType(t[12])+"",A,F,M,j;function B(h,L){return h[12].required?At:Pt}let c=B(t),_=c(t);function K(h,L){if(h[12].type==="text")return gt;if(h[12].type==="number")return Ut;if(h[12].type==="json")return It;if(h[12].type==="email")return Et;if(h[12].type==="url")return Nt;if(h[12].type==="file")return jt;if(h[12].type==="relation")return Ft;if(h[12].type==="user")return Bt}let H=K(t),S=H&&H(t);return{key:p,first:null,c(){l=r("tr"),s=r("td"),b=r("div"),_.c(),u=m(),d=r("span"),k=y(f),C=m(),v=r("td"),O=r("span"),A=y(D),F=m(),M=r("td"),S&&S.c(),j=m(),T(b,"class","inline-flex"),T(O,"class","label"),this.first=l},m(h,L){a(h,l,L),i(l,s),i(s,b),_.m(b,null),i(b,u),i(b,d),i(d,k),i(l,C),i(l,v),i(v,O),i(O,A),i(l,F),i(l,M),S&&S.m(M,null),i(l,j)},p(h,L){t=h,c!==(c=B(t))&&(_.d(1),_=c(t),_&&(_.c(),_.m(b,u))),L&1&&f!==(f=t[12].name+"")&&U(k,f),L&1&&D!==(D=I.getFieldValueType(t[12])+"")&&U(A,D),H===(H=K(t))&&S?S.p(t,L):(S&&S.d(1),S=H&&H(t),S&&(S.c(),S.m(M,null)))},d(h){h&&o(l),_.d(),S&&S.d()}}}function vt(p,t){let l,s=t[7].code+"",b,u,d,f;function k(){return t[6](t[7])}return{key:p,first:null,c(){l=r("button"),b=y(s),u=m(),T(l,"class","tab-item"),ce(l,"active",t[1]===t[7].code),this.first=l},m(C,v){a(C,l,v),i(l,b),i(l,u),d||(f=Ht(l,"click",k),d=!0)},p(C,v){t=C,v&4&&s!==(s=t[7].code+"")&&U(b,s),v&6&&ce(l,"active",t[1]===t[7].code)},d(C){C&&o(l),d=!1,f()}}}function wt(p,t){let l,s,b,u;return s=new Tt({props:{content:t[7].body}}),{key:p,first:null,c(){l=r("div"),Ae(s.$$.fragment),b=m(),T(l,"class","tab-item"),ce(l,"active",t[1]===t[7].code),this.first=l},m(d,f){a(d,l,f),Be(s,l,null),i(l,b),u=!0},p(d,f){t=d;const k={};f&4&&(k.content=t[7].body),s.$set(k),(!u||f&6)&&ce(l,"active",t[1]===t[7].code)},i(d){u||(pe(s.$$.fragment,d),u=!0)},o(d){fe(s.$$.fragment,d),u=!1},d(d){d&&o(l),Fe(s)}}}function Jt(p){var it,at,ot,dt;let t,l,s=p[0].name+"",b,u,d,f,k,C,v,O=p[0].name+"",D,A,F,M,j,B,c,_,K,H,S,h,L,je,ae,W,Ne,ue,oe=p[0].name+"",be,Ee,me,Ie,_e,X,ye,Z,ke,ee,he,g,ve,Ue,J,we,N=[],ge=new Map,Te,te,Ce,V,Se,Je,Oe,x,Me,Ve,$e,xe,$,Qe,Y,ze,Ke,We,Re,Ye,qe,Ge,De,Xe,He,le,Le,Q,se,E=[],Ze=new Map,et,ne,P=[],tt=new Map,z;_=new Lt({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${p[4]}');
...
// example update data
const data = ${JSON.stringify(Object.assign({},p[3],I.dummyCollectionSchemaData(p[0])),null,4)};
const record = await pb.collection('${(it=p[0])==null?void 0:it.name}').update('RECORD_ID', data);
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${p[4]}');
...
// example update body
final body = <String, dynamic>${JSON.stringify(Object.assign({},p[3],I.dummyCollectionSchemaData(p[0])),null,2)};
final record = await pb.collection('${(at=p[0])==null?void 0:at.name}').update('RECORD_ID', body: body);
`}});let R=p[5]&&yt(),q=((ot=p[0])==null?void 0:ot.isAuth)&&kt(),de=(dt=p[0])==null?void 0:dt.schema;const lt=e=>e[12].name;for(let e=0;e<de.length;e+=1){let n=_t(p,de,e),w=lt(n);ge.set(w,N[e]=ht(w,n))}Y=new Tt({props:{content:"?expand=relField1,relField2.subRelField21"}});let re=p[2];const st=e=>e[7].code;for(let e=0;e<re.length;e+=1){let n=mt(p,re,e),w=st(n);Ze.set(w,E[e]=vt(w,n))}let ie=p[2];const nt=e=>e[7].code;for(let e=0;e<ie.length;e+=1){let n=bt(p,ie,e),w=nt(n);tt.set(w,P[e]=wt(w,n))}return{c(){t=r("h3"),l=y("Update ("),b=y(s),u=y(")"),d=m(),f=r("div"),k=r("p"),C=y("Update a single "),v=r("strong"),D=y(O),A=y(" record."),F=m(),M=r("p"),M.innerHTML=`Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.`,j=m(),B=r("p"),B.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/#uploading-files" target="_blank" rel="noopener noreferrer">Files upload and handling docs
</a>.`,c=m(),Ae(_.$$.fragment),K=m(),H=r("h6"),H.textContent="API details",S=m(),h=r("div"),L=r("strong"),L.textContent="PATCH",je=m(),ae=r("div"),W=r("p"),Ne=y("/api/collections/"),ue=r("strong"),be=y(oe),Ee=y("/records/"),me=r("strong"),me.textContent=":id",Ie=m(),R&&R.c(),_e=m(),X=r("div"),X.textContent="Path parameters",ye=m(),Z=r("table"),Z.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr></thead>
<tbody><tr><td>id</td>
<td><span class="label">String</span></td>
<td>ID of the record to update.</td></tr></tbody>`,ke=m(),ee=r("div"),ee.textContent="Body Parameters",he=m(),g=r("table"),ve=r("thead"),ve.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="50%">Description</th></tr>`,Ue=m(),J=r("tbody"),q&&q.c(),we=m();for(let e=0;e<N.length;e+=1)N[e].c();Te=m(),te=r("div"),te.textContent="Query parameters",Ce=m(),V=r("table"),Se=r("thead"),Se.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Je=m(),Oe=r("tbody"),x=r("tr"),Me=r("td"),Me.textContent="expand",Ve=m(),$e=r("td"),$e.innerHTML='<span class="label">String</span>',xe=m(),$=r("td"),Qe=y(`Auto expand relations when returning the updated record. Ex.:
`),Ae(Y.$$.fragment),ze=y(`
Supports up to 6-levels depth nested relations expansion. `),Ke=r("br"),We=y(`
The expanded relations will be appended to the record under the
`),Re=r("code"),Re.textContent="expand",Ye=y(" property (eg. "),qe=r("code"),qe.textContent='"expand": {"relField1": {...}, ...}',Ge=y(`). Only
the relations that the user has permissions to `),De=r("strong"),De.textContent="view",Xe=y(" will be expanded."),He=m(),le=r("div"),le.textContent="Responses",Le=m(),Q=r("div"),se=r("div");for(let e=0;e<E.length;e+=1)E[e].c();et=m(),ne=r("div");for(let e=0;e<P.length;e+=1)P[e].c();T(t,"class","m-b-sm"),T(f,"class","content txt-lg m-b-sm"),T(H,"class","m-b-xs"),T(L,"class","label label-primary"),T(ae,"class","content"),T(h,"class","alert alert-warning"),T(X,"class","section-title"),T(Z,"class","table-compact table-border m-b-base"),T(ee,"class","section-title"),T(g,"class","table-compact table-border m-b-base"),T(te,"class","section-title"),T(V,"class","table-compact table-border m-b-lg"),T(le,"class","section-title"),T(se,"class","tabs-header compact left"),T(ne,"class","tabs-content"),T(Q,"class","tabs")},m(e,n){a(e,t,n),i(t,l),i(t,b),i(t,u),a(e,d,n),a(e,f,n),i(f,k),i(k,C),i(k,v),i(v,D),i(k,A),i(f,F),i(f,M),i(f,j),i(f,B),a(e,c,n),Be(_,e,n),a(e,K,n),a(e,H,n),a(e,S,n),a(e,h,n),i(h,L),i(h,je),i(h,ae),i(ae,W),i(W,Ne),i(W,ue),i(ue,be),i(W,Ee),i(W,me),i(h,Ie),R&&R.m(h,null),a(e,_e,n),a(e,X,n),a(e,ye,n),a(e,Z,n),a(e,ke,n),a(e,ee,n),a(e,he,n),a(e,g,n),i(g,ve),i(g,Ue),i(g,J),q&&q.m(J,null),i(J,we);for(let w=0;w<N.length;w+=1)N[w].m(J,null);a(e,Te,n),a(e,te,n),a(e,Ce,n),a(e,V,n),i(V,Se),i(V,Je),i(V,Oe),i(Oe,x),i(x,Me),i(x,Ve),i(x,$e),i(x,xe),i(x,$),i($,Qe),Be(Y,$,null),i($,ze),i($,Ke),i($,We),i($,Re),i($,Ye),i($,qe),i($,Ge),i($,De),i($,Xe),a(e,He,n),a(e,le,n),a(e,Le,n),a(e,Q,n),i(Q,se);for(let w=0;w<E.length;w+=1)E[w].m(se,null);i(Q,et),i(Q,ne);for(let w=0;w<P.length;w+=1)P[w].m(ne,null);z=!0},p(e,[n]){var rt,pt,ft,ct;(!z||n&1)&&s!==(s=e[0].name+"")&&U(b,s),(!z||n&1)&&O!==(O=e[0].name+"")&&U(D,O);const w={};n&25&&(w.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[4]}');
...
// example update data
const data = ${JSON.stringify(Object.assign({},e[3],I.dummyCollectionSchemaData(e[0])),null,4)};
const record = await pb.collection('${(rt=e[0])==null?void 0:rt.name}').update('RECORD_ID', data);
`),n&25&&(w.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[4]}');
...
// example update body
final body = <String, dynamic>${JSON.stringify(Object.assign({},e[3],I.dummyCollectionSchemaData(e[0])),null,2)};
final record = await pb.collection('${(pt=e[0])==null?void 0:pt.name}').update('RECORD_ID', body: body);
`),_.$set(w),(!z||n&1)&&oe!==(oe=e[0].name+"")&&U(be,oe),e[5]?R||(R=yt(),R.c(),R.m(h,null)):R&&(R.d(1),R=null),(ft=e[0])!=null&&ft.isAuth?q||(q=kt(),q.c(),q.m(J,we)):q&&(q.d(1),q=null),n&1&&(de=(ct=e[0])==null?void 0:ct.schema,N=Pe(N,n,lt,1,e,de,ge,J,ut,ht,null,_t)),n&6&&(re=e[2],E=Pe(E,n,st,1,e,re,Ze,se,ut,vt,null,mt)),n&6&&(ie=e[2],Mt(),P=Pe(P,n,nt,1,e,ie,tt,ne,$t,wt,null,bt),Rt())},i(e){if(!z){pe(_.$$.fragment,e),pe(Y.$$.fragment,e);for(let n=0;n<ie.length;n+=1)pe(P[n]);z=!0}},o(e){fe(_.$$.fragment,e),fe(Y.$$.fragment,e);for(let n=0;n<P.length;n+=1)fe(P[n]);z=!1},d(e){e&&o(t),e&&o(d),e&&o(f),e&&o(c),Fe(_,e),e&&o(K),e&&o(H),e&&o(S),e&&o(h),R&&R.d(),e&&o(_e),e&&o(X),e&&o(ye),e&&o(Z),e&&o(ke),e&&o(ee),e&&o(he),e&&o(g),q&&q.d();for(let n=0;n<N.length;n+=1)N[n].d();e&&o(Te),e&&o(te),e&&o(Ce),e&&o(V),Fe(Y),e&&o(He),e&&o(le),e&&o(Le),e&&o(Q);for(let n=0;n<E.length;n+=1)E[n].d();for(let n=0;n<P.length;n+=1)P[n].d()}}}function Vt(p,t,l){let s,b,{collection:u=new qt}=t,d=200,f=[],k={};const C=v=>l(1,d=v.code);return p.$$set=v=>{"collection"in v&&l(0,u=v.collection)},p.$$.update=()=>{var v,O;p.$$.dirty&1&&l(5,s=(u==null?void 0:u.updateRule)===null),p.$$.dirty&1&&l(2,f=[{code:200,body:JSON.stringify(I.dummyCollectionRecord(u),null,2)},{code:400,body:`
{
"code": 400,
"message": "Failed to update record.",
"data": {
"${(O=(v=u==null?void 0:u.schema)==null?void 0:v[0])==null?void 0:O.name}": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`},{code:403,body:`
{
"code": 403,
"message": "You are not allowed to perform this request.",
"data": {}
}
`},{code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}]),p.$$.dirty&1&&(u.isAuth?l(3,k={username:"test_username_update",emailVisibility:!1,password:"87654321",passwordConfirm:"87654321",oldPassword:"12345678"}):l(3,k={}))},l(4,b=I.getApiExampleUrl(Dt.baseUrl)),[u,d,f,k,b,s,C]}class zt extends Ct{constructor(t){super(),St(this,t,Vt,Jt,Ot,{collection:0})}}export{zt as default};
+66
View File
@@ -0,0 +1,66 @@
import{S as Ze,i as et,s as tt,O as Ye,e as o,w as m,b as f,c as _e,f as _,g as r,h as l,m as ke,x as me,P as Ve,Q as lt,k as st,R as nt,n as ot,t as z,a as G,o as d,d as he,L as it,C as ze,p as at,r as J,u as rt}from"./index.97f016a1.js";import{S as dt}from"./SdkTabs.88269ae0.js";function Ge(i,s,n){const a=i.slice();return a[6]=s[n],a}function Je(i,s,n){const a=i.slice();return a[6]=s[n],a}function Ke(i){let s;return{c(){s=o("p"),s.innerHTML="Requires admin <code>Authorization:TOKEN</code> header",_(s,"class","txt-hint txt-sm txt-right")},m(n,a){r(n,s,a)},d(n){n&&d(s)}}}function We(i,s){let n,a=s[6].code+"",w,c,p,u;function C(){return s[5](s[6])}return{key:i,first:null,c(){n=o("button"),w=m(a),c=f(),_(n,"class","tab-item"),J(n,"active",s[2]===s[6].code),this.first=n},m(h,F){r(h,n,F),l(n,w),l(n,c),p||(u=rt(n,"click",C),p=!0)},p(h,F){s=h,F&20&&J(n,"active",s[2]===s[6].code)},d(h){h&&d(n),p=!1,u()}}}function Xe(i,s){let n,a,w,c;return a=new Ye({props:{content:s[6].body}}),{key:i,first:null,c(){n=o("div"),_e(a.$$.fragment),w=f(),_(n,"class","tab-item"),J(n,"active",s[2]===s[6].code),this.first=n},m(p,u){r(p,n,u),ke(a,n,null),l(n,w),c=!0},p(p,u){s=p,(!c||u&20)&&J(n,"active",s[2]===s[6].code)},i(p){c||(z(a.$$.fragment,p),c=!0)},o(p){G(a.$$.fragment,p),c=!1},d(p){p&&d(n),he(a)}}}function ct(i){var Ue,je;let s,n,a=i[0].name+"",w,c,p,u,C,h,F,U=i[0].name+"",K,ve,W,g,X,B,Y,$,j,we,N,E,ye,Z,Q=i[0].name+"",ee,$e,te,Ce,le,I,se,x,ne,A,oe,O,ie,Re,ae,D,re,Fe,de,ge,k,Oe,S,De,Pe,Te,ce,Ee,pe,Se,Be,Ie,fe,xe,ue,M,be,P,H,R=[],Ae=new Map,Me,L,y=[],He=new Map,T;g=new dt({props:{js:`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${i[3]}');
...
const record1 = await pb.collection('${(Ue=i[0])==null?void 0:Ue.name}').getOne('RECORD_ID', {
expand: 'relField1,relField2.subRelField',
});
`,dart:`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${i[3]}');
...
final record1 = await pb.collection('${(je=i[0])==null?void 0:je.name}').getOne('RECORD_ID',
'expand': 'relField1,relField2.subRelField',
);
`}});let v=i[1]&&Ke();S=new Ye({props:{content:"?expand=relField1,relField2.subRelField"}});let V=i[4];const Le=e=>e[6].code;for(let e=0;e<V.length;e+=1){let t=Je(i,V,e),b=Le(t);Ae.set(b,R[e]=We(b,t))}let q=i[4];const qe=e=>e[6].code;for(let e=0;e<q.length;e+=1){let t=Ge(i,q,e),b=qe(t);He.set(b,y[e]=Xe(b,t))}return{c(){s=o("h3"),n=m("View ("),w=m(a),c=m(")"),p=f(),u=o("div"),C=o("p"),h=m("Fetch a single "),F=o("strong"),K=m(U),ve=m(" record."),W=f(),_e(g.$$.fragment),X=f(),B=o("h6"),B.textContent="API details",Y=f(),$=o("div"),j=o("strong"),j.textContent="GET",we=f(),N=o("div"),E=o("p"),ye=m("/api/collections/"),Z=o("strong"),ee=m(Q),$e=m("/records/"),te=o("strong"),te.textContent=":id",Ce=f(),v&&v.c(),le=f(),I=o("div"),I.textContent="Path Parameters",se=f(),x=o("table"),x.innerHTML=`<thead><tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr></thead>
<tbody><tr><td>id</td>
<td><span class="label">String</span></td>
<td>ID of the record to view.</td></tr></tbody>`,ne=f(),A=o("div"),A.textContent="Query parameters",oe=f(),O=o("table"),ie=o("thead"),ie.innerHTML=`<tr><th>Param</th>
<th>Type</th>
<th width="60%">Description</th></tr>`,Re=f(),ae=o("tbody"),D=o("tr"),re=o("td"),re.textContent="expand",Fe=f(),de=o("td"),de.innerHTML='<span class="label">String</span>',ge=f(),k=o("td"),Oe=m(`Auto expand record relations. Ex.:
`),_e(S.$$.fragment),De=m(`
Supports up to 6-levels depth nested relations expansion. `),Pe=o("br"),Te=m(`
The expanded relations will be appended to the record under the
`),ce=o("code"),ce.textContent="expand",Ee=m(" property (eg. "),pe=o("code"),pe.textContent='"expand": {"relField1": {...}, ...}',Se=m(`).
`),Be=o("br"),Ie=m(`
Only the relations to which the account has permissions to `),fe=o("strong"),fe.textContent="view",xe=m(" will be expanded."),ue=f(),M=o("div"),M.textContent="Responses",be=f(),P=o("div"),H=o("div");for(let e=0;e<R.length;e+=1)R[e].c();Me=f(),L=o("div");for(let e=0;e<y.length;e+=1)y[e].c();_(s,"class","m-b-sm"),_(u,"class","content txt-lg m-b-sm"),_(B,"class","m-b-xs"),_(j,"class","label label-primary"),_(N,"class","content"),_($,"class","alert alert-info"),_(I,"class","section-title"),_(x,"class","table-compact table-border m-b-base"),_(A,"class","section-title"),_(O,"class","table-compact table-border m-b-base"),_(M,"class","section-title"),_(H,"class","tabs-header compact left"),_(L,"class","tabs-content"),_(P,"class","tabs")},m(e,t){r(e,s,t),l(s,n),l(s,w),l(s,c),r(e,p,t),r(e,u,t),l(u,C),l(C,h),l(C,F),l(F,K),l(C,ve),r(e,W,t),ke(g,e,t),r(e,X,t),r(e,B,t),r(e,Y,t),r(e,$,t),l($,j),l($,we),l($,N),l(N,E),l(E,ye),l(E,Z),l(Z,ee),l(E,$e),l(E,te),l($,Ce),v&&v.m($,null),r(e,le,t),r(e,I,t),r(e,se,t),r(e,x,t),r(e,ne,t),r(e,A,t),r(e,oe,t),r(e,O,t),l(O,ie),l(O,Re),l(O,ae),l(ae,D),l(D,re),l(D,Fe),l(D,de),l(D,ge),l(D,k),l(k,Oe),ke(S,k,null),l(k,De),l(k,Pe),l(k,Te),l(k,ce),l(k,Ee),l(k,pe),l(k,Se),l(k,Be),l(k,Ie),l(k,fe),l(k,xe),r(e,ue,t),r(e,M,t),r(e,be,t),r(e,P,t),l(P,H);for(let b=0;b<R.length;b+=1)R[b].m(H,null);l(P,Me),l(P,L);for(let b=0;b<y.length;b+=1)y[b].m(L,null);T=!0},p(e,[t]){var Ne,Qe;(!T||t&1)&&a!==(a=e[0].name+"")&&me(w,a),(!T||t&1)&&U!==(U=e[0].name+"")&&me(K,U);const b={};t&9&&(b.js=`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${e[3]}');
...
const record1 = await pb.collection('${(Ne=e[0])==null?void 0:Ne.name}').getOne('RECORD_ID', {
expand: 'relField1,relField2.subRelField',
});
`),t&9&&(b.dart=`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${e[3]}');
...
final record1 = await pb.collection('${(Qe=e[0])==null?void 0:Qe.name}').getOne('RECORD_ID',
'expand': 'relField1,relField2.subRelField',
);
`),g.$set(b),(!T||t&1)&&Q!==(Q=e[0].name+"")&&me(ee,Q),e[1]?v||(v=Ke(),v.c(),v.m($,null)):v&&(v.d(1),v=null),t&20&&(V=e[4],R=Ve(R,t,Le,1,e,V,Ae,H,lt,We,null,Je)),t&20&&(q=e[4],st(),y=Ve(y,t,qe,1,e,q,He,L,nt,Xe,null,Ge),ot())},i(e){if(!T){z(g.$$.fragment,e),z(S.$$.fragment,e);for(let t=0;t<q.length;t+=1)z(y[t]);T=!0}},o(e){G(g.$$.fragment,e),G(S.$$.fragment,e);for(let t=0;t<y.length;t+=1)G(y[t]);T=!1},d(e){e&&d(s),e&&d(p),e&&d(u),e&&d(W),he(g,e),e&&d(X),e&&d(B),e&&d(Y),e&&d($),v&&v.d(),e&&d(le),e&&d(I),e&&d(se),e&&d(x),e&&d(ne),e&&d(A),e&&d(oe),e&&d(O),he(S),e&&d(ue),e&&d(M),e&&d(be),e&&d(P);for(let t=0;t<R.length;t+=1)R[t].d();for(let t=0;t<y.length;t+=1)y[t].d()}}}function pt(i,s,n){let a,w,{collection:c=new it}=s,p=200,u=[];const C=h=>n(2,p=h.code);return i.$$set=h=>{"collection"in h&&n(0,c=h.collection)},i.$$.update=()=>{i.$$.dirty&1&&n(1,a=(c==null?void 0:c.viewRule)===null),i.$$.dirty&3&&c!=null&&c.id&&(u.push({code:200,body:JSON.stringify(ze.dummyCollectionRecord(c),null,2)}),a&&u.push({code:403,body:`
{
"code": 403,
"message": "Only admins can access this action.",
"data": {}
}
`}),u.push({code:404,body:`
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`}))},n(3,w=ze.getApiExampleUrl(at.baseUrl)),[c,a,p,w,u,C]}class bt extends Ze{constructor(s){super(),et(this,s,pt,ct,tt,{collection:0})}}export{bt as default};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+175
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-661
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -24,8 +24,8 @@
window.Prism = window.Prism || {};
window.Prism.manual = true;
</script>
<script type="module" crossorigin src="./assets/index.e13041a6.js"></script>
<link rel="stylesheet" href="./assets/index.26987507.css">
<script type="module" crossorigin src="./assets/index.97f016a1.js"></script>
<link rel="stylesheet" href="./assets/index.0a5eb9c8.css">
</head>
<body>
<div id="app"></div>
+304 -337
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -23,9 +23,9 @@
"@codemirror/view": "^6.0.0",
"@sveltejs/vite-plugin-svelte": "^1.0.1",
"chart.js": "^3.7.1",
"chartjs-adapter-luxon": "^1.1.0",
"chartjs-adapter-luxon": "^1.2.0",
"luxon": "^2.3.2",
"pocketbase": "^0.7.0",
"pocketbase": "^0.8.0-rc1",
"prismjs": "^1.28.0",
"sass": "^1.45.0",
"svelte": "^3.44.0",
+2 -12
View File
@@ -90,16 +90,6 @@
>
<i class="ri-database-2-line" />
</a>
<a
href="/users"
class="menu-item"
aria-label="Users"
use:link
use:active={{ path: "/users/?.*", className: "current-route" }}
use:tooltip={{ text: "Users", position: "right" }}
>
<i class="ri-group-line" />
</a>
<a
href="/logs"
class="menu-item"
@@ -133,10 +123,10 @@
<span class="txt">Manage admins</span>
</a>
<hr />
<div tabindex="0" class="dropdown-item closable" on:click={logout}>
<button type="button" class="dropdown-item closable" on:click={logout}>
<i class="ri-logout-circle-line" />
<span class="txt">Logout</span>
</div>
</button>
</Toggler>
</figure>
</aside>
+1 -1
View File
@@ -141,7 +141,7 @@ function showTooltip(node, data) {
getTooltip().classList.add("active");
refreshTooltip(node, data);
}, (!isNaN(data.delay) ? data.delay : 200));
}, (!isNaN(data.delay) ? data.delay : 0));
}
export default function tooltip(node, tooltipData) {
@@ -4,6 +4,7 @@
import { Admin } from "pocketbase";
import CommonHelper from "@/utils/CommonHelper";
import ApiClient from "@/utils/ApiClient";
import tooltip from "@/actions/tooltip";
import { setErrors } from "@/stores/errors";
import { confirm } from "@/stores/confirmation";
import { addSuccessToast } from "@/stores/toasts";
@@ -43,7 +44,6 @@
}
function load(model) {
setErrors({}); // reset errors
admin = model?.clone ? model.clone() : new Admin();
reset(); // reset form
}
@@ -54,6 +54,7 @@
avatar = admin?.avatar || 0;
password = "";
passwordConfirm = "";
setErrors({}); // reset errors
}
function save() {
@@ -146,6 +147,15 @@
<i class={CommonHelper.getFieldTypeIcon("primary")} />
<span class="txt">ID</span>
</label>
<div class="form-field-addon">
<i
class="ri-calendar-event-line txt-disabled"
use:tooltip={{
text: `Created: ${admin.created}\nUpdated: ${admin.updated}`,
position: "left",
}}
/>
</div>
<input type="text" id={uniqueId} value={admin.id} disabled />
</Field>
{/if}
@@ -154,22 +164,16 @@
<p class="section-title">Avatar</p>
<div class="flex flex-gap-xs flex-wrap">
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as index}
<figure
tabindex="0"
<button
type="button"
class="link-fade thumb thumb-circle {index == avatar ? 'thumb-active' : 'thumb-sm'}"
on:click={() => (avatar = index)}
on:keydown={(e) => {
if (e.code === "Enter" || e.code === "Space") {
e.preventDefault();
avatar = index;
}
}}
>
<img
src="{import.meta.env.BASE_URL}images/avatars/avatar{index}.svg"
alt="Avatar {index}"
/>
</figure>
</button>
{/each}
</div>
</div>
@@ -234,7 +238,7 @@
<span />
<i class="ri-more-line" />
<Toggler class="dropdown dropdown-upside dropdown-left dropdown-nowrap">
<button type="button" class="dropdown-item" on:click={() => deleteConfirm()}>
<button type="button" class="dropdown-item txt-danger" on:click={() => deleteConfirm()}>
<i class="ri-delete-bin-7-line" />
<span class="txt">Delete</span>
</button>
@@ -3,7 +3,7 @@
import FullPage from "@/components/base/FullPage.svelte";
import ApiClient from "@/utils/ApiClient";
import Field from "@/components/base/Field.svelte";
import { addErrorToast } from "@/stores/toasts";
import { addErrorToast, removeAllToasts } from "@/stores/toasts";
const queryParams = new URLSearchParams($querystring);
@@ -18,8 +18,10 @@
isLoading = true;
return ApiClient.admins.authViaEmail(email, password)
return ApiClient.admins
.authWithPassword(email, password)
.then(() => {
removeAllToasts();
replace("/");
})
.catch(() => {
@@ -37,7 +39,7 @@
<h4>Admin sign in</h4>
</div>
<Field class="form-field required" name="email" let:uniqueId>
<Field class="form-field required" name="identity" let:uniqueId>
<label for={uniqueId}>Email</label>
<!-- svelte-ignore a11y-autofocus -->
<input type="email" id={uniqueId} bind:value={email} required autofocus />
+6 -2
View File
@@ -10,6 +10,7 @@
import SortHeader from "@/components/base/SortHeader.svelte";
import IdLabel from "@/components/base/IdLabel.svelte";
import FormattedDate from "@/components/base/FormattedDate.svelte";
import HorizontalScroller from "@/components/base/HorizontalScroller.svelte";
import SettingsSidebar from "@/components/settings/SettingsSidebar.svelte";
import AdminUpsertPanel from "@/components/admins/AdminUpsertPanel.svelte";
@@ -86,7 +87,7 @@
on:submit={(e) => (filter = e.detail)}
/>
<div class="table-wrapper">
<HorizontalScroller class="table-wrapper">
<table class="table" class:table-loading={isLoading}>
<thead>
<tr>
@@ -145,6 +146,7 @@
/>
</figure>
</td>
<td class="col-type-text col-field-id">
<IdLabel id={admin.id} />
{#if admin.id === $loggedAdmin.id}
@@ -161,9 +163,11 @@
<td class="col-type-date col-field-created">
<FormattedDate date={admin.created} />
</td>
<td class="col-type-date col-field-updated">
<FormattedDate date={admin.updated} />
</td>
<td class="col-type-action min-width">
<i class="ri-arrow-right-line" />
</td>
@@ -194,7 +198,7 @@
{/each}
</tbody>
</table>
</div>
</HorizontalScroller>
{#if admins.length}
<small class="block txt-hint txt-right m-t-sm">Showing {admins.length} of {admins.length}</small>
+30 -5
View File
@@ -10,10 +10,13 @@
let classes = "";
export { classes as class }; // export reserved keyword
export let draggable = false;
export let active = false;
export let interactive = true;
export let single = false; // ensures that only one accordion is expanded in its given parent container
let isDragOver = false;
$: if (active) {
clearTimeout(expandTimeoutId);
expandTimeoutId = setTimeout(() => {
@@ -49,10 +52,10 @@
}
export function collapseSiblings() {
if (single && accordionElem.parentElement) {
const handlers = accordionElem.parentElement.querySelectorAll(
".accordion.active .accordion-header.interactive"
);
if (single && accordionElem.closest(".accordions")) {
const handlers = accordionElem
.closest(".accordions")
.querySelectorAll(".accordion.active .accordion-header.interactive");
for (const handler of handlers) {
handler.click(); // @todo consider using store or other more reliable approach
}
@@ -78,14 +81,36 @@
<div
bind:this={accordionElem}
tabindex={interactive ? 0 : -1}
class="accordion {classes}"
class="accordion {isDragOver ? 'drag-over' : ''} {classes}"
class:active
on:keydown|self={keyToggle}
>
<header
class="accordion-header"
{draggable}
class:interactive
on:click|preventDefault={() => interactive && toggle()}
on:drop|preventDefault={(e) => {
if (draggable) {
isDragOver = false;
collapseSiblings();
dispatch("drop", e);
}
}}
on:dragstart={(e) => draggable && dispatch("dragstart", e)}
on:dragenter={(e) => {
if (draggable) {
isDragOver = true;
dispatch("dragenter", e);
}
}}
on:dragleave={(e) => {
if (draggable) {
isDragOver = false;
dispatch("dragleave", e);
}
}}
on:dragover|preventDefault
>
<slot name="header" {active} />
</header>
+1 -2
View File
@@ -1,5 +1,4 @@
<script>
// @todo consider replacing with readonly CodeEditor
import Prism from "prismjs";
import "prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js";
import "prismjs/components/prism-dart.js";
@@ -40,7 +39,7 @@
code {
display: block;
width: 100%;
padding: var(--xsSpacing);
padding: 10px 15px;
white-space: pre-wrap;
word-break: break-word;
}
+6 -4
View File
@@ -5,8 +5,10 @@
let confirmationPopup;
let isConfirmationBusy = false;
let confirmed = false;
$: if ($confirmation?.text) {
confirmed = false;
confirmationPopup?.show();
}
</script>
@@ -19,10 +21,11 @@
btnClose={false}
popup
on:hide={async () => {
if ($confirmation?.noCallback) {
if (!confirmed && $confirmation?.noCallback) {
$confirmation.noCallback();
}
await tick();
confirmed = false;
resetConfirmation();
}}
>
@@ -36,9 +39,7 @@
class="btn btn-secondary btn-expanded-sm"
disabled={isConfirmationBusy}
on:click={() => {
if ($confirmation?.noCallback) {
$confirmation.noCallback();
}
confirmed = false;
confirmationPopup?.hide();
}}
>
@@ -55,6 +56,7 @@
await Promise.resolve($confirmation.yesCallback());
isConfirmationBusy = false;
}
confirmed = true;
confirmationPopup?.hide();
}}
>
@@ -185,17 +185,23 @@
prefix + "updated",
];
if (collection.isAuth) {
result.push(prefix + "username");
result.push(prefix + "email");
result.push(prefix + "emailVisibility");
result.push(prefix + "verified");
}
for (const field of collection.schema) {
const key = prefix + field.name;
result.push(key);
if (field.type === "relation" && field.options.collectionId) {
const subKeys = getCollectionFieldKeys(field.options.collectionId, key + ".", level + 1);
if (subKeys.length) {
result = result.concat(subKeys);
} else {
result.push(key);
}
} else {
result.push(key);
}
}
@@ -217,28 +223,27 @@
result.push("@request.method");
result.push("@request.query.");
result.push("@request.data.");
result.push("@request.user.id");
result.push("@request.user.email");
result.push("@request.user.verified");
result.push("@request.user.created");
result.push("@request.user.updated");
result.push("@request.auth.");
result.push("@request.auth.id");
result.push("@request.auth.collectionId");
result.push("@request.auth.collectionName");
result.push("@request.auth.username");
result.push("@request.auth.email");
result.push("@request.auth.emailVisibility");
result.push("@request.auth.verified");
result.push("@request.auth.created");
result.push("@request.auth.updated");
}
// add @collections and @request.user.profile keys
// add @collections.* keys
if (includeRequestKeys || includeIndirectCollectionsKeys) {
for (const collection of mergedCollections) {
let prefix = "";
if (collection.name === import.meta.env.PB_PROFILE_COLLECTION) {
if (!includeRequestKeys) {
continue;
}
prefix = "@request.user.profile.";
} else {
if (!includeIndirectCollectionsKeys) {
continue;
}
prefix = "@collection." + collection.name + ".";
if (!includeIndirectCollectionsKeys) {
continue;
}
prefix = "@collection." + collection.name + ".";
const keys = getCollectionFieldKeys(collection.name, prefix);
for (const key of keys) {
@@ -258,8 +263,8 @@
// Returns object with all the completions matching the context.
function completions(context) {
let word = context.matchBefore(/[\@\w\.]*/);
if (word.from == word.to && !context.explicit) {
let word = context.matchBefore(/[\'\"\@\w\.]*/);
if (word && word.from == word.to && !context.explicit) {
return null;
}
@@ -269,18 +274,8 @@
options.push({ label: "@collection.*", apply: "@collection." });
}
const skipFields = [
"@request.user.profile.userId",
"@request.user.profile.created",
"@request.user.profile.updated",
];
const keys = getAllKeys(!disableRequestKeys, !disableRequestKeys && word.text.startsWith("@c"));
for (const key of keys) {
if (skipFields.includes(key)) {
continue;
}
options.push({
label: key.endsWith(".") ? key + "*" : key,
apply: key,
+19 -4
View File
@@ -1,13 +1,28 @@
<script>
export let date = "";
// note: manual trim the ms without converting to DateTime
// to help improving the rendering performance in large data sets
$: shortDate = date.length > 19 ? date.substring(0, 19) : date;
$: dateOnly = date ? date.substring(0, 10) : null;
$: timeOnly = date ? date.substring(10, 19) : null;
</script>
{#if date}
<span class="txt">{shortDate} UTC</span>
<div class="datetime">
<div class="date">{dateOnly}</div>
<div class="time">{timeOnly} UTC</div>
</div>
{:else}
<span class="txt txt-hint">N/A</span>
{/if}
<style>
.datetime {
width: 100%;
display: block;
line-height: var(--smLineHeight);
}
.time {
font-size: var(--smFontSize);
color: var(--txtHintColor);
}
</style>
@@ -0,0 +1,81 @@
<script>
import { onMount } from "svelte";
let classes = "";
export { classes as class }; // export reserved keyword
let wrapper = null;
let scrollClasses = "";
let scrollTimeoutId = null;
let observer;
export function refresh() {
if (!wrapper) {
return;
}
clearTimeout(scrollTimeoutId);
scrollTimeoutId = setTimeout(() => {
const offsetWidth = wrapper.offsetWidth;
const scrollWidth = wrapper.scrollWidth;
if (scrollWidth - offsetWidth) {
scrollClasses = "scrollable";
if (wrapper.scrollLeft === 0) {
scrollClasses += " scroll-start";
} else if (wrapper.scrollLeft + offsetWidth == scrollWidth) {
scrollClasses += " scroll-end";
}
} else {
scrollClasses = "";
}
}, 100);
}
onMount(() => {
refresh();
observer = new MutationObserver(() => {
refresh();
});
observer.observe(wrapper, {
attributeFilter: ["width"],
childList: true,
subtree: true,
});
return () => {
observer?.disconnect();
clearTimeout(scrollTimeoutId);
};
});
</script>
<svelte:window on:resize={refresh} />
<div class="horizontal-scroller-wrapper">
<slot name="before" />
<div bind:this={wrapper} class="horizontal-scroller {classes} {scrollClasses}" on:scroll={refresh}>
<slot />
</div>
<slot name="after" />
</div>
<style>
.horizontal-scroller {
width: auto;
overflow-x: auto;
}
.horizontal-scroller-wrapper {
position: relative;
}
:global(.horizontal-scroller-wrapper .columns-dropdown) {
top: 40px;
z-index: 100;
max-height: 340px;
}
</style>
+1 -1
View File
@@ -24,7 +24,7 @@
passwordConfirm,
});
await ApiClient.admins.authViaEmail(email, password);
await ApiClient.admins.authWithPassword(email, password);
dispatch("submit");
} catch (err) {
+7 -1
View File
@@ -86,10 +86,12 @@
oldFocusedElem = document.activeElement;
wrapper?.focus();
dispatch("show");
document.body.classList.add("overlay-active");
} else {
clearTimeout(contentScrollThrottle);
oldFocusedElem?.focus();
dispatch("hide");
document.body.classList.remove("overlay-active");
}
await tick();
@@ -179,13 +181,17 @@
// ensures that no artifacts remains
// (currently there is a bug with svelte transition)
wrapper?.classList?.add("hidden");
setTimeout(() => {
wrapper?.remove();
}, 0);
};
});
</script>
<svelte:window on:resize={handleResize} on:keydown={handleEscPress} />
<div class="overlay-panel-wrapper" bind:this={wrapper}>
<div bind:this={wrapper} class="overlay-panel-wrapper">
{#if active}
<div class="overlay-panel-container" class:padded={popup} class:active>
<div
+1 -1
View File
@@ -15,7 +15,7 @@
href={import.meta.env.PB_RELEASES}
class="inline-flex flex-gap-5"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
title="Releases"
>
<span class="txt">PocketBase {import.meta.env.PB_VERSION}</span>
+9 -3
View File
@@ -21,15 +21,21 @@
<OverlayPanel bind:this={panel} class="image-preview" btnClose={false} popup on:show on:hide>
<svelte:fragment slot="header">
<div class="overlay-close" on:click|preventDefault={hide}>
<button type="button" class="overlay-close" on:click|preventDefault={hide}>
<i class="ri-close-line" />
</div>
</button>
</svelte:fragment>
<img src={url} alt="Preview {url}" />
<svelte:fragment slot="footer">
<a href={url} title="Download" class="link-hint txt-ellipsis">
<a
href={url}
title="Download"
target="_blank"
rel="noreferrer noopener"
class="link-hint txt-ellipsis"
>
{url.substring(url.lastIndexOf("/") + 1)}
</a>
<div class="flex-fill" />
+2 -2
View File
@@ -20,7 +20,7 @@
refreshTimeoutId = setTimeout(() => {
refreshTimeoutId = null;
tooltipData = oldTooltipData;
}, 200);
}, 150);
}
onMount(() => {
@@ -45,6 +45,6 @@
}
}
.btn.refreshing i {
animation: refresh 200ms ease-out;
animation: refresh 150ms ease-out;
}
</style>
+2 -2
View File
@@ -53,8 +53,8 @@
});
</script>
<div class="searchbar-wrapper" on:click|stopPropagation>
<form class="searchbar" on:submit|preventDefault={submit}>
<div class="searchbar-wrapper">
<form class="searchbar" on:click|stopPropagation on:submit|preventDefault={submit}>
<label for={uniqueId} class="m-l-10 txt-xl">
<i class="ri-search-line" />
</label>
+9 -5
View File
@@ -194,13 +194,15 @@
});
</script>
<div class="select {classes}" class:multiple class:disabled bind:this={container}>
<div tabindex={disabled ? "-1" : "0"} class="selected-container" class:disabled bind:this={labelDiv}>
<div bind:this={container} class="select {classes}" class:multiple class:disabled>
<div bind:this={labelDiv} tabindex={disabled ? "-1" : "0"} class="selected-container" class:disabled>
{#each CommonHelper.toArray(selected) as item}
<div class="option">
{#if labelComponent}
<svelte:component this={labelComponent} {item} {...labelComponentProps} />
{:else}<span class="txt">{item}</span>{/if}
{:else}
<span class="txt">{item}</span>
{/if}
{#if multiple || toggle}
<span
@@ -213,17 +215,19 @@
{/if}
</div>
{:else}
<div class="txt-placeholder">{selectPlaceholder}</div>
<div class="block txt-placeholder" class:link-hint={!disabled}>
{selectPlaceholder}
</div>
{/each}
</div>
{#if !disabled}
<Toggler
bind:this={toggler}
class="dropdown dropdown-block options-dropdown dropdown-left"
trigger={labelDiv}
on:show={onDropdownShow}
on:hide
bind:this={toggler}
>
{#if searchable}
<div class="form-field form-field-sm options-search">
+2 -2
View File
@@ -29,9 +29,9 @@
<div class="content">{toast.message}</div>
<div class="close" on:click|preventDefault={() => removeToast(toast)}>
<button type="button" class="close" on:click|preventDefault={() => removeToast(toast)}>
<i class="ri-close-line" />
</div>
</button>
</div>
{/each}
</div>
+39 -14
View File
@@ -9,15 +9,20 @@
let classes = "";
export { classes as class }; // export reserved keyword
let container;
let container = undefined;
let activeTrigger = undefined;
const dispatch = createEventDispatcher();
$: if (container) {
bindTrigger(trigger);
}
$: if (active) {
trigger?.classList?.add("active");
activeTrigger?.classList?.add("active");
dispatch("show");
} else {
trigger?.classList?.remove("active");
activeTrigger?.classList?.remove("active");
dispatch("hide");
}
@@ -42,7 +47,7 @@
!container ||
elem.classList.contains(closableClass) ||
// is the trigger itself (or a direct child)
(trigger?.contains(elem) && !container.contains(elem)) ||
(activeTrigger?.contains(elem) && !container.contains(elem)) ||
// is closable toggler child
(container.contains(elem) && elem.closest && elem.closest("." + closableClass))
);
@@ -51,6 +56,8 @@
function handleClickToggle(e) {
if (!active || isClosable(e.target)) {
e.preventDefault();
e.stopPropagation();
toggle();
}
}
@@ -67,13 +74,13 @@
}
function handleOutsideClick(e) {
if (active && !container?.contains(e.target) && !trigger?.contains(e.target)) {
if (active && !container?.contains(e.target) && !activeTrigger?.contains(e.target)) {
hide();
}
}
function handleEscPress(e) {
if (active && escClose && e.code == "Escape") {
if (active && escClose && e.code === "Escape") {
e.preventDefault();
hide();
}
@@ -83,16 +90,34 @@
return handleOutsideClick(e);
}
function bindTrigger(newTrigger) {
cleanup();
activeTrigger = newTrigger || container?.parentNode;
if (!activeTrigger) {
return;
}
container?.addEventListener("click", handleClickToggle);
activeTrigger.addEventListener("click", handleClickToggle);
activeTrigger.addEventListener("keydown", handleKeydownToggle);
}
function cleanup() {
if (!activeTrigger) {
return;
}
container?.removeEventListener("click", handleClickToggle);
activeTrigger.removeEventListener("click", handleClickToggle);
activeTrigger.removeEventListener("keydown", handleKeydownToggle);
}
onMount(() => {
trigger = trigger || container.parentNode;
bindTrigger();
trigger.addEventListener("click", handleClickToggle);
trigger.addEventListener("keydown", handleKeydownToggle);
return () => {
trigger.removeEventListener("click", handleClickToggle);
trigger.removeEventListener("keydown", handleKeydownToggle);
};
return () => cleanup();
});
</script>
@@ -0,0 +1,221 @@
<script>
import { scale, slide } from "svelte/transition";
import { Collection } from "pocketbase";
import { errors } from "@/stores/errors";
import tooltip from "@/actions/tooltip";
import Field from "@/components/base/Field.svelte";
import CommonHelper from "@/utils/CommonHelper";
import MultipleValueInput from "@/components/base/MultipleValueInput.svelte";
import Accordion from "@/components/base/Accordion.svelte";
export let collection = new Collection();
$: if (collection.isAuth && CommonHelper.isEmpty(collection.options)) {
collection.options = {
allowEmailAuth: true,
allowUsernameAuth: true,
allowOAuth2Auth: true,
minPasswordLength: 8,
};
}
$: hasUsernameErrors = false;
$: hasEmailErrors =
!CommonHelper.isEmpty($errors?.options?.allowEmailAuth) ||
!CommonHelper.isEmpty($errors?.options?.onlyEmailDomains) ||
!CommonHelper.isEmpty($errors?.options?.exceptEmailDomains);
$: hasOAuth2Errors = !CommonHelper.isEmpty($errors?.options?.allowOAuth2Auth);
</script>
<h4 class="section-title">Auth methods</h4>
<div class="accordions">
<Accordion single>
<svelte:fragment slot="header">
<div class="inline-flex">
<i class="ri-user-star-line" />
<span class="txt">Username/Password</span>
</div>
<div class="flex-fill" />
{#if collection.options.allowUsernameAuth}
<span class="label label-success">Enabled</span>
{:else}
<span class="label">Disabled</span>
{/if}
{#if hasUsernameErrors}
<i
class="ri-error-warning-fill txt-danger"
transition:scale={{ duration: 150, start: 0.7 }}
use:tooltip={{ text: "Has errors", position: "left" }}
/>
{/if}
</svelte:fragment>
<Field class="form-field form-field-toggle m-b-0" name="options.allowUsernameAuth" let:uniqueId>
<input type="checkbox" id={uniqueId} bind:checked={collection.options.allowUsernameAuth} />
<label for={uniqueId}>Enable</label>
</Field>
</Accordion>
<Accordion single>
<svelte:fragment slot="header">
<div class="inline-flex">
<i class="ri-mail-star-line" />
<span class="txt">Email/Password</span>
</div>
<div class="flex-fill" />
{#if collection.options.allowEmailAuth}
<span class="label label-success">Enabled</span>
{:else}
<span class="label">Disabled</span>
{/if}
{#if hasEmailErrors}
<i
class="ri-error-warning-fill txt-danger"
transition:scale={{ duration: 150, start: 0.7 }}
use:tooltip={{ text: "Has errors", position: "left" }}
/>
{/if}
</svelte:fragment>
<Field class="form-field form-field-toggle m-0" name="options.allowEmailAuth" let:uniqueId>
<input type="checkbox" id={uniqueId} bind:checked={collection.options.allowEmailAuth} />
<label for={uniqueId}>Enable</label>
</Field>
{#if collection.options.allowEmailAuth}
<div class="grid grid-sm p-t-sm" transition:slide|local={{ duration: 150 }}>
<div class="col-lg-6">
<Field
class="form-field {!CommonHelper.isEmpty(collection.options.onlyEmailDomains)
? 'disabled'
: ''}"
name="options.exceptEmailDomains"
let:uniqueId
>
<label for={uniqueId}>
<span class="txt">Except domains</span>
<i
class="ri-information-line link-hint"
use:tooltip={{
text: 'Email domains that are NOT allowed to sign up. \n This field is disabled if "Only domains" is set.',
position: "top",
}}
/>
</label>
<MultipleValueInput
id={uniqueId}
disabled={!CommonHelper.isEmpty(collection.options.onlyEmailDomains)}
bind:value={collection.options.exceptEmailDomains}
/>
<div class="help-block">Use comma as separator.</div>
</Field>
</div>
<div class="col-lg-6">
<Field
class="form-field {!CommonHelper.isEmpty(collection.options.exceptEmailDomains)
? 'disabled'
: ''}"
name="options.onlyEmailDomains"
let:uniqueId
>
<label for={uniqueId}>
<span class="txt">Only domains</span>
<i
class="ri-information-line link-hint"
use:tooltip={{
text: 'Email domains that are ONLY allowed to sign up. \n This field is disabled if "Except domains" is set.',
position: "top",
}}
/>
</label>
<MultipleValueInput
id={uniqueId}
disabled={!CommonHelper.isEmpty(collection.options.exceptEmailDomains)}
bind:value={collection.options.onlyEmailDomains}
/>
<div class="help-block">Use comma as separator.</div>
</Field>
</div>
</div>
{/if}
</Accordion>
<Accordion single>
<svelte:fragment slot="header">
<div class="inline-flex">
<i class="ri-shield-star-line" />
<span class="txt">OAuth2</span>
</div>
<div class="flex-fill" />
{#if collection.options.allowOAuth2Auth}
<span class="label label-success">Enabled</span>
{:else}
<span class="label">Disabled</span>
{/if}
{#if hasOAuth2Errors}
<i
class="ri-error-warning-fill txt-danger"
transition:scale={{ duration: 150, start: 0.7 }}
use:tooltip={{ text: "Has errors", position: "left" }}
/>
{/if}
</svelte:fragment>
<Field class="form-field form-field-toggle m-b-0" name="options.allowOAuth2Auth" let:uniqueId>
<input type="checkbox" id={uniqueId} bind:checked={collection.options.allowOAuth2Auth} />
<label for={uniqueId}>Enable</label>
</Field>
{#if collection.options.allowOAuth2Auth}
<div class="block" transition:slide|local={{ duration: 150 }}>
<div class="flex p-t-base">
<a href="/_/#/settings/auth-providers" target="_blank" class="btn btn-sm btn-outline">
<span class="txt">Manage OAuth2 providers</span>
</a>
</div>
</div>
{/if}
</Accordion>
</div>
<hr />
<h4 class="section-title">General</h4>
<Field class="form-field required" name="options.minPasswordLength" let:uniqueId>
<label for={uniqueId}>Minimum password length</label>
<input
type="number"
id={uniqueId}
required
min="6"
max="72"
bind:value={collection.options.minPasswordLength}
/>
</Field>
<Field class="form-field form-field-toggle m-b-sm" name="options.requireEmail" let:uniqueId>
<input type="checkbox" id={uniqueId} bind:checked={collection.options.requireEmail} />
<label for={uniqueId}>
<span class="txt">Always require email</span>
<i
class="ri-information-line txt-sm link-hint"
use:tooltip={{
text: "The constraint is applied only for new records.\nAlso note that some OAuth2 providers (like Twitter), don't return an email and the authentication may fail if the email field is required.",
position: "right",
}}
/>
</label>
</Field>
@@ -0,0 +1,156 @@
<script>
import { Collection } from "pocketbase";
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
const baseTabs = {
list: {
label: "List/Search",
component: import("@/components/collections/docs/ListApiDocs.svelte"),
},
view: {
label: "View",
component: import("@/components/collections/docs/ViewApiDocs.svelte"),
},
create: {
label: "Create",
component: import("@/components/collections/docs/CreateApiDocs.svelte"),
},
update: {
label: "Update",
component: import("@/components/collections/docs/UpdateApiDocs.svelte"),
},
delete: {
label: "Delete",
component: import("@/components/collections/docs/DeleteApiDocs.svelte"),
},
realtime: {
label: "Realtime",
component: import("@/components/collections/docs/RealtimeApiDocs.svelte"),
},
};
const authTabs = {
"auth-with-password": {
label: "Auth with password",
component: import("@/components/collections/docs/AuthWithPasswordDocs.svelte"),
},
"auth-with-oauth2": {
label: "Auth with OAuth2",
component: import("@/components/collections/docs/AuthWithOAuth2Docs.svelte"),
},
refresh: {
label: "Auth refresh",
component: import("@/components/collections/docs/AuthRefreshDocs.svelte"),
},
"request-verification": {
label: "Request verification",
component: import("@/components/collections/docs/RequestVerificationDocs.svelte"),
},
"confirm-verification": {
label: "Confirm verification",
component: import("@/components/collections/docs/ConfirmVerificationDocs.svelte"),
},
"request-password-reset": {
label: "Request password reset",
component: import("@/components/collections/docs/RequestPasswordResetDocs.svelte"),
},
"confirm-password-reset": {
label: "Confirm password reset",
component: import("@/components/collections/docs/ConfirmPasswordResetDocs.svelte"),
},
"request-email-change": {
label: "Request email change",
component: import("@/components/collections/docs/RequestEmailChangeDocs.svelte"),
},
"confirm-email-change": {
label: "Confirm email change",
component: import("@/components/collections/docs/ConfirmEmailChangeDocs.svelte"),
},
"list-auth-methods": {
label: "List auth methods",
component: import("@/components/collections/docs/AuthMethodsDocs.svelte"),
},
"list-linked-accounts": {
label: "List OAuth2 accounts",
component: import("@/components/collections/docs/ListExternalAuthsDocs.svelte"),
},
"unlink-account": {
label: "Unlink OAuth2 account",
component: import("@/components/collections/docs/UnlinkExternalAuthDocs.svelte"),
},
};
let docsPanel;
let collection = new Collection();
let activeTab;
let tabs = [];
$: if (collection.isAuth) {
tabs = Object.assign({}, baseTabs, authTabs);
if (!collection?.options.allowUsernameAuth && !collection?.options.allowEmailAuth) {
delete tabs["auth-with-password"];
}
if (!collection?.options.allowOAuth2Auth) {
delete tabs["auth-with-oauth2"];
}
} else {
tabs = Object.assign({}, baseTabs);
}
// reset active tab on tabs list change
if (tabs.length) {
activeTab = Object.keys(tabs)[0];
}
export function show(model) {
collection = model;
changeTab(Object.keys(tabs)[0]);
return docsPanel?.show();
}
export function hide() {
return docsPanel?.hide();
}
export function changeTab(newTab) {
activeTab = newTab;
}
</script>
<OverlayPanel bind:this={docsPanel} on:hide on:show class="docs-panel">
<div class="docs-content-wrapper">
<aside class="docs-sidebar" class:compact={collection?.isAuth}>
<nav class="sidebar-content">
{#each Object.entries(tabs) as [key, tab] (key)}
<button
type="button"
class="sidebar-item"
class:active={activeTab === key}
on:click={() => changeTab(key)}
>
{tab.label}
</button>
{/each}
</nav>
</aside>
<div class="docs-content">
{#each Object.entries(tabs) as [key, tab] (key)}
{#if activeTab === key}
{#await tab.component then { default: TabComponent }}
<TabComponent {collection} />
{/await}
{/if}
{/each}
</div>
</div>
<!-- visible only on small screens -->
<svelte:fragment slot="footer">
<button type="button" class="btn btn-secondary" on:click={() => hide()}>
<span class="txt">Close</span>
</button>
</svelte:fragment>
</OverlayPanel>
@@ -2,10 +2,40 @@
import { SchemaField } from "pocketbase";
import FieldAccordion from "@/components/collections/FieldAccordion.svelte";
const reservedNames = ["id", "created", "updated"];
export let collection = {};
const baseReservedNames = [
"id",
"created",
"updated",
"collectionId",
"collectionName",
"expand",
"true",
"false",
"null",
];
let reservedNames = [];
$: if (collection.isAuth) {
reservedNames = baseReservedNames.concat([
"username",
"email",
"emailVisibility",
"verified",
"tokenKey",
"passwordHash",
"lastResetSentAt",
"lastVerificationSentAt",
"password",
"passwordConfirm",
"oldPassword",
]);
} else {
reservedNames = baseReservedNames.slice(0);
}
$: if (typeof collection?.schema === "undefined") {
collection = collection || {};
collection.schema = [];
@@ -58,15 +88,68 @@
return result;
}
// ---------------------------------------------------------------
// fields drag&drop handling
// ---------------------------------------------------------------
function onFieldDrag(event, i) {
if (!event) {
return;
}
event.dataTransfer.effectAllowed = "move";
event.dataTransfer.dropEffect = "move";
event.dataTransfer.setData("text/plain", i);
}
function onFieldDrop(event, target) {
if (!event) {
return;
}
event.dataTransfer.dropEffect = "move";
const start = parseInt(event.dataTransfer.getData("text/plain"));
const newSchema = collection.schema;
if (start < target) {
newSchema.splice(target + 1, 0, newSchema[start]);
newSchema.splice(start, 1);
} else {
newSchema.splice(target, 0, newSchema[start]);
newSchema.splice(start + 1, 1);
}
collection.schema = newSchema;
}
</script>
<div class="block m-b-25">
<p class="txt-sm">
System fields:
<code class="txt-sm">id</code> ,
<code class="txt-sm">created</code> ,
<code class="txt-sm">updated</code>
{#if collection.isAuth}
,
<code class="txt-sm">username</code> ,
<code class="txt-sm">email</code> ,
<code class="txt-sm">emailVisibility</code> ,
<code class="txt-sm">verified</code>
{/if}
.
</p>
</div>
<div class="accordions">
{#each collection.schema as field, i (i)}
{#each collection.schema as field, i (i + field.id)}
<FieldAccordion
bind:field
key={i}
excludeNames={reservedNames.concat(getSiblingsFieldNames(field))}
on:remove={() => removeField(i)}
on:dragstart={(e) => onFieldDrag(e?.detail, i)}
on:drop={(e) => onFieldDrop(e?.detail, i)}
/>
{/each}
</div>
@@ -75,7 +158,7 @@
<button
type="button"
class="btn btn-block {collection.schema?.length ? 'btn-secondary' : 'btn-success'}"
class="btn btn-block {collection.schema?.length ? 'btn-secondary' : 'btn-warning'}"
on:click={newField}
>
<i class="ri-add-line" />
@@ -1,52 +1,18 @@
<script>
import { onMount, tick } from "svelte";
import { slide } from "svelte/transition";
import { Collection } from "pocketbase";
import tooltip from "@/actions/tooltip";
import Field from "@/components/base/Field.svelte";
import RuleField from "@/components/collections/RuleField.svelte";
export let collection = new Collection();
let tempValues = {};
let showFiltersInfo = false;
let editorRefs = {};
let ruleInputComponent;
let isRuleComponentLoading = false;
// all supported collection rules in "collection_rule_prop: label" format
const ruleProps = {
listRule: "List Action",
viewRule: "View Action",
createRule: "Create Action",
updateRule: "Update Action",
deleteRule: "Delete Action",
};
function isAdminOnly(propVal) {
return propVal === null;
}
async function loadEditorComponent() {
isRuleComponentLoading = true;
try {
ruleInputComponent = (await import("@/components/base/FilterAutocompleteInput.svelte")).default;
} catch (err) {
console.warn(err);
ruleInputComponent = null;
}
isRuleComponentLoading = false;
}
onMount(() => {
loadEditorComponent();
});
</script>
<div class="block m-b-base">
<div class="flex">
<div class="flex txt-sm m-b-5">
<p>
All rules follow the
<a href={import.meta.env.PB_RULES_SYNTAX_DOCS} target="_blank" rel="noopener">
<a href={import.meta.env.PB_RULES_SYNTAX_DOCS} target="_blank" rel="noopener noreferrer">
PocketBase filter syntax and operators
</a>.
</p>
@@ -85,7 +51,7 @@
<code>@request.method</code>
<code>@request.query.*</code>
<code>@request.data.*</code>
<code>@request.user.*</code>
<code>@request.auth.*</code>
</div>
<hr class="m-t-10 m-b-5" />
@@ -104,7 +70,7 @@
<p>
Example rule:
<br />
<code>@request.user.id!="" && created>"2022-01-01 00:00:00"</code>
<code>@request.auth.id != "" && created > "2022-01-01 00:00:00"</code>
</p>
</div>
</div>
@@ -112,78 +78,37 @@
{/if}
</div>
{#if isRuleComponentLoading}
<div class="txt-center">
<span class="loader" />
</div>
{:else}
{#each Object.entries(ruleProps) as [prop, label] (prop)}
<hr class="m-t-sm m-b-sm" />
<div class="rule-block">
{#if isAdminOnly(collection[prop])}
<button
type="button"
class="rule-toggle-btn btn btn-circle btn-outline btn-success"
use:tooltip={"Unlock and set custom rule"}
on:click={async () => {
collection[prop] = tempValues[prop] || "";
await tick();
editorRefs[prop]?.focus();
}}
>
<i class="ri-lock-unlock-line" />
</button>
{:else}
<button
type="button"
class="rule-toggle-btn btn btn-circle btn-outline"
use:tooltip={"Lock and set to Admins only"}
on:click={() => {
tempValues[prop] = collection[prop];
collection[prop] = null;
}}
>
<i class="ri-lock-line" />
</button>
{/if}
<RuleField label="List/Search action" formKey="listRule" {collection} bind:rule={collection.listRule} />
<Field
class="form-field rule-field m-0 {isAdminOnly(collection[prop]) ? 'disabled' : ''}"
name={prop}
let:uniqueId
>
<label for={uniqueId}>
{label} - {isAdminOnly(collection[prop]) ? "Admins only" : "Custom rule"}
</label>
<hr class="m-t-sm m-b-sm" />
<RuleField label="View action" formKey="viewRule" {collection} bind:rule={collection.viewRule} />
<svelte:component
this={ruleInputComponent}
id={uniqueId}
bind:this={editorRefs[prop]}
bind:value={collection[prop]}
baseCollection={collection}
disabled={isAdminOnly(collection[prop])}
/>
<hr class="m-t-sm m-b-sm" />
<RuleField label="Create action" formKey="createRule" {collection} bind:rule={collection.createRule} />
<div class="help-block">
{#if isAdminOnly(collection[prop])}
Only admins will be able to access (unlock to change)
{:else}
Leave empty to grant everyone access
{/if}
</div>
</Field>
</div>
{/each}
<hr class="m-t-sm m-b-sm" />
<RuleField label="Update action" formKey="updateRule" {collection} bind:rule={collection.updateRule} />
<hr class="m-t-sm m-b-sm" />
<RuleField label="Delete action" formKey="deleteRule" {collection} bind:rule={collection.deleteRule} />
{#if collection?.isAuth}
<hr class="m-t-sm m-b-sm" />
<RuleField
label="Manage action"
formKey="options.manageRule"
{collection}
bind:rule={collection.options.manageRule}
>
<svelte:fragment>
<p>
This API rule gives admin-like permissions to allow fully managing the auth record(s), eg.
changing the password without requiring to enter the old one, directly updating the verified
state or email, etc.
</p>
<p>
This rule is executed in addition to the <code>create</code> and <code>update</code> API rules.
</p>
</svelte:fragment>
</RuleField>
{/if}
<style>
.rule-block {
display: flex;
align-items: flex-start;
gap: var(--xsSpacing);
}
.rule-toggle-btn {
margin-top: 15px;
}
</style>
@@ -7,17 +7,27 @@
import { errors, setErrors } from "@/stores/errors";
import { confirm } from "@/stores/confirmation";
import { addSuccessToast } from "@/stores/toasts";
import { addCollection, removeCollection, activeCollection } from "@/stores/collections";
import { addCollection, removeCollection } from "@/stores/collections";
import tooltip from "@/actions/tooltip";
import Field from "@/components/base/Field.svelte";
import Toggler from "@/components/base/Toggler.svelte";
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
import CollectionFieldsTab from "@/components/collections/CollectionFieldsTab.svelte";
import CollectionRulesTab from "@/components/collections/CollectionRulesTab.svelte";
import CollectionAuthOptionsTab from "@/components/collections/CollectionAuthOptionsTab.svelte";
import CollectionUpdateConfirm from "@/components/collections/CollectionUpdateConfirm.svelte";
const TAB_FIELDS = "fields";
const TAB_RULES = "api_rules";
const TAB_OPTIONS = "options";
const TYPE_BASE = "base";
const TYPE_AUTH = "auth";
const collectionTypes = {};
collectionTypes[TYPE_BASE] = "Base";
collectionTypes[TYPE_AUTH] = "Auth";
const dispatch = createEventDispatcher();
let collectionPanel;
@@ -42,6 +52,11 @@
$: canSave = collection.isNew || hasChanges;
$: if (activeTab === TAB_OPTIONS && collection.type !== TYPE_AUTH) {
// reset selected tab
changeTab(TAB_FIELDS);
}
export function changeTab(newTab) {
activeTab = newTab;
}
@@ -111,11 +126,10 @@
);
addCollection(result);
if (collection.isNew) {
$activeCollection = result;
}
dispatch("save", result);
dispatch("save", {
isNew: collection.isNew,
collection: result,
});
})
.catch((err) => {
ApiClient.errorResponseHandler(err);
@@ -163,11 +177,15 @@
function calculateFormHash(m) {
return JSON.stringify(m);
}
function setCollectionType(t) {
collection.type = t;
}
</script>
<OverlayPanel
bind:this={collectionPanel}
class="overlay-panel-lg colored-header compact-header collection-panel"
class="overlay-panel-lg colored-header collection-panel"
beforeHide={() => {
if (hasChanges && confirmClose) {
confirm("You have unsaved changes. Do you really want to close the panel?", () => {
@@ -191,7 +209,11 @@
<button type="button" class="btn btn-sm btn-circle btn-secondary flex-gap-0">
<i class="ri-more-line" />
<Toggler class="dropdown dropdown-right m-t-5">
<button type="button" class="dropdown-item closable" on:click={() => deleteConfirm()}>
<button
type="button"
class="dropdown-item txt-danger closable"
on:click|preventDefault|stopPropagation={() => deleteConfirm()}
>
<i class="ri-delete-bin-7-line" />
<span class="txt">Delete</span>
</button>
@@ -206,11 +228,12 @@
}}
>
<Field
class="form-field required m-b-0 {isSystemUpdate ? 'disabled' : ''}"
class="form-field collection-field-name required m-b-0 {isSystemUpdate ? 'disabled' : ''}"
name="name"
let:uniqueId
>
<label for={uniqueId}>Name</label>
<!-- svelte-ignore a11y-autofocus -->
<input
type="text"
@@ -226,6 +249,35 @@
e.target.value = collection.name;
}}
/>
<div class="form-field-addon">
<button
type="button"
class="btn btn-sm p-r-10 p-l-10 {collection.isNew ? 'btn-hint' : 'btn-secondary'}"
disabled={!collection.isNew}
>
<!-- empty span for alignment -->
<span />
<span class="txt">Type: {collectionTypes[collection.type] || "N/A"}</span>
{#if collection.isNew}
<i class="ri-arrow-down-s-fill" />
<Toggler class="dropdown dropdown-right dropdown-nowrap m-t-5">
{#each Object.entries(collectionTypes) as [type, label]}
<button
type="button"
class="dropdown-item closable"
class:selected={type == collection.type}
on:click={() => setCollectionType(type)}
>
<i class={CommonHelper.getCollectionTypeIcon(type)} />
<span class="txt">{label} collection</span>
</button>
{/each}
</Toggler>
{/if}
</button>
</div>
{#if collection.system}
<div class="help-block">System collection</div>
{/if}
@@ -258,7 +310,7 @@
on:click={() => changeTab(TAB_RULES)}
>
<span class="txt">API Rules</span>
{#if !CommonHelper.isEmpty($errors?.listRule) || !CommonHelper.isEmpty($errors?.viewRule) || !CommonHelper.isEmpty($errors?.createRule) || !CommonHelper.isEmpty($errors?.updateRule) || !CommonHelper.isEmpty($errors?.deleteRule)}
{#if !CommonHelper.isEmpty($errors?.listRule) || !CommonHelper.isEmpty($errors?.viewRule) || !CommonHelper.isEmpty($errors?.createRule) || !CommonHelper.isEmpty($errors?.updateRule) || !CommonHelper.isEmpty($errors?.deleteRule) || !CommonHelper.isEmpty($errors?.options?.manageRule)}
<i
class="ri-error-warning-fill txt-danger"
transition:scale|local={{ duration: 150, start: 0.7 }}
@@ -266,6 +318,24 @@
/>
{/if}
</button>
{#if collection.isAuth}
<button
type="button"
class="tab-item"
class:active={activeTab === TAB_OPTIONS}
on:click={() => changeTab(TAB_OPTIONS)}
>
<span class="txt">Options</span>
{#if !CommonHelper.isEmpty($errors?.options) && !$errors?.options?.manageRule}
<i
class="ri-error-warning-fill txt-danger"
transition:scale|local={{ duration: 150, start: 0.7 }}
use:tooltip={"Has errors"}
/>
{/if}
</button>
{/if}
</div>
</svelte:fragment>
@@ -280,6 +350,12 @@
<CollectionRulesTab bind:collection />
</div>
{/if}
{#if collection.isAuth}
<div class="tab-item" class:active={activeTab === TAB_OPTIONS}>
<CollectionAuthOptionsTab bind:collection />
</div>
{/if}
</div>
<svelte:fragment slot="footer">
@@ -302,6 +378,6 @@
<style>
.tabs-content {
z-index: 3; /* autocomplete dropdown overlay fix */
z-index: auto; /* autocomplete dropdown overlay fix */
}
</style>
@@ -1,4 +1,6 @@
<script>
import { link } from "svelte-spa-router";
import CommonHelper from "@/utils/CommonHelper";
import { hideControls } from "@/stores/app";
import { collections, activeCollection } from "@/stores/collections";
import CollectionUpsertPanel from "@/components/collections/CollectionUpsertPanel.svelte";
@@ -12,15 +14,27 @@
$: filteredCollections = $collections.filter((collection) => {
return (
collection.name != import.meta.env.PB_PROFILE_COLLECTION &&
(collection.id == searchTerm ||
collection.name.replace(/\s+/g, "").toLowerCase().includes(normalizedSearch))
collection.id == searchTerm ||
collection.name.replace(/\s+/g, "").toLowerCase().includes(normalizedSearch)
);
});
$: if ($collections) {
scrollIntoView();
}
function selectCollection(collection) {
$activeCollection = collection;
}
function scrollIntoView() {
setTimeout(() => {
const activeItem = document.querySelector(".collection-sidebar .sidebar-list-item.active");
if (activeItem) {
activeItem?.scrollIntoView({ block: "nearest" });
}
}, 0);
}
</script>
<aside class="page-sidebar collection-sidebar">
@@ -42,21 +56,18 @@
<hr class="m-t-5 m-b-xs" />
<div class="sidebar-content">
<div class="sidebar-content" class:sidebar-content-compact={filteredCollections.length > 20}>
{#each filteredCollections as collection (collection.id)}
<div
tabindex="0"
<a
href="/collections?collectionId={collection.id}"
class="sidebar-list-item"
class:active={$activeCollection?.id === collection.id}
on:click={() => selectCollection(collection)}
use:link
>
{#if $activeCollection?.id === collection.id}
<i class="ri-folder-open-line" />
{:else}
<i class="ri-folder-2-line" />
{/if}
<i class={CommonHelper.getCollectionTypeIcon(collection.type)} />
<span class="txt">{collection.name}</span>
</div>
</a>
{:else}
{#if normalizedSearch.length}
<p class="txt-hint m-t-10 m-b-10 txt-center">No collections found.</p>
@@ -74,4 +85,11 @@
{/if}
</aside>
<CollectionUpsertPanel bind:this={collectionPanel} />
<CollectionUpsertPanel
bind:this={collectionPanel}
on:save={(e) => {
if (e.detail?.isNew && e.detail.collection) {
selectCollection(e.detail.collection);
}
}}
/>
@@ -121,9 +121,15 @@
on:expand
on:collapse
on:toggle
on:dragenter
on:dragleave
on:dragstart
on:drop
draggable
single
{interactive}
class={disabled || field.toDelete || field.system ? "field-accordion disabled" : "field-accordion"}
{...$$restProps}
>
<svelte:fragment slot="header">
<div class="inline-flex">
@@ -144,7 +150,7 @@
<span class="label" class:label-warning={interactive && !field.toDelete}>New</span>
{/if}
{#if field.required}
<span class="label label-success">Required</span>
<span class="label label-success">Nonempty</span>
{/if}
{#if field.unique}
<span class="label label-success">Unique</span>
@@ -177,6 +183,11 @@
<form
class="field-form"
on:dragstart={(e) => {
e.stopPropagation();
e.preventDefault();
e.stopImmediatePropagation();
}}
on:submit|preventDefault={() => {
canBeStored && collapse();
}}
@@ -192,6 +203,7 @@
<FieldTypeSelect id={uniqueId} disabled={field.id} bind:value={field.type} />
</Field>
</div>
<div class="col-sm-6">
<Field
class="
@@ -257,7 +269,18 @@
<div class="col-sm-4 flex">
<Field class="form-field form-field-toggle m-0" name="requried" let:uniqueId>
<input type="checkbox" id={uniqueId} bind:checked={field.required} />
<label for={uniqueId}>Required</label>
<label for={uniqueId}>
<span class="txt">Nonempty</span>
<i
class="ri-information-line link-hint"
use:tooltip={{
text: `Requires the field value to be nonempty\n(aka. not ${CommonHelper.zeroDefaultStr(
field
)}).`,
position: "right",
}}
/>
</label>
</Field>
</div>
@@ -0,0 +1,121 @@
<script context="module">
let cachedRuleComponent;
</script>
<script>
import { tick } from "svelte";
import tooltip from "@/actions/tooltip";
import Field from "@/components/base/Field.svelte";
export let collection = null;
export let rule = null;
export let label = "Rule";
export let formKey = "rule";
export let required = false;
let editorRef = null;
let tempValue = null;
let ruleInputComponent = cachedRuleComponent;
let isRuleComponentLoading = false;
$: isAdminOnly = rule === null;
async function loadEditorComponent() {
if (ruleInputComponent || isRuleComponentLoading) {
return; // already loaded or in the process
}
isRuleComponentLoading = true;
ruleInputComponent = (await import("@/components/base/FilterAutocompleteInput.svelte")).default;
cachedRuleComponent = ruleInputComponent;
isRuleComponentLoading = false;
}
loadEditorComponent();
</script>
{#if isRuleComponentLoading}
<div class="txt-center">
<span class="loader" />
</div>
{:else}
<div class="rule-block">
{#if isAdminOnly}
<button
type="button"
class="rule-toggle-btn btn btn-circle btn-outline btn-success"
use:tooltip={{
text: "Unlock and set custom rule",
position: "left",
}}
on:click={async () => {
rule = tempValue || "";
await tick();
editorRef?.focus();
}}
>
<i class="ri-lock-unlock-line" />
</button>
{:else}
<button
type="button"
class="rule-toggle-btn btn btn-circle btn-outline"
use:tooltip={{
text: "Lock and set to Admins only",
position: "left",
}}
on:click={() => {
tempValue = rule;
rule = null;
}}
>
<i class="ri-lock-line" />
</button>
{/if}
<Field
class="form-field rule-field m-0 {required ? 'requied' : ''} {isAdminOnly ? 'disabled' : ''}"
name={formKey}
let:uniqueId
>
<label for={uniqueId}>
{label} - {isAdminOnly ? "Admins only" : "Custom rule"}
</label>
<svelte:component
this={ruleInputComponent}
id={uniqueId}
bind:this={editorRef}
bind:value={rule}
baseCollection={collection}
disabled={isAdminOnly}
/>
<div class="help-block">
<slot {isAdminOnly}>
<p>
{#if isAdminOnly}
Only admins will be able to perform this action (unlock to change)
{:else}
Leave empty to grant everyone access
{/if}
</p>
</slot>
</div>
</Field>
</div>
{/if}
<style>
.rule-block {
display: flex;
align-items: flex-start;
gap: var(--xsSpacing);
}
.rule-toggle-btn {
margin-top: 15px;
}
</style>
@@ -0,0 +1,110 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: `
{
"usernamePassword": true,
"emailPassword": true,
"authProviders": [
{
"name": "github",
"state": "3Yd8jNkK_6PJG6hPWwBjLqKwse6Ejd",
"codeVerifier": "KxFDWz1B3fxscCDJ_9gHQhLuh__ie7",
"codeChallenge": "NM1oVexB6Q6QH8uPtOUfK7tq4pmu4Jz6lNDIwoxHZNE=",
"codeChallengeMethod": "S256",
"authUrl": "https://github.com/login/oauth/authorize?client_id=demo&code_challenge=NM1oVexB6Q6QH8uPtOUfK7tq4pmu4Jz6lNDIwoxHZNE%3D&code_challenge_method=S256&response_type=code&scope=user&state=3Yd8jNkK_6PJG6hPWwBjLqKwse6Ejd&redirect_uri="
},
{
"name": "gitlab",
"state": "NeQSbtO5cShr_mk5__3CUukiMnymeb",
"codeVerifier": "ahTFHOgua8mkvPAlIBGwCUJbWKR_xi",
"codeChallenge": "O-GATkTj4eXDCnfonsqGLCd6njvTixlpCMvy5kjgOOg=",
"codeChallengeMethod": "S256",
"authUrl": "https://gitlab.com/oauth/authorize?client_id=demo&code_challenge=O-GATkTj4eXDCnfonsqGLCd6njvTixlpCMvy5kjgOOg%3D&code_challenge_method=S256&response_type=code&scope=read_user&state=NeQSbtO5cShr_mk5__3CUukiMnymeb&redirect_uri="
},
{
"name": "google",
"state": "zB3ZPifV1TW2GMuvuFkamSXfSNkHPQ",
"codeVerifier": "t3CmO5VObGzdXqieakvR_fpjiW0zdO",
"codeChallenge": "KChwoQPKYlz2anAdqtgsSTdIo8hdwtc1fh2wHMwW2Yk=",
"codeChallengeMethod": "S256",
"authUrl": "https://accounts.google.com/o/oauth2/auth?client_id=demo&code_challenge=KChwoQPKYlz2anAdqtgsSTdIo8hdwtc1fh2wHMwW2Yk%3D&code_challenge_method=S256&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&state=zB3ZPifV1TW2GMuvuFkamSXfSNkHPQ&redirect_uri="
}
]
}
`,
},
];
</script>
<h3 class="m-b-sm">List auth methods ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Returns a public list with all allowed <strong>{collection.name}</strong> authentication methods.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const result = await pb.collection('${collection?.name}').listAuthMethods();
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final result = await pb.collection('${collection?.name}').listAuthMethods();
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-info">
<strong class="label label-primary">GET</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/auth-methods
</p>
</div>
</div>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,169 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"identity": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
{
code: 401,
body: `
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`,
},
{
code: 403,
body: `
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`,
},
];
</script>
<h3 class="m-b-sm">Auth refresh ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>
Returns a new auth response (token and account data) for an
<strong>already authenticated record</strong>.
</p>
<p>
<em>
This method is usually called by users on page/screen reload to ensure that the previously stored
data in <code>pb.authStore</code> is still valid and up-to-date.
</em>
</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').authRefresh();
// after the above you can also access the refreshed auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/auth-refresh
</p>
</div>
<p class="txt-hint txt-sm txt-right">Requires record <code>Authorization:TOKEN</code> header</p>
</div>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,261 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
meta: {
id: "abc123",
name: "John Doe",
username: "john.doe",
email: "test@example.com",
avatarUrl: "https://example.com/avatar.png",
},
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "An error occurred while submitting the form.",
"data": {
"provider": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Auth with OAuth2 ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Authenticate with an OAuth2 provider and returns a new auth token and account data.</p>
<p>This action usually should be called right after the provider login page redirect.</p>
<p>
You could also check the
<a href={import.meta.env.PB_OAUTH2_EXAMPLE} target="_blank" rel="noopener noreferrer">
OAuth2 web integration example
</a>.
</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
{
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').authWithOAuth2(
'google',
'CODE',
'VERIFIER',
'REDIRECT_URL',
// optional data that will be used for the new account on OAuth2 sign-up
createData: {
'name': 'test',
},
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/auth-with-oauth2
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>provider</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The name of the OAuth2 client provider (eg. "google").</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>code</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The authorization code returned from the initial request.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>codeVerifier</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The code verifier sent with the initial request as part of the code_challenge.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>redirectUrl</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The redirect url sent with the initial request.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>createData</span>
</div>
</td>
<td>
<span class="label">Object</span>
</td>
<td>
<p>Optional data that will be used when creating the auth record on OAuth2 sign-up.</p>
<p>
The created auth record must comply with the same requirements and validations in the
regular <strong>create</strong> action.
<br />
<em>
The data can only be in <code>json</code>, aka. <code>multipart/form-data</code> and files
upload currently are not supported during OAuth2 sign-ups.
</em>
</p>
</td>
</tr>
</tbody>
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,223 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: allowEmail = collection?.options?.allowEmailAuth;
$: allowUsername = collection?.options?.allowUsernameAuth;
$: exampleIdentityLabel =
allowUsername && allowEmail
? "YOUR_USERNAME_OR_EMAIL"
: allowUsername
? "YOUR_USERNAME"
: "YOUR_EMAIL";
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"identity": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Auth with password ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>
Returns new auth token and account data by a combination of
<strong>
{#if allowUsername && allowEmail}
username/email
{:else if allowUsername}
username
{:else if allowEmail}
email
{/if}
</strong>
and <strong>password</strong>.
</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').authWithPassword(
'${exampleIdentityLabel}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').authWithPassword(
'${exampleIdentityLabel}',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
print(pb.authStore.isValid);
print(pb.authStore.token);
print(pb.authStore.model.id);
// "logout" the last authenticated account
pb.authStore.clear();
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/auth-with-password
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>identity</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>
The
{#if allowUsername}
<strong>username</strong>
{/if}
{#if allowUsername && allowEmail}
or
{/if}
{#if allowEmail}
<strong>email</strong>
{/if}
of the record to authenticate.
</td>
</tr>
<tr>
<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>The auth record password.</td>
</tr>
</tbody>
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -1,111 +0,0 @@
<script>
import { Collection } from "pocketbase";
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
import ListApiDocs from "@/components/collections/docs/ListApiDocs.svelte";
import ViewApiDocs from "@/components/collections/docs/ViewApiDocs.svelte";
import CreateApiDocs from "@/components/collections/docs/CreateApiDocs.svelte";
import UpdateApiDocs from "@/components/collections/docs/UpdateApiDocs.svelte";
import DeleteApiDocs from "@/components/collections/docs/DeleteApiDocs.svelte";
import RealtimeApiDocs from "@/components/collections/docs/RealtimeApiDocs.svelte";
const tabs = [
{
id: "list",
label: "List",
component: ListApiDocs,
},
{
id: "view",
label: "View",
component: ViewApiDocs,
},
{
id: "create",
label: "Create",
component: CreateApiDocs,
},
{
id: "update",
label: "Update",
component: UpdateApiDocs,
},
{
id: "delete",
label: "Delete",
component: DeleteApiDocs,
},
{
id: "realtime",
label: "Realtime",
component: RealtimeApiDocs,
},
];
let collectionPanel;
let collection = new Collection();
let activeTab = tabs[0].id;
export function show(model) {
collection = model;
changeTab(tabs[0].id);
return collectionPanel?.show();
}
export function hide() {
return collectionPanel?.hide();
}
export function changeTab(newTab) {
activeTab = newTab;
}
function changeTabViaKey(e, newTab) {
if (e.code === "Enter" || e.code === "Space") {
e.preventDefault();
changeTab(newTab);
}
}
</script>
<OverlayPanel
bind:this={collectionPanel}
on:hide
on:show
class="overlay-panel-xl colored-header collection-panel"
>
<svelte:fragment slot="header">
<h4><strong>{collection.name}</strong> records API</h4>
<div class="tabs-header stretched">
{#each tabs as tab (tab.id)}
<button
tabindex="0"
class="tab-item"
class:active={activeTab === tab.id}
on:click={() => changeTab(tab.id)}
on:keydown|self={(e) => changeTabViaKey(e, tab.id)}
>
<span class="txt">{tab.label}</span>
</button>
{/each}
</div>
</svelte:fragment>
<div class="tabs-content">
{#each tabs as tab (tab.id)}
{#if activeTab === tab.id}
<div class="tab-item active">
<svelte:component this={tab.component} {collection} />
</div>
{/if}
{/each}
</div>
<svelte:fragment slot="footer">
<button type="button" class="btn btn-secondary" on:click={() => hide()}>
<span class="txt">Close</span>
</button>
</svelte:fragment>
</OverlayPanel>
@@ -0,0 +1,183 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Confirm email change ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Confirms <strong>{collection.name}</strong> email change request.</p>
<p>Returns the refreshed auth data.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').confirmEmailChange(
'TOKEN',
'YOUR_PASSWORD',
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/confirm-email-change
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>token</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The token from the change email request email.</td>
</tr>
<tr>
<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>The account password to confirm the email change.</td>
</tr>
</tbody>
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,197 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Confirm password reset ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Confirms <strong>{collection.name}</strong> password reset request.</p>
<p>Returns the refreshed auth data.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').confirmPasswordReset(
'TOKEN',
'NEW_PASSWORD',
'NEW_PASSWORD_CONFIRM',
);
// after the above you can also access the refreshed auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/confirm-password-reset
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>token</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The token from the password reset request email.</td>
</tr>
<tr>
<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>The new password to set.</td>
</tr>
<tr>
<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>The new password confirmation.</td>
</tr>
</tbody>
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,165 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: JSON.stringify(
{
token: "JWT_TOKEN",
record: CommonHelper.dummyCollectionRecord(collection),
},
null,
2
),
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"token": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Confirm verification ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Confirms <strong>{collection.name}</strong> account verification request.</p>
<p>Returns the refreshed auth data.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const authData = await pb.collection('${collection?.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final authData = await pb.collection('${collection?.name}').confirmVerification('TOKEN');
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/confirm-verification
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>token</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The token from the verification request email.</td>
</tr>
</tbody>
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>expand</td>
<td>
<span class="label">String</span>
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -9,6 +9,7 @@
let responseTab = 200;
let responses = [];
let baseData = {};
$: adminsOnly = collection?.createRule === null;
@@ -45,8 +46,66 @@
`,
},
];
$: if (collection.isAuth) {
baseData = {
username: "test_username",
email: "test@exampe.com",
emailVisibility: true,
password: "12345678",
passwordConfirm: "12345678",
};
} else {
baseData = {};
}
</script>
<h3 class="m-b-sm">Create ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Create a new <strong>{collection.name}</strong> record.</p>
<p>
Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.
</p>
<p>
File upload is supported only via <code>multipart/form-data</code>.
<br />
For more info and examples you could check the detailed
<a href={import.meta.env.PB_FILE_UPLOAD_DOCS} target="_blank" rel="noopener noreferrer">
Files upload and handling docs
</a>.
</p>
</div>
<!-- prettier-ignore -->
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
// example create data
const data = ${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 4)};
const record = await pb.collection('${collection?.name}').create(data);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
// example create body
final body = <String, dynamic>${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 2)};
final record = await pb.collection('${collection?.name}').create(body: body);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
@@ -55,49 +114,12 @@
</p>
</div>
{#if adminsOnly}
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization: Admin TOKEN</code> header</p>
<p class="txt-hint txt-sm txt-right">Requires admin <code>Authorization:TOKEN</code> header</p>
{/if}
</div>
<div class="content m-b-base">
<p>Create a new <strong>{collection.name}</strong> record.</p>
<p>
Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.
</p>
<p>
File upload is supported only via <code>multipart/form-data</code>.
</p>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
const data = { ... };
const record = await client.records.create('${collection?.name}', data);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
final body = <String, dynamic>{ ... };
final record = await client.records.create('${collection?.name}', body: body);
`}
/>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -122,6 +144,100 @@
If not set, it will be auto generated.
</td>
</tr>
{#if collection?.isAuth}
<tr>
<td colspan="3" class="txt-hint">Auth fields</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>username</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>
The username of the auth record.
<br />
If not set, it will be auto generated.
</td>
</tr>
<tr>
<td>
<div class="inline-flex">
{#if collection?.options?.requireEmail}
<span class="label label-success">Required</span>
{:else}
<span class="label label-warning">Optional</span>
{/if}
<span>email</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>Auth record email address.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>emailVisibility</span>
</div>
</td>
<td>
<span class="label">Boolean</span>
</td>
<td>Whether to show/hide the auth record email when fetching the record data.</td>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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 admins or auth records with "Manage" access.
</td>
</tr>
<tr>
<td colspan="3" class="txt-hint">Schema fields</td>
</tr>
{/if}
{#each collection?.schema as field (field.name)}
<tr>
<td>
@@ -152,9 +268,7 @@
File object.<br />
Set to <code>null</code> to delete already uploaded file(s).
{:else if field.type === "relation"}
Relation record {field.options?.maxSelect > 1 ? "ids" : "id"}.
{:else if field.type === "user"}
User {field.options?.maxSelect > 1 ? "ids" : "id"}.
Relation record {field.options?.maxSelect === 1 ? "id" : "ids"}.
{/if}
</td>
</tr>
@@ -163,7 +277,7 @@
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -179,15 +293,12 @@
</td>
<td>
Auto expand relations when returning the created record. Ex.:
<CodeBlock
content={`
?expand=rel1,rel2.subrel21.subrel22
`}
/>
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>@expand</code> property (eg. <code>{`"@expand": {"rel1": {...}, ...}`}</code>). Only the
relations that the user has permissions to <strong>view</strong> will be expanded.
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
@@ -59,6 +59,33 @@
}
</script>
<h3 class="m-b-sm">Delete ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Delete a single <strong>{collection.name}</strong> record.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').delete('RECORD_ID');
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').delete('RECORD_ID');
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-danger">
<strong class="label label-primary">DELETE</strong>
<div class="content">
@@ -67,38 +94,12 @@
</p>
</div>
{#if adminsOnly}
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization: Admin TOKEN</code> header</p>
<p class="txt-hint txt-sm txt-right">Requires admin <code>Authorization:TOKEN</code> header</p>
{/if}
</div>
<div class="content m-b-base">
<p>Delete a single <strong>{collection.name}</strong> record.</p>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
await client.records.delete('${collection?.name}', 'RECORD_ID');
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
await client.records.delete('${collection?.name}', 'RECORD_ID');
`}
/>
<div class="section-title">Path parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -1,66 +1,86 @@
<p>
The syntax basically follows the format
<code>
<span class="txt-success">OPERAND</span>
<span class="txt-danger">OPERATOR</span>
<span class="txt-success">OPERAND</span></code
>, where:
</p>
<ul>
<li>
<code class="txt-success">OPERAND</code> - could be any of the above field literal, string (single or double
quoted), number, null, true, false
</li>
<li>
<code class="txt-danger">OPERATOR</code> - is one of:
<br />
<ul>
<li>
<code class="filter-op">{"="}</code>
<span class="txt-hint">Equal</span>
</li>
<li>
<code class="filter-op">{"!="}</code>
<span class="txt-hint">NOT equal</span>
</li>
<li>
<code class="filter-op">{">"}</code>
<span class="txt-hint">Greater than</span>
</li>
<li>
<code class="filter-op">{">="}</code>
<span class="txt-hint">Greater than or equal</span>
</li>
<li>
<code class="filter-op">{"<"}</code>
<span class="txt-hint">Less than or equal</span>
</li>
<li>
<code class="filter-op">{"<="}</code>
<span class="txt-hint">Less than or equal</span>
</li>
<li>
<code class="filter-op">{"~"}</code>
<span class="txt-hint">
Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for wildcard
match)
</span>
</li>
<li>
<code class="filter-op">{"!~"}</code>
<span class="txt-hint">
NOT Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for
wildcard match)
</span>
</li>
</ul>
</li>
</ul>
<script>
let expanded = false;
<p>
To group and combine several expressions you could use brackets
<code>(...)</code>, <code>&&</code> (AND) and <code>||</code> (OR) tokens.
</p>
function toggle() {
expanded = !expanded;
}
</script>
<button class="btn btn-sm btn-secondary m-t-5" on:click={toggle}>
{#if expanded}
<span class="txt">Hide details</span>
<i class="ri-arrow-up-s-line" />
{:else}
<span class="txt">Show details</span>
<i class="ri-arrow-down-s-line" />
{/if}
</button>
{#if expanded}
<p>
The syntax basically follows the format
<code>
<span class="txt-success">OPERAND</span>
<span class="txt-danger">OPERATOR</span>
<span class="txt-success">OPERAND</span></code
>, where:
</p>
<ul>
<li>
<code class="txt-success">OPERAND</code> - could be any of the above field literal, string (single
or double quoted), number, null, true, false
</li>
<li>
<code class="txt-danger">OPERATOR</code> - is one of:
<br />
<ul>
<li>
<code class="filter-op">{"="}</code>
<span class="txt-hint">Equal</span>
</li>
<li>
<code class="filter-op">{"!="}</code>
<span class="txt-hint">NOT equal</span>
</li>
<li>
<code class="filter-op">{">"}</code>
<span class="txt-hint">Greater than</span>
</li>
<li>
<code class="filter-op">{">="}</code>
<span class="txt-hint">Greater than or equal</span>
</li>
<li>
<code class="filter-op">{"<"}</code>
<span class="txt-hint">Less than or equal</span>
</li>
<li>
<code class="filter-op">{"<="}</code>
<span class="txt-hint">Less than or equal</span>
</li>
<li>
<code class="filter-op">{"~"}</code>
<span class="txt-hint">
Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for
wildcard match)
</span>
</li>
<li>
<code class="filter-op">{"!~"}</code>
<span class="txt-hint">
NOT Like/Contains (if not specified auto wraps the right string OPERAND in a "%" for
wildcard match)
</span>
</li>
</ul>
</li>
</ul>
<p>
To group and combine several expressions you could use brackets
<code>(...)</code>, <code>&&</code> (AND) and <code>||</code> (OR) tokens.
</p>
{/if}
<style>
.filter-op {
@@ -22,6 +22,7 @@
{
page: 1,
perPage: 30,
totalPages: 1,
totalItems: 2,
items: [
CommonHelper.dummyCollectionRecord(collection),
@@ -70,6 +71,65 @@
}
</script>
<h3 class="m-b-sm">List/Search ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>
Fetch a paginated <strong>{collection.name}</strong> records list, supporting sorting and filtering.
</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
// fetch a paginated records list
const resultList = await pb.collection('${collection?.name}').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
});
// you can also fetch all records at once via getFullList:
const records = await pb.collection('${collection?.name}').getFullList(200 /* batch size */, {
sort: '-created'
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('${collection?.name}').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
// fetch a paginated records list
final result = await pb.collection('${collection?.name}').getList(
page: 1,
perPage: 50,
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
);
// alternatively you can also fetch all records at once via getFullList:
final records = await pb.collection('${collection?.name}').getFullList(
batch: 200,
sort: '-created',
);
// or fetch only the first record that matches the specified filter
final record2 = await pb.collection('${collection?.name}').getFirstListItem(
'someField="test"',
expand: 'relField1,relField2.subRelField',
);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-info">
<strong class="label label-primary">GET</strong>
<div class="content">
@@ -78,55 +138,12 @@
</p>
</div>
{#if adminsOnly}
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization: Admin TOKEN</code> header</p>
<p class="txt-hint txt-sm txt-right">Requires admin <code>Authorization:TOKEN</code> header</p>
{/if}
</div>
<div class="content m-b-base">
<p>Fetch a paginated <strong>{collection.name}</strong> records list.</p>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
// fetch a paginated records list
const resultList = await client.records.getList('${collection?.name}', 1, 50, {
filter: 'created >= "2022-01-01 00:00:00"',
});
// alternatively you can also fetch all records at once via getFullList:
const records = await client.records.getFullList('${collection?.name}', 200 /* batch size */, {
sort: '-created',
});
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
// fetch a paginated records list
final result = await client.records.getList(
'${collection?.name}',
page: 1,
perPage: 50,
filter: 'created >= "2022-01-01 00:00:00"',
);
// alternatively you can also fetch all records at once via getFullList:
final records = await client.records.getFullList('${collection?.name}', batch: 200, sort: '-created');
`}
/>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -188,15 +205,12 @@
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock
content={`
?expand=rel1,rel2.subrel21.subrel22
`}
/>
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to each individual record under the
<code>@expand</code> property (eg. <code>{`"@expand": {"rel1": {...}, ...}`}</code>). Only the
relations that the user has permissions to <strong>view</strong> will be expanded.
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
@@ -0,0 +1,162 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 200;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 200,
body: `
[
{
"id": "8171022dc95a4e8",
"created": "2022-09-01 10:24:18.434",
"updated": "2022-09-01 10:24:18.889",
"recordId": "e22581b6f1d44ea",
"collectionId": "${collection.id}",
"provider": "google",
"providerId": "2da15468800514p",
},
{
"id": "171022dc895a4e8",
"created": "2022-09-01 10:24:18.434",
"updated": "2022-09-01 10:24:18.889",
"recordId": "e22581b6f1d44ea",
"collectionId": "${collection.id}",
"provider": "twitter",
"providerId": "720688005140514",
}
]
`,
},
{
code: 401,
body: `
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`,
},
{
code: 403,
body: `
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`,
},
{
code: 404,
body: `
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`,
},
];
</script>
<h3 class="m-b-sm">List OAuth2 accounts ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>
Returns a list with all OAuth2 providers linked to a single <strong>{collection.name}</strong>.
</p>
<p>Only admins and the account owner can access this action.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
const result = await pb.collection('${collection?.name}').listExternalAuths(
pb.authStore.model.id
);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
final result = await pb.collection('${collection?.name}').listExternalAuths(
pb.authStore.model.id,
);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-info">
<strong class="label label-primary">GET</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/records/<strong>:id</strong>/external-auths
</p>
</div>
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization:TOKEN</code> header</p>
</div>
<div class="section-title">Path Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>
<span class="label">String</span>
</td>
<td>ID of the auth record.</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -10,6 +10,87 @@
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
</script>
<h3 class="m-b-sm">Realtime ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Subscribe to realtime changes via Server-Sent Events (SSE).</p>
<p>
Events are sent for <strong>create</strong>, <strong>update</strong>
and <strong>delete</strong> record operations (see "Event data format" section below).
</p>
</div>
<div class="alert alert-info m-t-10 m-b-sm">
<div class="icon">
<i class="ri-information-line" />
</div>
<div class="contet">
<p>
<strong>You could subscribe to a single record or to an entire collection.</strong>
</p>
<p>
When you subscribe to a <strong>single record</strong>, the collection's
<strong>ViewRule</strong> will be used to determine whether the subscriber has access to receive the
event message.
</p>
<p>
When you subscribe to an <strong>entire collection</strong>, the collection's
<strong>ListRule</strong> will be used to determine whether the subscriber has access to receive the
event message.
</p>
</div>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${collection?.name}').subscribe(function (e) {
console.log(e.record);
});
// Subscribe to changes in a single record
pb.collection('${collection?.name}').subscribeOne('RECORD_ID', function (e) {
console.log(e.record);
});
// Unsubscribe
pb.collection('${collection?.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${collection?.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
// (Optionally) authenticate
await pb.collection('users').authWithPassword('test@example.com', '123456');
// Subscribe to changes in any record from the collection
pb.collection('${collection?.name}').subscribe((e) {
print(e.record);
});
// Subscribe to changes in a single record
pb.collection('${collection?.name}').subscribeOne('RECORD_ID', (e) {
print(e.record);
});
// Unsubscribe
pb.collection('${collection?.name}').unsubscribe() // remove all collection subscriptions
pb.collection('${collection?.name}').unsubscribe('RECORD_ID') // remove only the record subscription
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert">
<strong class="label label-primary">SSE</strong>
<div class="content">
@@ -17,88 +98,6 @@
</div>
</div>
<div class="content m-b-base">
<p>Subscribe to realtime changes via Server-Sent Events (SSE).</p>
<p>
Events are sent for <strong>create</strong>, <strong>update</strong>
and <strong>delete</strong> record operations (see "Event data format" section below).
</p>
<div class="alert alert-info m-t-10">
<div class="icon">
<i class="ri-information-line" />
</div>
<div class="contet">
<p>
<strong>You could subscribe to a single record or to an entire collection.</strong>
</p>
<p>
When you subscribe to a <strong>single record</strong>, the collection's
<strong>ViewRule</strong> will be used to determine whether the subscriber has access to receive
the event message.
</p>
<p>
When you subscribe to an <strong>entire collection</strong>, the collection's
<strong>ListRule</strong> will be used to determine whether the subscriber has access to receive
the event message.
</p>
</div>
</div>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
// (Optionally) authenticate
client.users.authViaEmail('test@example.com', '123456');
// Subscribe to changes in any record from the collection
client.realtime.subscribe('${collection?.name}', function (e) {
console.log(e.record);
});
// Subscribe to changes in a single record
client.realtime.subscribe('${collection?.name}/RECORD_ID', function (e) {
console.log(e.record);
});
// Unsubscribe
client.realtime.unsubscribe() // remove all subscriptions
client.realtime.unsubscribe('${collection?.name}') // remove only the collection subscription
client.realtime.unsubscribe('${collection?.name}/RECORD_ID') // remove only the record subscription
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
// (Optionally) authenticate
client.users.authViaEmail('test@example.com', '123456');
// Subscribe to changes in any record from the collection
client.realtime.subscribe('${collection?.name}', (e) {
print(e.record);
});
// Subscribe to changes in a single record
client.realtime.subscribe('${collection?.name}/RECORD_ID', (e) {
print(e.record);
});
// Unsubscribe
client.realtime.unsubscribe() // remove all subscriptions
client.realtime.unsubscribe('${collection?.name}') // remove only the collection subscription
client.realtime.unsubscribe('${collection?.name}/RECORD_ID') // remove only the record subscription
`}
/>
<div class="section-title">Event data format</div>
<CodeBlock
content={JSON.stringify(
@@ -0,0 +1,144 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 204;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 204,
body: "null",
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"newEmail": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
{
code: 401,
body: `
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`,
},
{
code: 403,
body: `
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`,
},
];
</script>
<h3 class="m-b-sm">Request email change ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Sends <strong>{collection.name}</strong> email change request.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${collection?.name}').requestEmailChange('new@example.com');
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${collection?.name}').requestEmailChange('new@example.com');
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/confirm-email-change
</p>
</div>
<p class="txt-hint txt-sm txt-right">Requires record <code>Authorization:TOKEN</code> header</p>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>newEmail</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The new email address to send the change email request.</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,119 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 204;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 204,
body: "null",
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"email": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Request password reset ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Sends <strong>{collection.name}</strong> password reset email request.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').requestPasswordReset('test@example.com');
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').requestPasswordReset('test@example.com');
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/request-password-reset
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>email</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The auth record email address to send the password reset request (if exists).</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -0,0 +1,119 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 204;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 204,
body: "null",
},
{
code: 400,
body: `
{
"code": 400,
"message": "Failed to authenticate.",
"data": {
"email": {
"code": "validation_required",
"message": "Missing required value."
}
}
}
`,
},
];
</script>
<h3 class="m-b-sm">Request verification ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Sends <strong>{collection.name}</strong> verification email request.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').requestVerification('test@example.com');
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').requestVerification('test@example.com');
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-success">
<strong class="label label-primary">POST</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/request-password-reset
</p>
</div>
</div>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="50%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="inline-flex">
<span class="label label-success">Required</span>
<span>email</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The auth record email address to send the verification request (if exists).</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -18,16 +18,18 @@
title: "JavaScript",
language: "javascript",
content: js,
url: import.meta.env.PB_JS_SDK_URL,
},
{
title: "Dart",
language: "dart",
content: dart,
url: import.meta.env.PB_DART_SDK_URL,
},
];
</script>
<div class="tabs sdk-tabs m-b-lg">
<div class="tabs sdk-tabs m-b-base">
<div class="tabs-header compact left">
{#each sdkExamples as example (example.language)}
<button
@@ -43,6 +45,13 @@
{#each sdkExamples as example (example.language)}
<div class="tab-item" class:active={activeTab === example.language}>
<CodeBlock language={example.language} content={example.content} />
<div class="txt-right">
<em class="txt-sm txt-hint">
<a href={example.url} target="_blank" rel="noopener noreferrer">
{example.title} SDK
</a>
</em>
</div>
</div>
{/each}
</div>
@@ -0,0 +1,154 @@
<script>
import { Collection } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import CodeBlock from "@/components/base/CodeBlock.svelte";
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
export let collection = new Collection();
let responseTab = 204;
let responses = [];
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
$: responses = [
{
code: 204,
body: "null",
},
{
code: 401,
body: `
{
"code": 401,
"message": "The request requires valid record authorization token to be set.",
"data": {}
}
`,
},
{
code: 403,
body: `
{
"code": 403,
"message": "The authorized record model is not allowed to perform this action.",
"data": {}
}
`,
},
{
code: 404,
body: `
{
"code": 404,
"message": "The requested resource wasn't found.",
"data": {}
}
`,
},
];
</script>
<h3 class="m-b-sm">Unlink OAuth2 account ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>
Unlink a single external OAuth2 provider from <strong>{collection.name}</strong> record.
</p>
<p>Only admins and the account owner can access this action.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${collection?.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google'
);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
await pb.collection('${collection?.name}').authViaEmail('test@example.com', '123456');
await pb.collection('${collection?.name}').unlinkExternalAuth(
pb.authStore.model.id,
'google',
);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-danger">
<strong class="label label-primary">DELETE</strong>
<div class="content">
<p>
/api/collections/<strong>{collection.name}</strong>/records/<strong>:id</strong
>/external-auths/<strong>:provider</strong>
</p>
</div>
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization:TOKEN</code> header</p>
</div>
<div class="section-title">Path Parameters</div>
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th width="60%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>
<span class="label">String</span>
</td>
<td>ID of the auth record.</td>
</tr>
<tr>
<td>provider</td>
<td>
<span class="label">String</span>
</td>
<td>
The name of the auth provider to unlink, eg. <code>google</code>, <code>twitter</code>,
<code>github</code>, etc.
</td>
</tr>
</tbody>
</table>
<div class="section-title">Responses</div>
<div class="tabs">
<div class="tabs-header compact left">
{#each responses as response (response.code)}
<button
class="tab-item"
class:active={responseTab === response.code}
on:click={() => (responseTab = response.code)}
>
{response.code}
</button>
{/each}
</div>
<div class="tabs-content">
{#each responses as response (response.code)}
<div class="tab-item" class:active={responseTab === response.code}>
<CodeBlock content={response.body} />
</div>
{/each}
</div>
</div>
@@ -9,6 +9,7 @@
let responseTab = 200;
let responses = [];
let baseData = {};
$: adminsOnly = collection?.updateRule === null;
@@ -55,8 +56,66 @@
`,
},
];
$: if (collection.isAuth) {
baseData = {
username: "test_username_update",
emailVisibility: false,
password: "87654321",
passwordConfirm: "87654321",
oldPassword: "12345678",
};
} else {
baseData = {};
}
</script>
<h3 class="m-b-sm">Update ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Update a single <strong>{collection.name}</strong> record.</p>
<p>
Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.
</p>
<p>
File upload is supported only via <code>multipart/form-data</code>.
<br />
For more info and examples you could check the detailed
<a href={import.meta.env.PB_FILE_UPLOAD_DOCS} target="_blank" rel="noopener noreferrer">
Files upload and handling docs
</a>.
</p>
</div>
<!-- prettier-ignore -->
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
// example update data
const data = ${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 4)};
const record = await pb.collection('${collection?.name}').update('RECORD_ID', data);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
// example update body
final body = <String, dynamic>${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 2)};
final record = await pb.collection('${collection?.name}').update('RECORD_ID', body: body);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-warning">
<strong class="label label-primary">PATCH</strong>
<div class="content">
@@ -65,49 +124,12 @@
</p>
</div>
{#if adminsOnly}
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization: Admin TOKEN</code> header</p>
<p class="txt-hint txt-sm txt-right">Requires admin <code>Authorization:TOKEN</code> header</p>
{/if}
</div>
<div class="content m-b-base">
<p>Update a single <strong>{collection.name}</strong> record.</p>
<p>
Body parameters could be sent as <code>application/json</code> or
<code>multipart/form-data</code>.
</p>
<p>
File upload is supported only via <code>multipart/form-data</code>.
</p>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
const data = { ... };
const record = await client.records.update('${collection?.name}', 'RECORD_ID', data);
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
final body = <String, dynamic>{ ... };
final record = await client.records.update('${collection?.name}', 'RECORD_ID', body: body);
`}
/>
<div class="section-title">Path parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -127,7 +149,7 @@
</table>
<div class="section-title">Body Parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -136,6 +158,114 @@
</tr>
</thead>
<tbody>
{#if collection?.isAuth}
<tr>
<td colspan="3" class="txt-hint">Auth fields</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>username</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>The username of the auth record.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>email</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>
The auth record email address.
<br />
This field can be updated only by admins or auth records with "Manage" access.
<br />
Regular accounts can update their email by calling "Request email change".
</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>emailVisibility</span>
</div>
</td>
<td>
<span class="label">Boolean</span>
</td>
<td>Whether to show/hide the auth record email when fetching the record data.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>oldPassword</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>
Old auth record password.
<br />
This field is required only when changing the record password. Admins and auth records with
"Manage" access can skip this field.
</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>password</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>New auth record password.</td>
</tr>
<tr>
<td>
<div class="inline-flex">
<span class="label label-warning">Optional</span>
<span>passwordConfirm</span>
</div>
</td>
<td>
<span class="label">String</span>
</td>
<td>New auth record password confirmation.</td>
</tr>
<tr>
<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 admins or auth records with "Manage" access.
</td>
</tr>
<tr>
<td colspan="3" class="txt-hint">Schema fields</td>
</tr>
{/if}
{#each collection?.schema as field (field.name)}
<tr>
<td>
@@ -193,15 +323,11 @@
</td>
<td>
Auto expand relations when returning the updated record. Ex.:
<CodeBlock
content={`
?expand=rel1,rel2.subrel21.subrel22
`}
/>
<CodeBlock content={`?expand=relField1,relField2.subRelField21`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>@expand</code> property (eg. <code>{`"@expand": {"rel1": {...}, ...}`}</code>). Only the
relations that the user has permissions to <strong>view</strong> will be expanded.
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>). Only
the relations that the user has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
@@ -46,6 +46,37 @@
}
</script>
<h3 class="m-b-sm">View ({collection.name})</h3>
<div class="content txt-lg m-b-sm">
<p>Fetch a single <strong>{collection.name}</strong> record.</p>
</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const pb = new PocketBase('${backendAbsUrl}');
...
const record1 = await pb.collection('${collection?.name}').getOne('RECORD_ID', {
expand: 'relField1,relField2.subRelField',
});
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final pb = PocketBase('${backendAbsUrl}');
...
final record1 = await pb.collection('${collection?.name}').getOne('RECORD_ID',
'expand': 'relField1,relField2.subRelField',
);
`}
/>
<h6 class="m-b-xs">API details</h6>
<div class="alert alert-info">
<strong class="label label-primary">GET</strong>
<div class="content">
@@ -54,42 +85,12 @@
</p>
</div>
{#if adminsOnly}
<p class="txt-hint txt-sm txt-right">Requires <code>Authorization: Admin TOKEN</code> header</p>
<p class="txt-hint txt-sm txt-right">Requires admin <code>Authorization:TOKEN</code> header</p>
{/if}
</div>
<div class="content m-b-base">
<p>Fetch a single <strong>{collection.name}</strong> record.</p>
</div>
<div class="section-title">Client SDKs example</div>
<SdkTabs
js={`
import PocketBase from 'pocketbase';
const client = new PocketBase('${backendAbsUrl}');
...
const record = await client.records.getOne('${collection?.name}', 'RECORD_ID', {
expand: 'some_relation'
});
`}
dart={`
import 'package:pocketbase/pocketbase.dart';
final client = PocketBase('${backendAbsUrl}');
...
final record = await client.records.getOne('${collection?.name}', 'RECORD_ID', query: {
'expand': 'some_relation',
});
`}
/>
<div class="section-title">Path Parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -109,7 +110,7 @@
</table>
<div class="section-title">Query parameters</div>
<table class="table-compact table-border m-b-lg">
<table class="table-compact table-border m-b-base">
<thead>
<tr>
<th>Param</th>
@@ -125,15 +126,12 @@
</td>
<td>
Auto expand record relations. Ex.:
<CodeBlock
content={`
?expand=rel1,rel2.subrel21.subrel22
`}
/>
<CodeBlock content={`?expand=relField1,relField2.subRelField`} />
Supports up to 6-levels depth nested relations expansion. <br />
The expanded relations will be appended to the record under the
<code>@expand</code> property (eg. <code>{`"@expand": {"rel1": {...}, ...}`}</code>). Only the
relations that the user has permissions to <strong>view</strong> will be expanded.
<code>expand</code> property (eg. <code>{`"expand": {"relField1": {...}, ...}`}</code>).
<br />
Only the relations to which the account has permissions to <strong>view</strong> will be expanded.
</td>
</tr>
</tbody>
@@ -39,7 +39,7 @@
icon: CommonHelper.getFieldTypeIcon("date"),
},
{
label: "Multiple choices",
label: "Select",
value: "select",
icon: CommonHelper.getFieldTypeIcon("select"),
},
@@ -58,17 +58,11 @@
value: "relation",
icon: CommonHelper.getFieldTypeIcon("relation"),
},
{
label: "User",
value: "user",
icon: CommonHelper.getFieldTypeIcon("user"),
},
];
</script>
<ObjectSelect
class="field-type-select {classes}"
searchable
items={types}
bind:keyOfSelected={value}
{...$$restProps}
@@ -1,8 +1,10 @@
<script>
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import tooltip from "@/actions/tooltip";
import Field from "@/components/base/Field.svelte";
import ObjectSelect from "@/components/base/ObjectSelect.svelte";
import CollectionUpsertPanel from "@/components/collections/CollectionUpsertPanel.svelte";
export let key = "";
export let options = {};
@@ -14,6 +16,7 @@
let isLoading = false;
let collections = [];
let upsertPanel = null;
// load defaults
$: if (CommonHelper.isEmpty(options)) {
@@ -26,19 +29,20 @@
loadCollections();
function loadCollections() {
async function loadCollections() {
isLoading = true;
ApiClient.collections.getFullList(200, { sort: "-created" })
.then((items) => {
collections = items;
})
.catch((err) => {
ApiClient.errorResponseHandler(err);
})
.finally(() => {
isLoading = false;
try {
const result = await ApiClient.collections.getFullList(200, {
sort: "created",
});
collections = CommonHelper.sortCollections(result);
} catch (err) {
ApiClient.errorResponseHandler(err);
}
isLoading = false;
}
</script>
@@ -53,13 +57,32 @@
selectionKey="id"
items={collections}
bind:keyOfSelected={options.collectionId}
/>
>
<svelte:fragment slot="afterOptions">
<button
type="button"
class="btn btn-warning btn-block btn-sm m-t-5"
on:click={() => upsertPanel?.show()}
>
<span class="txt">New collection</span>
</button>
</svelte:fragment>
</ObjectSelect>
</Field>
</div>
<div class="col-sm-3">
<Field class="form-field required" name="schema.{key}.options.maxSelect" let:uniqueId>
<label for={uniqueId}>Max select</label>
<input type="number" id={uniqueId} step="1" min="1" required bind:value={options.maxSelect} />
<Field class="form-field" name="schema.{key}.options.maxSelect" let:uniqueId>
<label for={uniqueId}>
<span class="txt">Max select</span>
<i
class="ri-information-line link-hint"
use:tooltip={{
text: "Leave empty for no limit.",
position: "top",
}}
/>
</label>
<input type="number" id={uniqueId} step="1" min="1" bind:value={options.maxSelect} />
</Field>
</div>
<div class="col-sm-12">
@@ -69,3 +92,13 @@
</Field>
</div>
</div>
<CollectionUpsertPanel
bind:this={upsertPanel}
on:save={(e) => {
if (e?.detail?.collection?.id) {
options.collectionId = e.detail.collection.id;
}
loadCollections();
}}
/>
+1 -2
View File
@@ -2,7 +2,6 @@
import { onMount } from "svelte";
import { scale } from "svelte/transition";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import {
Chart,
LineElement,
@@ -44,7 +43,7 @@
resetData();
for (let item of result) {
chartData.push({
x: CommonHelper.getDateTime(item.date).toLocal().toJSDate(),
x: new Date(item.date),
y: item.total,
});
totalRequests += item.total;
+41 -10
View File
@@ -4,6 +4,7 @@
import CommonHelper from "@/utils/CommonHelper";
import SortHeader from "@/components/base/SortHeader.svelte";
import FormattedDate from "@/components/base/FormattedDate.svelte";
import HorizontalScroller from "@/components/base/HorizontalScroller.svelte";
const dispatch = createEventDispatcher();
const labelMethodClass = {
@@ -21,6 +22,7 @@
let currentPage = 1;
let totalItems = 0;
let isLoading = false;
let yieldedItemsId = 0;
$: if (typeof sort !== "undefined" || typeof filter !== "undefined" || typeof presets !== "undefined") {
clearList();
@@ -29,24 +31,39 @@
$: canLoadMore = totalItems > items.length;
export async function load(page = 1) {
export async function load(page = 1, breakTasks = true) {
isLoading = true;
return ApiClient.logs.getRequestsList(page, 40, {
sort: sort,
filter: [presets, filter].filter(Boolean).join("&&"),
})
.then((result) => {
return ApiClient.logs
.getRequestsList(page, 30, {
sort: sort,
filter: [presets, filter].filter(Boolean).join("&&"),
})
.then(async (result) => {
if (page <= 1) {
clearList();
}
isLoading = false;
items = items.concat(result.items);
currentPage = result.page;
totalItems = result.totalItems;
dispatch("load", items.concat(result.items));
dispatch("load", items);
// optimize the items listing by rendering the rows in task batches
if (breakTasks) {
const currentYieldId = ++yieldedItemsId;
while (result.items.length) {
if (yieldedItemsId != currentYieldId) {
break; // new yeild has been started
}
items = items.concat(result.items.splice(0, 10));
await CommonHelper.yieldToMain();
}
} else {
items = items.concat(result.items);
}
})
.catch((err) => {
if (!err?.isAbort) {
@@ -65,7 +82,7 @@
}
</script>
<div class="table-wrapper">
<HorizontalScroller class="table-wrapper">
<table class="table" class:table-loading={isLoading}>
<thead>
<tr>
@@ -90,6 +107,13 @@
</div>
</SortHeader>
<SortHeader disable class="col-type-number col-field-userIp" name="userIp" bind:sort>
<div class="col-header-content">
<i class={CommonHelper.getFieldTypeIcon("number")} />
<span class="txt">User IP</span>
</div>
</SortHeader>
<SortHeader disable class="col-type-number col-field-status" name="status" bind:sort>
<div class="col-header-content">
<i class={CommonHelper.getFieldTypeIcon("number")} />
@@ -103,6 +127,7 @@
<span class="txt">created</span>
</div>
</SortHeader>
<th class="col-type-action min-width" />
</tr>
</thead>
@@ -140,6 +165,12 @@
</span>
</td>
<td class="col-type-number col-field-userIp">
<span class="txt txt-ellipsis" class:txt-hint={!item.userIp} title={item.userIp}>
{item.userIp || "N/A"}
</span>
</td>
<td class="col-type-number col-field-status">
<span class="label" class:label-danger={item.status >= 400}>
{item.status}
@@ -180,7 +211,7 @@
{/each}
</tbody>
</table>
</div>
</HorizontalScroller>
{#if items.length}
<small class="block txt-hint txt-right m-t-sm">Showing {items.length} of {totalItems}</small>
@@ -1,5 +1,5 @@
<script>
import { onMount, createEventDispatcher } from "svelte";
import { createEventDispatcher } from "svelte";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import { confirm } from "@/stores/confirmation";
@@ -8,7 +8,7 @@
const dispatch = createEventDispatcher();
export let user;
export let record;
let externalAuths = [];
let isLoading = false;
@@ -22,7 +22,7 @@
}
async function loadExternalAuths() {
if (!user?.id) {
if (!record?.id) {
externalAuths = [];
isLoading = false;
return;
@@ -31,7 +31,7 @@
isLoading = true;
try {
externalAuths = await ApiClient.users.listExternalAuths(user.id);
externalAuths = await ApiClient.collection(record.collectionId).listExternalAuths(record.id);
} catch (err) {
ApiClient.errorResponseHandler(err);
}
@@ -40,13 +40,13 @@
}
function unlinkExternalAuth(provider) {
if (!user?.id || !provider) {
if (!record?.id || !provider) {
return; // nothing to unlink
}
confirm(`Do you really want to unlink the ${getProviderTitle(provider)} provider?`, () => {
return ApiClient.users
.unlinkExternalAuth(user.id, provider)
return ApiClient.collection(record.collectionId)
.unlinkExternalAuth(record.id, provider)
.then(() => {
addSuccessToast(`Successfully unlinked the ${getProviderTitle(provider)} provider.`);
dispatch("unlink", provider);
@@ -58,16 +58,14 @@
});
}
onMount(() => {
loadExternalAuths();
});
loadExternalAuths();
</script>
{#if isLoading}
<div class="block txt-center">
<span class="loader" />
</div>
{:else if user?.id && externalAuths.length}
{:else if record?.id && externalAuths.length}
<div class="list">
{#each externalAuths as auth}
<div class="list-item">
@@ -85,5 +83,5 @@
{/each}
</div>
{:else}
<p class="txt-hint txt-center">No authorized OAuth2 providers.</p>
<p class="txt-hint txt-center">No linked OAuth2 providers.</p>
{/if}
@@ -1,5 +1,5 @@
<script>
import PocketBase from "pocketbase";
import PocketBase, { getTokenPayload } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import FullPage from "@/components/base/FullPage.svelte";
@@ -24,7 +24,8 @@
const client = new PocketBase(import.meta.env.PB_BACKEND_URL);
try {
await client.users.confirmEmailChange(params?.token, password);
const payload = getTokenPayload(params?.token);
await client.collection(payload.collectionId).confirmEmailChange(params?.token, password);
success = true;
} catch (err) {
ApiClient.errorResponseHandler(err);
@@ -1,5 +1,5 @@
<script>
import PocketBase from "pocketbase";
import PocketBase, { getTokenPayload } from "pocketbase";
import ApiClient from "@/utils/ApiClient";
import CommonHelper from "@/utils/CommonHelper";
import FullPage from "@/components/base/FullPage.svelte";
@@ -25,7 +25,10 @@
const client = new PocketBase(import.meta.env.PB_BACKEND_URL);
try {
await client.users.confirmPasswordReset(params?.token, newPassword, newPasswordConfirm);
const payload = getTokenPayload(params?.token);
await client
.collection(payload.collectionId)
.confirmPasswordReset(params?.token, newPassword, newPasswordConfirm);
success = true;
} catch (err) {
ApiClient.errorResponseHandler(err);
@@ -1,5 +1,5 @@
<script>
import PocketBase from "pocketbase";
import PocketBase, { getTokenPayload } from "pocketbase";
import FullPage from "@/components/base/FullPage.svelte";
export let params;
@@ -16,7 +16,8 @@
const client = new PocketBase(import.meta.env.PB_BACKEND_URL);
try {
await client.users.confirmVerification(params?.token);
const payload = getTokenPayload(params?.token);
await client.collection(payload.collectionId).confirmVerification(params?.token);
success = true;
} catch (err) {
success = false;

Some files were not shown because too many files have changed in this diff Show More