@putiikkipalvelu/storefront-sdk 0.1.0 → 0.1.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 +44 -7
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -49
- package/dist/index.d.ts +125 -49
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -13,15 +13,15 @@ npm install @putiikkipalvelu/storefront-sdk
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import {
|
|
16
|
+
import { createStorefrontClient } from '@putiikkipalvelu/storefront-sdk';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const storefront = createStorefrontClient({
|
|
19
19
|
apiKey: process.env.STOREFRONT_API_KEY!,
|
|
20
|
-
baseUrl: 'https://putiikkipalvelu.fi',
|
|
20
|
+
baseUrl: 'https://putiikkipalvelu.fi/api/storefront/v1',
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Get store configuration
|
|
24
|
-
const config = await
|
|
24
|
+
const config = await storefront.store.getConfig();
|
|
25
25
|
console.log(config.store.name);
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -29,9 +29,9 @@ console.log(config.store.name);
|
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
31
|
// lib/storefront.ts
|
|
32
|
-
import {
|
|
32
|
+
import { createStorefrontClient } from '@putiikkipalvelu/storefront-sdk';
|
|
33
33
|
|
|
34
|
-
export const storefront =
|
|
34
|
+
export const storefront = createStorefrontClient({
|
|
35
35
|
apiKey: process.env.STOREFRONT_API_KEY!,
|
|
36
36
|
baseUrl: process.env.NEXT_PUBLIC_STOREFRONT_API_URL!,
|
|
37
37
|
});
|
|
@@ -41,10 +41,47 @@ export const storefront = new StorefrontClient({
|
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
const config = await storefront.store.getConfig({
|
|
44
|
-
next: { revalidate: 300
|
|
44
|
+
next: { revalidate: 300, tags: ['store-config'] }
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Error Handling
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import {
|
|
52
|
+
createStorefrontClient,
|
|
53
|
+
AuthError,
|
|
54
|
+
NotFoundError,
|
|
55
|
+
StorefrontError
|
|
56
|
+
} from '@putiikkipalvelu/storefront-sdk';
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const config = await storefront.store.getConfig();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof AuthError) {
|
|
62
|
+
// Invalid API key
|
|
63
|
+
} else if (error instanceof NotFoundError) {
|
|
64
|
+
// Resource not found
|
|
65
|
+
} else if (error instanceof StorefrontError) {
|
|
66
|
+
// Other API error
|
|
67
|
+
console.error(error.code, error.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## TypeScript
|
|
73
|
+
|
|
74
|
+
All types are exported for use in your application:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import type {
|
|
78
|
+
StoreConfig,
|
|
79
|
+
StoreInfo,
|
|
80
|
+
Product,
|
|
81
|
+
Campaign
|
|
82
|
+
} from '@putiikkipalvelu/storefront-sdk';
|
|
83
|
+
```
|
|
84
|
+
|
|
48
85
|
## Available Resources
|
|
49
86
|
|
|
50
87
|
- `store.getConfig()` - Store configuration, SEO, payments, campaigns
|
package/dist/index.cjs
CHANGED
|
@@ -5,8 +5,9 @@ var StorefrontError = class _StorefrontError extends Error {
|
|
|
5
5
|
this.name = "StorefrontError";
|
|
6
6
|
this.status = status;
|
|
7
7
|
this.code = code;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const ErrorWithCapture = Error;
|
|
9
|
+
if (ErrorWithCapture.captureStackTrace) {
|
|
10
|
+
ErrorWithCapture.captureStackTrace(this, _StorefrontError);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["d:\\Projektit\\
|
|
1
|
+
{"version":3,"sources":["d:\\Projektit\\Verkkokaupat\\putiikkipalvelu-sdk\\dist\\index.cjs"],"names":[],"mappings":"AAAA;AACA,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,QAAQ,MAAM;AAC3D,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACrC,IAAI,KAAK,CAAC,OAAO,CAAC;AAClB,IAAI,IAAI,CAAC,KAAK,EAAE,iBAAiB;AACjC,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM;AACxB,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI;AACpB,IAAI,MAAM,iBAAiB,EAAE,KAAK;AAClC,IAAI,GAAG,CAAC,gBAAgB,CAAC,iBAAiB,EAAE;AAC5C,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC;AAChE,IAAI;AACJ,EAAE;AACF,CAAC;AACD,IAAI,UAAU,EAAE,MAAM,QAAQ,gBAAgB;AAC9C,EAAE,WAAW,CAAC,QAAQ,EAAE,4BAA4B,EAAE;AACtD,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC;AACvC,IAAI,IAAI,CAAC,KAAK,EAAE,WAAW;AAC3B,EAAE;AACF,CAAC;AACD,IAAI,eAAe,EAAE,MAAM,QAAQ,gBAAgB;AACnD,EAAE,WAAW,CAAC,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,IAAI,EAAE;AAClE,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,qBAAqB,CAAC;AAC9C,IAAI,IAAI,CAAC,KAAK,EAAE,gBAAgB;AAChC,IAAI,IAAI,CAAC,WAAW,EAAE,UAAU;AAChC,EAAE;AACF,CAAC;AAC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,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\Projektit\\Verkkokaupat\\putiikkipalvelu-sdk\\dist\\index.cjs","sourcesContent":[null]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,137 +1,220 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Putiikkipalvelu Storefront SDK Types
|
|
3
|
+
*
|
|
4
|
+
* These types define the shape of data returned by the Storefront API.
|
|
5
|
+
* Keep in sync with API implementation when making changes.
|
|
3
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Complete store configuration returned by the API.
|
|
9
|
+
* Includes business info, SEO settings, payments, campaigns, and feature flags.
|
|
10
|
+
*/
|
|
11
|
+
interface StoreConfig {
|
|
12
|
+
store: StoreInfo;
|
|
13
|
+
seo: StoreSeo;
|
|
14
|
+
payments: PaymentConfig;
|
|
15
|
+
campaigns: Campaign[];
|
|
16
|
+
features: FeatureFlags;
|
|
17
|
+
}
|
|
4
18
|
/**
|
|
5
19
|
* Store business information
|
|
6
20
|
*/
|
|
7
21
|
interface StoreInfo {
|
|
22
|
+
/** Unique store identifier */
|
|
8
23
|
id: string;
|
|
24
|
+
/** Store display name */
|
|
9
25
|
name: string;
|
|
26
|
+
/** Contact email */
|
|
10
27
|
email: string;
|
|
28
|
+
/** Contact phone number */
|
|
11
29
|
phone: string;
|
|
30
|
+
/** Street address */
|
|
12
31
|
address: string;
|
|
32
|
+
/** City */
|
|
13
33
|
city: string;
|
|
34
|
+
/** Postal/ZIP code */
|
|
14
35
|
postalCode: string;
|
|
36
|
+
/** Country code (e.g., "FI") */
|
|
15
37
|
country: string;
|
|
38
|
+
/** Currency code (e.g., "EUR") */
|
|
16
39
|
currency: string;
|
|
40
|
+
/** Currency symbol (e.g., "€") */
|
|
17
41
|
currencySymbol: string;
|
|
42
|
+
/** Default VAT rate as percentage (e.g., 25.5) */
|
|
18
43
|
defaultVatRate: number;
|
|
44
|
+
/** Business/VAT ID */
|
|
19
45
|
businessId: string;
|
|
46
|
+
/** Store logo URL */
|
|
20
47
|
logoUrl: string | null;
|
|
21
48
|
}
|
|
22
49
|
/**
|
|
23
50
|
* Store SEO and social media configuration
|
|
24
51
|
*/
|
|
25
52
|
interface StoreSeo {
|
|
53
|
+
/** SEO meta title */
|
|
26
54
|
seoTitle: string | null;
|
|
55
|
+
/** SEO meta description */
|
|
27
56
|
seoDescription: string | null;
|
|
57
|
+
/** Store domain URL */
|
|
28
58
|
domain: string | null;
|
|
59
|
+
/** Open Graph image URL */
|
|
29
60
|
openGraphImageUrl: string | null;
|
|
61
|
+
/** Twitter card image URL */
|
|
30
62
|
twitterImageUrl: string | null;
|
|
63
|
+
/** Instagram profile URL */
|
|
31
64
|
instagramUrl: string | null;
|
|
65
|
+
/** Facebook page URL */
|
|
32
66
|
facebookUrl: string | null;
|
|
67
|
+
/** Price range indicator (e.g., "€€") */
|
|
33
68
|
priceRange: string | null;
|
|
69
|
+
/** Business type description */
|
|
34
70
|
businessType: string | null;
|
|
35
71
|
}
|
|
36
72
|
/**
|
|
37
73
|
* Payment configuration
|
|
38
74
|
*/
|
|
39
75
|
interface PaymentConfig {
|
|
76
|
+
/** Available payment methods (e.g., ["stripe", "paytrail"]) */
|
|
40
77
|
methods: string[];
|
|
78
|
+
/** Default VAT rate */
|
|
41
79
|
defaultVatRate: number;
|
|
42
80
|
}
|
|
43
81
|
/**
|
|
44
82
|
* Feature flags for the store
|
|
45
83
|
*/
|
|
46
84
|
interface FeatureFlags {
|
|
85
|
+
/** Whether wishlist functionality is enabled */
|
|
47
86
|
wishlistEnabled: boolean;
|
|
87
|
+
/** Whether guest checkout is allowed */
|
|
48
88
|
guestCheckoutEnabled: boolean;
|
|
89
|
+
/** Whether newsletter signup is enabled */
|
|
49
90
|
newsletterEnabled: boolean;
|
|
91
|
+
/** Whether product reviews are enabled */
|
|
50
92
|
reviewsEnabled: boolean;
|
|
51
93
|
}
|
|
52
94
|
/**
|
|
53
|
-
*
|
|
95
|
+
* Product information
|
|
54
96
|
*/
|
|
55
|
-
interface
|
|
97
|
+
interface Product {
|
|
98
|
+
/** Unique product identifier */
|
|
56
99
|
id: string;
|
|
57
|
-
|
|
100
|
+
/** Product name */
|
|
58
101
|
name: string;
|
|
102
|
+
/** URL-friendly slug */
|
|
103
|
+
slug: string;
|
|
104
|
+
/** Product description (HTML allowed) */
|
|
59
105
|
description: string | null;
|
|
106
|
+
/** Price in cents (e.g., 1500 = €15.00) */
|
|
60
107
|
price: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
108
|
+
/** Stock quantity (null = unlimited) */
|
|
109
|
+
quantity: number | null;
|
|
110
|
+
/** Array of image URLs */
|
|
111
|
+
images: string[];
|
|
112
|
+
/** Stock keeping unit */
|
|
113
|
+
sku: string | null;
|
|
114
|
+
}
|
|
115
|
+
/** Campaign type */
|
|
116
|
+
type CampaignType = "FREE_SHIPPING" | "BUY_X_PAY_Y";
|
|
117
|
+
/**
|
|
118
|
+
* Store campaign (promotion)
|
|
119
|
+
*/
|
|
120
|
+
interface Campaign {
|
|
121
|
+
/** Unique campaign identifier */
|
|
122
|
+
id: string;
|
|
123
|
+
/** Store ID this campaign belongs to */
|
|
124
|
+
storeId: string;
|
|
125
|
+
/** Campaign display name */
|
|
126
|
+
name: string;
|
|
127
|
+
/** Campaign description */
|
|
128
|
+
description: string | null;
|
|
129
|
+
/** Type of campaign */
|
|
130
|
+
type: CampaignType;
|
|
131
|
+
/** Campaign start date (ISO 8601) */
|
|
132
|
+
startDate: string;
|
|
133
|
+
/** Campaign end date (ISO 8601), null = no end */
|
|
134
|
+
endDate: string | null;
|
|
135
|
+
/** Whether campaign is currently active */
|
|
136
|
+
isActive: boolean;
|
|
137
|
+
/** Creation timestamp (ISO 8601) */
|
|
138
|
+
createdAt: string;
|
|
139
|
+
/** Last update timestamp (ISO 8601) */
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
/** Free shipping campaign details (if type is FREE_SHIPPING) */
|
|
142
|
+
FreeShippingCampaign: FreeShippingCampaign | null;
|
|
143
|
+
/** Buy X Pay Y campaign details (if type is BUY_X_PAY_Y) */
|
|
144
|
+
BuyXPayYCampaign: BuyXPayYCampaign | null;
|
|
64
145
|
}
|
|
65
146
|
/**
|
|
66
147
|
* Free shipping campaign details
|
|
67
148
|
*/
|
|
68
149
|
interface FreeShippingCampaign {
|
|
150
|
+
/** Unique identifier */
|
|
69
151
|
id: string;
|
|
152
|
+
/** Parent campaign ID */
|
|
70
153
|
campaignId: string;
|
|
154
|
+
/** Minimum spend in cents to qualify for free shipping */
|
|
71
155
|
minimumSpend: number;
|
|
156
|
+
/** Shipping methods eligible for free shipping */
|
|
72
157
|
shipmentMethods: ShipmentMethod[];
|
|
73
158
|
}
|
|
74
159
|
/**
|
|
75
|
-
*
|
|
76
|
-
*/
|
|
77
|
-
interface CategoryReference {
|
|
78
|
-
id: string;
|
|
79
|
-
name?: string;
|
|
80
|
-
slug?: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Buy X Pay Y campaign details
|
|
160
|
+
* Buy X Pay Y campaign details (e.g., "Buy 3, Pay 2")
|
|
84
161
|
*/
|
|
85
162
|
interface BuyXPayYCampaign {
|
|
163
|
+
/** Unique identifier */
|
|
86
164
|
id: string;
|
|
165
|
+
/** Parent campaign ID */
|
|
87
166
|
campaignId: string;
|
|
167
|
+
/** Number of items customer must buy */
|
|
88
168
|
buyQuantity: number;
|
|
169
|
+
/** Number of items customer pays for */
|
|
89
170
|
payQuantity: number;
|
|
171
|
+
/** Categories this campaign applies to */
|
|
90
172
|
applicableCategories: CategoryReference[];
|
|
91
173
|
}
|
|
92
174
|
/**
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
type CampaignType = "FREE_SHIPPING" | "BUY_X_PAY_Y";
|
|
96
|
-
/**
|
|
97
|
-
* Store campaign
|
|
98
|
-
* Note: Date fields can be Date objects (from Prisma) or strings (after JSON serialization)
|
|
175
|
+
* Shipping method
|
|
99
176
|
*/
|
|
100
|
-
interface
|
|
177
|
+
interface ShipmentMethod {
|
|
178
|
+
/** Unique identifier */
|
|
101
179
|
id: string;
|
|
180
|
+
/** Store ID */
|
|
102
181
|
storeId: string;
|
|
182
|
+
/** Shipping method name (e.g., "Posti - Paketti") */
|
|
103
183
|
name: string;
|
|
184
|
+
/** Description */
|
|
104
185
|
description: string | null;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
186
|
+
/** Price in cents */
|
|
187
|
+
price: number;
|
|
188
|
+
/** Whether this method is active */
|
|
189
|
+
active: boolean;
|
|
190
|
+
/** Minimum estimated delivery days */
|
|
191
|
+
min_estimate_delivery_days: number | null;
|
|
192
|
+
/** Maximum estimated delivery days */
|
|
193
|
+
max_estimate_delivery_days: number | null;
|
|
113
194
|
}
|
|
114
195
|
/**
|
|
115
|
-
*
|
|
196
|
+
* Category reference (lightweight, used in relationships)
|
|
116
197
|
*/
|
|
117
|
-
interface
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
198
|
+
interface CategoryReference {
|
|
199
|
+
/** Unique identifier */
|
|
200
|
+
id: string;
|
|
201
|
+
/** Category name */
|
|
202
|
+
name: string;
|
|
203
|
+
/** URL-friendly slug */
|
|
204
|
+
slug: string;
|
|
123
205
|
}
|
|
124
|
-
|
|
125
206
|
/**
|
|
126
|
-
* SDK
|
|
207
|
+
* SDK client configuration options
|
|
127
208
|
*/
|
|
128
209
|
interface StorefrontClientConfig {
|
|
129
210
|
/**
|
|
130
211
|
* Your store's API key (required)
|
|
212
|
+
* Get this from Dashboard > Settings > API Keys
|
|
131
213
|
*/
|
|
132
214
|
apiKey: string;
|
|
133
215
|
/**
|
|
134
216
|
* Base URL for the Storefront API
|
|
217
|
+
* @example "https://putiikkipalvelu.fi/api/storefront/v1"
|
|
135
218
|
*/
|
|
136
219
|
baseUrl: string;
|
|
137
220
|
/**
|
|
@@ -141,7 +224,7 @@ interface StorefrontClientConfig {
|
|
|
141
224
|
timeout?: number;
|
|
142
225
|
}
|
|
143
226
|
/**
|
|
144
|
-
*
|
|
227
|
+
* Options that can be passed to any API method.
|
|
145
228
|
* Framework-agnostic - works with Next.js, Nuxt, or plain fetch.
|
|
146
229
|
*/
|
|
147
230
|
interface FetchOptions {
|
|
@@ -167,13 +250,6 @@ interface FetchOptions {
|
|
|
167
250
|
* next: { revalidate: 60, tags: ['store-config'] }
|
|
168
251
|
* });
|
|
169
252
|
* ```
|
|
170
|
-
*
|
|
171
|
-
* @example Standard fetch
|
|
172
|
-
* ```typescript
|
|
173
|
-
* await client.store.getConfig({
|
|
174
|
-
* cache: 'force-cache'
|
|
175
|
-
* });
|
|
176
|
-
* ```
|
|
177
253
|
*/
|
|
178
254
|
[key: string]: unknown;
|
|
179
255
|
}
|
|
@@ -299,4 +375,4 @@ declare class ValidationError extends StorefrontError {
|
|
|
299
375
|
constructor(message?: string);
|
|
300
376
|
}
|
|
301
377
|
|
|
302
|
-
export { AuthError, type BuyXPayYCampaign, type Campaign, type CampaignType, type CategoryReference, type FeatureFlags, type FetchOptions, type FreeShippingCampaign, NotFoundError, type PaymentConfig, RateLimitError, type ShipmentMethod, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, ValidationError, createStorefrontClient };
|
|
378
|
+
export { AuthError, type BuyXPayYCampaign, type Campaign, type CampaignType, type CategoryReference, type FeatureFlags, type FetchOptions, type FreeShippingCampaign, NotFoundError, type PaymentConfig, type Product, RateLimitError, type ShipmentMethod, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, ValidationError, createStorefrontClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,137 +1,220 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Putiikkipalvelu Storefront SDK Types
|
|
3
|
+
*
|
|
4
|
+
* These types define the shape of data returned by the Storefront API.
|
|
5
|
+
* Keep in sync with API implementation when making changes.
|
|
3
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Complete store configuration returned by the API.
|
|
9
|
+
* Includes business info, SEO settings, payments, campaigns, and feature flags.
|
|
10
|
+
*/
|
|
11
|
+
interface StoreConfig {
|
|
12
|
+
store: StoreInfo;
|
|
13
|
+
seo: StoreSeo;
|
|
14
|
+
payments: PaymentConfig;
|
|
15
|
+
campaigns: Campaign[];
|
|
16
|
+
features: FeatureFlags;
|
|
17
|
+
}
|
|
4
18
|
/**
|
|
5
19
|
* Store business information
|
|
6
20
|
*/
|
|
7
21
|
interface StoreInfo {
|
|
22
|
+
/** Unique store identifier */
|
|
8
23
|
id: string;
|
|
24
|
+
/** Store display name */
|
|
9
25
|
name: string;
|
|
26
|
+
/** Contact email */
|
|
10
27
|
email: string;
|
|
28
|
+
/** Contact phone number */
|
|
11
29
|
phone: string;
|
|
30
|
+
/** Street address */
|
|
12
31
|
address: string;
|
|
32
|
+
/** City */
|
|
13
33
|
city: string;
|
|
34
|
+
/** Postal/ZIP code */
|
|
14
35
|
postalCode: string;
|
|
36
|
+
/** Country code (e.g., "FI") */
|
|
15
37
|
country: string;
|
|
38
|
+
/** Currency code (e.g., "EUR") */
|
|
16
39
|
currency: string;
|
|
40
|
+
/** Currency symbol (e.g., "€") */
|
|
17
41
|
currencySymbol: string;
|
|
42
|
+
/** Default VAT rate as percentage (e.g., 25.5) */
|
|
18
43
|
defaultVatRate: number;
|
|
44
|
+
/** Business/VAT ID */
|
|
19
45
|
businessId: string;
|
|
46
|
+
/** Store logo URL */
|
|
20
47
|
logoUrl: string | null;
|
|
21
48
|
}
|
|
22
49
|
/**
|
|
23
50
|
* Store SEO and social media configuration
|
|
24
51
|
*/
|
|
25
52
|
interface StoreSeo {
|
|
53
|
+
/** SEO meta title */
|
|
26
54
|
seoTitle: string | null;
|
|
55
|
+
/** SEO meta description */
|
|
27
56
|
seoDescription: string | null;
|
|
57
|
+
/** Store domain URL */
|
|
28
58
|
domain: string | null;
|
|
59
|
+
/** Open Graph image URL */
|
|
29
60
|
openGraphImageUrl: string | null;
|
|
61
|
+
/** Twitter card image URL */
|
|
30
62
|
twitterImageUrl: string | null;
|
|
63
|
+
/** Instagram profile URL */
|
|
31
64
|
instagramUrl: string | null;
|
|
65
|
+
/** Facebook page URL */
|
|
32
66
|
facebookUrl: string | null;
|
|
67
|
+
/** Price range indicator (e.g., "€€") */
|
|
33
68
|
priceRange: string | null;
|
|
69
|
+
/** Business type description */
|
|
34
70
|
businessType: string | null;
|
|
35
71
|
}
|
|
36
72
|
/**
|
|
37
73
|
* Payment configuration
|
|
38
74
|
*/
|
|
39
75
|
interface PaymentConfig {
|
|
76
|
+
/** Available payment methods (e.g., ["stripe", "paytrail"]) */
|
|
40
77
|
methods: string[];
|
|
78
|
+
/** Default VAT rate */
|
|
41
79
|
defaultVatRate: number;
|
|
42
80
|
}
|
|
43
81
|
/**
|
|
44
82
|
* Feature flags for the store
|
|
45
83
|
*/
|
|
46
84
|
interface FeatureFlags {
|
|
85
|
+
/** Whether wishlist functionality is enabled */
|
|
47
86
|
wishlistEnabled: boolean;
|
|
87
|
+
/** Whether guest checkout is allowed */
|
|
48
88
|
guestCheckoutEnabled: boolean;
|
|
89
|
+
/** Whether newsletter signup is enabled */
|
|
49
90
|
newsletterEnabled: boolean;
|
|
91
|
+
/** Whether product reviews are enabled */
|
|
50
92
|
reviewsEnabled: boolean;
|
|
51
93
|
}
|
|
52
94
|
/**
|
|
53
|
-
*
|
|
95
|
+
* Product information
|
|
54
96
|
*/
|
|
55
|
-
interface
|
|
97
|
+
interface Product {
|
|
98
|
+
/** Unique product identifier */
|
|
56
99
|
id: string;
|
|
57
|
-
|
|
100
|
+
/** Product name */
|
|
58
101
|
name: string;
|
|
102
|
+
/** URL-friendly slug */
|
|
103
|
+
slug: string;
|
|
104
|
+
/** Product description (HTML allowed) */
|
|
59
105
|
description: string | null;
|
|
106
|
+
/** Price in cents (e.g., 1500 = €15.00) */
|
|
60
107
|
price: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
108
|
+
/** Stock quantity (null = unlimited) */
|
|
109
|
+
quantity: number | null;
|
|
110
|
+
/** Array of image URLs */
|
|
111
|
+
images: string[];
|
|
112
|
+
/** Stock keeping unit */
|
|
113
|
+
sku: string | null;
|
|
114
|
+
}
|
|
115
|
+
/** Campaign type */
|
|
116
|
+
type CampaignType = "FREE_SHIPPING" | "BUY_X_PAY_Y";
|
|
117
|
+
/**
|
|
118
|
+
* Store campaign (promotion)
|
|
119
|
+
*/
|
|
120
|
+
interface Campaign {
|
|
121
|
+
/** Unique campaign identifier */
|
|
122
|
+
id: string;
|
|
123
|
+
/** Store ID this campaign belongs to */
|
|
124
|
+
storeId: string;
|
|
125
|
+
/** Campaign display name */
|
|
126
|
+
name: string;
|
|
127
|
+
/** Campaign description */
|
|
128
|
+
description: string | null;
|
|
129
|
+
/** Type of campaign */
|
|
130
|
+
type: CampaignType;
|
|
131
|
+
/** Campaign start date (ISO 8601) */
|
|
132
|
+
startDate: string;
|
|
133
|
+
/** Campaign end date (ISO 8601), null = no end */
|
|
134
|
+
endDate: string | null;
|
|
135
|
+
/** Whether campaign is currently active */
|
|
136
|
+
isActive: boolean;
|
|
137
|
+
/** Creation timestamp (ISO 8601) */
|
|
138
|
+
createdAt: string;
|
|
139
|
+
/** Last update timestamp (ISO 8601) */
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
/** Free shipping campaign details (if type is FREE_SHIPPING) */
|
|
142
|
+
FreeShippingCampaign: FreeShippingCampaign | null;
|
|
143
|
+
/** Buy X Pay Y campaign details (if type is BUY_X_PAY_Y) */
|
|
144
|
+
BuyXPayYCampaign: BuyXPayYCampaign | null;
|
|
64
145
|
}
|
|
65
146
|
/**
|
|
66
147
|
* Free shipping campaign details
|
|
67
148
|
*/
|
|
68
149
|
interface FreeShippingCampaign {
|
|
150
|
+
/** Unique identifier */
|
|
69
151
|
id: string;
|
|
152
|
+
/** Parent campaign ID */
|
|
70
153
|
campaignId: string;
|
|
154
|
+
/** Minimum spend in cents to qualify for free shipping */
|
|
71
155
|
minimumSpend: number;
|
|
156
|
+
/** Shipping methods eligible for free shipping */
|
|
72
157
|
shipmentMethods: ShipmentMethod[];
|
|
73
158
|
}
|
|
74
159
|
/**
|
|
75
|
-
*
|
|
76
|
-
*/
|
|
77
|
-
interface CategoryReference {
|
|
78
|
-
id: string;
|
|
79
|
-
name?: string;
|
|
80
|
-
slug?: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Buy X Pay Y campaign details
|
|
160
|
+
* Buy X Pay Y campaign details (e.g., "Buy 3, Pay 2")
|
|
84
161
|
*/
|
|
85
162
|
interface BuyXPayYCampaign {
|
|
163
|
+
/** Unique identifier */
|
|
86
164
|
id: string;
|
|
165
|
+
/** Parent campaign ID */
|
|
87
166
|
campaignId: string;
|
|
167
|
+
/** Number of items customer must buy */
|
|
88
168
|
buyQuantity: number;
|
|
169
|
+
/** Number of items customer pays for */
|
|
89
170
|
payQuantity: number;
|
|
171
|
+
/** Categories this campaign applies to */
|
|
90
172
|
applicableCategories: CategoryReference[];
|
|
91
173
|
}
|
|
92
174
|
/**
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
type CampaignType = "FREE_SHIPPING" | "BUY_X_PAY_Y";
|
|
96
|
-
/**
|
|
97
|
-
* Store campaign
|
|
98
|
-
* Note: Date fields can be Date objects (from Prisma) or strings (after JSON serialization)
|
|
175
|
+
* Shipping method
|
|
99
176
|
*/
|
|
100
|
-
interface
|
|
177
|
+
interface ShipmentMethod {
|
|
178
|
+
/** Unique identifier */
|
|
101
179
|
id: string;
|
|
180
|
+
/** Store ID */
|
|
102
181
|
storeId: string;
|
|
182
|
+
/** Shipping method name (e.g., "Posti - Paketti") */
|
|
103
183
|
name: string;
|
|
184
|
+
/** Description */
|
|
104
185
|
description: string | null;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
186
|
+
/** Price in cents */
|
|
187
|
+
price: number;
|
|
188
|
+
/** Whether this method is active */
|
|
189
|
+
active: boolean;
|
|
190
|
+
/** Minimum estimated delivery days */
|
|
191
|
+
min_estimate_delivery_days: number | null;
|
|
192
|
+
/** Maximum estimated delivery days */
|
|
193
|
+
max_estimate_delivery_days: number | null;
|
|
113
194
|
}
|
|
114
195
|
/**
|
|
115
|
-
*
|
|
196
|
+
* Category reference (lightweight, used in relationships)
|
|
116
197
|
*/
|
|
117
|
-
interface
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
198
|
+
interface CategoryReference {
|
|
199
|
+
/** Unique identifier */
|
|
200
|
+
id: string;
|
|
201
|
+
/** Category name */
|
|
202
|
+
name: string;
|
|
203
|
+
/** URL-friendly slug */
|
|
204
|
+
slug: string;
|
|
123
205
|
}
|
|
124
|
-
|
|
125
206
|
/**
|
|
126
|
-
* SDK
|
|
207
|
+
* SDK client configuration options
|
|
127
208
|
*/
|
|
128
209
|
interface StorefrontClientConfig {
|
|
129
210
|
/**
|
|
130
211
|
* Your store's API key (required)
|
|
212
|
+
* Get this from Dashboard > Settings > API Keys
|
|
131
213
|
*/
|
|
132
214
|
apiKey: string;
|
|
133
215
|
/**
|
|
134
216
|
* Base URL for the Storefront API
|
|
217
|
+
* @example "https://putiikkipalvelu.fi/api/storefront/v1"
|
|
135
218
|
*/
|
|
136
219
|
baseUrl: string;
|
|
137
220
|
/**
|
|
@@ -141,7 +224,7 @@ interface StorefrontClientConfig {
|
|
|
141
224
|
timeout?: number;
|
|
142
225
|
}
|
|
143
226
|
/**
|
|
144
|
-
*
|
|
227
|
+
* Options that can be passed to any API method.
|
|
145
228
|
* Framework-agnostic - works with Next.js, Nuxt, or plain fetch.
|
|
146
229
|
*/
|
|
147
230
|
interface FetchOptions {
|
|
@@ -167,13 +250,6 @@ interface FetchOptions {
|
|
|
167
250
|
* next: { revalidate: 60, tags: ['store-config'] }
|
|
168
251
|
* });
|
|
169
252
|
* ```
|
|
170
|
-
*
|
|
171
|
-
* @example Standard fetch
|
|
172
|
-
* ```typescript
|
|
173
|
-
* await client.store.getConfig({
|
|
174
|
-
* cache: 'force-cache'
|
|
175
|
-
* });
|
|
176
|
-
* ```
|
|
177
253
|
*/
|
|
178
254
|
[key: string]: unknown;
|
|
179
255
|
}
|
|
@@ -299,4 +375,4 @@ declare class ValidationError extends StorefrontError {
|
|
|
299
375
|
constructor(message?: string);
|
|
300
376
|
}
|
|
301
377
|
|
|
302
|
-
export { AuthError, type BuyXPayYCampaign, type Campaign, type CampaignType, type CategoryReference, type FeatureFlags, type FetchOptions, type FreeShippingCampaign, NotFoundError, type PaymentConfig, RateLimitError, type ShipmentMethod, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, ValidationError, createStorefrontClient };
|
|
378
|
+
export { AuthError, type BuyXPayYCampaign, type Campaign, type CampaignType, type CategoryReference, type FeatureFlags, type FetchOptions, type FreeShippingCampaign, NotFoundError, type PaymentConfig, type Product, RateLimitError, type ShipmentMethod, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, ValidationError, createStorefrontClient };
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,9 @@ var StorefrontError = class _StorefrontError extends Error {
|
|
|
5
5
|
this.name = "StorefrontError";
|
|
6
6
|
this.status = status;
|
|
7
7
|
this.code = code;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const ErrorWithCapture = Error;
|
|
9
|
+
if (ErrorWithCapture.captureStackTrace) {
|
|
10
|
+
ErrorWithCapture.captureStackTrace(this, _StorefrontError);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/errors.ts","../src/utils/fetch.ts","../src/resources/store.ts","../src/client.ts"],"sourcesContent":["/**\r\n * Base error class for all Storefront API errors\r\n */\r\nexport class StorefrontError extends Error {\r\n public readonly status: number;\r\n public readonly code: string;\r\n\r\n constructor(message: string, status: number, code: string) {\r\n super(message);\r\n this.name = \"StorefrontError\";\r\n this.status = status;\r\n this.code = code;\r\n\r\n // Maintains proper stack trace in V8 environments\r\n if (Error.captureStackTrace) {\r\n Error.captureStackTrace(this, StorefrontError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when API returns 401 Unauthorized\r\n */\r\nexport class AuthError extends StorefrontError {\r\n constructor(message: string = \"Invalid or missing API key\") {\r\n super(message, 401, \"UNAUTHORIZED\");\r\n this.name = \"AuthError\";\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when API returns 429 Too Many Requests\r\n */\r\nexport class RateLimitError extends StorefrontError {\r\n public readonly retryAfter: number | null;\r\n\r\n constructor(message: string = \"Rate limit exceeded\", retryAfter: number | null = null) {\r\n super(message, 429, \"RATE_LIMIT_EXCEEDED\");\r\n this.name = \"RateLimitError\";\r\n this.retryAfter = retryAfter;\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a requested resource is not found (404)\r\n */\r\nexport class NotFoundError extends StorefrontError {\r\n constructor(message: string = \"Resource not found\") {\r\n super(message, 404, \"NOT_FOUND\");\r\n this.name = \"NotFoundError\";\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when request validation fails (400)\r\n */\r\nexport class ValidationError extends StorefrontError {\r\n constructor(message: string = \"Validation failed\") {\r\n super(message, 400, \"VALIDATION_ERROR\");\r\n this.name = \"ValidationError\";\r\n }\r\n}\r\n","import type { FetchOptions } from \"../types/index.js\";\r\nimport { StorefrontError, AuthError, RateLimitError, NotFoundError, ValidationError } from \"./errors.js\";\r\n\r\n// SDK version - will be replaced during build or read from package.json\r\nconst SDK_VERSION = \"0.1.0\";\r\n\r\nexport interface FetcherConfig {\r\n apiKey: string;\r\n baseUrl: string;\r\n timeout?: number;\r\n}\r\n\r\nexport interface RequestOptions extends FetchOptions {\r\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\r\n body?: unknown;\r\n params?: Record<string, string | number | boolean | undefined>;\r\n}\r\n\r\n/**\r\n * Fetcher instance type returned by createFetcher\r\n */\r\nexport type Fetcher = ReturnType<typeof createFetcher>;\r\n\r\n/**\r\n * Create a configured fetcher instance for making API requests\r\n */\r\nexport function createFetcher(config: FetcherConfig) {\r\n const { apiKey, baseUrl, timeout = 30000 } = config;\r\n\r\n /**\r\n * Make an authenticated request to the Storefront API\r\n */\r\n async function request<T>(endpoint: string, options: RequestOptions = {}): Promise<T> {\r\n const { method = \"GET\", body, params, signal, headers = {}, cache, ...frameworkOptions } = options;\r\n\r\n // Build URL with query parameters\r\n // Ensure baseUrl ends with / for proper URL resolution\r\n const normalizedBase = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\r\n // Remove leading slash from endpoint to avoid URL resolution issues\r\n const normalizedEndpoint = endpoint.startsWith(\"/\") ? endpoint.slice(1) : endpoint;\r\n const url = new URL(normalizedEndpoint, normalizedBase);\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n if (value !== undefined) {\r\n url.searchParams.set(key, String(value));\r\n }\r\n }\r\n }\r\n\r\n // Create abort controller for timeout\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), timeout);\r\n\r\n // Combine signals if provided\r\n const combinedSignal = signal\r\n ? AbortSignal.any([signal, controller.signal])\r\n : controller.signal;\r\n\r\n try {\r\n const fetchOptions: RequestInit & Record<string, unknown> = {\r\n method,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n \"x-api-key\": apiKey,\r\n \"x-sdk-version\": SDK_VERSION,\r\n ...headers,\r\n },\r\n body: body ? JSON.stringify(body) : undefined,\r\n signal: combinedSignal,\r\n cache,\r\n // Spread framework-specific options (e.g., Next.js `next`, or any other)\r\n ...frameworkOptions,\r\n };\r\n\r\n const response = await fetch(url.toString(), fetchOptions);\r\n\r\n clearTimeout(timeoutId);\r\n\r\n // Handle error responses\r\n if (!response.ok) {\r\n await handleErrorResponse(response);\r\n }\r\n\r\n // Parse response\r\n const data = await response.json();\r\n return data as T;\r\n } catch (error) {\r\n clearTimeout(timeoutId);\r\n\r\n // Re-throw SDK errors\r\n if (error instanceof StorefrontError) {\r\n throw error;\r\n }\r\n\r\n // Handle abort/timeout\r\n if (error instanceof Error && error.name === \"AbortError\") {\r\n throw new StorefrontError(\"Request timed out\", 408, \"TIMEOUT\");\r\n }\r\n\r\n // Handle network errors\r\n throw new StorefrontError(\r\n error instanceof Error ? error.message : \"Network error\",\r\n 0,\r\n \"NETWORK_ERROR\"\r\n );\r\n }\r\n }\r\n\r\n return { request };\r\n}\r\n\r\n/**\r\n * Handle non-2xx responses and throw appropriate errors\r\n */\r\nasync function handleErrorResponse(response: Response): Promise<never> {\r\n let errorMessage: string | null = null;\r\n\r\n try {\r\n const json: unknown = await response.json();\r\n // Extract error message if present\r\n if (json && typeof json === \"object\" && \"error\" in json) {\r\n errorMessage = (json as { error: string }).error;\r\n }\r\n } catch {\r\n // Response body is not JSON\r\n }\r\n\r\n const message = errorMessage || response.statusText || \"Request failed\";\r\n\r\n switch (response.status) {\r\n case 401:\r\n throw new AuthError(message);\r\n\r\n case 404:\r\n throw new NotFoundError(message);\r\n\r\n case 429: {\r\n const retryAfter = response.headers.get(\"Retry-After\");\r\n throw new RateLimitError(message, retryAfter ? parseInt(retryAfter, 10) : null);\r\n }\r\n\r\n case 400:\r\n throw new ValidationError(message);\r\n\r\n default:\r\n throw new StorefrontError(message, response.status, \"API_ERROR\");\r\n }\r\n}\r\n","import type { FetchOptions } from \"../types/index.js\";\r\nimport type { StoreConfig } from \"../types/store.js\";\r\nimport type { Fetcher } from \"../utils/fetch.js\";\r\n\r\n/**\r\n * Store resource for fetching store configuration\r\n */\r\nexport function createStoreResource(fetcher: Fetcher) {\r\n return {\r\n /**\r\n * Get the complete store configuration including settings, SEO, payments, campaigns, and features.\r\n *\r\n * @example Basic usage\r\n * ```typescript\r\n * const config = await client.store.getConfig();\r\n * console.log(config.store.name);\r\n * console.log(config.seo.seoTitle);\r\n * console.log(config.campaigns);\r\n * ```\r\n *\r\n * @example Next.js - with caching\r\n * ```typescript\r\n * const config = await client.store.getConfig({\r\n * next: { revalidate: 300, tags: ['store-config'] }\r\n * });\r\n * ```\r\n *\r\n * @example Nuxt - wrap with useAsyncData\r\n * ```typescript\r\n * const { data: config } = await useAsyncData(\r\n * 'store-config',\r\n * () => client.store.getConfig()\r\n * );\r\n * ```\r\n *\r\n * @example Standard fetch caching\r\n * ```typescript\r\n * const config = await client.store.getConfig({\r\n * cache: 'force-cache'\r\n * });\r\n * ```\r\n */\r\n async getConfig(options?: FetchOptions): Promise<StoreConfig> {\r\n return fetcher.request<StoreConfig>(\"/api/storefront/v1/store-config\", {\r\n ...options,\r\n });\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Type for the store resource\r\n */\r\nexport type StoreResource = ReturnType<typeof createStoreResource>;\r\n","import type { StorefrontClientConfig } from \"./types/index.js\";\r\nimport { createFetcher } from \"./utils/fetch.js\";\r\nimport { createStoreResource, type StoreResource } from \"./resources/store.js\";\r\n\r\n/**\r\n * The Storefront API client\r\n */\r\nexport interface StorefrontClient {\r\n /**\r\n * The configured API key (masked for security)\r\n */\r\n readonly apiKey: string;\r\n\r\n /**\r\n * The base URL for API requests\r\n */\r\n readonly baseUrl: string;\r\n\r\n /**\r\n * Store configuration resource\r\n */\r\n readonly store: StoreResource;\r\n}\r\n\r\n/**\r\n * Create a new Storefront API client\r\n */\r\nexport function createStorefrontClient(config: StorefrontClientConfig): StorefrontClient {\r\n if (!config.apiKey) {\r\n throw new Error(\"apiKey is required\");\r\n }\r\n if (!config.baseUrl) {\r\n throw new Error(\"baseUrl is required\");\r\n }\r\n\r\n // Ensure baseUrl doesn't have trailing slash\r\n const baseUrl = config.baseUrl.replace(/\\/$/, \"\");\r\n\r\n // Mask API key for security (show first 8 chars only)\r\n const maskedApiKey =\r\n config.apiKey.length > 8\r\n ? `${config.apiKey.slice(0, 8)}...`\r\n : config.apiKey;\r\n\r\n // Create the fetcher for making authenticated requests\r\n const fetcher = createFetcher({\r\n apiKey: config.apiKey,\r\n baseUrl,\r\n timeout: config.timeout,\r\n });\r\n\r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,QAAQ,OAAO,EAAE;AAGhD,QAAM,eACJ,OAAO,OAAO,SAAS,IACnB,GAAG,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC,QAC5B,OAAO;AAGb,QAAM,UAAU,cAAc;AAAA,IAC5B,QAAQ,OAAO;AAAA,IACf;AAAA,IACA,SAAS,OAAO;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,OAAO,oBAAoB,OAAO;AAAA,EACpC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/errors.ts","../src/utils/fetch.ts","../src/resources/store.ts","../src/client.ts"],"sourcesContent":["/**\r\n * Base error class for all Storefront API errors\r\n */\r\nexport class StorefrontError extends Error {\r\n public readonly status: number;\r\n public readonly code: string;\r\n\r\n constructor(message: string, status: number, code: string) {\r\n super(message);\r\n this.name = \"StorefrontError\";\r\n this.status = status;\r\n this.code = code;\r\n\r\n // Maintains proper stack trace in V8 environments\r\n const ErrorWithCapture = Error as typeof Error & {\r\n captureStackTrace?: (target: object, constructor: Function) => void;\r\n };\r\n if (ErrorWithCapture.captureStackTrace) {\r\n ErrorWithCapture.captureStackTrace(this, StorefrontError);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when API returns 401 Unauthorized\r\n */\r\nexport class AuthError extends StorefrontError {\r\n constructor(message: string = \"Invalid or missing API key\") {\r\n super(message, 401, \"UNAUTHORIZED\");\r\n this.name = \"AuthError\";\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when API returns 429 Too Many Requests\r\n */\r\nexport class RateLimitError extends StorefrontError {\r\n public readonly retryAfter: number | null;\r\n\r\n constructor(message: string = \"Rate limit exceeded\", retryAfter: number | null = null) {\r\n super(message, 429, \"RATE_LIMIT_EXCEEDED\");\r\n this.name = \"RateLimitError\";\r\n this.retryAfter = retryAfter;\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a requested resource is not found (404)\r\n */\r\nexport class NotFoundError extends StorefrontError {\r\n constructor(message: string = \"Resource not found\") {\r\n super(message, 404, \"NOT_FOUND\");\r\n this.name = \"NotFoundError\";\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when request validation fails (400)\r\n */\r\nexport class ValidationError extends StorefrontError {\r\n constructor(message: string = \"Validation failed\") {\r\n super(message, 400, \"VALIDATION_ERROR\");\r\n this.name = \"ValidationError\";\r\n }\r\n}\r\n","import type { FetchOptions } from \"../types/index.js\";\r\nimport { StorefrontError, AuthError, RateLimitError, NotFoundError, ValidationError } from \"./errors.js\";\r\n\r\n// SDK version - will be replaced during build or read from package.json\r\nconst SDK_VERSION = \"0.1.0\";\r\n\r\nexport interface FetcherConfig {\r\n apiKey: string;\r\n baseUrl: string;\r\n timeout?: number;\r\n}\r\n\r\nexport interface RequestOptions extends FetchOptions {\r\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\r\n body?: unknown;\r\n params?: Record<string, string | number | boolean | undefined>;\r\n}\r\n\r\n/**\r\n * Fetcher instance type returned by createFetcher\r\n */\r\nexport type Fetcher = ReturnType<typeof createFetcher>;\r\n\r\n/**\r\n * Create a configured fetcher instance for making API requests\r\n */\r\nexport function createFetcher(config: FetcherConfig) {\r\n const { apiKey, baseUrl, timeout = 30000 } = config;\r\n\r\n /**\r\n * Make an authenticated request to the Storefront API\r\n */\r\n async function request<T>(endpoint: string, options: RequestOptions = {}): Promise<T> {\r\n const { method = \"GET\", body, params, signal, headers = {}, cache, ...frameworkOptions } = options;\r\n\r\n // Build URL with query parameters\r\n // Ensure baseUrl ends with / for proper URL resolution\r\n const normalizedBase = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\r\n // Remove leading slash from endpoint to avoid URL resolution issues\r\n const normalizedEndpoint = endpoint.startsWith(\"/\") ? endpoint.slice(1) : endpoint;\r\n const url = new URL(normalizedEndpoint, normalizedBase);\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n if (value !== undefined) {\r\n url.searchParams.set(key, String(value));\r\n }\r\n }\r\n }\r\n\r\n // Create abort controller for timeout\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), timeout);\r\n\r\n // Combine signals if provided\r\n const combinedSignal = signal\r\n ? AbortSignal.any([signal, controller.signal])\r\n : controller.signal;\r\n\r\n try {\r\n const fetchOptions: RequestInit & Record<string, unknown> = {\r\n method,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n \"x-api-key\": apiKey,\r\n \"x-sdk-version\": SDK_VERSION,\r\n ...headers,\r\n },\r\n body: body ? JSON.stringify(body) : undefined,\r\n signal: combinedSignal,\r\n cache,\r\n // Spread framework-specific options (e.g., Next.js `next`, or any other)\r\n ...frameworkOptions,\r\n };\r\n\r\n const response = await fetch(url.toString(), fetchOptions);\r\n\r\n clearTimeout(timeoutId);\r\n\r\n // Handle error responses\r\n if (!response.ok) {\r\n await handleErrorResponse(response);\r\n }\r\n\r\n // Parse response\r\n const data = await response.json();\r\n return data as T;\r\n } catch (error) {\r\n clearTimeout(timeoutId);\r\n\r\n // Re-throw SDK errors\r\n if (error instanceof StorefrontError) {\r\n throw error;\r\n }\r\n\r\n // Handle abort/timeout\r\n if (error instanceof Error && error.name === \"AbortError\") {\r\n throw new StorefrontError(\"Request timed out\", 408, \"TIMEOUT\");\r\n }\r\n\r\n // Handle network errors\r\n throw new StorefrontError(\r\n error instanceof Error ? error.message : \"Network error\",\r\n 0,\r\n \"NETWORK_ERROR\"\r\n );\r\n }\r\n }\r\n\r\n return { request };\r\n}\r\n\r\n/**\r\n * Handle non-2xx responses and throw appropriate errors\r\n */\r\nasync function handleErrorResponse(response: Response): Promise<never> {\r\n let errorMessage: string | null = null;\r\n\r\n try {\r\n const json: unknown = await response.json();\r\n // Extract error message if present\r\n if (json && typeof json === \"object\" && \"error\" in json) {\r\n errorMessage = (json as { error: string }).error;\r\n }\r\n } catch {\r\n // Response body is not JSON\r\n }\r\n\r\n const message = errorMessage || response.statusText || \"Request failed\";\r\n\r\n switch (response.status) {\r\n case 401:\r\n throw new AuthError(message);\r\n\r\n case 404:\r\n throw new NotFoundError(message);\r\n\r\n case 429: {\r\n const retryAfter = response.headers.get(\"Retry-After\");\r\n throw new RateLimitError(message, retryAfter ? parseInt(retryAfter, 10) : null);\r\n }\r\n\r\n case 400:\r\n throw new ValidationError(message);\r\n\r\n default:\r\n throw new StorefrontError(message, response.status, \"API_ERROR\");\r\n }\r\n}\r\n","import type { FetchOptions, StoreConfig } from \"../types/index.js\";\r\nimport type { Fetcher } from \"../utils/fetch.js\";\r\n\r\n/**\r\n * Store resource for fetching store configuration\r\n */\r\nexport function createStoreResource(fetcher: Fetcher) {\r\n return {\r\n /**\r\n * Get the complete store configuration including settings, SEO, payments, campaigns, and features.\r\n *\r\n * @example Basic usage\r\n * ```typescript\r\n * const config = await client.store.getConfig();\r\n * console.log(config.store.name);\r\n * console.log(config.seo.seoTitle);\r\n * console.log(config.campaigns);\r\n * ```\r\n *\r\n * @example Next.js - with caching\r\n * ```typescript\r\n * const config = await client.store.getConfig({\r\n * next: { revalidate: 300, tags: ['store-config'] }\r\n * });\r\n * ```\r\n *\r\n * @example Nuxt - wrap with useAsyncData\r\n * ```typescript\r\n * const { data: config } = await useAsyncData(\r\n * 'store-config',\r\n * () => client.store.getConfig()\r\n * );\r\n * ```\r\n *\r\n * @example Standard fetch caching\r\n * ```typescript\r\n * const config = await client.store.getConfig({\r\n * cache: 'force-cache'\r\n * });\r\n * ```\r\n */\r\n async getConfig(options?: FetchOptions): Promise<StoreConfig> {\r\n return fetcher.request<StoreConfig>(\"/api/storefront/v1/store-config\", {\r\n ...options,\r\n });\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Type for the store resource\r\n */\r\nexport type StoreResource = ReturnType<typeof createStoreResource>;\r\n","import type { StorefrontClientConfig } from \"./types/index.js\";\r\nimport { createFetcher } from \"./utils/fetch.js\";\r\nimport { createStoreResource, type StoreResource } from \"./resources/store.js\";\r\n\r\n/**\r\n * The Storefront API client\r\n */\r\nexport interface StorefrontClient {\r\n /**\r\n * The configured API key (masked for security)\r\n */\r\n readonly apiKey: string;\r\n\r\n /**\r\n * The base URL for API requests\r\n */\r\n readonly baseUrl: string;\r\n\r\n /**\r\n * Store configuration resource\r\n */\r\n readonly store: StoreResource;\r\n}\r\n\r\n/**\r\n * Create a new Storefront API client\r\n */\r\nexport function createStorefrontClient(config: StorefrontClientConfig): StorefrontClient {\r\n if (!config.apiKey) {\r\n throw new Error(\"apiKey is required\");\r\n }\r\n if (!config.baseUrl) {\r\n throw new Error(\"baseUrl is required\");\r\n }\r\n\r\n // Ensure baseUrl doesn't have trailing slash\r\n const baseUrl = config.baseUrl.replace(/\\/$/, \"\");\r\n\r\n // Mask API key for security (show first 8 chars only)\r\n const maskedApiKey =\r\n config.apiKey.length > 8\r\n ? `${config.apiKey.slice(0, 8)}...`\r\n : config.apiKey;\r\n\r\n // Create the fetcher for making authenticated requests\r\n const fetcher = createFetcher({\r\n apiKey: config.apiKey,\r\n baseUrl,\r\n timeout: config.timeout,\r\n });\r\n\r\n return {\r\n apiKey: maskedApiKey,\r\n baseUrl,\r\n store: createStoreResource(fetcher),\r\n };\r\n}\r\n"],"mappings":";AAGO,IAAM,kBAAN,MAAM,yBAAwB,MAAM;AAAA,EAIzC,YAAY,SAAiB,QAAgB,MAAc;AACzD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAGZ,UAAM,mBAAmB;AAGzB,QAAI,iBAAiB,mBAAmB;AACtC,uBAAiB,kBAAkB,MAAM,gBAAe;AAAA,IAC1D;AAAA,EACF;AACF;AAKO,IAAM,YAAN,cAAwB,gBAAgB;AAAA,EAC7C,YAAY,UAAkB,8BAA8B;AAC1D,UAAM,SAAS,KAAK,cAAc;AAClC,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,iBAAN,cAA6B,gBAAgB;AAAA,EAGlD,YAAY,UAAkB,uBAAuB,aAA4B,MAAM;AACrF,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IAAI,gBAAgB,OAAO;AAAA,IAEnC;AACE,YAAM,IAAI,gBAAgB,SAAS,SAAS,QAAQ,WAAW;AAAA,EACnE;AACF;;;AC9IO,SAAS,oBAAoB,SAAkB;AACpD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkCL,MAAM,UAAU,SAA8C;AAC5D,aAAO,QAAQ,QAAqB,mCAAmC;AAAA,QACrE,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;ACpBO,SAAS,uBAAuB,QAAkD;AACvF,MAAI,CAAC,OAAO,QAAQ;AAClB,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AACA,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAGA,QAAM,UAAU,OAAO,QAAQ,QAAQ,OAAO,EAAE;AAGhD,QAAM,eACJ,OAAO,OAAO,SAAS,IACnB,GAAG,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC,QAC5B,OAAO;AAGb,QAAM,UAAU,cAAc;AAAA,IAC5B,QAAQ,OAAO;AAAA,IACf;AAAA,IACA,SAAS,OAAO;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,OAAO,oBAAoB,OAAO;AAAA,EACpC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putiikkipalvelu/storefront-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript SDK for Putiikkipalvelu Storefront API",
|
|
5
5
|
"author": "Putiikkipalvelu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,13 +48,12 @@
|
|
|
48
48
|
"sdk",
|
|
49
49
|
"api-client"
|
|
50
50
|
],
|
|
51
|
+
"homepage": "https://www.putiikkipalvelu.fi/fi/docs",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/Nikojuu/putiikkipalvelu-sdk/issues"
|
|
54
|
+
},
|
|
51
55
|
"repository": {
|
|
52
56
|
"type": "git",
|
|
53
|
-
"url": "https://github.com/Nikojuu/
|
|
54
|
-
"directory": "packages/sdk"
|
|
55
|
-
},
|
|
56
|
-
"homepage": "https://github.com/Nikojuu/verkkokauppapalvelu/tree/SDK-package/packages/sdk",
|
|
57
|
-
"bugs": {
|
|
58
|
-
"url": "https://github.com/Nikojuu/verkkokauppapalvelu/issues"
|
|
57
|
+
"url": "https://github.com/Nikojuu/putiikkipalvelu-sdk"
|
|
59
58
|
}
|
|
60
59
|
}
|