@chaibuilder/pages 0.1.0-beta.1 → 0.1.0-beta.10
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/index.cjs +10 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1103 -991
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.js +59 -30
- package/package.json +2 -2
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c="https://api.chaibuilder.com",h=async(t,a)=>{try{const e=new Headers;e.append("x-chai-api-key",a);const s={headers:e,method:"POST",body:JSON.stringify(t)},i=await fetch(c+"/v1/api/chai",s);if(i.ok)return{data:await i.json()};throw new Error("Failed to handle request: "+i.statusText)}catch(e){return{error:e}}},n={},p=(t,a)=>{n[t]={key:t,...a}},d=()=>Object.values(n),o=t=>n[t],r="https://api.chaibuilder.com";class u{constructor(a){this.apiKey=a,p("pages",{name:"Pages",search:async e=>(await fetch(`${r}/v1/api/chai`,{method:"POST",body:JSON.stringify({action:"SEARCH_PAGES",data:{query:e}}),headers:{"x-chai-api-key":this.apiKey}})).json(),resolveLink:async()=>""})}async handle(a){if(a.action==="GET_COLLECTIONS")return d().map(e=>({key:e.key,name:e.name,urlIdentifier:e.urlIdentifier}));if(a.action==="SEARCH_COLLECTION_ITEMS"){const e=o(a.data.collection);return e?await(e==null?void 0:e.search(a.data.query)):{error:"Collection not found"}}return await h(a,this.apiKey)}async resolveLink(a,e){const s=o(a);return s?await(s==null?void 0:s.resolveLink(e)):""}async getPageMeta(a){return(await fetch(`${r}/v1/api/chai`,{method:"POST",body:JSON.stringify({action:"GET_PAGE_META",data:{slug:a,published:!0}}),headers:{"x-chai-api-key":this.apiKey}})).json()}async getPage(a){return(await fetch(`${r}/v1/api/chai`,{method:"POST",body:JSON.stringify({action:"GET_PAGE",data:{id:a,published:!0,mergeGlobal:!0}}),headers:{"x-chai-api-key":this.apiKey}})).json()}}exports.ChaiBuilderPages=u;
|
package/dist/server.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export declare class ChaiBuilderPages {
|
|
|
2
2
|
private apiKey;
|
|
3
3
|
constructor(apiKey: string);
|
|
4
4
|
handle(body: any): Promise<any>;
|
|
5
|
-
|
|
5
|
+
resolveLink(collectionKey: string, id: string): Promise<string>;
|
|
6
|
+
getPageMeta(slug: string): Promise<any>;
|
|
6
7
|
getPage(id: string): Promise<any>;
|
|
7
8
|
}
|
|
8
9
|
|
package/dist/server.js
CHANGED
|
@@ -1,45 +1,74 @@
|
|
|
1
|
-
const
|
|
1
|
+
const c = "https://api.chaibuilder.com", h = async (t, a) => {
|
|
2
2
|
try {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
const e = new Headers();
|
|
4
|
+
e.append("x-chai-api-key", a);
|
|
5
|
+
const s = {
|
|
6
|
+
headers: e,
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: JSON.stringify(t)
|
|
9
|
+
}, i = await fetch(
|
|
10
|
+
c + "/v1/api/chai",
|
|
11
|
+
s
|
|
12
|
+
);
|
|
13
|
+
if (i.ok)
|
|
14
|
+
return { data: await i.json() };
|
|
15
|
+
throw new Error("Failed to handle request: " + i.statusText);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return { error: e };
|
|
17
18
|
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
}, r = {}, p = (t, a) => {
|
|
20
|
+
r[t] = { key: t, ...a };
|
|
21
|
+
}, d = () => Object.values(r), o = (t) => r[t], n = "https://api.chaibuilder.com";
|
|
22
|
+
class y {
|
|
23
|
+
constructor(a) {
|
|
24
|
+
this.apiKey = a, p("pages", {
|
|
25
|
+
name: "Pages",
|
|
26
|
+
search: async (e) => (await fetch(`${n}/v1/api/chai`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
body: JSON.stringify({ action: "SEARCH_PAGES", data: { query: e } }),
|
|
29
|
+
headers: { "x-chai-api-key": this.apiKey }
|
|
30
|
+
})).json(),
|
|
31
|
+
resolveLink: async () => ""
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async handle(a) {
|
|
35
|
+
if (a.action === "GET_COLLECTIONS")
|
|
36
|
+
return d().map((e) => ({
|
|
37
|
+
key: e.key,
|
|
38
|
+
name: e.name,
|
|
39
|
+
urlIdentifier: e.urlIdentifier
|
|
40
|
+
}));
|
|
41
|
+
if (a.action === "SEARCH_COLLECTION_ITEMS") {
|
|
42
|
+
const e = o(a.data.collection);
|
|
43
|
+
return e ? await (e == null ? void 0 : e.search(a.data.query)) : { error: "Collection not found" };
|
|
44
|
+
}
|
|
45
|
+
return await h(a, this.apiKey);
|
|
22
46
|
}
|
|
23
|
-
async
|
|
24
|
-
|
|
47
|
+
async resolveLink(a, e) {
|
|
48
|
+
const s = o(a);
|
|
49
|
+
return s ? await (s == null ? void 0 : s.resolveLink(e)) : "";
|
|
25
50
|
}
|
|
26
|
-
async
|
|
27
|
-
|
|
28
|
-
return a.append("action", "GET_PAGE_ID"), a.append("data", JSON.stringify({ slug: t, draft: !1 })), (await fetch(`${i}/v1/api/chai`, {
|
|
51
|
+
async getPageMeta(a) {
|
|
52
|
+
return (await fetch(`${n}/v1/api/chai`, {
|
|
29
53
|
method: "POST",
|
|
30
|
-
body:
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
action: "GET_PAGE_META",
|
|
56
|
+
data: { slug: a, published: !0 }
|
|
57
|
+
}),
|
|
31
58
|
headers: { "x-chai-api-key": this.apiKey }
|
|
32
59
|
})).json();
|
|
33
60
|
}
|
|
34
|
-
async getPage(
|
|
35
|
-
|
|
36
|
-
return a.append("action", "GET_PAGE"), a.append("data", JSON.stringify({ id: t, draft: !1 })), (await fetch(`${i}/v1/api/chai`, {
|
|
61
|
+
async getPage(a) {
|
|
62
|
+
return (await fetch(`${n}/v1/api/chai`, {
|
|
37
63
|
method: "POST",
|
|
38
|
-
body:
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
action: "GET_PAGE",
|
|
66
|
+
data: { id: a, published: !0, mergeGlobal: !0 }
|
|
67
|
+
}),
|
|
39
68
|
headers: { "x-chai-api-key": this.apiKey }
|
|
40
69
|
})).json();
|
|
41
70
|
}
|
|
42
71
|
}
|
|
43
72
|
export {
|
|
44
|
-
|
|
73
|
+
y as ChaiBuilderPages
|
|
45
74
|
};
|
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.
|
|
6
|
+
"version": "0.1.0-beta.10",
|
|
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.
|
|
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",
|