oneentry 1.0.175 → 1.0.176
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/changelog.md +24 -0
- package/dist/attribute-sets/attributeSetsApi.js +3 -3
- package/dist/auth-provider/authProviderApi.js +12 -12
- package/dist/base/asyncModules.d.ts +11 -0
- package/dist/base/asyncModules.js +14 -0
- package/dist/blocks/blocksApi.js +24 -15
- package/dist/discounts/discountsApi.js +2 -1
- package/dist/events/eventsApi.js +4 -4
- package/dist/filters/filtersApi.js +1 -1
- package/dist/forms/formsApi.js +1 -1
- package/dist/forms-data/formsDataApi.d.ts +10 -8
- package/dist/forms-data/formsDataApi.js +14 -10
- package/dist/forms-data/formsDataInterfaces.d.ts +75 -54
- package/dist/integration-collections/integrationCollectionsApi.js +7 -6
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.js +7 -6
- package/dist/pages/pagesApi.js +2 -2
- package/dist/product-statuses/productStatusesApi.js +2 -2
- package/dist/templates/templatesApi.js +1 -1
- package/dist/templates-preview/templatesPreviewApi.js +1 -1
- package/dist/user-groups/userGroupsApi.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.js +3 -3
- package/esm/auth-provider/authProviderApi.js +12 -12
- package/esm/base/asyncModules.d.ts +11 -0
- package/esm/base/asyncModules.js +14 -0
- package/esm/blocks/blocksApi.js +24 -15
- package/esm/discounts/discountsApi.js +2 -1
- package/esm/events/eventsApi.js +4 -4
- package/esm/filters/filtersApi.js +1 -1
- package/esm/forms/formsApi.js +1 -1
- package/esm/forms-data/formsDataApi.d.ts +10 -8
- package/esm/forms-data/formsDataApi.js +14 -10
- package/esm/forms-data/formsDataInterfaces.d.ts +75 -54
- package/esm/integration-collections/integrationCollectionsApi.js +7 -6
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.js +7 -6
- package/esm/pages/pagesApi.js +2 -2
- package/esm/product-statuses/productStatusesApi.js +2 -2
- package/esm/templates/templatesApi.js +1 -1
- package/esm/templates-preview/templatesPreviewApi.js +1 -1
- package/esm/user-groups/userGroupsApi.js +2 -2
- package/package.json +2 -2
package/changelog.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.176
|
|
4
|
+
|
|
5
|
+
### What's Changed
|
|
6
|
+
|
|
7
|
+
- **`FormDataType` describes `formData` as a read returns it** (CMS-1143). Checked on `getFormsDataByMarker` against every field type of a form:
|
|
8
|
+
- new branches `IBodyTypeEntity` (`entity`, `value: number[]`) and `IBodyTypeTimeInterval` (`timeInterval`, `value: string[][]` — `[start, end]` pairs); `IBodyTypeStringNumberFloat.type` takes `'integer'`;
|
|
9
|
+
- `list` and `radioButton` come back as the stored option values — `["1"]` and `"1"` — so `IBodyTypeRadioButtonList.value` is `IListOptionValue[] | string[] | string`;
|
|
10
|
+
- `text` and `textWithHeader` come back as a one-element array without `plainValue` and with `params.editorMode`: `value` takes an array too, `plainValue` and `isEditorDisabled` are optional, `editorMode` is added;
|
|
11
|
+
- the JSDoc no longer promises numbers and single-file objects on a read: numeric fields come back as strings (`3` → `"3"`), a single file as a one-element array.
|
|
12
|
+
Code that wrote these fields still compiles; code that read `value.plainValue` or `value[0].title` of a read now sees in the types what the API sends.
|
|
13
|
+
|
|
14
|
+
### What's Fixed
|
|
15
|
+
|
|
16
|
+
- **A marker is encoded before it goes into the request path** (CMS-1144). It was put into the URL as is in 59 places: `getFormsDataByMarker('..', 2)` resolved to `POST /api/content/form-data/` — the create endpoint — and `'test-form#'` cut the whole query off. Markers go through a new `AsyncModules._pathSegment` now: `?`, `#` and `/` are encoded, and a dot-only value reaches the API as an invalid marker (`400 marker must match …`) instead of another route. Valid markers are sent exactly as before. Page and product URLs (`getPageByUrl` and similar) are not changed.
|
|
17
|
+
|
|
18
|
+
- **`FormData.postFormsData` unwraps the answer from the language it was sent in** (CMS-1125). A call with a `langCode` other than the client's returned `formData.formData` still keyed by the locale (`{ "ru_RU": [ … ] }`); the response is normalized with that `langCode` now, like the other methods of the module.
|
|
19
|
+
|
|
20
|
+
- **JSDoc of the FormData module** (CMS-1145): `offset` from `0` and `limit` from `1`; `queryText` 1–512 characters, `vectorDistanceThreshold` from `0` and `maxHits` from `1` in vector search; `dateFrom` / `dateTo` take `YYYY-MM-DD HH:MM:SS` as well. The filter description said the API silently ignores an unknown field — it answers `400 property statuses should not exist`; a marker that matches nothing answers `200` with an empty list, not `404`.
|
|
21
|
+
|
|
22
|
+
### Tests
|
|
23
|
+
|
|
24
|
+
- **`callercontracts.spec.ts`**: `..` and `#` in a marker stay inside the path, a valid marker is sent unchanged; `postFormsData` in another language returns `formData` as an array; the field shapes of a `full_form` record compile as `FormDataType`.
|
|
25
|
+
- **`formsdata.spec.ts`**: vector search no longer expects `ip` and `fingerprint` — the API does not send them.
|
|
26
|
+
|
|
3
27
|
## v.1.0.175
|
|
4
28
|
|
|
5
29
|
### What's Changed
|
|
@@ -96,7 +96,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
96
96
|
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
97
97
|
*/
|
|
98
98
|
async getAttributesByMarker(marker, langCode = this.state.lang) {
|
|
99
|
-
const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
|
|
99
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/attributes?langCode=${langCode}`);
|
|
100
100
|
// Validate response if validation is enabled
|
|
101
101
|
const validated = await this._validateResponse(result, schema('AttributesArrayResponseSchema'));
|
|
102
102
|
return this._normalizeData(validated, langCode);
|
|
@@ -112,7 +112,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
112
112
|
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
113
113
|
*/
|
|
114
114
|
async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
|
|
115
|
-
const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
|
|
115
|
+
const result = await this._fetchGet(`/${this._pathSegment(setMarker)}/attributes/${this._pathSegment(attributeMarker)}?langCode=${langCode}`);
|
|
116
116
|
// Validate response if validation is enabled
|
|
117
117
|
const validated = await this._validateResponse(result, schema('AttributeEntitySchema'));
|
|
118
118
|
return this._normalizeData(validated, langCode);
|
|
@@ -127,7 +127,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
127
127
|
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
128
128
|
*/
|
|
129
129
|
async getAttributeSetByMarker(marker, langCode = this.state.lang) {
|
|
130
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
130
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
131
131
|
// Validate response if validation is enabled
|
|
132
132
|
const validated = await this._validateResponse(result, schema('AttributeSetEntitySchema'));
|
|
133
133
|
return this._normalizeData(validated, langCode);
|
|
@@ -126,7 +126,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
126
126
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
127
127
|
// `langCode` goes onto our own copy — the caller's body stays as it was
|
|
128
128
|
// given, so a retry or a second parallel call sends the same thing (CMS-909).
|
|
129
|
-
const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody({ ...body, langCode }, langCode));
|
|
129
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/sign-up`, this._normalizePostBody({ ...body, langCode }, langCode));
|
|
130
130
|
// Validate response if validation is enabled
|
|
131
131
|
const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
|
|
132
132
|
return this._normalizeData(validated);
|
|
@@ -147,7 +147,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
147
147
|
userIdentifier,
|
|
148
148
|
eventIdentifier,
|
|
149
149
|
};
|
|
150
|
-
const result = await this._fetchPost(`/marker/${marker}/users/generate-code`, data);
|
|
150
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/generate-code`, data);
|
|
151
151
|
return result;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
@@ -168,7 +168,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
168
168
|
eventIdentifier,
|
|
169
169
|
code,
|
|
170
170
|
};
|
|
171
|
-
const result = await this._fetchPost(`/marker/${marker}/users/check-code`, data);
|
|
171
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/check-code`, data);
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
@@ -187,7 +187,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
187
187
|
userIdentifier: userIdentifier,
|
|
188
188
|
code: code,
|
|
189
189
|
};
|
|
190
|
-
const result = await this._fetchPost(`/marker/${marker}/users/activate`, data);
|
|
190
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/activate`, data);
|
|
191
191
|
return result;
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
@@ -224,7 +224,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
224
224
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
|
|
225
225
|
*/
|
|
226
226
|
async auth(marker, body) {
|
|
227
|
-
const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
|
|
227
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/auth`, body);
|
|
228
228
|
// Validate response if validation is enabled
|
|
229
229
|
const validated = await this._validateResponse(result, schema('AuthResponseSchema'));
|
|
230
230
|
if (!('statusCode' in validated)) {
|
|
@@ -248,7 +248,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
248
248
|
*/
|
|
249
249
|
async refresh(marker, token) {
|
|
250
250
|
const data = { refreshToken: token };
|
|
251
|
-
const result = await this._fetchPost(`/marker/${marker}/users/refresh`, data);
|
|
251
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/refresh`, data);
|
|
252
252
|
if (!('statusCode' in result)) {
|
|
253
253
|
this.state.accessToken = result.accessToken;
|
|
254
254
|
this.state.refreshToken = result.refreshToken;
|
|
@@ -273,7 +273,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
273
273
|
const data = {
|
|
274
274
|
refreshToken: token,
|
|
275
275
|
};
|
|
276
|
-
const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
|
|
276
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/logout`, data);
|
|
277
277
|
if (result) {
|
|
278
278
|
this.state.accessToken = undefined;
|
|
279
279
|
this.state.refreshToken = undefined;
|
|
@@ -294,7 +294,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
294
294
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
|
|
295
295
|
*/
|
|
296
296
|
async logoutAll(marker) {
|
|
297
|
-
const result = await this._fetchPost(`/marker/${marker}/users/logout-all`);
|
|
297
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/logout-all`);
|
|
298
298
|
if (result) {
|
|
299
299
|
this.state.accessToken = undefined;
|
|
300
300
|
this.state.refreshToken = undefined;
|
|
@@ -328,7 +328,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
328
328
|
password1: newPassword,
|
|
329
329
|
password2: repeatPassword !== null && repeatPassword !== void 0 ? repeatPassword : newPassword,
|
|
330
330
|
};
|
|
331
|
-
const result = await this._fetchPost(`/marker/${marker}/users/change-password`, data);
|
|
331
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/users/change-password`, data);
|
|
332
332
|
return result;
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
@@ -359,7 +359,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
359
359
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
|
|
360
360
|
*/
|
|
361
361
|
async getAuthProviderByMarker(marker, langCode = this.state.lang) {
|
|
362
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
362
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
363
363
|
return this._normalizeData(result);
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
@@ -372,7 +372,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
372
372
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
|
|
373
373
|
*/
|
|
374
374
|
async getActiveSessionsByMarker(marker) {
|
|
375
|
-
const result = await this._fetchGet(`/marker/${marker}/users/sessions`);
|
|
375
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/users/sessions`);
|
|
376
376
|
return this._normalizeData(result);
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
@@ -395,7 +395,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
395
395
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
|
|
396
396
|
*/
|
|
397
397
|
async oauth(marker, body, langCode = this.state.lang) {
|
|
398
|
-
const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
|
|
398
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}/oauth`, this._normalizePostBody(body, langCode));
|
|
399
399
|
return result;
|
|
400
400
|
}
|
|
401
401
|
}
|
|
@@ -36,6 +36,17 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
36
36
|
* validation disabled (the default) never pulls Zod into its bundle.
|
|
37
37
|
*/
|
|
38
38
|
protected _validateResponse<T>(data: unknown, loadSchema?: () => Promise<z.ZodSchema<T>>): Promise<T | IError>;
|
|
39
|
+
/**
|
|
40
|
+
* Prepares a caller value (a marker) to be one segment of a request path.
|
|
41
|
+
* @param {string} value - The value to put into the path.
|
|
42
|
+
* @returns {string} The value encoded as a single path segment.
|
|
43
|
+
* @description `encodeURIComponent` keeps `?`, `#` and `/` from cutting the query or
|
|
44
|
+
* adding segments, but leaves `.` alone, and `URL` resolves a `.` or `..` segment
|
|
45
|
+
* (`%2E` included) — `form-data/marker/..` turned a read into `POST /form-data/`,
|
|
46
|
+
* the create endpoint. A dot-only value is sent with its `%` escaped instead, so the
|
|
47
|
+
* API gets a marker it rejects as invalid rather than another route.
|
|
48
|
+
*/
|
|
49
|
+
protected _pathSegment(value: string): string;
|
|
39
50
|
/**
|
|
40
51
|
* Performs an HTTP GET request.
|
|
41
52
|
* @param {string} path - The path to append to the base URL.
|
|
@@ -117,6 +117,20 @@ class AsyncModules extends syncModules_1.default {
|
|
|
117
117
|
return validateResponseSafe(schema, data, this.state.validationLogErrors);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Prepares a caller value (a marker) to be one segment of a request path.
|
|
122
|
+
* @param {string} value - The value to put into the path.
|
|
123
|
+
* @returns {string} The value encoded as a single path segment.
|
|
124
|
+
* @description `encodeURIComponent` keeps `?`, `#` and `/` from cutting the query or
|
|
125
|
+
* adding segments, but leaves `.` alone, and `URL` resolves a `.` or `..` segment
|
|
126
|
+
* (`%2E` included) — `form-data/marker/..` turned a read into `POST /form-data/`,
|
|
127
|
+
* the create endpoint. A dot-only value is sent with its `%` escaped instead, so the
|
|
128
|
+
* API gets a marker it rejects as invalid rather than another route.
|
|
129
|
+
*/
|
|
130
|
+
_pathSegment(value) {
|
|
131
|
+
const encoded = encodeURIComponent(value);
|
|
132
|
+
return /^\.{1,2}$/.test(value) ? encoded.replace(/\./g, '%252E') : encoded;
|
|
133
|
+
}
|
|
120
134
|
/**
|
|
121
135
|
* Performs an HTTP GET request.
|
|
122
136
|
* @param {string} path - The path to append to the base URL.
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -100,7 +100,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
100
100
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlockByMarker getBlockByMarker} documentation.
|
|
101
101
|
*/
|
|
102
102
|
async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
103
|
-
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
103
|
+
const response = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
104
104
|
// Validate response if validation is enabled
|
|
105
105
|
const validated = await this._validateResponse(response, schema('BlockEntitySchema'));
|
|
106
106
|
const normalizeResponse = this._normalizeData(validated);
|
|
@@ -184,7 +184,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
184
184
|
signPrice,
|
|
185
185
|
productId,
|
|
186
186
|
};
|
|
187
|
-
const result = await this._fetchGet(`/${marker}/similar-products?` +
|
|
187
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?` +
|
|
188
|
+
this._queryParamsToString(query));
|
|
188
189
|
return this._normalizeData(result);
|
|
189
190
|
}
|
|
190
191
|
/**
|
|
@@ -207,7 +208,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
207
208
|
limit,
|
|
208
209
|
signPrice,
|
|
209
210
|
};
|
|
210
|
-
const result = await this._fetchGet(`/${marker}/products?` +
|
|
211
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?` +
|
|
212
|
+
this._queryParamsToString(query));
|
|
211
213
|
// On API error responses there is no `items` array — return the (normalized)
|
|
212
214
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
213
215
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
@@ -234,7 +236,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
234
236
|
signPrice,
|
|
235
237
|
limit,
|
|
236
238
|
};
|
|
237
|
-
const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
|
|
239
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/products/${productId}/frequently-ordered?` +
|
|
238
240
|
this._queryParamsToString(query));
|
|
239
241
|
return this._normalizeData(data);
|
|
240
242
|
}
|
|
@@ -267,7 +269,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
267
269
|
*/
|
|
268
270
|
async getCartComplement(marker, langCode = this.state.lang, signPrice, limit) {
|
|
269
271
|
const query = { langCode, signPrice, limit };
|
|
270
|
-
const data = await this._fetchGet(`/${marker}/cart-complement?` +
|
|
272
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-complement?` +
|
|
273
|
+
this._queryParamsToString(query));
|
|
271
274
|
return this._normalizeData(data);
|
|
272
275
|
}
|
|
273
276
|
/**
|
|
@@ -285,7 +288,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
285
288
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
|
|
286
289
|
*/
|
|
287
290
|
async getCartComplementByProductIds(marker, body) {
|
|
288
|
-
const data = await this._fetchPost(`/${marker}/cart-complement`, { langCode: this.state.lang, ...body });
|
|
291
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-complement`, { langCode: this.state.lang, ...body });
|
|
289
292
|
return this._normalizeData(data);
|
|
290
293
|
}
|
|
291
294
|
/**
|
|
@@ -302,7 +305,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
302
305
|
*/
|
|
303
306
|
async getCartSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
304
307
|
const query = { langCode, signPrice, limit };
|
|
305
|
-
const data = await this._fetchGet(`/${marker}/cart-similar?` +
|
|
308
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-similar?` +
|
|
309
|
+
this._queryParamsToString(query));
|
|
306
310
|
return this._normalizeData(data);
|
|
307
311
|
}
|
|
308
312
|
/**
|
|
@@ -320,7 +324,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
320
324
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
|
|
321
325
|
*/
|
|
322
326
|
async getCartSimilarByProductIds(marker, body) {
|
|
323
|
-
const data = await this._fetchPost(`/${marker}/cart-similar`, { langCode: this.state.lang, ...body });
|
|
327
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-similar`, { langCode: this.state.lang, ...body });
|
|
324
328
|
return this._normalizeData(data);
|
|
325
329
|
}
|
|
326
330
|
/**
|
|
@@ -337,7 +341,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
337
341
|
*/
|
|
338
342
|
async getPersonalRecommendations(marker, langCode = this.state.lang, signPrice, limit) {
|
|
339
343
|
const query = { langCode, signPrice, limit };
|
|
340
|
-
const data = await this._fetchGet(`/${marker}/personal-recommendations?` +
|
|
344
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/personal-recommendations?` +
|
|
345
|
+
this._queryParamsToString(query));
|
|
341
346
|
return this._normalizeData(data);
|
|
342
347
|
}
|
|
343
348
|
/**
|
|
@@ -354,7 +359,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
354
359
|
*/
|
|
355
360
|
async getRecentlyViewed(marker, langCode = this.state.lang, signPrice, limit) {
|
|
356
361
|
const query = { langCode, signPrice, limit };
|
|
357
|
-
const data = await this._fetchGet(`/${marker}/recently-viewed?` +
|
|
362
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/recently-viewed?` +
|
|
363
|
+
this._queryParamsToString(query));
|
|
358
364
|
return this._normalizeData(data);
|
|
359
365
|
}
|
|
360
366
|
/**
|
|
@@ -371,7 +377,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
371
377
|
*/
|
|
372
378
|
async getRepeatPurchase(marker, langCode = this.state.lang, signPrice, limit) {
|
|
373
379
|
const query = { langCode, signPrice, limit };
|
|
374
|
-
const data = await this._fetchGet(`/${marker}/repeat-purchase?` +
|
|
380
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/repeat-purchase?` +
|
|
381
|
+
this._queryParamsToString(query));
|
|
375
382
|
return this._normalizeData(data);
|
|
376
383
|
}
|
|
377
384
|
/**
|
|
@@ -383,7 +390,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
383
390
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSlides getSlides} documentation.
|
|
384
391
|
*/
|
|
385
392
|
async getSlides(marker) {
|
|
386
|
-
const data = await this._fetchGet(`/${marker}/slides`);
|
|
393
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/slides`);
|
|
387
394
|
return this._normalizeData(data);
|
|
388
395
|
}
|
|
389
396
|
/**
|
|
@@ -400,7 +407,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
400
407
|
*/
|
|
401
408
|
async getTrending(marker, langCode = this.state.lang, signPrice, limit) {
|
|
402
409
|
const query = { langCode, signPrice, limit };
|
|
403
|
-
const data = await this._fetchGet(`/${marker}/trending?` +
|
|
410
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/trending?` +
|
|
411
|
+
this._queryParamsToString(query));
|
|
404
412
|
return this._normalizeData(data);
|
|
405
413
|
}
|
|
406
414
|
/**
|
|
@@ -417,7 +425,8 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
417
425
|
*/
|
|
418
426
|
async getWishlistSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
419
427
|
const query = { langCode, signPrice, limit };
|
|
420
|
-
const data = await this._fetchGet(`/${marker}/wishlist-similar?` +
|
|
428
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/wishlist-similar?` +
|
|
429
|
+
this._queryParamsToString(query));
|
|
421
430
|
return this._normalizeData(data);
|
|
422
431
|
}
|
|
423
432
|
/**
|
|
@@ -435,7 +444,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
435
444
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
|
|
436
445
|
*/
|
|
437
446
|
async getWishlistSimilarByProductIds(marker, body) {
|
|
438
|
-
const data = await this._fetchPost(`/${marker}/wishlist-similar`, { langCode: this.state.lang, ...body });
|
|
447
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/wishlist-similar`, { langCode: this.state.lang, ...body });
|
|
439
448
|
return this._normalizeData(data);
|
|
440
449
|
}
|
|
441
450
|
}
|
|
@@ -62,7 +62,8 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
62
62
|
marker: '',
|
|
63
63
|
langCode,
|
|
64
64
|
};
|
|
65
|
-
const data = await this._fetchGet(`/marker/${marker}?` +
|
|
65
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?` +
|
|
66
|
+
this._queryParamsToString(query));
|
|
66
67
|
return this._normalizeData(data);
|
|
67
68
|
}
|
|
68
69
|
/**
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -62,7 +62,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
62
62
|
locale: langCode,
|
|
63
63
|
productId,
|
|
64
64
|
};
|
|
65
|
-
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${marker}`, body));
|
|
65
|
+
return this._fetchBoolean(() => this._fetchPost(`/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Unsubscribing to an event on a product.
|
|
@@ -81,7 +81,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
81
81
|
productId: productId,
|
|
82
82
|
locale: langCode,
|
|
83
83
|
};
|
|
84
|
-
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${marker}`, body));
|
|
84
|
+
return this._fetchBoolean(() => this._fetchDelete(`/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Returns all available events.
|
|
@@ -107,7 +107,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
107
107
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/subscribeToForm subscribeToForm} documentation.
|
|
108
108
|
*/
|
|
109
109
|
async subscribeToForm(marker, body) {
|
|
110
|
-
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${marker}`, body));
|
|
110
|
+
return this._fetchBoolean(() => this._fetchPost(`/forms/subscribe/marker/${this._pathSegment(marker)}`, body));
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Returns all form subscriptions.
|
|
@@ -140,7 +140,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
140
140
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/unsubscribeFromForm unsubscribeFromForm} documentation.
|
|
141
141
|
*/
|
|
142
142
|
async unsubscribeFromForm(marker, body) {
|
|
143
|
-
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${marker}`, body));
|
|
143
|
+
return this._fetchBoolean(() => this._fetchDelete(`/forms/unsubscribe/marker/${this._pathSegment(marker)}`, body));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
exports.default = EventsApi;
|
|
@@ -67,7 +67,7 @@ class FiltersApi extends asyncModules_1.default {
|
|
|
67
67
|
* @see {@link https://js-sdk.oneentry.cloud/docs/filters/getFilterByMarker getFilterByMarker} documentation.
|
|
68
68
|
*/
|
|
69
69
|
async getFilterByMarker(marker, langCode = this.state.lang) {
|
|
70
|
-
const data = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
70
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
71
71
|
const validated = await this._validateResponse(data, schema('ContentFilterSchema'));
|
|
72
72
|
return this._normalizeData(validated);
|
|
73
73
|
}
|
package/dist/forms/formsApi.js
CHANGED
|
@@ -84,7 +84,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
84
84
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms/getFormByMarker getFormByMarker} documentation.
|
|
85
85
|
*/
|
|
86
86
|
async getFormByMarker(marker, langCode = this.state.lang) {
|
|
87
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
87
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
88
88
|
// Validate response if validation is enabled
|
|
89
89
|
const validated = await this._validateResponse(result, schema('FormEntitySchema'));
|
|
90
90
|
return this._normalizeData(validated, langCode);
|
|
@@ -118,17 +118,19 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
118
118
|
* @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
|
|
119
119
|
* @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
|
|
120
120
|
* @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
|
|
121
|
-
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
122
|
-
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
121
|
+
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
122
|
+
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
123
123
|
* @param {number} [isExtended] - Pass `1` to return additional fields for each record. Default: `0`. Example: 1.
|
|
124
124
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
125
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
126
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
125
|
+
* @param {number} [offset] - Number of records to skip, `0` or more (a negative one answers `400 offset must not be less than 0`). Default: 0.
|
|
126
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more (`0` answers `400 limit must not be less than 1`). Default: 30.
|
|
127
127
|
* @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
|
|
128
128
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
129
129
|
* @description Each record's `formData` comes back **already unwrapped from its locale**. The API sends `formData: { "en_US": [ … ] }`; the SDK normalizes the response and hands over the array for `langCode`, so read `record.formData` — `record.formData[langCode]` is `undefined` and yields an empty list with no error. This holds for both values of `isExtended`.
|
|
130
130
|
*
|
|
131
|
-
* The filter body is typed
|
|
131
|
+
* The filter body is typed because the API refuses a field it does not know: a misspelled `statuses` answers `400 property statuses should not exist`.
|
|
132
|
+
*
|
|
133
|
+
* A marker or `formModuleConfigId` that matches nothing answers `200` with `{ items: [], total: 0 }`, not `404` — an empty list does not prove the form exists.
|
|
132
134
|
*
|
|
133
135
|
* Empty `dateFrom` / `dateTo` are stripped from the body before it is sent: the endpoint validates the pair as dates and rejects an empty string with a `400`, while every other field still treats "" as "no filter".
|
|
134
136
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
@@ -164,11 +166,11 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
|
|
|
164
166
|
* @handleName getFormsDataByVectorSearch
|
|
165
167
|
* @param {IFormsDataVectorSearch} body - Vector search parameters. Example: `{ queryText: "order confirmation" }`.
|
|
166
168
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
167
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
168
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
169
|
+
* @param {number} [offset] - Number of records to skip, `0` or more. Default: 0.
|
|
170
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more. Default: 30.
|
|
169
171
|
* @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
|
|
170
172
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
171
|
-
* @description This method performs a semantic (vector) search for form data.
|
|
173
|
+
* @description This method performs a semantic (vector) search for form data. The body is checked by the API: an empty `queryText` or one longer than 512 characters, a negative `vectorDistanceThreshold` and a `maxHits` below `1` each answer `400`.
|
|
172
174
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
|
|
173
175
|
*/
|
|
174
176
|
getFormsDataByVectorSearch(body: IFormsDataVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>;
|
|
@@ -171,7 +171,9 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
171
171
|
const result = await this._fetchPost(``, { ...body, formData });
|
|
172
172
|
// Validate response if validation is enabled
|
|
173
173
|
const validated = await this._validateResponse(result, schema('PostFormResponseSchema'));
|
|
174
|
-
|
|
174
|
+
// The fields went in under `langCode`, so the response is unwrapped from the same
|
|
175
|
+
// locale; without it a call in another language returned `formData` still keyed by it
|
|
176
|
+
return this._normalizeData(validated, langCode);
|
|
175
177
|
}
|
|
176
178
|
/**
|
|
177
179
|
* Tells a file the SDK still has to upload from one already in storage.
|
|
@@ -252,23 +254,25 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
252
254
|
* @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
|
|
253
255
|
* @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
|
|
254
256
|
* @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
|
|
255
|
-
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
256
|
-
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
257
|
+
* @param {string} [body.dateFrom] - Lower bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound" — the SDK removes it from the body, because the endpoint answers `400 dateFrom must be a valid date in format "YYYY-MM-DD"` to one. An unparsable non-empty value still fails the request. Example: "2025-01-01".
|
|
258
|
+
* @param {string} [body.dateTo] - Upper bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`. An empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
257
259
|
* @param {number} [isExtended] - Pass `1` to return additional fields for each record. Default: `0`. Example: 1.
|
|
258
260
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
259
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
260
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
261
|
+
* @param {number} [offset] - Number of records to skip, `0` or more (a negative one answers `400 offset must not be less than 0`). Default: 0.
|
|
262
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more (`0` answers `400 limit must not be less than 1`). Default: 30.
|
|
261
263
|
* @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
|
|
262
264
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
263
265
|
* @description Each record's `formData` comes back **already unwrapped from its locale**. The API sends `formData: { "en_US": [ … ] }`; the SDK normalizes the response and hands over the array for `langCode`, so read `record.formData` — `record.formData[langCode]` is `undefined` and yields an empty list with no error. This holds for both values of `isExtended`.
|
|
264
266
|
*
|
|
265
|
-
* The filter body is typed
|
|
267
|
+
* The filter body is typed because the API refuses a field it does not know: a misspelled `statuses` answers `400 property statuses should not exist`.
|
|
268
|
+
*
|
|
269
|
+
* A marker or `formModuleConfigId` that matches nothing answers `200` with `{ items: [], total: 0 }`, not `404` — an empty list does not prove the form exists.
|
|
266
270
|
*
|
|
267
271
|
* Empty `dateFrom` / `dateTo` are stripped from the body before it is sent: the endpoint validates the pair as dates and rejects an empty string with a `400`, while every other field still treats "" as "no filter".
|
|
268
272
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByMarker getFormsDataByMarker} documentation.
|
|
269
273
|
*/
|
|
270
274
|
async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
271
|
-
const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, this._stripEmptyDates(body));
|
|
275
|
+
const result = await this._fetchPost(`/marker/${this._pathSegment(marker)}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, this._stripEmptyDates(body));
|
|
272
276
|
// Validate response if validation is enabled
|
|
273
277
|
const validated = await this._validateResponse(result, schema('FormsByMarkerDataResponseSchema'));
|
|
274
278
|
return this._normalizeData(validated, langCode);
|
|
@@ -314,11 +318,11 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
314
318
|
* @handleName getFormsDataByVectorSearch
|
|
315
319
|
* @param {IFormsDataVectorSearch} body - Vector search parameters. Example: `{ queryText: "order confirmation" }`.
|
|
316
320
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
317
|
-
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
318
|
-
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
321
|
+
* @param {number} [offset] - Number of records to skip, `0` or more. Default: 0.
|
|
322
|
+
* @param {number} [limit] - Maximum number of records to return, `1` or more. Default: 30.
|
|
319
323
|
* @returns {Promise<IVectorSearchResponse<IFormsDataSearchResponse> | IError>} Returns an object with an array of found form data records and total count.
|
|
320
324
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
321
|
-
* @description This method performs a semantic (vector) search for form data.
|
|
325
|
+
* @description This method performs a semantic (vector) search for form data. The body is checked by the API: an empty `queryText` or one longer than 512 characters, a negative `vectorDistanceThreshold` and a `maxHits` below `1` each answer `400`.
|
|
322
326
|
* @see {@link https://js-sdk.oneentry.cloud/docs/forms-data/getFormsDataByVectorSearch getFormsDataByVectorSearch} documentation.
|
|
323
327
|
*/
|
|
324
328
|
async getFormsDataByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|