balendar 0.0.13 → 0.0.15

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.
@@ -522,103 +522,105 @@ export declare function createBalendar(config: BalendarConfig): {
522
522
  }>>;
523
523
  };
524
524
  };
525
- "user-time-slots": {
526
- post: (body: {
527
- filters: {
528
- dateFrom: string;
529
- dateTo: string;
530
- timeFrom: string;
531
- timeTo: string;
532
- userId: number;
533
- bookingLocations: {
534
- bookingLocationId: number;
535
- bufferMinutes: number;
536
- leadMinutes: number;
537
- }[];
538
- bookingDurationMinutes: number;
539
- slotGapMinutes: number;
540
- timeZone: string;
541
- };
542
- }, options?: {
543
- headers?: Record<string, unknown> | undefined;
544
- query?: Record<string, unknown> | undefined;
545
- fetch?: RequestInit | undefined;
546
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
547
- 200: {
548
- userId: number;
549
- timeZone: string;
550
- bookingLocationAvailability: {
551
- bookingLocationId: number;
552
- timeSlotCount: number;
553
- timeSlots: {
554
- date: string;
555
- time: string[];
525
+ availability: {
526
+ "user-time-slots": {
527
+ post: (body: {
528
+ filters: {
529
+ dateFrom: string;
530
+ dateTo: string;
531
+ timeFrom: string;
532
+ timeTo: string;
533
+ userId: number;
534
+ bookingLocations: {
535
+ bookingLocationId: number;
536
+ bufferMinutes: number;
537
+ leadMinutes: number;
556
538
  }[];
539
+ bookingDurationMinutes: number;
540
+ slotGapMinutes: number;
541
+ timeZone: string;
542
+ };
543
+ }, options?: {
544
+ headers?: Record<string, unknown> | undefined;
545
+ query?: Record<string, unknown> | undefined;
546
+ fetch?: RequestInit | undefined;
547
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
548
+ 200: {
549
+ userId: number;
550
+ timeZone: string;
551
+ bookingLocationAvailability: {
552
+ bookingLocationId: number;
553
+ timeSlotCount: number;
554
+ timeSlots: {
555
+ date: string;
556
+ time: string[];
557
+ }[];
558
+ }[];
559
+ };
560
+ 400: {
561
+ error: string;
562
+ };
563
+ 422: {
564
+ type: "validation";
565
+ on: string;
566
+ summary?: string;
567
+ message?: string;
568
+ found?: unknown;
569
+ property?: string;
570
+ expected?: string;
571
+ };
572
+ }>>;
573
+ };
574
+ "users-time-slots": {
575
+ post: (body: {
576
+ baseFilters: {
577
+ dateFrom: string;
578
+ dateTo: string;
579
+ timeFrom: string;
580
+ timeTo: string;
581
+ };
582
+ userFilters: {
583
+ userId: number;
584
+ bookingLocations: {
585
+ bookingLocationId: number;
586
+ bufferMinutes: number;
587
+ leadMinutes: number;
588
+ }[];
589
+ bookingDurationMinutes: number;
590
+ slotGapMinutes: number;
591
+ timeZone: string;
557
592
  }[];
558
- };
559
- 400: {
560
- error: string;
561
- };
562
- 422: {
563
- type: "validation";
564
- on: string;
565
- summary?: string;
566
- message?: string;
567
- found?: unknown;
568
- property?: string;
569
- expected?: string;
570
- };
571
- }>>;
572
- };
573
- "users-time-slots": {
574
- post: (body: {
575
- baseFilters: {
576
- dateFrom: string;
577
- dateTo: string;
578
- timeFrom: string;
579
- timeTo: string;
580
- };
581
- userFilters: {
582
- userId: number;
583
- bookingLocations: {
584
- bookingLocationId: number;
585
- bufferMinutes: number;
586
- leadMinutes: number;
587
- }[];
588
- bookingDurationMinutes: number;
589
- slotGapMinutes: number;
590
- timeZone: string;
591
- }[];
592
- }, options?: {
593
- headers?: Record<string, unknown> | undefined;
594
- query?: Record<string, unknown> | undefined;
595
- fetch?: RequestInit | undefined;
596
- } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
597
- 200: {
598
- userId: number;
599
- timeZone: string;
600
- bookingLocationAvailability: {
601
- bookingLocationId: number;
602
- timeSlotCount: number;
603
- timeSlots: {
604
- date: string;
605
- time: string[];
593
+ }, options?: {
594
+ headers?: Record<string, unknown> | undefined;
595
+ query?: Record<string, unknown> | undefined;
596
+ fetch?: RequestInit | undefined;
597
+ } | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
598
+ 200: {
599
+ userId: number;
600
+ timeZone: string;
601
+ bookingLocationAvailability: {
602
+ bookingLocationId: number;
603
+ timeSlotCount: number;
604
+ timeSlots: {
605
+ date: string;
606
+ time: string[];
607
+ }[];
606
608
  }[];
607
609
  }[];
608
- }[];
609
- 400: {
610
- error: string;
611
- };
612
- 422: {
613
- type: "validation";
614
- on: string;
615
- summary?: string;
616
- message?: string;
617
- found?: unknown;
618
- property?: string;
619
- expected?: string;
620
- };
621
- }>>;
610
+ 400: {
611
+ error: string;
612
+ };
613
+ 422: {
614
+ type: "validation";
615
+ on: string;
616
+ summary?: string;
617
+ message?: string;
618
+ found?: unknown;
619
+ property?: string;
620
+ expected?: string;
621
+ };
622
+ }>>;
623
+ };
622
624
  };
623
625
  calendars: {
624
626
  connections: ((params: {
@@ -1,6 +1,6 @@
1
- var U=Object.defineProperty;var Y=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0,configurable:!0,set:(s)=>t[r]=()=>s})};var v=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=t}},B=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,H=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,I=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,G=(e)=>e.trim().length!==0&&!Number.isNaN(Number(e)),N=(e)=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(B.test(t)||H.test(t)||I.test(t)){let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null},Z=(e)=>{let t=e.charCodeAt(0),r=e.charCodeAt(e.length-1);return t===123&&r===125||t===91&&r===93},z=(e)=>JSON.parse(e,(t,r)=>{return N(r)||r}),g=(e)=>{if(!e)return e;if(G(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=N(e);if(t)return t;if(Z(e))try{return z(e)}catch{}return e},T=(e)=>{let t=e.data.toString();return t==="null"?null:g(t)};var Q=class{constructor(e){this.url=e,this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach((t)=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,(s)=>{if(e==="message"){let d=T(s);t({...s,data:d})}else t(s)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},_=["get","post","put","delete","patch","options","head","connect","subscribe"],W=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",M=(e)=>C?e instanceof Blob:e instanceof FileList||e instanceof File,K=(e)=>{if(!e)return!1;for(let t in e)if(M(e[t])||Array.isArray(e[t])&&e[t].find(M))return!0;return!1},k=(e)=>C?e:new Promise((t)=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},r.readAsArrayBuffer(e)}),A=(e,t,r={},s={})=>{if(Array.isArray(e)){for(let d of e)if(!Array.isArray(d))s=A(d,t,r,s);else{let o=d[0];if(typeof o=="string")s[o.toLowerCase()]=d[1];else for(let[n,h]of o)s[n.toLowerCase()]=h}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return A(e,t,r,s);let d=e(t,r);return d?A(d,t,r,s):s;case"object":if(e instanceof Headers)return e.forEach((o,n)=>{s[n.toLowerCase()]=o}),s;for(let[o,n]of Object.entries(e))s[o.toLowerCase()]=n;return s;default:return s}};async function*V(e){let t=e.body;if(!t)return;let r=t.getReader(),s=new TextDecoder;try{for(;;){let{done:d,value:o}=await r.read();if(d)break;let n=typeof o=="string"?o:s.decode(o);n.includes(`
1
+ var U=Object.defineProperty;var Y=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0,configurable:!0,set:(s)=>t[r]=()=>s})};var A=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=t}},B=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,H=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,I=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,G=(e)=>e.trim().length!==0&&!Number.isNaN(Number(e)),N=(e)=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(B.test(t)||H.test(t)||I.test(t)){let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null},Z=(e)=>{let t=e.charCodeAt(0),r=e.charCodeAt(e.length-1);return t===123&&r===125||t===91&&r===93},z=(e)=>JSON.parse(e,(t,r)=>{return N(r)||r}),g=(e)=>{if(!e)return e;if(G(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=N(e);if(t)return t;if(Z(e))try{return z(e)}catch{}return e},T=(e)=>{let t=e.data.toString();return t==="null"?null:g(t)};var Q=class{constructor(e){this.url=e,this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach((t)=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,(s)=>{if(e==="message"){let d=T(s);t({...s,data:d})}else t(s)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},_=["get","post","put","delete","patch","options","head","connect","subscribe"],W=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",M=(e)=>C?e instanceof Blob:e instanceof FileList||e instanceof File,K=(e)=>{if(!e)return!1;for(let t in e)if(M(e[t])||Array.isArray(e[t])&&e[t].find(M))return!0;return!1},k=(e)=>C?e:new Promise((t)=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},r.readAsArrayBuffer(e)}),j=(e,t,r={},s={})=>{if(Array.isArray(e)){for(let d of e)if(!Array.isArray(d))s=j(d,t,r,s);else{let o=d[0];if(typeof o=="string")s[o.toLowerCase()]=d[1];else for(let[n,h]of o)s[n.toLowerCase()]=h}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,r,s);let d=e(t,r);return d?j(d,t,r,s):s;case"object":if(e instanceof Headers)return e.forEach((o,n)=>{s[n.toLowerCase()]=o}),s;for(let[o,n]of Object.entries(e))s[o.toLowerCase()]=n;return s;default:return s}};async function*V(e){let t=e.body;if(!t)return;let r=t.getReader(),s=new TextDecoder;try{for(;;){let{done:d,value:o}=await r.read();if(d)break;let n=typeof o=="string"?o:s.decode(o);n.includes(`
2
2
 
3
3
  `)?yield*X(n):yield g(n)}}finally{r.releaseLock()}}function*X(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||_.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 Q(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,K(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=V(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 me(e){let{baseUrl:t,apiKey:r,fetch:s}=e;return J(t,{headers:{"X-API-Key":r},fetch:s})}export{me as createBalendar};
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||_.includes(r.at(-1))){let $=[...r],E=$.pop(),m="/"+$.join("/"),{fetcher:P=fetch,headers:S,onRequest:y,onResponse:L,fetch:q}=t,v=E==="get"||E==="head"||E==="subscribe";S=j(S,m,h);let D=v?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(E==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||W.find((b)=>e.includes(b))?"ws://":"wss://")+m+x;return new Q(a)}return(async()=>{let a={method:E?.toUpperCase(),body:n,...q,headers:S};a.headers={...S,...j(v?n?.headers:h?.headers,m,a)};let b=v&&typeof n=="object"?n.fetch:h?.fetch;if(a={...a,...b},v&&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,...j(i.headers,m,a)}})}}if(v&&delete a.body,K(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(v&&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,...j(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(L){Array.isArray(L)||(L=[L]);for(let u of L)try{let i=await u(f.clone());if(i!=null){c=i;break}}catch(i){i instanceof A?O=i:O=new A(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=V(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 A(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 me(e){let{baseUrl:t,apiKey:r,fetch:s}=e;return J(t,{headers:{"X-API-Key":r},fetch:s})}export{me as createBalendar};