@pagesolver/sdk 1.0.0 → 1.0.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/README.md +42 -37
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -31,6 +31,12 @@ if (showcases.data) {
|
|
|
31
31
|
console.log(showcases.data.showcases);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Get quick quotes
|
|
35
|
+
const quickQuotes = await client.getQuickQuotes();
|
|
36
|
+
if (quickQuotes.data) {
|
|
37
|
+
console.log(quickQuotes.data.quotes);
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
// Send contact form
|
|
35
41
|
const contactResult = await client.contact({
|
|
36
42
|
name: "John Doe",
|
|
@@ -75,6 +81,15 @@ const result = await client.getShowcases();
|
|
|
75
81
|
// Returns: ApiResponse<{ showcases: ShowcaseImage[] }>
|
|
76
82
|
```
|
|
77
83
|
|
|
84
|
+
##### `getQuickQuotes()`
|
|
85
|
+
|
|
86
|
+
Retrieves all quick quotes for your business.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const result = await client.getQuickQuotes();
|
|
90
|
+
// Returns: ApiResponse<{ quotes: QuickQuote[] }>
|
|
91
|
+
```
|
|
92
|
+
|
|
78
93
|
##### `contact(data: ContactData)`
|
|
79
94
|
|
|
80
95
|
Sends a contact form submission.
|
|
@@ -96,11 +111,12 @@ const result = await client.contact({
|
|
|
96
111
|
```typescript
|
|
97
112
|
interface ComparisonImage {
|
|
98
113
|
id: string;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
businessId: string;
|
|
115
|
+
beforeUrl: string;
|
|
116
|
+
afterUrl: string;
|
|
117
|
+
description: string | null;
|
|
118
|
+
createdAt: Date;
|
|
119
|
+
title: string;
|
|
104
120
|
}
|
|
105
121
|
```
|
|
106
122
|
|
|
@@ -109,11 +125,27 @@ interface ComparisonImage {
|
|
|
109
125
|
```typescript
|
|
110
126
|
interface ShowcaseImage {
|
|
111
127
|
id: string;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
businessId: string;
|
|
129
|
+
blobUrl: string[];
|
|
130
|
+
createdAt: Date;
|
|
131
|
+
description: string | null;
|
|
132
|
+
title: string;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### QuickQuote
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface QuickQuote {
|
|
140
|
+
id: string;
|
|
141
|
+
businessId: string;
|
|
142
|
+
parentId: string | null;
|
|
143
|
+
name: string;
|
|
144
|
+
description: string | null;
|
|
145
|
+
basePrice: string | null;
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
createdAt: Date;
|
|
148
|
+
updatedAt: Date;
|
|
117
149
|
}
|
|
118
150
|
```
|
|
119
151
|
|
|
@@ -157,33 +189,6 @@ if (result.error) {
|
|
|
157
189
|
}
|
|
158
190
|
```
|
|
159
191
|
|
|
160
|
-
## Development
|
|
161
|
-
|
|
162
|
-
### Building
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
bun run build
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Testing
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
bun test
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Linting
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
bun run lint
|
|
178
|
-
bun run lint:fix
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Type Checking
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
bun run type-check
|
|
185
|
-
```
|
|
186
|
-
|
|
187
192
|
## License
|
|
188
193
|
|
|
189
194
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class
|
|
1
|
+
class i{baseUrl="https://pagesolver.com/api/v1";businessKey;constructor(s){this.businessKey=s}async request(s,r={}){try{let t=`${this.baseUrl}${s}`,a={"Content-Type":"application/json","x-business-key":this.businessKey,...r.headers},e=await fetch(t,{...r,headers:a}),n;if(e.headers.get("Content-Type")?.includes("application/json"))n=await e.json();else n=await e.text();if(!e.ok)return{error:n?.error||"An unknown error occurred",status:e.status};return{data:n,status:e.status}}catch(t){return{error:t instanceof Error?t.message:"Network error",status:500}}}async getComparisons(){return this.request("/business/comparisons")}async getShowcases(){return this.request("/business/showcases")}async getQuickQuotes(){return this.request("/business/quick-quotes")}async contact(s){return this.request("/business/contact",{method:"POST",body:JSON.stringify(s)})}}export{i as PageSolverClient};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=7DE63FC008843B0364756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// Database schema types\nexport interface ComparisonImage {\n id: string;\n businessId: string;\n beforeUrl: string;\n afterUrl: string;\n description: string | null;\n createdAt: Date;\n title: string;\n}\n\nexport interface ShowcaseImage {\n id: string;\n businessId: string;\n blobUrl: string[];\n createdAt: Date;\n description: string | null;\n title: string;\n}\n\nexport interface QuickQuote {\n id: string;\n businessId: string;\n parentId: string | null;\n name: string;\n description: string | null;\n basePrice: string | null;\n enabled: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\ninterface ApiResponse<T> {\n data?: T;\n error?: string;\n status: number;\n}\n\ninterface ContactData {\n name: string;\n email: string;\n phone?: string;\n message?: string;\n}\n\ninterface ContactResponse {\n success: boolean;\n}\n\
|
|
5
|
+
"// Database schema types\nexport interface ComparisonImage {\n id: string;\n businessId: string;\n beforeUrl: string;\n afterUrl: string;\n description: string | null;\n createdAt: Date;\n title: string;\n}\n\nexport interface ShowcaseImage {\n id: string;\n businessId: string;\n blobUrl: string[];\n createdAt: Date;\n description: string | null;\n title: string;\n}\n\nexport interface QuickQuote {\n id: string;\n businessId: string;\n parentId: string | null;\n name: string;\n description: string | null;\n basePrice: string | null;\n enabled: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\ninterface ApiResponse<T> {\n data?: T;\n error?: string;\n status: number;\n}\n\ninterface ContactData {\n name: string;\n email: string;\n phone?: string;\n message?: string;\n}\n\ninterface ContactResponse {\n success: boolean;\n}\n\nexport class PageSolverClient {\n private baseUrl = \"https://pagesolver.com/api/v1\";\n private businessKey: string;\n\n constructor(businessKey: string) {\n this.businessKey = businessKey;\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {}\n ): Promise<ApiResponse<T>> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n\n const headers = {\n \"Content-Type\": \"application/json\",\n \"x-business-key\": this.businessKey,\n ...options.headers,\n };\n\n const response = await fetch(url, {\n ...options,\n headers,\n });\n\n let data: unknown;\n const contentType = response.headers.get(\"Content-Type\");\n if (contentType?.includes(\"application/json\")) {\n data = await response.json();\n } else {\n data = await response.text();\n }\n\n if (!response.ok) {\n return {\n error:\n (data as { error?: string })?.error || \"An unknown error occurred\",\n status: response.status,\n };\n }\n\n return {\n data: data as T,\n status: response.status,\n };\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : \"Network error\",\n status: 500,\n };\n }\n }\n\n // Comparison Images\n async getComparisons(): Promise<\n ApiResponse<{ comparisons: ComparisonImage[] }>\n > {\n return this.request<{ comparisons: ComparisonImage[] }>(\n \"/business/comparisons\"\n );\n }\n\n // Showcase Images\n async getShowcases(): Promise<ApiResponse<{ showcases: ShowcaseImage[] }>> {\n return this.request<{ showcases: ShowcaseImage[] }>(\"/business/showcases\");\n }\n\n // Quick Quotes\n async getQuickQuotes(): Promise<ApiResponse<{ quotes: QuickQuote[] }>> {\n return this.request<{ quotes: QuickQuote[] }>(\"/business/quick-quotes\");\n }\n\n // Contact\n async contact(data: ContactData): Promise<ApiResponse<ContactResponse>> {\n return this.request<ContactResponse>(\"/business/contact\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n }\n}\n\n// Export types for consumers\nexport type { ApiResponse, ContactData, ContactResponse };\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAiDO,MAAM,CAAiB,CACpB,QAAU,gCACV,YAER,WAAW,CAAC,EAAqB,CAC/B,KAAK,YAAc,OAGP,QAAU,CACtB,EACA,EAAuB,CAAC,EACC,CACzB,GAAI,CACF,IAAM,EAAM,GAAG,KAAK,UAAU,IAExB,EAAU,CACd,eAAgB,mBAChB,iBAAkB,KAAK,eACpB,EAAQ,OACb,EAEM,EAAW,MAAM,MAAM,EAAK,IAC7B,EACH,SACF,CAAC,EAEG,EAEJ,GADoB,EAAS,QAAQ,IAAI,cAAc,GACtC,SAAS,kBAAkB,EAC1C,EAAO,MAAM,EAAS,KAAK,EAE3B,OAAO,MAAM,EAAS,KAAK,EAG7B,IAAK,EAAS,GACZ,MAAO,CACL,MACG,GAA6B,OAAS,4BACzC,OAAQ,EAAS,MACnB,EAGF,MAAO,CACL,KAAM,EACN,OAAQ,EAAS,MACnB,EACA,MAAO,EAAO,CACd,MAAO,CACL,MAAO,aAAiB,MAAQ,EAAM,QAAU,gBAChD,OAAQ,GACV,QAKE,eAAc,EAElB,CACA,OAAO,KAAK,QACV,uBACF,OAII,aAAY,EAAyD,CACzE,OAAO,KAAK,QAAwC,qBAAqB,OAIrE,eAAc,EAAmD,CACrE,OAAO,KAAK,QAAkC,wBAAwB,OAIlE,QAAO,CAAC,EAA0D,CACtE,OAAO,KAAK,QAAyB,oBAAqB,CACxD,OAAQ,OACR,KAAM,KAAK,UAAU,CAAI,CAC3B,CAAC,EAEL",
|
|
8
|
+
"debugId": "7DE63FC008843B0364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagesolver/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Official SDK for PageSolver API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"lint:fix": "bunx @biomejs/biome check --apply src",
|
|
25
25
|
"type-check": "bunx tsc --noEmit",
|
|
26
26
|
"prepare": "bun run build",
|
|
27
|
-
"prepublishOnly": "bun run lint && bun run type-check && bun run test && bun run build"
|
|
27
|
+
"prepublishOnly": "bun run lint && bun run type-check && bun run test && bun run build",
|
|
28
|
+
"version:patch": "npm version patch",
|
|
29
|
+
"version:minor": "npm version minor",
|
|
30
|
+
"version:major": "npm version major"
|
|
28
31
|
},
|
|
29
32
|
"keywords": [
|
|
30
33
|
"pagesolver",
|