balendar 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,9 +31,9 @@ export interface BalendarConfig {
31
31
  *
32
32
  * @example
33
33
  * ```typescript
34
- * import { Balendar } from 'balendar/client'
34
+ * import { createBalendar } from 'balendar'
35
35
  *
36
- * const client = Balendar({
36
+ * const client = createBalendar({
37
37
  * baseUrl: 'https://calendar-api.balendar.com',
38
38
  * apiKey: 'your-api-key-here'
39
39
  * })
@@ -47,7 +47,7 @@ export interface BalendarConfig {
47
47
  * })
48
48
  * ```
49
49
  */
50
- export declare function Balendar(config: BalendarConfig): {
50
+ export declare function createBalendar(config: BalendarConfig): {
51
51
  health: {
52
52
  get: (options?: {
53
53
  headers?: Record<string, unknown> | undefined;
@@ -91,7 +91,7 @@ export declare function Balendar(config: BalendarConfig): {
91
91
  get: (options: {
92
92
  headers?: Record<string, unknown> | undefined;
93
93
  query: {
94
- externalProvider: "google" | "microsoft" | "apple";
94
+ externalProvider: "apple" | "google" | "microsoft";
95
95
  redirectUri: string;
96
96
  scopes?: string | undefined;
97
97
  state?: string | undefined;
@@ -150,7 +150,7 @@ export declare function Balendar(config: BalendarConfig): {
150
150
  syncStatus: "error" | "pending" | "syncing" | "synced";
151
151
  syncError: string | null;
152
152
  retryCount: number;
153
- externalProvider: "google" | "microsoft" | "apple";
153
+ externalProvider: "apple" | "google" | "microsoft";
154
154
  externalId: string;
155
155
  connectionId: string;
156
156
  accessToken: string;
@@ -805,3 +805,4 @@ export declare function Balendar(config: BalendarConfig): {
805
805
  };
806
806
  };
807
807
  };
808
+ export type Balendar = ReturnType<typeof createBalendar>;
@@ -3,4 +3,4 @@ var v=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=
3
3
  `)?yield*V(n):yield g(n)}}finally{r.releaseLock()}}function*V(e){let t=e.split(`
4
4
 
5
5
  `);for(let r of t){if(r.indexOf(":")<=0){r&&(yield g(r));continue}let s=r.split(`
6
- `),d={};for(let o of s){let n=o.indexOf(":");if(n>0){let h=o.slice(0,n).trim(),$=o.slice(n+1).trim();d[h]=g($)}}yield d}}var F=(e,t,r=[],s)=>new Proxy(()=>{},{get(d,o){return F(e,t,o==="index"?r:[...r,o],s)},apply(d,o,[n,h]){if(!n||h||typeof n=="object"&&Object.keys(n).length!==1||Q.includes(r.at(-1))){let $=[...r],L=$.pop(),m="/"+$.join("/"),{fetcher:P=fetch,headers:S,onRequest:y,onResponse:E,fetch:q}=t,j=L==="get"||L==="head"||L==="subscribe";S=A(S,m,h);let D=j?n?.query:h?.query,x="";if(D){let a=(b,p)=>{x+=(x?"&":"?")+`${encodeURIComponent(b)}=${encodeURIComponent(p)}`};for(let[b,p]of Object.entries(D)){if(Array.isArray(p)){for(let f of p)a(b,f);continue}if(p!=null){if(typeof p=="object"){a(b,JSON.stringify(p));continue}a(b,`${p}`)}}}if(L==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||W.find((b)=>e.includes(b))?"ws://":"wss://")+m+x;return new z(a)}return(async()=>{let a={method:L?.toUpperCase(),body:n,...q,headers:S};a.headers={...S,...A(j?n?.headers:h?.headers,m,a)};let b=j&&typeof n=="object"?n.fetch:h?.fetch;if(a={...a,...b},j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}if(j&&delete a.body,_(n)){let u=new FormData;for(let[i,l]of Object.entries(a.body)){if(Array.isArray(l)){for(let w=0;w<l.length;w++){let R=l[w];u.append(i,R instanceof File?await k(R):R)}continue}if(C){if(Array.isArray(l))for(let w of l)u.append(i,w);else u.append(i,l);continue}if(l instanceof File){u.append(i,await k(l));continue}if(l instanceof FileList){for(let w=0;w<l.length;w++)u.append(i,await k(l[w]));continue}u.append(i,l)}a.body=u}else typeof n=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(n)):n!=null&&(a.headers["content-type"]="text/plain");if(j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}h?.headers?.["content-type"]&&(a.headers["content-type"]=h?.headers["content-type"]);let p=e+m+x,f=await(s?.handle(new Request(p,a))??P(p,a)),c=null,O=null;if(E){Array.isArray(E)||(E=[E]);for(let u of E)try{let i=await u(f.clone());if(i!=null){c=i;break}}catch(i){i instanceof v?O=i:O=new v(422,i);break}}if(c!==null)return{data:c,error:O,response:f,status:f.status,headers:f.headers};switch(f.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":c=K(f);break;case"application/json":c=JSON.parse(await f.text(),(i,l)=>{if(typeof l!="string")return l;return N(l)||l});break;case"application/octet-stream":c=await f.arrayBuffer();break;case"multipart/form-data":let u=await f.formData();c={},u.forEach((i,l)=>{c[l]=i});break;default:c=await f.text().then(g)}return(f.status>=300||f.status<200)&&(O=new v(f.status,c),c=null),{data:c,error:O,response:f,status:f.status,headers:f.headers}})()}return typeof n=="object"?F(e,t,[...r,Object.values(n)[0]],s):F(e,t,r)}}),J=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(W.find((r)=>e.includes(r))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),F(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),F("http://e.ly",t,[],e));function ye(e){let{baseUrl:t,apiKey:r,fetch:s}=e;return J(t,{headers:{"X-API-Key":r},fetch:s})}export{ye as Balendar};
6
+ `),d={};for(let o of s){let n=o.indexOf(":");if(n>0){let h=o.slice(0,n).trim(),$=o.slice(n+1).trim();d[h]=g($)}}yield d}}var F=(e,t,r=[],s)=>new Proxy(()=>{},{get(d,o){return F(e,t,o==="index"?r:[...r,o],s)},apply(d,o,[n,h]){if(!n||h||typeof n=="object"&&Object.keys(n).length!==1||Q.includes(r.at(-1))){let $=[...r],L=$.pop(),m="/"+$.join("/"),{fetcher:P=fetch,headers:S,onRequest:y,onResponse:E,fetch:q}=t,j=L==="get"||L==="head"||L==="subscribe";S=A(S,m,h);let D=j?n?.query:h?.query,x="";if(D){let a=(b,p)=>{x+=(x?"&":"?")+`${encodeURIComponent(b)}=${encodeURIComponent(p)}`};for(let[b,p]of Object.entries(D)){if(Array.isArray(p)){for(let f of p)a(b,f);continue}if(p!=null){if(typeof p=="object"){a(b,JSON.stringify(p));continue}a(b,`${p}`)}}}if(L==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||W.find((b)=>e.includes(b))?"ws://":"wss://")+m+x;return new z(a)}return(async()=>{let a={method:L?.toUpperCase(),body:n,...q,headers:S};a.headers={...S,...A(j?n?.headers:h?.headers,m,a)};let b=j&&typeof n=="object"?n.fetch:h?.fetch;if(a={...a,...b},j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}if(j&&delete a.body,_(n)){let u=new FormData;for(let[i,l]of Object.entries(a.body)){if(Array.isArray(l)){for(let w=0;w<l.length;w++){let R=l[w];u.append(i,R instanceof File?await k(R):R)}continue}if(C){if(Array.isArray(l))for(let w of l)u.append(i,w);else u.append(i,l);continue}if(l instanceof File){u.append(i,await k(l));continue}if(l instanceof FileList){for(let w=0;w<l.length;w++)u.append(i,await k(l[w]));continue}u.append(i,l)}a.body=u}else typeof n=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(n)):n!=null&&(a.headers["content-type"]="text/plain");if(j&&delete a.body,y){Array.isArray(y)||(y=[y]);for(let u of y){let i=await u(m,a);typeof i=="object"&&(a={...a,...i,headers:{...a.headers,...A(i.headers,m,a)}})}}h?.headers?.["content-type"]&&(a.headers["content-type"]=h?.headers["content-type"]);let p=e+m+x,f=await(s?.handle(new Request(p,a))??P(p,a)),c=null,O=null;if(E){Array.isArray(E)||(E=[E]);for(let u of E)try{let i=await u(f.clone());if(i!=null){c=i;break}}catch(i){i instanceof v?O=i:O=new v(422,i);break}}if(c!==null)return{data:c,error:O,response:f,status:f.status,headers:f.headers};switch(f.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":c=K(f);break;case"application/json":c=JSON.parse(await f.text(),(i,l)=>{if(typeof l!="string")return l;return N(l)||l});break;case"application/octet-stream":c=await f.arrayBuffer();break;case"multipart/form-data":let u=await f.formData();c={},u.forEach((i,l)=>{c[l]=i});break;default:c=await f.text().then(g)}return(f.status>=300||f.status<200)&&(O=new v(f.status,c),c=null),{data:c,error:O,response:f,status:f.status,headers:f.headers}})()}return typeof n=="object"?F(e,t,[...r,Object.values(n)[0]],s):F(e,t,r)}}),J=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(W.find((r)=>e.includes(r))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),F(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),F("http://e.ly",t,[],e));function ye(e){let{baseUrl:t,apiKey:r,fetch:s}=e;return J(t,{headers:{"X-API-Key":r},fetch:s})}export{ye as createBalendar};
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "balendar",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "module": "client.ts",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "exports": {
8
- "./client": "./dist/lib/client.js"
8
+ ".": {
9
+ "types": "./dist/lib/client.d.ts",
10
+ "import": "./dist/lib/client.js"
11
+ }
9
12
  },
10
13
  "files": [
11
14
  "dist/lib/client.d.ts",