@pagesolver/sdk 1.0.6 → 1.2.1
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 +25 -23
- package/dist/index.d.ts +10 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,34 +19,36 @@ import { PageSolverClient } from "@pagesolver/sdk";
|
|
|
19
19
|
|
|
20
20
|
const client = new PageSolverClient("your-business-key");
|
|
21
21
|
|
|
22
|
-
// Get comparisons
|
|
22
|
+
// Get comparisons - returns array directly
|
|
23
23
|
const comparisons = await client.getComparisons();
|
|
24
|
-
|
|
25
|
-
console.log(comparisons.data.comparisons);
|
|
26
|
-
}
|
|
24
|
+
console.log(comparisons); // ComparisonImage[]
|
|
27
25
|
|
|
28
|
-
// Get showcases
|
|
26
|
+
// Get showcases - returns array directly
|
|
29
27
|
const showcases = await client.getShowcases();
|
|
30
|
-
|
|
31
|
-
console.log(showcases.data.showcases);
|
|
32
|
-
}
|
|
28
|
+
console.log(showcases); // ShowcaseImage[]
|
|
33
29
|
|
|
34
|
-
// Get quick quotes
|
|
30
|
+
// Get quick quotes - returns array directly
|
|
35
31
|
const quickQuotes = await client.getQuickQuotes();
|
|
36
|
-
|
|
37
|
-
console.log(quickQuotes.data.quotes);
|
|
38
|
-
}
|
|
32
|
+
console.log(quickQuotes); // QuickQuote[]
|
|
39
33
|
|
|
40
|
-
// Send contact form
|
|
41
|
-
const
|
|
34
|
+
// Send contact form - returns boolean
|
|
35
|
+
const success = await client.contact({
|
|
42
36
|
name: "John Doe",
|
|
43
37
|
email: "john@example.com",
|
|
44
38
|
message: "Hello from the SDK!",
|
|
45
39
|
});
|
|
46
40
|
|
|
47
|
-
if (
|
|
41
|
+
if (success) {
|
|
48
42
|
console.log("Contact form sent successfully!");
|
|
49
43
|
}
|
|
44
|
+
|
|
45
|
+
// Error handling with try/catch
|
|
46
|
+
try {
|
|
47
|
+
const comparisons = await client.getComparisons();
|
|
48
|
+
console.log(`Found ${comparisons.length} comparisons`);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("Failed to get comparisons:", error.message);
|
|
51
|
+
}
|
|
50
52
|
```
|
|
51
53
|
|
|
52
54
|
## API Reference
|
|
@@ -68,8 +70,8 @@ new PageSolverClient(businessKey: string)
|
|
|
68
70
|
Retrieves all comparison images for your business.
|
|
69
71
|
|
|
70
72
|
```typescript
|
|
71
|
-
const
|
|
72
|
-
// Returns:
|
|
73
|
+
const comparisons = await client.getComparisons();
|
|
74
|
+
// Returns: ComparisonImage[]
|
|
73
75
|
```
|
|
74
76
|
|
|
75
77
|
##### `getShowcases()`
|
|
@@ -77,8 +79,8 @@ const result = await client.getComparisons();
|
|
|
77
79
|
Retrieves all showcase images for your business.
|
|
78
80
|
|
|
79
81
|
```typescript
|
|
80
|
-
const
|
|
81
|
-
// Returns:
|
|
82
|
+
const showcases = await client.getShowcases();
|
|
83
|
+
// Returns: ShowcaseImage[]
|
|
82
84
|
```
|
|
83
85
|
|
|
84
86
|
##### `getQuickQuotes()`
|
|
@@ -86,8 +88,8 @@ const result = await client.getShowcases();
|
|
|
86
88
|
Retrieves all quick quotes for your business.
|
|
87
89
|
|
|
88
90
|
```typescript
|
|
89
|
-
const
|
|
90
|
-
// Returns:
|
|
91
|
+
const quotes = await client.getQuickQuotes();
|
|
92
|
+
// Returns: QuickQuote[]
|
|
91
93
|
```
|
|
92
94
|
|
|
93
95
|
##### `contact(data: ContactData)`
|
|
@@ -95,13 +97,13 @@ const result = await client.getQuickQuotes();
|
|
|
95
97
|
Sends a contact form submission.
|
|
96
98
|
|
|
97
99
|
```typescript
|
|
98
|
-
const
|
|
100
|
+
const success = await client.contact({
|
|
99
101
|
name: "John Doe",
|
|
100
102
|
email: "john@example.com",
|
|
101
103
|
phone: "+1234567890", // optional
|
|
102
104
|
message: "Hello!", // optional
|
|
103
105
|
});
|
|
104
|
-
// Returns:
|
|
106
|
+
// Returns: boolean
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
## Types
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface ComparisonImage {
|
|
2
2
|
id: string;
|
|
3
|
-
|
|
3
|
+
clientId: number;
|
|
4
4
|
beforeUrl: string;
|
|
5
5
|
afterUrl: string;
|
|
6
6
|
description: string | null;
|
|
@@ -9,7 +9,7 @@ export interface ComparisonImage {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ShowcaseImage {
|
|
11
11
|
id: string;
|
|
12
|
-
|
|
12
|
+
clientId: number;
|
|
13
13
|
blobUrl: string[];
|
|
14
14
|
createdAt: Date;
|
|
15
15
|
description: string | null;
|
|
@@ -17,7 +17,7 @@ export interface ShowcaseImage {
|
|
|
17
17
|
}
|
|
18
18
|
export interface QuickQuote {
|
|
19
19
|
id: string;
|
|
20
|
-
|
|
20
|
+
clientId: number;
|
|
21
21
|
parentId: string | null;
|
|
22
22
|
name: string;
|
|
23
23
|
description: string | null;
|
|
@@ -26,11 +26,6 @@ export interface QuickQuote {
|
|
|
26
26
|
createdAt: Date;
|
|
27
27
|
updatedAt: Date;
|
|
28
28
|
}
|
|
29
|
-
interface ApiResponse<T> {
|
|
30
|
-
data?: T;
|
|
31
|
-
error?: string;
|
|
32
|
-
status: number;
|
|
33
|
-
}
|
|
34
29
|
interface ContactData {
|
|
35
30
|
name: string;
|
|
36
31
|
email: string;
|
|
@@ -42,19 +37,13 @@ interface ContactResponse {
|
|
|
42
37
|
}
|
|
43
38
|
export declare class PageSolverClient {
|
|
44
39
|
private baseUrl;
|
|
45
|
-
private
|
|
46
|
-
constructor(
|
|
40
|
+
private clientKey;
|
|
41
|
+
constructor(clientKey: string);
|
|
47
42
|
private request;
|
|
48
|
-
getComparisons(): Promise<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
showcases: ShowcaseImage[];
|
|
53
|
-
}>>;
|
|
54
|
-
getQuickQuotes(): Promise<ApiResponse<{
|
|
55
|
-
quotes: QuickQuote[];
|
|
56
|
-
}>>;
|
|
57
|
-
contact(data: ContactData): Promise<ApiResponse<ContactResponse>>;
|
|
43
|
+
getComparisons(): Promise<ComparisonImage[]>;
|
|
44
|
+
getShowcases(): Promise<ShowcaseImage[]>;
|
|
45
|
+
getQuickQuotes(): Promise<QuickQuote[]>;
|
|
46
|
+
contact(data: ContactData): Promise<boolean>;
|
|
58
47
|
}
|
|
59
|
-
export type {
|
|
48
|
+
export type { ContactData, ContactResponse };
|
|
60
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAQD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,SAAS,CAAS;gBAEd,SAAS,EAAE,MAAM;YAIf,OAAO;IA0Cf,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAQ5C,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAQxC,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAQvC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAOnD;AAGD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class i{baseUrl="https://pagesolver.com/api/v1";
|
|
1
|
+
class i{baseUrl="https://pagesolver.com/api/v1";clientKey;constructor(e){this.clientKey=e}async request(e,n={}){try{let s=`${this.baseUrl}${e}`,o={"Content-Type":"application/json","x-client-key":this.clientKey,...n.headers},t=await fetch(s,{...n,headers:o}),r;if(t.headers.get("Content-Type")?.includes("application/json"))r=await t.json();else r=await t.text();if(!t.ok){let a=r?.error||"An unknown error occurred";throw new Error(`API Error (${t.status}): ${a}`)}return r}catch(s){if(s instanceof Error)throw s;throw new Error("Network error occurred")}}async getComparisons(){return(await this.request("/business/comparisons")).comparisons}async getShowcases(){return(await this.request("/business/showcases")).showcases}async getQuickQuotes(){return(await this.request("/business/quick-quotes")).quotes}async contact(e){return(await this.request("/business/contact",{method:"POST",body:JSON.stringify(e)})).success}}export{i as PageSolverClient};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=70BDE78DFE427A1064756E2164756E21
|
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
|
|
5
|
+
"// Database schema types\nexport interface ComparisonImage {\n id: string;\n clientId: number;\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 clientId: number;\n blobUrl: string[];\n createdAt: Date;\n description: string | null;\n title: string;\n}\n\nexport interface QuickQuote {\n id: string;\n clientId: number;\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 clientKey: string;\n\n constructor(clientKey: string) {\n this.clientKey = clientKey;\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {}\n ): Promise<T> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n\n const headers = {\n \"Content-Type\": \"application/json\",\n \"x-client-key\": this.clientKey,\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 const errorMessage =\n (data as { error?: string })?.error || \"An unknown error occurred\";\n throw new Error(`API Error (${response.status}): ${errorMessage}`);\n }\n\n return data as T;\n } catch (error) {\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(\"Network error occurred\");\n }\n }\n\n // Comparison Images\n async getComparisons(): Promise<ComparisonImage[]> {\n const response = await this.request<{ comparisons: ComparisonImage[] }>(\n \"/business/comparisons\"\n );\n return response.comparisons;\n }\n\n // Showcase Images\n async getShowcases(): Promise<ShowcaseImage[]> {\n const response = await this.request<{ showcases: ShowcaseImage[] }>(\n \"/business/showcases\"\n );\n return response.showcases;\n }\n\n // Quick Quotes\n async getQuickQuotes(): Promise<QuickQuote[]> {\n const response = await this.request<{ quotes: QuickQuote[] }>(\n \"/business/quick-quotes\"\n );\n return response.quotes;\n }\n\n // Contact\n async contact(data: ContactData): Promise<boolean> {\n const response = await this.request<ContactResponse>(\"/business/contact\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n return response.success;\n }\n}\n\n// Export types for consumers\nexport type { ContactData, ContactResponse };\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "AAiDO,MAAM,CAAiB,CACpB,QAAU,gCACV,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAiDO,MAAM,CAAiB,CACpB,QAAU,gCACV,UAER,WAAW,CAAC,EAAmB,CAC7B,KAAK,UAAY,OAGL,QAAU,CACtB,EACA,EAAuB,CAAC,EACZ,CACZ,GAAI,CACF,IAAM,EAAM,GAAG,KAAK,UAAU,IAExB,EAAU,CACd,eAAgB,mBAChB,eAAgB,KAAK,aAClB,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,GAAI,CAChB,IAAM,EACH,GAA6B,OAAS,4BACzC,MAAM,IAAI,MAAM,cAAc,EAAS,YAAY,GAAc,EAGnE,OAAO,EACP,MAAO,EAAO,CACd,GAAI,aAAiB,MACnB,MAAM,EAER,MAAM,IAAI,MAAM,wBAAwB,QAKtC,eAAc,EAA+B,CAIjD,OAHiB,MAAM,KAAK,QAC1B,uBACF,GACgB,iBAIZ,aAAY,EAA6B,CAI7C,OAHiB,MAAM,KAAK,QAC1B,qBACF,GACgB,eAIZ,eAAc,EAA0B,CAI5C,OAHiB,MAAM,KAAK,QAC1B,wBACF,GACgB,YAIZ,QAAO,CAAC,EAAqC,CAKjD,OAJiB,MAAM,KAAK,QAAyB,oBAAqB,CACxE,OAAQ,OACR,KAAM,KAAK,UAAU,CAAI,CAC3B,CAAC,GACe,QAEpB",
|
|
8
|
+
"debugId": "70BDE78DFE427A1064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|