ce-storefront 0.15.3 → 0.15.6
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 +15 -2
- package/docs/sdks/auth/README.md +10 -0
- package/docs/sdks/carts/README.md +12 -0
- package/docs/sdks/catalog/README.md +11 -0
- package/docs/sdks/common/README.md +1 -0
- package/docs/sdks/customers/README.md +7 -0
- package/docs/sdks/orders/README.md +7 -0
- package/docs/sdks/pos/README.md +397 -0
- package/docs/sdks/shipping/README.md +1 -0
- package/esm/funcs/posCreatePosCart.d.ts +17 -0
- package/esm/funcs/posCreatePosCart.d.ts.map +1 -0
- package/esm/funcs/posCreatePosCart.js +80 -0
- package/esm/funcs/posCreatePosCart.js.map +1 -0
- package/esm/funcs/posLoginToPosDevice.d.ts +17 -0
- package/esm/funcs/posLoginToPosDevice.d.ts.map +1 -0
- package/esm/funcs/posLoginToPosDevice.js +84 -0
- package/esm/funcs/posLoginToPosDevice.js.map +1 -0
- package/esm/funcs/posPairPosDevice.d.ts +17 -0
- package/esm/funcs/posPairPosDevice.d.ts.map +1 -0
- package/esm/funcs/posPairPosDevice.js +84 -0
- package/esm/funcs/posPairPosDevice.js.map +1 -0
- package/esm/funcs/posRefreshPosAccessToken.d.ts +17 -0
- package/esm/funcs/posRefreshPosAccessToken.d.ts.map +1 -0
- package/esm/funcs/posRefreshPosAccessToken.js +81 -0
- package/esm/funcs/posRefreshPosAccessToken.js.map +1 -0
- package/esm/funcs/posUpdatePosCart.d.ts +17 -0
- package/esm/funcs/posUpdatePosCart.d.ts.map +1 -0
- package/esm/funcs/posUpdatePosCart.js +84 -0
- package/esm/funcs/posUpdatePosCart.js.map +1 -0
- package/esm/lib/base64.d.ts +2 -2
- package/esm/lib/base64.d.ts.map +1 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/encodings.d.ts.map +1 -1
- package/esm/models/components/index.d.ts +1 -0
- package/esm/models/components/index.d.ts.map +1 -1
- package/esm/models/components/index.js +1 -0
- package/esm/models/components/index.js.map +1 -1
- package/esm/models/components/posuser.d.ts +124 -0
- package/esm/models/components/posuser.d.ts.map +1 -0
- package/esm/models/components/posuser.js +139 -0
- package/esm/models/components/posuser.js.map +1 -0
- package/esm/models/operations/createposcart.d.ts +90 -0
- package/esm/models/operations/createposcart.d.ts.map +1 -0
- package/esm/models/operations/createposcart.js +86 -0
- package/esm/models/operations/createposcart.js.map +1 -0
- package/esm/models/operations/index.d.ts +5 -0
- package/esm/models/operations/index.d.ts.map +1 -1
- package/esm/models/operations/index.js +5 -0
- package/esm/models/operations/index.js.map +1 -1
- package/esm/models/operations/logintoposdevice.d.ts +118 -0
- package/esm/models/operations/logintoposdevice.d.ts.map +1 -0
- package/esm/models/operations/logintoposdevice.js +146 -0
- package/esm/models/operations/logintoposdevice.js.map +1 -0
- package/esm/models/operations/pairposdevice.d.ts +115 -0
- package/esm/models/operations/pairposdevice.d.ts.map +1 -0
- package/esm/models/operations/pairposdevice.js +141 -0
- package/esm/models/operations/pairposdevice.js.map +1 -0
- package/esm/models/operations/refreshposaccesstoken.d.ts +88 -0
- package/esm/models/operations/refreshposaccesstoken.d.ts.map +1 -0
- package/esm/models/operations/refreshposaccesstoken.js +106 -0
- package/esm/models/operations/refreshposaccesstoken.js.map +1 -0
- package/esm/models/operations/updateposcart.d.ts +120 -0
- package/esm/models/operations/updateposcart.d.ts.map +1 -0
- package/esm/models/operations/updateposcart.js +122 -0
- package/esm/models/operations/updateposcart.js.map +1 -0
- package/esm/sdk/pos.d.ts +40 -0
- package/esm/sdk/pos.d.ts.map +1 -0
- package/esm/sdk/pos.js +58 -0
- package/esm/sdk/pos.js.map +1 -0
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.d.ts.map +1 -1
- package/esm/sdk/sdk.js +4 -0
- package/esm/sdk/sdk.js.map +1 -1
- package/examples/README.md +5 -0
- package/examples/catalogListProducts.example.ts +2 -0
- package/examples/package-lock.json +6 -7
- package/jsr.json +1 -1
- package/package.json +5 -6
- package/src/funcs/posCreatePosCart.ts +165 -0
- package/src/funcs/posLoginToPosDevice.ts +174 -0
- package/src/funcs/posPairPosDevice.ts +174 -0
- package/src/funcs/posRefreshPosAccessToken.ts +164 -0
- package/src/funcs/posUpdatePosCart.ts +167 -0
- package/src/lib/config.ts +3 -3
- package/src/models/components/index.ts +1 -0
- package/src/models/components/posuser.ts +263 -0
- package/src/models/operations/createposcart.ts +197 -0
- package/src/models/operations/index.ts +5 -0
- package/src/models/operations/logintoposdevice.ts +297 -0
- package/src/models/operations/pairposdevice.ts +286 -0
- package/src/models/operations/refreshposaccesstoken.ts +223 -0
- package/src/models/operations/updateposcart.ts +271 -0
- package/src/sdk/pos.ts +103 -0
- package/src/sdk/sdk.ts +6 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# Pos
|
|
2
|
+
(*pos*)
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
|
|
6
|
+
### Available Operations
|
|
7
|
+
|
|
8
|
+
* [pairPosDevice](#pairposdevice) - Pair POS device
|
|
9
|
+
* [loginToPosDevice](#logintoposdevice) - Login to POS device
|
|
10
|
+
* [refreshPosAccessToken](#refreshposaccesstoken) - Refresh POS access token
|
|
11
|
+
* [createPosCart](#createposcart) - Create cart
|
|
12
|
+
* [updatePosCart](#updateposcart) - Add/update/delete cart item
|
|
13
|
+
|
|
14
|
+
## pairPosDevice
|
|
15
|
+
|
|
16
|
+
Pair POS device
|
|
17
|
+
|
|
18
|
+
### Example Usage
|
|
19
|
+
|
|
20
|
+
<!-- UsageSnippet language="typescript" operationID="pair-pos-device" method="post" path="/pos/auth/pair-device" -->
|
|
21
|
+
```typescript
|
|
22
|
+
import { CeStorefront } from "ce-storefront";
|
|
23
|
+
|
|
24
|
+
const ceStorefront = new CeStorefront();
|
|
25
|
+
|
|
26
|
+
async function run() {
|
|
27
|
+
const result = await ceStorefront.pos.pairPosDevice({
|
|
28
|
+
xApiKey: "<YOUR_API_KEY_HERE>",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(result);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
run();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Standalone function
|
|
38
|
+
|
|
39
|
+
The standalone function version of this method:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { CeStorefrontCore } from "ce-storefront/core.js";
|
|
43
|
+
import { posPairPosDevice } from "ce-storefront/funcs/posPairPosDevice.js";
|
|
44
|
+
|
|
45
|
+
// Use `CeStorefrontCore` for best tree-shaking performance.
|
|
46
|
+
// You can create one instance of it to use across an application.
|
|
47
|
+
const ceStorefront = new CeStorefrontCore();
|
|
48
|
+
|
|
49
|
+
async function run() {
|
|
50
|
+
const res = await posPairPosDevice(ceStorefront, {
|
|
51
|
+
xApiKey: "<YOUR_API_KEY_HERE>",
|
|
52
|
+
});
|
|
53
|
+
if (res.ok) {
|
|
54
|
+
const { value: result } = res;
|
|
55
|
+
console.log(result);
|
|
56
|
+
} else {
|
|
57
|
+
console.log("posPairPosDevice failed:", res.error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
run();
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Parameters
|
|
65
|
+
|
|
66
|
+
| Parameter | Type | Required | Description |
|
|
67
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
68
|
+
| `request` | [operations.PairPosDeviceRequestBody](../../models/operations/pairposdevicerequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
69
|
+
| `security` | [operations.PairPosDeviceSecurity](../../models/operations/pairposdevicesecurity.md) | :heavy_check_mark: | The security requirements to use for the request. |
|
|
70
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
71
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
72
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
73
|
+
|
|
74
|
+
### Response
|
|
75
|
+
|
|
76
|
+
**Promise\<[operations.PairPosDeviceResponseBody](../../models/operations/pairposdeviceresponsebody.md)\>**
|
|
77
|
+
|
|
78
|
+
### Errors
|
|
79
|
+
|
|
80
|
+
| Error Type | Status Code | Content Type |
|
|
81
|
+
| -------------- | -------------- | -------------- |
|
|
82
|
+
| errors.CeError | 4XX, 5XX | \*/\* |
|
|
83
|
+
|
|
84
|
+
## loginToPosDevice
|
|
85
|
+
|
|
86
|
+
Login to POS device
|
|
87
|
+
|
|
88
|
+
### Example Usage
|
|
89
|
+
|
|
90
|
+
<!-- UsageSnippet language="typescript" operationID="login-to-pos-device" method="post" path="/pos/auth/login" -->
|
|
91
|
+
```typescript
|
|
92
|
+
import { CeStorefront } from "ce-storefront";
|
|
93
|
+
|
|
94
|
+
const ceStorefront = new CeStorefront();
|
|
95
|
+
|
|
96
|
+
async function run() {
|
|
97
|
+
const result = await ceStorefront.pos.loginToPosDevice({
|
|
98
|
+
xApiKey: "<YOUR_API_KEY_HERE>",
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log(result);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
run();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Standalone function
|
|
108
|
+
|
|
109
|
+
The standalone function version of this method:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { CeStorefrontCore } from "ce-storefront/core.js";
|
|
113
|
+
import { posLoginToPosDevice } from "ce-storefront/funcs/posLoginToPosDevice.js";
|
|
114
|
+
|
|
115
|
+
// Use `CeStorefrontCore` for best tree-shaking performance.
|
|
116
|
+
// You can create one instance of it to use across an application.
|
|
117
|
+
const ceStorefront = new CeStorefrontCore();
|
|
118
|
+
|
|
119
|
+
async function run() {
|
|
120
|
+
const res = await posLoginToPosDevice(ceStorefront, {
|
|
121
|
+
xApiKey: "<YOUR_API_KEY_HERE>",
|
|
122
|
+
});
|
|
123
|
+
if (res.ok) {
|
|
124
|
+
const { value: result } = res;
|
|
125
|
+
console.log(result);
|
|
126
|
+
} else {
|
|
127
|
+
console.log("posLoginToPosDevice failed:", res.error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
run();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Parameters
|
|
135
|
+
|
|
136
|
+
| Parameter | Type | Required | Description |
|
|
137
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
138
|
+
| `request` | [operations.LoginToPosDeviceRequestBody](../../models/operations/logintoposdevicerequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
139
|
+
| `security` | [operations.LoginToPosDeviceSecurity](../../models/operations/logintoposdevicesecurity.md) | :heavy_check_mark: | The security requirements to use for the request. |
|
|
140
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
141
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
142
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
143
|
+
|
|
144
|
+
### Response
|
|
145
|
+
|
|
146
|
+
**Promise\<[operations.LoginToPosDeviceResponseBody](../../models/operations/logintoposdeviceresponsebody.md)\>**
|
|
147
|
+
|
|
148
|
+
### Errors
|
|
149
|
+
|
|
150
|
+
| Error Type | Status Code | Content Type |
|
|
151
|
+
| -------------- | -------------- | -------------- |
|
|
152
|
+
| errors.CeError | 4XX, 5XX | \*/\* |
|
|
153
|
+
|
|
154
|
+
## refreshPosAccessToken
|
|
155
|
+
|
|
156
|
+
Refresh POS access token
|
|
157
|
+
|
|
158
|
+
### Example Usage
|
|
159
|
+
|
|
160
|
+
<!-- UsageSnippet language="typescript" operationID="refresh-pos-access-token" method="post" path="/pos/auth/refresh-token" -->
|
|
161
|
+
```typescript
|
|
162
|
+
import { CeStorefront } from "ce-storefront";
|
|
163
|
+
|
|
164
|
+
const ceStorefront = new CeStorefront({
|
|
165
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
async function run() {
|
|
169
|
+
const result = await ceStorefront.pos.refreshPosAccessToken();
|
|
170
|
+
|
|
171
|
+
console.log(result);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
run();
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Standalone function
|
|
178
|
+
|
|
179
|
+
The standalone function version of this method:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { CeStorefrontCore } from "ce-storefront/core.js";
|
|
183
|
+
import { posRefreshPosAccessToken } from "ce-storefront/funcs/posRefreshPosAccessToken.js";
|
|
184
|
+
|
|
185
|
+
// Use `CeStorefrontCore` for best tree-shaking performance.
|
|
186
|
+
// You can create one instance of it to use across an application.
|
|
187
|
+
const ceStorefront = new CeStorefrontCore({
|
|
188
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
async function run() {
|
|
192
|
+
const res = await posRefreshPosAccessToken(ceStorefront);
|
|
193
|
+
if (res.ok) {
|
|
194
|
+
const { value: result } = res;
|
|
195
|
+
console.log(result);
|
|
196
|
+
} else {
|
|
197
|
+
console.log("posRefreshPosAccessToken failed:", res.error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
run();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Parameters
|
|
205
|
+
|
|
206
|
+
| Parameter | Type | Required | Description |
|
|
207
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
208
|
+
| `request` | [operations.RefreshPosAccessTokenRequestBody](../../models/operations/refreshposaccesstokenrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
209
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
210
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
211
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
212
|
+
|
|
213
|
+
### Response
|
|
214
|
+
|
|
215
|
+
**Promise\<[operations.RefreshPosAccessTokenResponseBody](../../models/operations/refreshposaccesstokenresponsebody.md)\>**
|
|
216
|
+
|
|
217
|
+
### Errors
|
|
218
|
+
|
|
219
|
+
| Error Type | Status Code | Content Type |
|
|
220
|
+
| -------------- | -------------- | -------------- |
|
|
221
|
+
| errors.CeError | 4XX, 5XX | \*/\* |
|
|
222
|
+
|
|
223
|
+
## createPosCart
|
|
224
|
+
|
|
225
|
+
Create cart from POS device
|
|
226
|
+
|
|
227
|
+
### Example Usage
|
|
228
|
+
|
|
229
|
+
<!-- UsageSnippet language="typescript" operationID="create-pos-cart" method="post" path="/pos/carts" -->
|
|
230
|
+
```typescript
|
|
231
|
+
import { CeStorefront } from "ce-storefront";
|
|
232
|
+
|
|
233
|
+
const ceStorefront = new CeStorefront({
|
|
234
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
async function run() {
|
|
238
|
+
const result = await ceStorefront.pos.createPosCart({
|
|
239
|
+
items: [
|
|
240
|
+
{
|
|
241
|
+
productId: "01H9XYZ12345ABCDE",
|
|
242
|
+
variantId: null,
|
|
243
|
+
quantity: 1,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
console.log(result);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
run();
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Standalone function
|
|
255
|
+
|
|
256
|
+
The standalone function version of this method:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { CeStorefrontCore } from "ce-storefront/core.js";
|
|
260
|
+
import { posCreatePosCart } from "ce-storefront/funcs/posCreatePosCart.js";
|
|
261
|
+
|
|
262
|
+
// Use `CeStorefrontCore` for best tree-shaking performance.
|
|
263
|
+
// You can create one instance of it to use across an application.
|
|
264
|
+
const ceStorefront = new CeStorefrontCore({
|
|
265
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
async function run() {
|
|
269
|
+
const res = await posCreatePosCart(ceStorefront, {
|
|
270
|
+
items: [
|
|
271
|
+
{
|
|
272
|
+
productId: "01H9XYZ12345ABCDE",
|
|
273
|
+
variantId: null,
|
|
274
|
+
quantity: 1,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
});
|
|
278
|
+
if (res.ok) {
|
|
279
|
+
const { value: result } = res;
|
|
280
|
+
console.log(result);
|
|
281
|
+
} else {
|
|
282
|
+
console.log("posCreatePosCart failed:", res.error);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
run();
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Parameters
|
|
290
|
+
|
|
291
|
+
| Parameter | Type | Required | Description |
|
|
292
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
293
|
+
| `request` | [operations.CreatePosCartRequestBody](../../models/operations/createposcartrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
294
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
295
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
296
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
297
|
+
|
|
298
|
+
### Response
|
|
299
|
+
|
|
300
|
+
**Promise\<[operations.CreatePosCartResponseBody](../../models/operations/createposcartresponsebody.md)\>**
|
|
301
|
+
|
|
302
|
+
### Errors
|
|
303
|
+
|
|
304
|
+
| Error Type | Status Code | Content Type |
|
|
305
|
+
| -------------- | -------------- | -------------- |
|
|
306
|
+
| errors.CeError | 4XX, 5XX | \*/\* |
|
|
307
|
+
|
|
308
|
+
## updatePosCart
|
|
309
|
+
|
|
310
|
+
Add/update item to cart. To delete item from cart, pass quantity = 0
|
|
311
|
+
|
|
312
|
+
### Example Usage
|
|
313
|
+
|
|
314
|
+
<!-- UsageSnippet language="typescript" operationID="update-pos-cart" method="post" path="/pos/carts/{id}/items" -->
|
|
315
|
+
```typescript
|
|
316
|
+
import { CeStorefront } from "ce-storefront";
|
|
317
|
+
|
|
318
|
+
const ceStorefront = new CeStorefront({
|
|
319
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
async function run() {
|
|
323
|
+
const result = await ceStorefront.pos.updatePosCart({
|
|
324
|
+
id: "<id>",
|
|
325
|
+
requestBody: {
|
|
326
|
+
items: [
|
|
327
|
+
{
|
|
328
|
+
productId: "01H9XYZ12345ABCDE",
|
|
329
|
+
variantId: null,
|
|
330
|
+
quantity: 1,
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
console.log(result);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
run();
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Standalone function
|
|
343
|
+
|
|
344
|
+
The standalone function version of this method:
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import { CeStorefrontCore } from "ce-storefront/core.js";
|
|
348
|
+
import { posUpdatePosCart } from "ce-storefront/funcs/posUpdatePosCart.js";
|
|
349
|
+
|
|
350
|
+
// Use `CeStorefrontCore` for best tree-shaking performance.
|
|
351
|
+
// You can create one instance of it to use across an application.
|
|
352
|
+
const ceStorefront = new CeStorefrontCore({
|
|
353
|
+
authorization: "<YOUR_BEARER_TOKEN_HERE>",
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
async function run() {
|
|
357
|
+
const res = await posUpdatePosCart(ceStorefront, {
|
|
358
|
+
id: "<id>",
|
|
359
|
+
requestBody: {
|
|
360
|
+
items: [
|
|
361
|
+
{
|
|
362
|
+
productId: "01H9XYZ12345ABCDE",
|
|
363
|
+
variantId: null,
|
|
364
|
+
quantity: 1,
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
if (res.ok) {
|
|
370
|
+
const { value: result } = res;
|
|
371
|
+
console.log(result);
|
|
372
|
+
} else {
|
|
373
|
+
console.log("posUpdatePosCart failed:", res.error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
run();
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Parameters
|
|
381
|
+
|
|
382
|
+
| Parameter | Type | Required | Description |
|
|
383
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
384
|
+
| `request` | [operations.UpdatePosCartRequest](../../models/operations/updateposcartrequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
385
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
386
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
387
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
388
|
+
|
|
389
|
+
### Response
|
|
390
|
+
|
|
391
|
+
**Promise\<[operations.UpdatePosCartResponseBody](../../models/operations/updateposcartresponsebody.md)\>**
|
|
392
|
+
|
|
393
|
+
### Errors
|
|
394
|
+
|
|
395
|
+
| Error Type | Status Code | Content Type |
|
|
396
|
+
| -------------- | -------------- | -------------- |
|
|
397
|
+
| errors.CeError | 4XX, 5XX | \*/\* |
|
|
@@ -13,6 +13,7 @@ Checks whether a given pincode is serviceable and returns all available shipping
|
|
|
13
13
|
|
|
14
14
|
### Example Usage
|
|
15
15
|
|
|
16
|
+
<!-- UsageSnippet language="typescript" operationID="get-shipping-methods" method="post" path="/shipping/shipping-methods" -->
|
|
16
17
|
```typescript
|
|
17
18
|
import { CeStorefront } from "ce-storefront";
|
|
18
19
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CeStorefrontCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
4
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
7
|
+
import * as operations from "../models/operations/index.js";
|
|
8
|
+
import { APIPromise } from "../types/async.js";
|
|
9
|
+
import { Result } from "../types/fp.js";
|
|
10
|
+
/**
|
|
11
|
+
* Create cart
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Create cart from POS device
|
|
15
|
+
*/
|
|
16
|
+
export declare function posCreatePosCart(client: CeStorefrontCore, request?: operations.CreatePosCartRequestBody | undefined, options?: RequestOptions): APIPromise<Result<operations.CreatePosCartResponseBody, CeStorefrontError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
17
|
+
//# sourceMappingURL=posCreatePosCart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posCreatePosCart.d.ts","sourceRoot":"","sources":["../../src/funcs/posCreatePosCart.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,UAAU,CAAC,wBAAwB,GAAG,SAAS,EACzD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,yBAAyB,EAClC,iBAAiB,GACjB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAMA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
5
|
+
import * as M from "../lib/matchers.js";
|
|
6
|
+
import { compactMap } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
9
|
+
import { pathToFunc } from "../lib/url.js";
|
|
10
|
+
import * as operations from "../models/operations/index.js";
|
|
11
|
+
import { APIPromise } from "../types/async.js";
|
|
12
|
+
/**
|
|
13
|
+
* Create cart
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Create cart from POS device
|
|
17
|
+
*/
|
|
18
|
+
export function posCreatePosCart(client, request, options) {
|
|
19
|
+
return new APIPromise($do(client, request, options));
|
|
20
|
+
}
|
|
21
|
+
async function $do(client, request, options) {
|
|
22
|
+
const parsed = safeParse(request, (value) => operations.CreatePosCartRequestBody$outboundSchema.optional().parse(value), "Input validation failed");
|
|
23
|
+
if (!parsed.ok) {
|
|
24
|
+
return [parsed, { status: "invalid" }];
|
|
25
|
+
}
|
|
26
|
+
const payload = parsed.value;
|
|
27
|
+
const body = payload === undefined
|
|
28
|
+
? null
|
|
29
|
+
: encodeJSON("body", payload, { explode: true });
|
|
30
|
+
const path = pathToFunc("/pos/carts")();
|
|
31
|
+
const headers = new Headers(compactMap({
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
}));
|
|
35
|
+
const secConfig = await extractSecurity(client._options.authorization);
|
|
36
|
+
const securityInput = secConfig == null ? {} : { authorization: secConfig };
|
|
37
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
38
|
+
const context = {
|
|
39
|
+
options: client._options,
|
|
40
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
41
|
+
operationID: "create-pos-cart",
|
|
42
|
+
oAuth2Scopes: [],
|
|
43
|
+
resolvedSecurity: requestSecurity,
|
|
44
|
+
securitySource: client._options.authorization,
|
|
45
|
+
retryConfig: options?.retries
|
|
46
|
+
|| client._options.retryConfig
|
|
47
|
+
|| { strategy: "none" },
|
|
48
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
49
|
+
};
|
|
50
|
+
const requestRes = client._createRequest(context, {
|
|
51
|
+
security: requestSecurity,
|
|
52
|
+
method: "POST",
|
|
53
|
+
baseURL: options?.serverURL,
|
|
54
|
+
path: path,
|
|
55
|
+
headers: headers,
|
|
56
|
+
body: body,
|
|
57
|
+
userAgent: client._options.userAgent,
|
|
58
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
59
|
+
}, options);
|
|
60
|
+
if (!requestRes.ok) {
|
|
61
|
+
return [requestRes, { status: "invalid" }];
|
|
62
|
+
}
|
|
63
|
+
const req = requestRes.value;
|
|
64
|
+
const doResult = await client._do(req, {
|
|
65
|
+
context,
|
|
66
|
+
errorCodes: ["4XX", "5XX"],
|
|
67
|
+
retryConfig: context.retryConfig,
|
|
68
|
+
retryCodes: context.retryCodes,
|
|
69
|
+
});
|
|
70
|
+
if (!doResult.ok) {
|
|
71
|
+
return [doResult, { status: "request-error", request: req }];
|
|
72
|
+
}
|
|
73
|
+
const response = doResult.value;
|
|
74
|
+
const [result] = await M.match(M.json(200, operations.CreatePosCartResponseBody$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req);
|
|
75
|
+
if (!result.ok) {
|
|
76
|
+
return [result, { status: "complete", request: req, response }];
|
|
77
|
+
}
|
|
78
|
+
return [result, { status: "complete", request: req, response }];
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=posCreatePosCart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posCreatePosCart.js","sourceRoot":"","sources":["../../src/funcs/posCreatePosCart.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAW3C,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAwB,EACxB,OAAyD,EACzD,OAAwB;IAcxB,OAAO,IAAI,UAAU,CAAC,GAAG,CACvB,MAAM,EACN,OAAO,EACP,OAAO,CACR,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,GAAG,CAChB,MAAwB,EACxB,OAAyD,EACzD,OAAwB;IAiBx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,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAW5B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,uCAAuC,CAAC,EAC/D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EACb,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CACd,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACjB,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CeStorefrontCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
4
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
7
|
+
import * as operations from "../models/operations/index.js";
|
|
8
|
+
import { APIPromise } from "../types/async.js";
|
|
9
|
+
import { Result } from "../types/fp.js";
|
|
10
|
+
/**
|
|
11
|
+
* Login to POS device
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Login to POS device
|
|
15
|
+
*/
|
|
16
|
+
export declare function posLoginToPosDevice(client: CeStorefrontCore, security: operations.LoginToPosDeviceSecurity, request?: operations.LoginToPosDeviceRequestBody | undefined, options?: RequestOptions): APIPromise<Result<operations.LoginToPosDeviceResponseBody, CeStorefrontError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
17
|
+
//# sourceMappingURL=posLoginToPosDevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posLoginToPosDevice.d.ts","sourceRoot":"","sources":["../../src/funcs/posLoginToPosDevice.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,UAAU,CAAC,wBAAwB,EAC7C,OAAO,CAAC,EAAE,UAAU,CAAC,2BAA2B,GAAG,SAAS,EAC5D,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,UAAU,CAAC,4BAA4B,EACrC,iBAAiB,GACjB,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,CACrB,CACF,CAOA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
5
|
+
import * as M from "../lib/matchers.js";
|
|
6
|
+
import { compactMap } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import { resolveSecurity } from "../lib/security.js";
|
|
9
|
+
import { pathToFunc } from "../lib/url.js";
|
|
10
|
+
import * as operations from "../models/operations/index.js";
|
|
11
|
+
import { APIPromise } from "../types/async.js";
|
|
12
|
+
/**
|
|
13
|
+
* Login to POS device
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Login to POS device
|
|
17
|
+
*/
|
|
18
|
+
export function posLoginToPosDevice(client, security, request, options) {
|
|
19
|
+
return new APIPromise($do(client, security, request, options));
|
|
20
|
+
}
|
|
21
|
+
async function $do(client, security, request, options) {
|
|
22
|
+
const parsed = safeParse(request, (value) => operations.LoginToPosDeviceRequestBody$outboundSchema.optional().parse(value), "Input validation failed");
|
|
23
|
+
if (!parsed.ok) {
|
|
24
|
+
return [parsed, { status: "invalid" }];
|
|
25
|
+
}
|
|
26
|
+
const payload = parsed.value;
|
|
27
|
+
const body = payload === undefined
|
|
28
|
+
? null
|
|
29
|
+
: encodeJSON("body", payload, { explode: true });
|
|
30
|
+
const path = pathToFunc("/pos/auth/login")();
|
|
31
|
+
const headers = new Headers(compactMap({
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
}));
|
|
35
|
+
const requestSecurity = resolveSecurity([
|
|
36
|
+
{
|
|
37
|
+
fieldName: "X-Api-Key",
|
|
38
|
+
type: "apiKey:header",
|
|
39
|
+
value: security?.xApiKey,
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
const context = {
|
|
43
|
+
options: client._options,
|
|
44
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
45
|
+
operationID: "login-to-pos-device",
|
|
46
|
+
oAuth2Scopes: null,
|
|
47
|
+
resolvedSecurity: requestSecurity,
|
|
48
|
+
securitySource: security,
|
|
49
|
+
retryConfig: options?.retries
|
|
50
|
+
|| client._options.retryConfig
|
|
51
|
+
|| { strategy: "none" },
|
|
52
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
53
|
+
};
|
|
54
|
+
const requestRes = client._createRequest(context, {
|
|
55
|
+
security: requestSecurity,
|
|
56
|
+
method: "POST",
|
|
57
|
+
baseURL: options?.serverURL,
|
|
58
|
+
path: path,
|
|
59
|
+
headers: headers,
|
|
60
|
+
body: body,
|
|
61
|
+
userAgent: client._options.userAgent,
|
|
62
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
63
|
+
}, options);
|
|
64
|
+
if (!requestRes.ok) {
|
|
65
|
+
return [requestRes, { status: "invalid" }];
|
|
66
|
+
}
|
|
67
|
+
const req = requestRes.value;
|
|
68
|
+
const doResult = await client._do(req, {
|
|
69
|
+
context,
|
|
70
|
+
errorCodes: ["4XX", "5XX"],
|
|
71
|
+
retryConfig: context.retryConfig,
|
|
72
|
+
retryCodes: context.retryCodes,
|
|
73
|
+
});
|
|
74
|
+
if (!doResult.ok) {
|
|
75
|
+
return [doResult, { status: "request-error", request: req }];
|
|
76
|
+
}
|
|
77
|
+
const response = doResult.value;
|
|
78
|
+
const [result] = await M.match(M.json(200, operations.LoginToPosDeviceResponseBody$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req);
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
return [result, { status: "complete", request: req, response }];
|
|
81
|
+
}
|
|
82
|
+
return [result, { status: "complete", request: req, response }];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=posLoginToPosDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posLoginToPosDevice.js","sourceRoot":"","sources":["../../src/funcs/posLoginToPosDevice.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE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