@chaibuilder/pages 0.1.0-beta.2 → 0.1.0-beta.3

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.
package/dist/server.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="https://api.chaibuilder.com",c=async(s,t)=>{try{const a=new Headers;a.append("x-chai-api-key",t);const e=new FormData;if(e.append("action",s.action),s.data){const n=s.data;typeof n=="string"?e.append("data",n):typeof n=="object"&&e.append("data",JSON.stringify(n))}const o={headers:a,method:"POST",body:e};return{data:await(await fetch(r+"/v1/api/chai",o)).json()}}catch(a){return{error:a}}},i="https://api.chaibuilder.com";class p{constructor(t){this.apiKey=t}async handle(t){return await c(t,this.apiKey)}async getPageId(t){const a=new FormData;return a.append("action","GET_PAGE_ID"),a.append("data",JSON.stringify({slug:t,draft:!1})),(await fetch(`${i}/v1/api/chai`,{method:"POST",body:a,headers:{"x-chai-api-key":this.apiKey}})).json()}async getPage(t){const a=new FormData;return a.append("action","GET_PAGE"),a.append("data",JSON.stringify({id:t,draft:!1})),(await fetch(`${i}/v1/api/chai`,{method:"POST",body:a,headers:{"x-chai-api-key":this.apiKey}})).json()}}exports.ChaiBuilderPages=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c="https://api.chaibuilder.com",p=async(i,t)=>{try{const a=new Headers;a.append("x-chai-api-key",t);const e=new FormData;if(e.append("action",i.action),i.data){const s=i.data;typeof s=="string"?e.append("data",s):typeof s=="object"&&e.append("data",JSON.stringify(s))}const r={headers:a,method:"POST",body:e},n=await fetch(c+"/v1/api/chai",r);if(n.ok)return{data:await n.json()};throw new Error("Failed to handle request: "+n.statusText)}catch(a){return{error:a}}},o="https://api.chaibuilder.com";class d{constructor(t){this.apiKey=t}async handle(t){return await p(t,this.apiKey)}async getPageId(t){const a=new FormData;return a.append("action","GET_PAGE_ID"),a.append("data",JSON.stringify({slug:t,draft:!1})),(await fetch(`${o}/v1/api/chai`,{method:"POST",body:a,headers:{"x-chai-api-key":this.apiKey}})).json()}async getPage(t){const a=new FormData;return a.append("action","GET_PAGE"),a.append("data",JSON.stringify({id:t,draft:!1})),(await fetch(`${o}/v1/api/chai`,{method:"POST",body:a,headers:{"x-chai-api-key":this.apiKey}})).json()}}exports.ChaiBuilderPages=d;
package/dist/server.js CHANGED
@@ -1,31 +1,33 @@
1
- const r = "https://api.chaibuilder.com", c = async (s, t) => {
1
+ const c = "https://api.chaibuilder.com", p = async (n, t) => {
2
2
  try {
3
3
  const a = new Headers();
4
4
  a.append("x-chai-api-key", t);
5
5
  const e = new FormData();
6
- if (e.append("action", s.action), s.data) {
7
- const n = s.data;
8
- typeof n == "string" ? e.append("data", n) : typeof n == "object" && e.append("data", JSON.stringify(n));
6
+ if (e.append("action", n.action), n.data) {
7
+ const s = n.data;
8
+ typeof s == "string" ? e.append("data", s) : typeof s == "object" && e.append("data", JSON.stringify(s));
9
9
  }
10
- const o = { headers: a, method: "POST", body: e };
11
- return { data: await (await fetch(
12
- r + "/v1/api/chai",
13
- o
14
- )).json() };
10
+ const r = { headers: a, method: "POST", body: e }, i = await fetch(
11
+ c + "/v1/api/chai",
12
+ r
13
+ );
14
+ if (i.ok)
15
+ return { data: await i.json() };
16
+ throw new Error("Failed to handle request: " + i.statusText);
15
17
  } catch (a) {
16
18
  return { error: a };
17
19
  }
18
- }, i = "https://api.chaibuilder.com";
19
- class h {
20
+ }, o = "https://api.chaibuilder.com";
21
+ class d {
20
22
  constructor(t) {
21
23
  this.apiKey = t;
22
24
  }
23
25
  async handle(t) {
24
- return await c(t, this.apiKey);
26
+ return await p(t, this.apiKey);
25
27
  }
26
28
  async getPageId(t) {
27
29
  const a = new FormData();
28
- return a.append("action", "GET_PAGE_ID"), a.append("data", JSON.stringify({ slug: t, draft: !1 })), (await fetch(`${i}/v1/api/chai`, {
30
+ return a.append("action", "GET_PAGE_ID"), a.append("data", JSON.stringify({ slug: t, draft: !1 })), (await fetch(`${o}/v1/api/chai`, {
29
31
  method: "POST",
30
32
  body: a,
31
33
  headers: { "x-chai-api-key": this.apiKey }
@@ -33,7 +35,7 @@ class h {
33
35
  }
34
36
  async getPage(t) {
35
37
  const a = new FormData();
36
- return a.append("action", "GET_PAGE"), a.append("data", JSON.stringify({ id: t, draft: !1 })), (await fetch(`${i}/v1/api/chai`, {
38
+ return a.append("action", "GET_PAGE"), a.append("data", JSON.stringify({ id: t, draft: !1 })), (await fetch(`${o}/v1/api/chai`, {
37
39
  method: "POST",
38
40
  body: a,
39
41
  headers: { "x-chai-api-key": this.apiKey }
@@ -41,5 +43,5 @@ class h {
41
43
  }
42
44
  }
43
45
  export {
44
- h as ChaiBuilderPages
46
+ d as ChaiBuilderPages
45
47
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Suraj Air",
4
4
  "license": "Private",
5
5
  "homepage": "https://chaibuilder.com",
6
- "version": "0.1.0-beta.2",
6
+ "version": "0.1.0-beta.3",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
@@ -61,7 +61,7 @@
61
61
  "@ai-sdk/openai": "^0.0.66",
62
62
  "@chaibuilder/ai": "^0.1.2",
63
63
  "@chaibuilder/runtime": "0.2.12",
64
- "@chaibuilder/sdk": "^1.2.110",
64
+ "@chaibuilder/sdk": "^1.2.111",
65
65
  "@mhsdesign/jit-browser-tailwindcss": "^0.4.1",
66
66
  "@supabase/supabase-js": "^2.45.6",
67
67
  "@tailwindcss/aspect-ratio": "^0.4.2",