2023-11-26 20:59:14 +08:00
import { S as Ee , i as Je , s as Ne , N as Le , O as z , e as o , w as k , b as h , c as I , f as p , g as r , h as a , m as K , x as pe , P as Ue , Q as Qe , k as xe , R as ze , n as Ie , t as L , a as E , o as c , d as G , C as Be , p as Ke , r as X , u as Ge } from "./index-5476b7fc.js" ; import { S as Xe } from "./SdkTabs-4c16169d.js" ; import { F as Ye } from "./FieldsQueryParam-b098cba7.js" ; function Fe ( s , l , n ) { const i = s . slice ( ) ; return i [ 5 ] = l [ n ] , i } function He ( s , l , n ) { const i = s . slice ( ) ; return i [ 5 ] = l [ n ] , i } function je ( s , l ) { let n , i = l [ 5 ] . code + "" , f , g , d , b ; function _ ( ) { return l [ 4 ] ( l [ 5 ] ) } return { key : s , first : null , c ( ) { n = o ( "button" ) , f = k ( i ) , g = h ( ) , p ( n , "class" , "tab-item" ) , X ( n , "active" , l [ 1 ] === l [ 5 ] . code ) , this . first = n } , m ( v , O ) { r ( v , n , O ) , a ( n , f ) , a ( n , g ) , d || ( b = Ge ( n , "click" , _ ) , d = ! 0 ) } , p ( v , O ) { l = v , O & 4 && i !== ( i = l [ 5 ] . code + "" ) && pe ( f , i ) , O & 6 && X ( n , "active" , l [ 1 ] === l [ 5 ] . code ) } , d ( v ) { v && c ( n ) , d = ! 1 , b ( ) } } } function Ve ( s , l ) { let n , i , f , g ; return i = new Le ( { props : { content : l [ 5 ] . body } } ) , { key : s , first : null , c ( ) { n = o ( "div" ) , I ( i . $$ . fragment ) , f = h ( ) , p ( n , "class" , "tab-item" ) , X ( n , "active" , l [ 1 ] === l [ 5 ] . code ) , this . first = n } , m ( d , b ) { r ( d , n , b ) , K ( i , n , null ) , a ( n , f ) , g = ! 0 } , p ( d , b ) { l = d ; const _ = { } ; b & 4 && ( _ . content = l [ 5 ] . body ) , i . $set ( _ ) , ( ! g || b & 6 ) && X ( n , "active" , l [ 1 ] === l [ 5 ] . code ) } , i ( d ) { g || ( L ( i . $$ . fragment , d ) , g = ! 0 ) } , o ( d ) { E ( i . $$ . fragment , d ) , g = ! 1 } , d ( d ) { d && c ( n ) , G ( i ) } } } function Ze ( s ) { let l , n , i = s [ 0 ] . name + "" , f , g , d , b , _ , v , O , P , Y , A , J , be , N , R , me , Z , Q = s [ 0 ] . name + "" , ee , fe , te , M , ae , W , le , U , ne , S , oe , ge , B , y , se , ke , ie , _e , m , ve , C , we , $e , Oe , re , Ae , ce , Se , ye , Te , de , Ce , qe , q , ue , F , he , T , H , $ = [ ] , De = new Map , Pe , j , w = [ ] , Re = new Map , D ; v = new Xe ( { props : { js : `
2023-10-26 03:18:18 +08:00
import PocketBase from 'pocketbase' ;
const pb = new PocketBase ( '${s[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${s[3]}/api/oauth2-redirect as redirect url.
const authData = await pb . collection ( '${s[0].name}' ) . authWithOAuth2 ( { provider : 'google' } ) ;
// OR authenticate with manual OAuth2 code exchange
// const authData = await pb.collection('${s[0].name}').authWithOAuth2Code(...);
// 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 model
pb . authStore . clear ( ) ;
` ,dart: `
import 'package:pocketbase/pocketbase.dart' ;
import 'package:url_launcher/url_launcher.dart' ;
final pb = PocketBase ( '${s[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${s[3]}/api/oauth2-redirect as redirect url.
final authData = await pb . collection ( '${s[0].name}' ) . authWithOAuth2 ( 'google' , ( url ) async {
await launchUrl ( url ) ;
} ) ;
// OR authenticate with manual OAuth2 code exchange
// final authData = await pb.collection('${s[0].name}').authWithOAuth2Code(...);
// 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 model
pb . authStore . clear ( ) ;
` }}),C=new Le({props:{content:"?expand=relField1,relField2.subRelField"}}),q=new Ye({});let x=z(s[2]);const Me=e=>e[5].code;for(let e=0;e<x.length;e+=1){let t=He(s,x,e),u=Me(t);De.set(u, $ [e]=je(u,t))}let V=z(s[2]);const We=e=>e[5].code;for(let e=0;e<V.length;e+=1){let t=Fe(s,V,e),u=We(t);Re.set(u,w[e]=Ve(u,t))}return{c(){l=o("h3"),n=k("Auth with OAuth2 ("),f=k(i),g=k(")"),d=h(),b=o("div"),b.innerHTML= ` < p > Authenticate with an OAuth2 provider and returns a new auth token and record data . < / p > < p > F o r m o r e d e t a i l s p l e a s e c h e c k t h e
< a href = "https://pocketbase.io/docs/authentication/#oauth2-integration" target = "_blank" rel = "noopener noreferrer" > OAuth2 integration documentation
< / a > . < / p > ` , _ = h ( ) , I ( v . $ $ . f r a g m e n t ) , O = h ( ) , P = o ( " h 6 " ) , P . t e x t C o n t e n t = " A P I d e t a i l s " , Y = h ( ) , A = o ( " d i v " ) , J = o ( " s t r o n g " ) , J . t e x t C o n t e n t = " P O S T " , b e = h ( ) , N = o ( " d i v " ) , R = o ( " p " ) , m e = k ( " / a p i / c o l l e c t i o n s / " ) , Z = o ( " s t r o n g " ) , e e = k ( Q ) , f e = k ( " / a u t h - w i t h - o a u t h 2 " ) , t e = h ( ) , M = o ( " d i v " ) , M . t e x t C o n t e n t = " B o d y P a r a m e t e r s " , a e = h ( ) , W = o ( " t a b l e " ) , W . i n n e r H T M L = ` < t h e a d > < t r > < t h > P a r a m < / t h > < t h > T y p e < / t h > < t h w i d t h = " 5 0 % " > D e s c r i p t i o n < / t h > < / t r > < / t h e a d > < t b o d y > < t r > < t d > < d i v c l a s s = " i n l i n e - f l e x " > < s p a n c l a s s = " l a b e l l a b e l - s u c c e s s " > R e q u i r e d < / s p a n > < s p a n > p r o v i d e r < / s p a n > < / d i v > < / t d > < t d > < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > < / t d > < t d > T h e n a m e o f t h e O A u t h 2 c l i e n t p r o v i d e r ( e g . & q u o t ; g o o g l e & q u o t ; ) . < / t d > < / t r > < t r > < t d > < d i v c l a s s = " i n l i n e - f l e x " > < s p a n c l a s s = " l a b e l l a b e l - s u c c e s s " > R e q u i r e d < / s p a n > < s p a n > c o d e < / s p a n > < / d i v > < / t d > < t d > < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > < / t d > < t d > T h e a u t h o r i z a t i o n c o d e r e t u r n e d f r o m t h e i n i t i a l r e q u e s t . < / t d > < / t r > < t r > < t d > < d i v c l a s s = " i n l i n e - f l e x " > < s p a n c l a s s = " l a b e l l a b e l - s u c c e s s " > R e q u i r e d < / s p a n > < s p a n > c o d e V e r i f i e r < / s p a n > < / d i v > < / t d > < t d > < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > < / t d > < t d > T h e c o d e v e r i f i e r s e n t w i t h t h e i n i t i a l r e q u e s t a s p a r t o f t h e c o d e _ c h a l l e n g e . < / t d > < / t r > < t r > < t d > < d i v c l a s s = " i n l i n e - f l e x " > < s p a n c l a s s = " l a b e l l a b e l - s u c c e s s " > R e q u i r e d < / s p a n > < s p a n > r e d i r e c t U r l < / s p a n > < / d i v > < / t d > < t d > < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > < / t d > < t d > T h e r e d i r e c t u r l s e n t w i t h t h e i n i t i a l r e q u e s t . < / t d > < / t r > < t r > < t d > < d i v c l a s s = " i n l i n e - f l e x " > < s p a n c l a s s = " l a b e l l a b e l - w a r n i n g " > O p t i o n a l < / s p a n > < s p a n > c r e a t e D a t a < / s p a n > < / d i v > < / t d > < t d > < s p a n c l a s s = " l a b e l " > O b j e c t < / s p a n > < / t d > < t d > < p > O p t i o n a l d a t a t h a t w i l l b e u s e d w h e n c r e a t i n g t h e a u t h r e c o r d o n O A u t h 2 s i g n - u p . < / p > < p > T h e c r e a t e d a u t h r e c o r d m u s t c o m p l y w i t h t h e s a m e r e q u i r e m e n t s a n d v a l i d a t i o n s i n t h e
regular < strong > create < / s t r o n g > a c t i o n .
< br / > < em > The data can only be in < code > json < / c o d e > , a k a . < c o d e > m u l t i p a r t / f o r m - d a t a < / c o d e > a n d f i l e s
upload currently are not supported during OAuth2 sign - ups . < / e m > < / p > < / t d > < / t r > < / t b o d y > ` , l e = h ( ) , U = o ( " d i v " ) , U . t e x t C o n t e n t = " Q u e r y p a r a m e t e r s " , n e = h ( ) , S = o ( " t a b l e " ) , o e = o ( " t h e a d " ) , o e . i n n e r H T M L = ' < t r > < t h > P a r a m < / t h > < t h > T y p e < / t h > < t h w i d t h = " 6 0 % " > D e s c r i p t i o n < / t h > < / t r > ' , g e = h ( ) , B = o ( " t b o d y " ) , y = o ( " t r " ) , s e = o ( " t d " ) , s e . t e x t C o n t e n t = " e x p a n d " , k e = h ( ) , i e = o ( " t d " ) , i e . i n n e r H T M L = ' < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > ' , _ e = h ( ) , m = o ( " t d " ) , v e = k ( ` A u t o e x p a n d r e c o r d r e l a t i o n s . E x . :
` ),I(C. $ $ .fragment),we=k( `
Supports up to 6 - levels depth nested relations expansion . ` ), $ e=o("br"),Oe=k( `
The expanded relations will be appended to the record under the
` ),re=o("code"),re.textContent="expand",Ae=k(" property (eg. "),ce=o("code"),ce.textContent='"expand": {"relField1": {...}, ...}',Se=k( ` ) .
` ),ye=o("br"),Te=k( `
Only the relations to which the request user has permissions to ` ),de=o("strong"),de.textContent="view",Ce=k(" will be expanded."),qe=h(),I(q. $ $ .fragment),ue=h(),F=o("div"),F.textContent="Responses",he=h(),T=o("div"),H=o("div");for(let e=0;e< $ .length;e+=1) $ [e].c();Pe=h(),j=o("div");for(let e=0;e<w.length;e+=1)w[e].c();p(l,"class","m-b-sm"),p(b,"class","content txt-lg m-b-sm"),p(P,"class","m-b-xs"),p(J,"class","label label-primary"),p(N,"class","content"),p(A,"class","alert alert-success"),p(M,"class","section-title"),p(W,"class","table-compact table-border m-b-base"),p(U,"class","section-title"),p(S,"class","table-compact table-border m-b-base"),p(F,"class","section-title"),p(H,"class","tabs-header compact combined left"),p(j,"class","tabs-content"),p(T,"class","tabs")},m(e,t){r(e,l,t),a(l,n),a(l,f),a(l,g),r(e,d,t),r(e,b,t),r(e,_,t),K(v,e,t),r(e,O,t),r(e,P,t),r(e,Y,t),r(e,A,t),a(A,J),a(A,be),a(A,N),a(N,R),a(R,me),a(R,Z),a(Z,ee),a(R,fe),r(e,te,t),r(e,M,t),r(e,ae,t),r(e,W,t),r(e,le,t),r(e,U,t),r(e,ne,t),r(e,S,t),a(S,oe),a(S,ge),a(S,B),a(B,y),a(y,se),a(y,ke),a(y,ie),a(y,_e),a(y,m),a(m,ve),K(C,m,null),a(m,we),a(m, $ e),a(m,Oe),a(m,re),a(m,Ae),a(m,ce),a(m,Se),a(m,ye),a(m,Te),a(m,de),a(m,Ce),a(B,qe),K(q,B,null),r(e,ue,t),r(e,F,t),r(e,he,t),r(e,T,t),a(T,H);for(let u=0;u< $ .length;u+=1) $ [u]&& $ [u].m(H,null);a(T,Pe),a(T,j);for(let u=0;u<w.length;u+=1)w[u]&&w[u].m(j,null);D=!0},p(e,[t]){(!D||t&1)&&i!==(i=e[0].name+"")&&pe(f,i);const u={};t&9&&(u.js= `
import PocketBase from 'pocketbase' ;
const pb = new PocketBase ( '${e[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${e[3]}/api/oauth2-redirect as redirect url.
const authData = await pb . collection ( '${e[0].name}' ) . authWithOAuth2 ( { provider : 'google' } ) ;
// OR authenticate with manual OAuth2 code exchange
// const authData = await pb.collection('${e[0].name}').authWithOAuth2Code(...);
// 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 model
pb . authStore . clear ( ) ;
` ),t&9&&(u.dart= `
import 'package:pocketbase/pocketbase.dart' ;
import 'package:url_launcher/url_launcher.dart' ;
final pb = PocketBase ( '${e[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${e[3]}/api/oauth2-redirect as redirect url.
final authData = await pb . collection ( '${e[0].name}' ) . authWithOAuth2 ( 'google' , ( url ) async {
await launchUrl ( url ) ;
} ) ;
// OR authenticate with manual OAuth2 code exchange
// final authData = await pb.collection('${e[0].name}').authWithOAuth2Code(...);
// 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 model
pb . authStore . clear ( ) ;
` ),v. $ set(u),(!D||t&1)&&Q!==(Q=e[0].name+"")&&pe(ee,Q),t&6&&(x=z(e[2]), $ =Ue( $ ,t,Me,1,e,x,De,H,Qe,je,null,He)),t&6&&(V=z(e[2]),xe(),w=Ue(w,t,We,1,e,V,Re,j,ze,Ve,null,Fe),Ie())},i(e){if(!D){L(v. $ $ .fragment,e),L(C. $ $ .fragment,e),L(q. $ $ .fragment,e);for(let t=0;t<V.length;t+=1)L(w[t]);D=!0}},o(e){E(v. $ $ .fragment,e),E(C. $ $ .fragment,e),E(q. $ $ .fragment,e);for(let t=0;t<w.length;t+=1)E(w[t]);D=!1},d(e){e&&(c(l),c(d),c(b),c(_),c(O),c(P),c(Y),c(A),c(te),c(M),c(ae),c(W),c(le),c(U),c(ne),c(S),c(ue),c(F),c(he),c(T)),G(v,e),G(C),G(q);for(let t=0;t< $ .length;t+=1) $ [t].d();for(let t=0;t<w.length;t+=1)w[t].d()}}}function et(s,l,n){let i,{collection:f}=l,g=200,d=[];const b=_=>n(1,g=_.code);return s. $ $ set=_=>{"collection"in _&&n(0,f=_.collection)},s. $ $ .update=()=>{s. $ $ .dirty&1&&n(2,d=[{code:200,body:JSON.stringify({token:"JWT_AUTH_TOKEN",record:Be.dummyCollectionRecord(f),meta:{id:"abc123",name:"John Doe",username:"john.doe",email:"test@example.com",avatarUrl:"https://example.com/avatar.png",accessToken:"...",refreshToken:"...",rawUser:{}}},null,2)},{code:400,body: `
{
"code" : 400 ,
"message" : "An error occurred while submitting the form." ,
"data" : {
"provider" : {
"code" : "validation_required" ,
"message" : "Missing required value."
}
}
}
` }])},n(3,i=Be.getApiExampleUrl(Ke.baseUrl)),[f,g,d,i,b]}class nt extends Ee{constructor(l){super(),Je(this,l,et,Ze,Ne,{collection:0})}}export{nt as default};