arky-sdk 0.9.20 → 0.11.0
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 +179 -105
- package/dist/admin.cjs +55 -5
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +5 -3
- package/dist/admin.d.ts +5 -3
- package/dist/admin.js +55 -5
- package/dist/admin.js.map +1 -1
- package/dist/{api-C_2AMzmc.d.cts → index-B0Pd1s-2.d.cts} +4457 -4451
- package/dist/{api-C_2AMzmc.d.ts → index-B0Pd1s-2.d.ts} +4457 -4451
- package/dist/index.cjs +2360 -546
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3829 -3
- package/dist/index.d.ts +3829 -3
- package/dist/index.js +2356 -547
- package/dist/index.js.map +1 -1
- package/dist/{inventory-DdgZ5MI_.d.ts → inventory-C2EZEnV9.d.ts} +1 -1
- package/dist/{inventory-DgPpeRWU.d.cts → inventory-t9OBR0CC.d.cts} +1 -1
- package/dist/storefront.cjs +692 -686
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +5 -512
- package/dist/storefront.d.ts +5 -512
- package/dist/storefront.js +692 -686
- package/dist/storefront.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
- package/dist/admin-CTtJoarO.d.ts +0 -1543
- package/dist/admin-DB_GYW2b.d.cts +0 -1543
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# arky-sdk
|
|
2
2
|
|
|
3
|
-
Official TypeScript SDK for [Arky](https://arky.io), the website backend and client
|
|
4
|
-
|
|
5
|
-
Arky lets you keep frontend control while using one backend for CMS, commerce, bookings, forms, profiles, action, experiments, support, workflows, API, and SDK.
|
|
3
|
+
Official TypeScript SDK for [Arky](https://arky.io), the website backend and Admin client for custom frontends.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -10,114 +8,75 @@ Arky lets you keep frontend control while using one backend for CMS, commerce, b
|
|
|
10
8
|
npm install arky-sdk
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
## Storefront
|
|
11
|
+
## Storefront quick start
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
Copy the Store publishable key from Developer and initialize one client:
|
|
16
14
|
|
|
17
15
|
```typescript
|
|
18
|
-
import { initialize } from "arky-sdk
|
|
19
|
-
|
|
20
|
-
const arky = initialize({
|
|
21
|
-
baseUrl: "https://api.arky.io",
|
|
22
|
-
storeId: "your-store-id",
|
|
23
|
-
market: "us",
|
|
24
|
-
locale: "en",
|
|
25
|
-
marketForLocale: (locale) => (locale === "it" ? "ita" : "us"),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const homepage = await arky.cms.entry.get({
|
|
29
|
-
collection_id: "pages",
|
|
30
|
-
key: "homepage",
|
|
31
|
-
locale: "en",
|
|
32
|
-
});
|
|
16
|
+
import { initialize } from "arky-sdk";
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
18
|
+
export const arky = initialize(
|
|
19
|
+
import.meta.env.PUBLIC_ARKY_PUBLISHABLE_KEY,
|
|
20
|
+
);
|
|
38
21
|
```
|
|
39
22
|
|
|
40
|
-
`initialize` is
|
|
23
|
+
`initialize` is synchronous. It makes no request and creates no visitor. Production requests use `https://api.arky.io` by default.
|
|
41
24
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
The storefront module API is the preferred surface for websites:
|
|
25
|
+
For local development or an explicit initial context:
|
|
45
26
|
|
|
46
27
|
```typescript
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
key: "homepage",
|
|
52
|
-
locale: "en",
|
|
53
|
-
});
|
|
54
|
-
await arky.cms.form.submitByKey({ key: "contact", values: {} });
|
|
55
|
-
|
|
56
|
-
const { items: products } = await arky.eshop.product.list({ limit: 20 });
|
|
57
|
-
await arky.eshop.cart.addProduct(products[0], products[0].variants[0], 1);
|
|
58
|
-
await arky.eshop.cart.quote();
|
|
59
|
-
await arky.eshop.cart.checkout({ payment_method_key: "cash" });
|
|
60
|
-
|
|
61
|
-
const { items: services } = await arky.eshop.service.list({ limit: 20 });
|
|
62
|
-
await arky.eshop.service.initialize();
|
|
63
|
-
|
|
64
|
-
await arky.action.track({
|
|
65
|
-
key: "project.inquiry.started",
|
|
66
|
-
payload: { placement: "homepage" },
|
|
28
|
+
export const arky = initialize("arky_pk_...", {
|
|
29
|
+
apiUrl: "http://localhost:8000",
|
|
30
|
+
locale: "it",
|
|
31
|
+
market: "ita",
|
|
67
32
|
});
|
|
68
33
|
```
|
|
69
34
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
const unsubscribe = arky.eshop.cart.snapshot.subscribe((snapshot) => {
|
|
74
|
-
console.log(snapshot.item_count, snapshot.cart?.id);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
await arky.eshop.cart.load();
|
|
78
|
-
unsubscribe();
|
|
79
|
-
```
|
|
35
|
+
The SDK accepts only an `arky_pk_...` publishable key. A personal `arky_api_...` token or an `arky_vst_...` visitor session is rejected at initialization. Publishable keys identify a Store; they grant no Admin access and are safe to include in browser code.
|
|
80
36
|
|
|
81
|
-
## Read
|
|
37
|
+
## Read content and submit forms
|
|
82
38
|
|
|
83
|
-
|
|
39
|
+
Anonymous CMS and catalog reads do not create a visitor:
|
|
84
40
|
|
|
85
41
|
```typescript
|
|
86
42
|
const page = await arky.cms.entry.get({
|
|
87
43
|
collection_id: "pages",
|
|
88
44
|
key: "homepage",
|
|
89
|
-
locale: "en",
|
|
90
45
|
});
|
|
91
46
|
|
|
92
47
|
const titleBlock = page.blocks.find((block) => block.key === "title");
|
|
93
|
-
const title = arky.utils.getBlockTextValue(titleBlock,
|
|
48
|
+
const title = arky.utils.getBlockTextValue(titleBlock, arky.getLocale());
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Stateful operations identify the visitor lazily. Concurrent first operations share one identify request:
|
|
94
52
|
|
|
53
|
+
```typescript
|
|
95
54
|
await arky.cms.form.submitByKey({
|
|
96
55
|
key: "contact",
|
|
97
56
|
values: {
|
|
98
|
-
email: "
|
|
57
|
+
email: "visitor@example.com",
|
|
99
58
|
message: "Hello from the storefront",
|
|
100
59
|
},
|
|
101
60
|
});
|
|
102
61
|
```
|
|
103
62
|
|
|
104
|
-
|
|
63
|
+
The browser persists only the `arky_vst_...` visitor-session token. Storage is isolated by API endpoint and a fingerprint of the publishable key.
|
|
64
|
+
|
|
65
|
+
## Products, services, and checkout
|
|
105
66
|
|
|
106
67
|
```typescript
|
|
107
68
|
const { items: products } = await arky.eshop.product.list({ limit: 20 });
|
|
108
69
|
const product = await arky.eshop.product.get({ id: products[0].id });
|
|
109
|
-
const variant = product.variants[0];
|
|
110
|
-
|
|
111
|
-
await arky.eshop.cart.addProduct(product, variant, 2);
|
|
112
70
|
|
|
113
|
-
|
|
71
|
+
await arky.eshop.cart.addProduct(product, product.variants[0], 2);
|
|
72
|
+
await arky.eshop.cart.quote();
|
|
114
73
|
|
|
115
74
|
const order = await arky.eshop.cart.checkout({
|
|
116
|
-
payment_method_key: "
|
|
75
|
+
payment_method_key: "cash",
|
|
117
76
|
});
|
|
118
77
|
```
|
|
119
78
|
|
|
120
|
-
|
|
79
|
+
Scheduled services use the same cart:
|
|
121
80
|
|
|
122
81
|
```typescript
|
|
123
82
|
const { items: services } = await arky.eshop.service.list({ limit: 20 });
|
|
@@ -129,68 +88,183 @@ arky.eshop.service.findFirstAvailable();
|
|
|
129
88
|
const state = arky.eshop.service.state.get();
|
|
130
89
|
if (state.slots[0]) {
|
|
131
90
|
arky.eshop.service.selectTimeSlot(state.slots[0]);
|
|
132
|
-
const configuredForms = arky.eshop.service.form_groups.get();
|
|
133
|
-
// Render and bind each configuredForms[i].blocks before adding the booking.
|
|
134
91
|
arky.eshop.service.nextStep();
|
|
135
92
|
await arky.eshop.service.addToCart();
|
|
136
93
|
}
|
|
94
|
+
```
|
|
137
95
|
|
|
138
|
-
|
|
139
|
-
|
|
96
|
+
Nano Stores expose reactive module state:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const unsubscribe = arky.eshop.cart.snapshot.subscribe((snapshot) => {
|
|
100
|
+
console.log(snapshot.item_count, snapshot.cart?.id);
|
|
140
101
|
});
|
|
102
|
+
|
|
103
|
+
await arky.eshop.cart.load();
|
|
104
|
+
unsubscribe();
|
|
141
105
|
```
|
|
142
106
|
|
|
143
|
-
|
|
107
|
+
## Locale and market context
|
|
144
108
|
|
|
145
|
-
|
|
109
|
+
Locale and market are independent. Neither is inferred from the other, browser language, IP address, or geolocation:
|
|
146
110
|
|
|
147
|
-
|
|
111
|
+
```typescript
|
|
112
|
+
arky.setContext({ locale: "bs" });
|
|
113
|
+
arky.setContext({ market: "bih" });
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Use an isolated scoped client for SSR, static generation, or parallel contexts:
|
|
148
117
|
|
|
149
118
|
```typescript
|
|
150
|
-
const
|
|
119
|
+
const italian = arky.withContext({ locale: "it", market: "ita" });
|
|
120
|
+
const page = await italian.cms.entry.get({
|
|
121
|
+
collection_id: "pages",
|
|
122
|
+
key: "homepage",
|
|
123
|
+
});
|
|
124
|
+
```
|
|
151
125
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
126
|
+
Changing the scoped client does not mutate the original client. A market change while the cart contains items throws `CART_MARKET_LOCKED`; the SDK never silently clears or reprices the cart.
|
|
127
|
+
|
|
128
|
+
## Store setup and Stripe
|
|
129
|
+
|
|
130
|
+
Store setup is fetched lazily and deduplicated:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const setup = await arky.store.load();
|
|
134
|
+
console.log(setup.languages.default, setup.markets.default);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Payment configuration belongs to Arky. Mounting card payment waits for setup internally and accepts no Stripe publishable key or connected Account ID:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
await arky.eshop.cart.payment.mount("#payment", {
|
|
141
|
+
appearance: { theme: "stripe" },
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For a paid flow outside the cart, pass only customer-facing amount and currency:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
await arky.eshop.cart.payment.mount("#payment", {
|
|
149
|
+
amount: 2500,
|
|
150
|
+
currency: "EUR",
|
|
151
|
+
setupFutureUsage: "off_session",
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`setupFutureUsage` is optional. Use `"off_session"` when the paid flow will
|
|
156
|
+
reuse the payment method later, such as a subscription.
|
|
157
|
+
|
|
158
|
+
## SSR and static generation
|
|
159
|
+
|
|
160
|
+
Anonymous reads work without browser storage. Stateful SSR requires an explicit request-local adapter so a server module cannot retain one visitor across requests:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const arky = initialize(process.env.ARKY_PUBLISHABLE_KEY!, {
|
|
164
|
+
locale: requestLocale,
|
|
165
|
+
market: requestMarket,
|
|
166
|
+
sessionStorage: {
|
|
167
|
+
getItem: (key) => requestSession.get(key) ?? null,
|
|
168
|
+
setItem: (key, value) => requestSession.set(key, value),
|
|
169
|
+
removeItem: (key) => requestSession.delete(key),
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Create one client per request. `withContext` also creates an isolated visitor session; when used during SSR it reuses the request-local adapter under a separate scoped storage key. The SDK does not ship framework-specific cookie adapters.
|
|
175
|
+
|
|
176
|
+
## Low-level storefront client
|
|
177
|
+
|
|
178
|
+
The module facade exposes its low-level client as `arky.client`:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
await arky.client.eshop.product.find({ limit: 20 });
|
|
182
|
+
const cart = await arky.client.eshop.cart.current();
|
|
183
|
+
await arky.client.eshop.cart.get({ id: cart.id, token: cart.token });
|
|
184
|
+
await arky.client.cms.entry.find({
|
|
156
185
|
collection_id: "pages",
|
|
157
186
|
key: "homepage",
|
|
158
187
|
limit: 1,
|
|
159
188
|
});
|
|
160
189
|
```
|
|
161
190
|
|
|
162
|
-
|
|
191
|
+
Low-level requests use Store-ID-free `/v1/storefront` routes and send connection context as headers:
|
|
163
192
|
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
193
|
+
```http
|
|
194
|
+
X-Arky-Publishable-Key: arky_pk_...
|
|
195
|
+
X-Arky-Locale: it
|
|
196
|
+
X-Arky-Market: ita
|
|
197
|
+
Authorization: Bearer arky_vst_...
|
|
198
|
+
```
|
|
169
199
|
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
For cart recovery, `cart.get({ id, token })` sends the recovery credential as
|
|
201
|
+
`X-Arky-Cart-Token`. It is never placed in the request URL or body.
|
|
202
|
+
|
|
203
|
+
Locale and market headers are omitted when no explicit context is set, allowing the server to use Store defaults.
|
|
204
|
+
|
|
205
|
+
## Configuration
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
initialize(publishableKey: string, {
|
|
209
|
+
apiUrl?: string,
|
|
172
210
|
locale?: string,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
211
|
+
market?: string,
|
|
212
|
+
sessionStorage?: StorefrontSessionStorage,
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
One storefront client always represents one publishable key and one Store. To connect to another Store, initialize a second explicit client with its publishable key.
|
|
217
|
+
|
|
218
|
+
## Admin client
|
|
219
|
+
|
|
220
|
+
Private operator integrations use the separate Admin client. Personal API tokens must never be exposed in browser code:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { createAdmin } from "arky-sdk/admin";
|
|
224
|
+
|
|
225
|
+
const admin = createAdmin({
|
|
226
|
+
baseUrl: "https://api.arky.io",
|
|
227
|
+
storeId: "internal-store-id",
|
|
228
|
+
apiToken: process.env.ARKY_PERSONAL_API_TOKEN,
|
|
177
229
|
});
|
|
178
230
|
```
|
|
179
231
|
|
|
180
|
-
|
|
232
|
+
Store connection management is available through the Admin surface:
|
|
181
233
|
|
|
182
234
|
```typescript
|
|
183
|
-
|
|
184
|
-
|
|
235
|
+
const store = await admin.store.regeneratePublishableKey({
|
|
236
|
+
store_id: "internal-store-id",
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await admin.store.update({
|
|
240
|
+
id: store.id,
|
|
241
|
+
default_market_id: "market-id",
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## TypeScript
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import {
|
|
249
|
+
initialize,
|
|
250
|
+
type ArkyStore,
|
|
251
|
+
type StorefrontDto,
|
|
252
|
+
type StorefrontSetup,
|
|
253
|
+
} from "arky-sdk";
|
|
254
|
+
import type { Block, Cart, Order, Price, Product, Service } from "arky-sdk";
|
|
255
|
+
|
|
256
|
+
type StorefrontProduct = StorefrontDto<Product>;
|
|
257
|
+
type StorefrontCart = StorefrontDto<Cart>;
|
|
185
258
|
```
|
|
186
259
|
|
|
187
|
-
|
|
260
|
+
Storefront request types intentionally contain no Store routing ID. Admin request types remain Store-explicit.
|
|
261
|
+
|
|
262
|
+
## Adding an endpoint
|
|
188
263
|
|
|
189
|
-
When adding
|
|
264
|
+
When adding SDK methods:
|
|
190
265
|
|
|
191
|
-
1.
|
|
192
|
-
2.
|
|
193
|
-
3.
|
|
194
|
-
4.
|
|
195
|
-
5.
|
|
196
|
-
6. Re-export the entity from `src/index.ts` if consumers will import it.
|
|
266
|
+
1. Mirror server response DTOs in `src/types/index.ts` or the relevant API module.
|
|
267
|
+
2. Keep Admin inputs Store-explicit, but omit `store_id` from every storefront input, URL, and body.
|
|
268
|
+
3. Use `/v1/storefront/...` keyless routes and let the shared client attach publishable-key, locale, market, and visitor headers.
|
|
269
|
+
4. Mark customer mutations as stateful so they call the deduplicated visitor-session lifecycle.
|
|
270
|
+
5. Add explicit response generics to every HTTP call and re-export consumer-facing types.
|
package/dist/admin.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('nanostores');
|
|
4
|
+
|
|
3
5
|
// src/utils/queryParams.ts
|
|
4
6
|
function buildQueryString(params) {
|
|
5
7
|
const queryParts = Object.entries(params).flatMap(
|
|
@@ -27,6 +29,15 @@ function requestError(name, message, details = {}) {
|
|
|
27
29
|
function isRecord(value) {
|
|
28
30
|
return typeof value === "object" && value !== null;
|
|
29
31
|
}
|
|
32
|
+
function omitStorefrontRouting(value) {
|
|
33
|
+
if (!isRecord(value) || Array.isArray(value)) return value;
|
|
34
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35
|
+
if (prototype !== Object.prototype && prototype !== null) return value;
|
|
36
|
+
const result = { ...value };
|
|
37
|
+
delete result.store_id;
|
|
38
|
+
delete result.market;
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
30
41
|
function isTokenSet(value) {
|
|
31
42
|
return isRecord(value) && typeof value.access_token === "string" && (value.refresh_token === void 0 || typeof value.refresh_token === "string") && (value.access_expires_at === void 0 || typeof value.access_expires_at === "number");
|
|
32
43
|
}
|
|
@@ -102,10 +113,25 @@ function createHttpClient(cfg) {
|
|
|
102
113
|
if (!retried && options?.transformRequest) {
|
|
103
114
|
body = options.transformRequest(body);
|
|
104
115
|
}
|
|
116
|
+
if (cfg.storefrontMode) {
|
|
117
|
+
body = omitStorefrontRouting(body);
|
|
118
|
+
}
|
|
119
|
+
const forcedHeaders = typeof cfg.forcedHeaders === "function" ? cfg.forcedHeaders() : cfg.forcedHeaders || {};
|
|
120
|
+
const callerHeaders = { ...options?.headers || {} };
|
|
121
|
+
const protectedHeaderNames = new Set(
|
|
122
|
+
Object.keys(forcedHeaders).map((name) => name.toLowerCase())
|
|
123
|
+
);
|
|
124
|
+
if (cfg.storefrontMode) protectedHeaderNames.add("authorization");
|
|
125
|
+
for (const name of Object.keys(callerHeaders)) {
|
|
126
|
+
if (protectedHeaderNames.has(name.toLowerCase())) {
|
|
127
|
+
delete callerHeaders[name];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
105
130
|
const headers = {
|
|
106
131
|
Accept: "application/json",
|
|
107
132
|
"Content-Type": "application/json",
|
|
108
|
-
...
|
|
133
|
+
...callerHeaders,
|
|
134
|
+
...forcedHeaders
|
|
109
135
|
};
|
|
110
136
|
let tokens = authStorage.getTokens();
|
|
111
137
|
const nowSec = Date.now() / 1e3;
|
|
@@ -116,7 +142,8 @@ function createHttpClient(cfg) {
|
|
|
116
142
|
if (tokens?.access_token) {
|
|
117
143
|
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
118
144
|
}
|
|
119
|
-
const
|
|
145
|
+
const requestParams = cfg.storefrontMode ? omitStorefrontRouting(options?.params) : options?.params;
|
|
146
|
+
const finalPath = requestParams ? path + buildQueryString(requestParams) : path;
|
|
120
147
|
const fetchOptions = {
|
|
121
148
|
method,
|
|
122
149
|
headers,
|
|
@@ -147,8 +174,19 @@ function createHttpClient(cfg) {
|
|
|
147
174
|
throw err;
|
|
148
175
|
}
|
|
149
176
|
if (res.status === 401 && !retried) {
|
|
150
|
-
|
|
151
|
-
|
|
177
|
+
if (cfg.onUnauthorized) {
|
|
178
|
+
const recovered = await cfg.onUnauthorized({
|
|
179
|
+
hadAuthorization: Boolean(tokens?.access_token),
|
|
180
|
+
authorizationToken: tokens?.access_token || null,
|
|
181
|
+
path
|
|
182
|
+
});
|
|
183
|
+
if (recovered) {
|
|
184
|
+
return request(method, path, body, options, true);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
await ensureFreshToken();
|
|
188
|
+
return request(method, path, body, options, true);
|
|
189
|
+
}
|
|
152
190
|
}
|
|
153
191
|
try {
|
|
154
192
|
const contentLength = res.headers.get("content-length");
|
|
@@ -364,6 +402,14 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
364
402
|
params
|
|
365
403
|
});
|
|
366
404
|
},
|
|
405
|
+
async regeneratePublishableKey(params = {}, options) {
|
|
406
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
407
|
+
return apiConfig.httpClient.post(
|
|
408
|
+
`/v1/stores/${store_id}/publishable-key/regenerate`,
|
|
409
|
+
{},
|
|
410
|
+
options
|
|
411
|
+
);
|
|
412
|
+
},
|
|
367
413
|
async getSubscriptionPlans(_params, options) {
|
|
368
414
|
return apiConfig.httpClient.get("/v1/stores/plans", options);
|
|
369
415
|
},
|
|
@@ -1262,7 +1308,10 @@ var createMarketApi = (apiConfig) => {
|
|
|
1262
1308
|
async delete(params, options) {
|
|
1263
1309
|
return apiConfig.httpClient.delete(
|
|
1264
1310
|
`/v1/stores/${apiConfig.storeId}/markets/${params.id}`,
|
|
1265
|
-
|
|
1311
|
+
{
|
|
1312
|
+
...options,
|
|
1313
|
+
params: params.replacement_default_market_id ? { replacement_default_market_id: params.replacement_default_market_id } : options?.params
|
|
1314
|
+
}
|
|
1266
1315
|
);
|
|
1267
1316
|
}
|
|
1268
1317
|
};
|
|
@@ -3508,6 +3557,7 @@ function createAdmin(config) {
|
|
|
3508
3557
|
update: storeApi.updateStore,
|
|
3509
3558
|
get: storeApi.getStore,
|
|
3510
3559
|
find: storeApi.getStores,
|
|
3560
|
+
regeneratePublishableKey: storeApi.regeneratePublishableKey,
|
|
3511
3561
|
subscription: {
|
|
3512
3562
|
get: storeApi.getSubscription,
|
|
3513
3563
|
getPlans: storeApi.getSubscriptionPlans,
|