oneentry 1.0.167 → 1.0.168
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 +18 -0
- package/dist/auth-provider/authProviderApi.js +3 -2
- package/dist/base/asyncModules.d.ts +18 -0
- package/dist/base/asyncModules.js +34 -1
- package/dist/base/syncModules.d.ts +10 -3
- package/dist/base/syncModules.js +25 -14
- package/dist/discounts/discountsApi.d.ts +3 -3
- package/dist/discounts/discountsApi.js +1 -1
- package/dist/discounts/discountsInterfaces.d.ts +15 -3
- package/dist/forms-data/formsDataInterfaces.d.ts +130 -3
- package/dist/search/searchApi.d.ts +3 -2
- package/dist/search/searchApi.js +6 -2
- package/dist/search/searchInterfaces.d.ts +3 -2
- package/dist/users/usersApi.js +3 -3
- package/esm/auth-provider/authProviderApi.js +3 -2
- package/esm/base/asyncModules.d.ts +18 -0
- package/esm/base/asyncModules.js +34 -1
- package/esm/base/syncModules.d.ts +10 -3
- package/esm/base/syncModules.js +25 -14
- package/esm/discounts/discountsApi.d.ts +3 -3
- package/esm/discounts/discountsApi.js +1 -1
- package/esm/discounts/discountsInterfaces.d.ts +15 -3
- package/esm/forms-data/formsDataInterfaces.d.ts +130 -3
- package/esm/search/searchApi.d.ts +3 -2
- package/esm/search/searchApi.js +6 -2
- package/esm/search/searchInterfaces.d.ts +3 -2
- package/esm/users/usersApi.js +3 -3
- package/package.json +2 -2
package/changelog.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.168
|
|
4
|
+
|
|
5
|
+
### What's Fixed
|
|
6
|
+
|
|
7
|
+
- **`Search.globalSearch` could not ask for a language, so a second-locale word found nothing.** The search index is per language, and the method sent no `langCode` — not even the one given to `defineOneEntry`. On a bilingual project the Spanish word "agua" came back with an empty group while the same request with `langCode=es_ES` returned a full page. The method now takes `langCode` as its last parameter, defaulting to the client's own language, so an existing call needs no edit and starts asking in the right language by itself. Measured on a bilingual stand: "agua" 0 → 30+, the English control unchanged (CMS-912).
|
|
8
|
+
|
|
9
|
+
- **Methods that post a body no longer modify the object they are given.** `_normalizePostBody` wrapped `formData` and dropped an empty `phoneSMS` in place, and `signUp` and `updateUser` wrote `langCode` onto the caller's object. A body that is reused — a retry wrapper, two parallel calls, a shared default — came back already wrapped, was wrapped a second time, and the platform answered `400 "formData.en_US[0].marker" is required`: a validation error about a field the caller never sent. The normalizer now works on a copy, `notificationData` included, and the caller's object is identical after the call (CMS-909).
|
|
10
|
+
|
|
11
|
+
- **A dropped connection returned `{}`, which reads exactly like an empty answer.** With `isShell` on — the default — a network failure was handed back as the thrown `TypeError`, whose `message` and `stack` are not enumerable, so it serialized to an empty object. There was no way to tell "no connection" from "no data": on one site such a value entered the page cache and was served for minutes after the link came back, and a static build baked a site of 404s while reporting success. A failure that never reached the platform now returns `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0` is a value no HTTP answer uses. An error the platform itself sent is passed through untouched (CMS-780).
|
|
12
|
+
|
|
13
|
+
- **`Discounts.getBonusHistory` was declared to return an array; it returns a container.** The endpoint answers `{ items, total }` — an account with no transactions gives `{"items":[],"total":0}` — while the method and the `IDiscounts` interface both promised `IBonusTransactionEntity[]`. Code written from the type read `.length` off an object and found `undefined`. The return type is now `IBonusHistoryResponse`, exported alongside the rest. Found while covering the module with tests (CMS-531); types only, the wire format did not change.
|
|
14
|
+
|
|
15
|
+
- **The declared value shapes of a form submission were the ones the platform refuses.** A body written from the types got three `400`s in a row: a `list` field typed as `[{ title, value }]` (a page attribute's shape) answers `value[0] must be a string`, a `text` field typed as an object answers `value must be an array`, and `params` inside it answers `is not allowed`; a `spam` field had no type at all and a bare token is refused with the same sentence as a wrong one. `IBodyPostFormData.formData` now uses submission-specific types — `IBodyPostTypeList` (a list of strings), `IBodyPostTypeText` (a one-element array holding exactly one of `plainValue`, `htmlValue` or `mdValue`, no `params`) and `IBodyPostTypeSpam` (`{ event: { token, siteKey } }`) — with the read types left as they were. Types and documentation only; the wire format did not change (CMS-888).
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
|
|
19
|
+
- **`discounts` and `oauth` now have tests that run.** The discounts suite covered four of six methods; `getBonusBalance` and `getBonusHistory` were untested, and it was the new coverage that found the wrong return type above. The suite went from 5 cases to 8, and the bonus ones authenticate first — the balance belongs to the signed-in user and answers `401` under the app token alone. The `oauth` case was an empty shell: its body was commented out and the expectation rule disabled, so it passed while testing nothing. The happy path still cannot be covered from the test stand — it needs a provider of type `oauth` and a one-time code from that provider's consent screen, and the stand has neither — so what is pinned instead is the SDK's own half of the contract: a refusal comes back as an error value rather than an exception, and the caller's body is not modified. The limitation is written into the test rather than left as a silent pass (CMS-531, CMS-532).
|
|
20
|
+
|
|
3
21
|
## v.1.0.167
|
|
4
22
|
|
|
5
23
|
### What's New
|
|
@@ -124,8 +124,9 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
124
124
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
125
125
|
*/
|
|
126
126
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
// `langCode` goes onto our own copy — the caller's body stays as it was
|
|
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
130
|
// Validate response if validation is enabled
|
|
130
131
|
const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
|
|
131
132
|
return this._normalizeData(validated);
|
|
@@ -120,4 +120,22 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
120
120
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
121
121
|
*/
|
|
122
122
|
private browserResponse;
|
|
123
|
+
/**
|
|
124
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
125
|
+
*
|
|
126
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
127
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
128
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
129
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
130
|
+
* page cache and was served for minutes after the link came back, and
|
|
131
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
132
|
+
*
|
|
133
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
134
|
+
* and is passed through untouched. Everything else becomes
|
|
135
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
136
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
137
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
138
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
139
|
+
*/
|
|
140
|
+
private _toShellError;
|
|
123
141
|
}
|
|
@@ -410,12 +410,45 @@ class AsyncModules extends syncModules_1.default {
|
|
|
410
410
|
// Handle any errors that occur during the fetch process
|
|
411
411
|
// Determine whether to return or throw the error based on 'isShell' state
|
|
412
412
|
if (this.state.isShell) {
|
|
413
|
-
return e;
|
|
413
|
+
return this._toShellError(e);
|
|
414
414
|
}
|
|
415
415
|
else {
|
|
416
416
|
throw e;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
422
|
+
*
|
|
423
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
424
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
425
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
426
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
427
|
+
* page cache and was served for minutes after the link came back, and
|
|
428
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
429
|
+
*
|
|
430
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
431
|
+
* and is passed through untouched. Everything else becomes
|
|
432
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
433
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
434
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
435
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
436
|
+
*/
|
|
437
|
+
_toShellError(e) {
|
|
438
|
+
if (e && typeof e === 'object' && 'statusCode' in e) {
|
|
439
|
+
return e;
|
|
440
|
+
}
|
|
441
|
+
const message = e instanceof Error
|
|
442
|
+
? `${e.name}: ${e.message}`
|
|
443
|
+
: typeof e === 'string'
|
|
444
|
+
? e
|
|
445
|
+
: 'Request failed before a response was received';
|
|
446
|
+
return {
|
|
447
|
+
statusCode: 0,
|
|
448
|
+
message,
|
|
449
|
+
pageData: null,
|
|
450
|
+
timestamp: new Date().toISOString(),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
420
453
|
}
|
|
421
454
|
exports.default = AsyncModules;
|
|
@@ -81,10 +81,17 @@ export default abstract class SyncModules {
|
|
|
81
81
|
* 2. **formData localization**: the API expects formData as
|
|
82
82
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
83
83
|
* The method wraps the data into the required structure.
|
|
84
|
-
* If `formData` is absent from the body — return
|
|
85
|
-
*
|
|
84
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
85
|
+
*
|
|
86
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
87
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
88
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
89
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
90
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
91
|
+
* never sent (CMS-909).
|
|
92
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
86
93
|
* @param {string} [langCode] - The language code for normalization.
|
|
87
|
-
* @returns {any}
|
|
94
|
+
* @returns {any} A normalized copy of the body.
|
|
88
95
|
*/
|
|
89
96
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
90
97
|
/**
|
package/dist/base/syncModules.js
CHANGED
|
@@ -220,27 +220,38 @@ class SyncModules {
|
|
|
220
220
|
* 2. **formData localization**: the API expects formData as
|
|
221
221
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
222
222
|
* The method wraps the data into the required structure.
|
|
223
|
-
* If `formData` is absent from the body — return
|
|
224
|
-
*
|
|
223
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
224
|
+
*
|
|
225
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
226
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
227
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
228
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
229
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
230
|
+
* never sent (CMS-909).
|
|
231
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
225
232
|
* @param {string} [langCode] - The language code for normalization.
|
|
226
|
-
* @returns {any}
|
|
233
|
+
* @returns {any} A normalized copy of the body.
|
|
227
234
|
*/
|
|
228
235
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
236
|
+
const next = { ...body };
|
|
237
|
+
// API does not accept phoneSMS = '' — drop the field if empty. `notificationData`
|
|
238
|
+
// is copied too: deleting the key on the original would reach the caller.
|
|
239
|
+
if (next.notificationData && next.notificationData.phoneSMS === '') {
|
|
240
|
+
next.notificationData = { ...next.notificationData };
|
|
241
|
+
delete next.notificationData.phoneSMS;
|
|
232
242
|
}
|
|
233
243
|
// If formData is not provided — no further normalization needed.
|
|
234
|
-
if (!
|
|
235
|
-
return
|
|
244
|
+
if (!next.formData)
|
|
245
|
+
return next;
|
|
236
246
|
// Wrap form fields in an object keyed by locale:
|
|
237
247
|
// [{ marker, value }] → { "en_US": [{ marker, value }] }
|
|
238
|
-
|
|
239
|
-
formData
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
// The fields themselves are reused by reference — they are not modified.
|
|
249
|
+
next.formData = {
|
|
250
|
+
[langCode]: Array.isArray(next.formData)
|
|
251
|
+
? next.formData
|
|
252
|
+
: [next.formData],
|
|
253
|
+
};
|
|
254
|
+
return next;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
246
257
|
* Normalizes the value of a single attribute in place.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IBonusBalanceEntity,
|
|
4
|
+
import type { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
7
|
* @handle /api/content/events
|
|
@@ -63,11 +63,11 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
63
63
|
* @param {number} [discountId] - Discount id filter.
|
|
64
64
|
* @param {number} [moduleId] - Module id filter.
|
|
65
65
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
66
|
-
* @returns {Promise<
|
|
66
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
67
67
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
68
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
69
69
|
*/
|
|
70
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
70
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
71
71
|
/**
|
|
72
72
|
* Validate discounts coupon
|
|
73
73
|
* @handleName validateDiscountsCoupon
|
|
@@ -85,7 +85,7 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
85
85
|
* @param {number} [discountId] - Discount id filter.
|
|
86
86
|
* @param {number} [moduleId] - Module id filter.
|
|
87
87
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
88
|
-
* @returns {Promise<
|
|
88
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
89
89
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
90
90
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
91
91
|
*/
|
|
@@ -55,10 +55,10 @@ interface IDiscountsApi {
|
|
|
55
55
|
* @param {number} [discountId] - Discount id filter.
|
|
56
56
|
* @param {number} [moduleId] - Module id filter.
|
|
57
57
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
58
|
-
* @returns {Promise<
|
|
58
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
59
59
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
60
|
*/
|
|
61
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
61
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
62
62
|
/**
|
|
63
63
|
* Semantic (vector) search for discounts.
|
|
64
64
|
* @handleName getDiscountsByVectorSearch
|
|
@@ -284,6 +284,18 @@ interface IBonusTransactionEntity {
|
|
|
284
284
|
expiresAt?: string;
|
|
285
285
|
createdAt?: string;
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* @interface IBonusHistoryResponse
|
|
289
|
+
* @property {IBonusTransactionEntity[]} items - The transactions of the current page.
|
|
290
|
+
* @property {number} total - How many transactions the filter matches in total.
|
|
291
|
+
* @description Container the bonus history arrives in. The endpoint answers
|
|
292
|
+
* `{ items, total }`, not a bare array — measured on the SDK test stand,
|
|
293
|
+
* 2026-09-28: an account with no transactions answers `{"items":[],"total":0}`.
|
|
294
|
+
*/
|
|
295
|
+
interface IBonusHistoryResponse {
|
|
296
|
+
items: IBonusTransactionEntity[];
|
|
297
|
+
total: number;
|
|
298
|
+
}
|
|
287
299
|
/**
|
|
288
300
|
* @interface IBonusBalanceEntity
|
|
289
301
|
* @description Represents the balance of bonus points.
|
|
@@ -292,4 +304,4 @@ interface IBonusTransactionEntity {
|
|
|
292
304
|
interface IBonusBalanceEntity {
|
|
293
305
|
balance: number;
|
|
294
306
|
}
|
|
295
|
-
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
307
|
+
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusHistoryResponse, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
@@ -420,6 +420,133 @@ interface IUpdateFormsData {
|
|
|
420
420
|
* Contains an array of data form objects with the following values
|
|
421
421
|
*/
|
|
422
422
|
type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | Record<string, unknown>;
|
|
423
|
+
/**
|
|
424
|
+
* Value shapes accepted by a SUBMISSION (`POST /form-data`).
|
|
425
|
+
*
|
|
426
|
+
* For three field kinds they are not the shapes a page attribute uses, and a
|
|
427
|
+
* body written from the read types is refused. Measured on
|
|
428
|
+
* rwah2o.oneentry.cloud, 2026-09-12 and again 2026-09-28 (CMS-888).
|
|
429
|
+
*
|
|
430
|
+
* `list` takes a list of strings; the `[{ title, value }]` form of a page
|
|
431
|
+
* attribute answers `400 formData's marker '<marker>' value[0] must be a string`.
|
|
432
|
+
*
|
|
433
|
+
* `text` takes a one-element array holding exactly ONE of `plainValue`,
|
|
434
|
+
* `htmlValue` or `mdValue`, and no `params`. The object form answers
|
|
435
|
+
* `400 … value must be an array`, `params` answers `… is not allowed`, and two
|
|
436
|
+
* representations answer `Only one of htmlValue, plainValue or mdValue can be provided`.
|
|
437
|
+
*
|
|
438
|
+
* `spam` takes the captcha event, not the bare token.
|
|
439
|
+
*/
|
|
440
|
+
type FormDataPostType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyPostTypeText | IBodyPostTypeList | IBodyPostTypeSpam | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | Record<string, unknown>;
|
|
441
|
+
/**
|
|
442
|
+
* Represents a `list` field of a form SUBMISSION.
|
|
443
|
+
* @interface IBodyPostTypeList
|
|
444
|
+
* @property {string} marker - marker name. Example: "recipient".
|
|
445
|
+
* @property {string} type - Type value. Example: "list".
|
|
446
|
+
* @property {string[]} value - Chosen options as plain strings. Example: ["Tom Hoffart"].
|
|
447
|
+
* @example
|
|
448
|
+
{
|
|
449
|
+
"marker": "recipient",
|
|
450
|
+
"type": "list",
|
|
451
|
+
"value": ["Tom Hoffart"]
|
|
452
|
+
}
|
|
453
|
+
* @description A submission sends the chosen options as strings. The `[{ title, value }]`
|
|
454
|
+
* shape a page attribute stores is refused here with `value[0] must be a string`.
|
|
455
|
+
*/
|
|
456
|
+
interface IBodyPostTypeList {
|
|
457
|
+
marker: string;
|
|
458
|
+
type: 'list';
|
|
459
|
+
value: string[];
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Represents a `text` field of a form SUBMISSION.
|
|
463
|
+
* @interface IBodyPostTypeText
|
|
464
|
+
* @property {string} marker - marker name. Example: "your_message".
|
|
465
|
+
* @property {string} type - Type value. Example: "text".
|
|
466
|
+
* @property {ITextSubmissionValue[]} value - One-element array holding exactly one representation.
|
|
467
|
+
* @example
|
|
468
|
+
{
|
|
469
|
+
"marker": "your_message",
|
|
470
|
+
"type": "text",
|
|
471
|
+
"value": [{ "plainValue": "Hello" }]
|
|
472
|
+
}
|
|
473
|
+
* @description The array holds one object carrying exactly one of `plainValue`,
|
|
474
|
+
* `htmlValue` or `mdValue`. Editor `params` are refused, and so is sending two
|
|
475
|
+
* representations at once.
|
|
476
|
+
*/
|
|
477
|
+
interface IBodyPostTypeText {
|
|
478
|
+
marker: string;
|
|
479
|
+
type: 'text';
|
|
480
|
+
value: ITextSubmissionValue[];
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* @interface ITextSubmissionValuePlain
|
|
484
|
+
* @property {string} plainValue - Plain-text representation. Example: "Hello".
|
|
485
|
+
* @description Plain-text branch of a submitted text value.
|
|
486
|
+
*/
|
|
487
|
+
interface ITextSubmissionValuePlain {
|
|
488
|
+
plainValue: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* @interface ITextSubmissionValueHtml
|
|
492
|
+
* @property {string} htmlValue - HTML representation. Example: "<p>Hello</p>".
|
|
493
|
+
* @description HTML branch of a submitted text value.
|
|
494
|
+
*/
|
|
495
|
+
interface ITextSubmissionValueHtml {
|
|
496
|
+
htmlValue: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @interface ITextSubmissionValueMd
|
|
500
|
+
* @property {string} mdValue - Markdown representation. Must not be empty. Example: "**Hello**".
|
|
501
|
+
* @description Markdown branch of a submitted text value.
|
|
502
|
+
*/
|
|
503
|
+
interface ITextSubmissionValueMd {
|
|
504
|
+
mdValue: string;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Exactly one representation of a submitted text value.
|
|
508
|
+
*/
|
|
509
|
+
type ITextSubmissionValue = ITextSubmissionValuePlain | ITextSubmissionValueHtml | ITextSubmissionValueMd;
|
|
510
|
+
/**
|
|
511
|
+
* Represents a `spam` (captcha) field of a form SUBMISSION.
|
|
512
|
+
* @interface IBodyPostTypeSpam
|
|
513
|
+
* @property {string} marker - marker name. Example: "spam".
|
|
514
|
+
* @property {string} type - Type value. Example: "spam".
|
|
515
|
+
* @property {ICaptchaValue} value - The captcha event, not the bare token.
|
|
516
|
+
* @example
|
|
517
|
+
{
|
|
518
|
+
"marker": "spam",
|
|
519
|
+
"type": "spam",
|
|
520
|
+
"value": { "event": { "token": "<reCAPTCHA v3 token>", "siteKey": "6Ldjk7Yt…" } }
|
|
521
|
+
}
|
|
522
|
+
* @description The field carries a reCAPTCHA v3 token obtained in the browser.
|
|
523
|
+
* A bare string is refused with the same sentence as a wrong token —
|
|
524
|
+
* `Captcha Validation Failed, captcha type is: google` — so a malformed value
|
|
525
|
+
* is indistinguishable from a bot.
|
|
526
|
+
*/
|
|
527
|
+
interface IBodyPostTypeSpam {
|
|
528
|
+
marker: string;
|
|
529
|
+
type: 'spam';
|
|
530
|
+
value: ICaptchaValue;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* @interface ICaptchaEvent
|
|
534
|
+
* @property {string} token - The token issued by the captcha provider in the browser.
|
|
535
|
+
* @property {string} siteKey - The site key the token was issued for. Example: "6Ldjk7Yt…".
|
|
536
|
+
* @description The captcha payload of a `spam` field.
|
|
537
|
+
*/
|
|
538
|
+
interface ICaptchaEvent {
|
|
539
|
+
token: string;
|
|
540
|
+
siteKey: string;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* @interface ICaptchaValue
|
|
544
|
+
* @property {ICaptchaEvent} event - The captcha payload.
|
|
545
|
+
* @description Wrapper the platform expects around the captcha payload.
|
|
546
|
+
*/
|
|
547
|
+
interface ICaptchaValue {
|
|
548
|
+
event: ICaptchaEvent;
|
|
549
|
+
}
|
|
423
550
|
/**
|
|
424
551
|
* Represents the structure of the body for posting form data.
|
|
425
552
|
* @interface IBodyPostFormData
|
|
@@ -428,7 +555,7 @@ type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeTe
|
|
|
428
555
|
* @property {string} moduleEntityIdentifier - Text identifier (marker) of the module entity. Example: "blog".
|
|
429
556
|
* @property {string | null} replayTo - Email to reply to. Example: "some@email.com".
|
|
430
557
|
* @property {string} status - Status of the form. Example: "sent".
|
|
431
|
-
* @property {
|
|
558
|
+
* @property {FormDataPostType[]} formData - Array of form data objects. A submission's value shapes differ from the read shapes — see FormDataPostType.
|
|
432
559
|
* @example
|
|
433
560
|
[
|
|
434
561
|
{
|
|
@@ -455,7 +582,7 @@ interface IBodyPostFormData {
|
|
|
455
582
|
moduleEntityIdentifier: string;
|
|
456
583
|
replayTo: string | null;
|
|
457
584
|
status: string;
|
|
458
|
-
formData:
|
|
585
|
+
formData: FormDataPostType[];
|
|
459
586
|
fileQuery?: IUploadingQuery;
|
|
460
587
|
}
|
|
461
588
|
/**
|
|
@@ -711,4 +838,4 @@ interface IListOptionValue {
|
|
|
711
838
|
value: string;
|
|
712
839
|
extended: IListOptionExtended;
|
|
713
840
|
}
|
|
714
|
-
export type { FormDataStatus, FormDataType, IBodyPostFormData, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
841
|
+
export type { FormDataPostType, FormDataStatus, FormDataType, IBodyPostFormData, IBodyPostTypeList, IBodyPostTypeSpam, IBodyPostTypeText, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, ICaptchaEvent, ICaptchaValue, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextSubmissionValue, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
@@ -26,10 +26,11 @@ export default class SearchApi extends AsyncModules implements ISearchApi {
|
|
|
26
26
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
27
27
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
28
28
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
29
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
29
30
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
30
31
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
31
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
32
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
32
33
|
* @see {@link https://js-sdk.oneentry.cloud/docs/search/globalSearch globalSearch} documentation.
|
|
33
34
|
*/
|
|
34
|
-
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number): Promise<IGlobalSearchResponse | IError>;
|
|
35
|
+
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number, langCode?: string): Promise<IGlobalSearchResponse | IError>;
|
|
35
36
|
}
|
package/dist/search/searchApi.js
CHANGED
|
@@ -64,19 +64,23 @@ class SearchApi extends asyncModules_1.default {
|
|
|
64
64
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
65
65
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
66
66
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
67
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
67
68
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
68
69
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
69
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
70
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
70
71
|
* @see {@link https://js-sdk.oneentry.cloud/docs/search/globalSearch globalSearch} documentation.
|
|
71
72
|
*/
|
|
72
|
-
async globalSearch(query, types, visibility, offset, limit) {
|
|
73
|
+
async globalSearch(query, types, visibility, offset, limit, langCode = this.state.lang) {
|
|
73
74
|
// `types` is sent comma-separated — the array stringifies to exactly that.
|
|
75
|
+
// `langCode` is not optional decoration: the index is per language, and
|
|
76
|
+
// without it a word of a second locale answers an empty group (CMS-912).
|
|
74
77
|
const params = {
|
|
75
78
|
q: query,
|
|
76
79
|
types,
|
|
77
80
|
visibility,
|
|
78
81
|
offset,
|
|
79
82
|
limit,
|
|
83
|
+
langCode,
|
|
80
84
|
};
|
|
81
85
|
const data = await this._fetchGet(`?` + this._queryParamsToString(params));
|
|
82
86
|
const validated = await this._validateResponse(data, schema('GlobalSearchResponseSchema'));
|
|
@@ -13,11 +13,12 @@ interface ISearchApi {
|
|
|
13
13
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
14
14
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
15
15
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
16
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
16
17
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
17
18
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
18
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
19
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
19
20
|
*/
|
|
20
|
-
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number): Promise<IGlobalSearchResponse | IError>;
|
|
21
|
+
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number, langCode?: string): Promise<IGlobalSearchResponse | IError>;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Entity type a global search group or item belongs to.
|
package/dist/users/usersApi.js
CHANGED
|
@@ -147,9 +147,9 @@ class UsersApi extends asyncModules_1.default {
|
|
|
147
147
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/updateUser updateUser} documentation.
|
|
148
148
|
*/
|
|
149
149
|
async updateUser(body, langCode = this.state.lang) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const result = await this._fetchPut('/me', this._normalizePostBody(
|
|
150
|
+
// The language goes onto our own copy; the caller's body is left alone (CMS-909).
|
|
151
|
+
const payload = 'langCode' in body ? body : { ...body, langCode };
|
|
152
|
+
const result = await this._fetchPut('/me', this._normalizePostBody(payload, langCode));
|
|
153
153
|
const validated = await this._validateResponse(result, schema('UpdateUserResponseSchema'));
|
|
154
154
|
return validated;
|
|
155
155
|
}
|
|
@@ -86,8 +86,9 @@ export default class AuthProviderApi extends AsyncModules {
|
|
|
86
86
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
87
87
|
*/
|
|
88
88
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
// `langCode` goes onto our own copy — the caller's body stays as it was
|
|
90
|
+
// given, so a retry or a second parallel call sends the same thing (CMS-909).
|
|
91
|
+
const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody({ ...body, langCode }, langCode));
|
|
91
92
|
// Validate response if validation is enabled
|
|
92
93
|
const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
|
|
93
94
|
return this._normalizeData(validated);
|
|
@@ -120,4 +120,22 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
120
120
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
121
121
|
*/
|
|
122
122
|
private browserResponse;
|
|
123
|
+
/**
|
|
124
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
125
|
+
*
|
|
126
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
127
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
128
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
129
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
130
|
+
* page cache and was served for minutes after the link came back, and
|
|
131
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
132
|
+
*
|
|
133
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
134
|
+
* and is passed through untouched. Everything else becomes
|
|
135
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
136
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
137
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
138
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
139
|
+
*/
|
|
140
|
+
private _toShellError;
|
|
123
141
|
}
|
package/esm/base/asyncModules.js
CHANGED
|
@@ -372,11 +372,44 @@ export default class AsyncModules extends SyncModules {
|
|
|
372
372
|
// Handle any errors that occur during the fetch process
|
|
373
373
|
// Determine whether to return or throw the error based on 'isShell' state
|
|
374
374
|
if (this.state.isShell) {
|
|
375
|
-
return e;
|
|
375
|
+
return this._toShellError(e);
|
|
376
376
|
}
|
|
377
377
|
else {
|
|
378
378
|
throw e;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
384
|
+
*
|
|
385
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
386
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
387
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
388
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
389
|
+
* page cache and was served for minutes after the link came back, and
|
|
390
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
391
|
+
*
|
|
392
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
393
|
+
* and is passed through untouched. Everything else becomes
|
|
394
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
395
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
396
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
397
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
398
|
+
*/
|
|
399
|
+
_toShellError(e) {
|
|
400
|
+
if (e && typeof e === 'object' && 'statusCode' in e) {
|
|
401
|
+
return e;
|
|
402
|
+
}
|
|
403
|
+
const message = e instanceof Error
|
|
404
|
+
? `${e.name}: ${e.message}`
|
|
405
|
+
: typeof e === 'string'
|
|
406
|
+
? e
|
|
407
|
+
: 'Request failed before a response was received';
|
|
408
|
+
return {
|
|
409
|
+
statusCode: 0,
|
|
410
|
+
message,
|
|
411
|
+
pageData: null,
|
|
412
|
+
timestamp: new Date().toISOString(),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
382
415
|
}
|
|
@@ -81,10 +81,17 @@ export default abstract class SyncModules {
|
|
|
81
81
|
* 2. **formData localization**: the API expects formData as
|
|
82
82
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
83
83
|
* The method wraps the data into the required structure.
|
|
84
|
-
* If `formData` is absent from the body — return
|
|
85
|
-
*
|
|
84
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
85
|
+
*
|
|
86
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
87
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
88
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
89
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
90
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
91
|
+
* never sent (CMS-909).
|
|
92
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
86
93
|
* @param {string} [langCode] - The language code for normalization.
|
|
87
|
-
* @returns {any}
|
|
94
|
+
* @returns {any} A normalized copy of the body.
|
|
88
95
|
*/
|
|
89
96
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
90
97
|
/**
|
package/esm/base/syncModules.js
CHANGED
|
@@ -218,27 +218,38 @@ export default class SyncModules {
|
|
|
218
218
|
* 2. **formData localization**: the API expects formData as
|
|
219
219
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
220
220
|
* The method wraps the data into the required structure.
|
|
221
|
-
* If `formData` is absent from the body — return
|
|
222
|
-
*
|
|
221
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
222
|
+
*
|
|
223
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
224
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
225
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
226
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
227
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
228
|
+
* never sent (CMS-909).
|
|
229
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
223
230
|
* @param {string} [langCode] - The language code for normalization.
|
|
224
|
-
* @returns {any}
|
|
231
|
+
* @returns {any} A normalized copy of the body.
|
|
225
232
|
*/
|
|
226
233
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
const next = { ...body };
|
|
235
|
+
// API does not accept phoneSMS = '' — drop the field if empty. `notificationData`
|
|
236
|
+
// is copied too: deleting the key on the original would reach the caller.
|
|
237
|
+
if (next.notificationData && next.notificationData.phoneSMS === '') {
|
|
238
|
+
next.notificationData = { ...next.notificationData };
|
|
239
|
+
delete next.notificationData.phoneSMS;
|
|
230
240
|
}
|
|
231
241
|
// If formData is not provided — no further normalization needed.
|
|
232
|
-
if (!
|
|
233
|
-
return
|
|
242
|
+
if (!next.formData)
|
|
243
|
+
return next;
|
|
234
244
|
// Wrap form fields in an object keyed by locale:
|
|
235
245
|
// [{ marker, value }] → { "en_US": [{ marker, value }] }
|
|
236
|
-
|
|
237
|
-
formData
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
// The fields themselves are reused by reference — they are not modified.
|
|
247
|
+
next.formData = {
|
|
248
|
+
[langCode]: Array.isArray(next.formData)
|
|
249
|
+
? next.formData
|
|
250
|
+
: [next.formData],
|
|
251
|
+
};
|
|
252
|
+
return next;
|
|
242
253
|
}
|
|
243
254
|
/**
|
|
244
255
|
* Normalizes the value of a single attribute in place.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules.js';
|
|
2
2
|
import type StateModule from '../base/stateModule.js';
|
|
3
3
|
import type { IError } from '../base/utils.js';
|
|
4
|
-
import type { IBonusBalanceEntity,
|
|
4
|
+
import type { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces.js';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
7
|
* @handle /api/content/events
|
|
@@ -63,11 +63,11 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
63
63
|
* @param {number} [discountId] - Discount id filter.
|
|
64
64
|
* @param {number} [moduleId] - Module id filter.
|
|
65
65
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
66
|
-
* @returns {Promise<
|
|
66
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
67
67
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
68
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
69
69
|
*/
|
|
70
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
70
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
71
71
|
/**
|
|
72
72
|
* Validate discounts coupon
|
|
73
73
|
* @handleName validateDiscountsCoupon
|
|
@@ -80,7 +80,7 @@ export default class DiscountsApi extends AsyncModules {
|
|
|
80
80
|
* @param {number} [discountId] - Discount id filter.
|
|
81
81
|
* @param {number} [moduleId] - Module id filter.
|
|
82
82
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
83
|
-
* @returns {Promise<
|
|
83
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
84
84
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
85
85
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
86
86
|
*/
|
|
@@ -55,10 +55,10 @@ interface IDiscountsApi {
|
|
|
55
55
|
* @param {number} [discountId] - Discount id filter.
|
|
56
56
|
* @param {number} [moduleId] - Module id filter.
|
|
57
57
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
58
|
-
* @returns {Promise<
|
|
58
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
59
59
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
60
|
*/
|
|
61
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
61
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
62
62
|
/**
|
|
63
63
|
* Semantic (vector) search for discounts.
|
|
64
64
|
* @handleName getDiscountsByVectorSearch
|
|
@@ -284,6 +284,18 @@ interface IBonusTransactionEntity {
|
|
|
284
284
|
expiresAt?: string;
|
|
285
285
|
createdAt?: string;
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* @interface IBonusHistoryResponse
|
|
289
|
+
* @property {IBonusTransactionEntity[]} items - The transactions of the current page.
|
|
290
|
+
* @property {number} total - How many transactions the filter matches in total.
|
|
291
|
+
* @description Container the bonus history arrives in. The endpoint answers
|
|
292
|
+
* `{ items, total }`, not a bare array — measured on the SDK test stand,
|
|
293
|
+
* 2026-09-28: an account with no transactions answers `{"items":[],"total":0}`.
|
|
294
|
+
*/
|
|
295
|
+
interface IBonusHistoryResponse {
|
|
296
|
+
items: IBonusTransactionEntity[];
|
|
297
|
+
total: number;
|
|
298
|
+
}
|
|
287
299
|
/**
|
|
288
300
|
* @interface IBonusBalanceEntity
|
|
289
301
|
* @description Represents the balance of bonus points.
|
|
@@ -292,4 +304,4 @@ interface IBonusTransactionEntity {
|
|
|
292
304
|
interface IBonusBalanceEntity {
|
|
293
305
|
balance: number;
|
|
294
306
|
}
|
|
295
|
-
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
307
|
+
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusHistoryResponse, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
@@ -420,6 +420,133 @@ interface IUpdateFormsData {
|
|
|
420
420
|
* Contains an array of data form objects with the following values
|
|
421
421
|
*/
|
|
422
422
|
type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | Record<string, unknown>;
|
|
423
|
+
/**
|
|
424
|
+
* Value shapes accepted by a SUBMISSION (`POST /form-data`).
|
|
425
|
+
*
|
|
426
|
+
* For three field kinds they are not the shapes a page attribute uses, and a
|
|
427
|
+
* body written from the read types is refused. Measured on
|
|
428
|
+
* rwah2o.oneentry.cloud, 2026-09-12 and again 2026-09-28 (CMS-888).
|
|
429
|
+
*
|
|
430
|
+
* `list` takes a list of strings; the `[{ title, value }]` form of a page
|
|
431
|
+
* attribute answers `400 formData's marker '<marker>' value[0] must be a string`.
|
|
432
|
+
*
|
|
433
|
+
* `text` takes a one-element array holding exactly ONE of `plainValue`,
|
|
434
|
+
* `htmlValue` or `mdValue`, and no `params`. The object form answers
|
|
435
|
+
* `400 … value must be an array`, `params` answers `… is not allowed`, and two
|
|
436
|
+
* representations answer `Only one of htmlValue, plainValue or mdValue can be provided`.
|
|
437
|
+
*
|
|
438
|
+
* `spam` takes the captcha event, not the bare token.
|
|
439
|
+
*/
|
|
440
|
+
type FormDataPostType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyPostTypeText | IBodyPostTypeList | IBodyPostTypeSpam | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | Record<string, unknown>;
|
|
441
|
+
/**
|
|
442
|
+
* Represents a `list` field of a form SUBMISSION.
|
|
443
|
+
* @interface IBodyPostTypeList
|
|
444
|
+
* @property {string} marker - marker name. Example: "recipient".
|
|
445
|
+
* @property {string} type - Type value. Example: "list".
|
|
446
|
+
* @property {string[]} value - Chosen options as plain strings. Example: ["Tom Hoffart"].
|
|
447
|
+
* @example
|
|
448
|
+
{
|
|
449
|
+
"marker": "recipient",
|
|
450
|
+
"type": "list",
|
|
451
|
+
"value": ["Tom Hoffart"]
|
|
452
|
+
}
|
|
453
|
+
* @description A submission sends the chosen options as strings. The `[{ title, value }]`
|
|
454
|
+
* shape a page attribute stores is refused here with `value[0] must be a string`.
|
|
455
|
+
*/
|
|
456
|
+
interface IBodyPostTypeList {
|
|
457
|
+
marker: string;
|
|
458
|
+
type: 'list';
|
|
459
|
+
value: string[];
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Represents a `text` field of a form SUBMISSION.
|
|
463
|
+
* @interface IBodyPostTypeText
|
|
464
|
+
* @property {string} marker - marker name. Example: "your_message".
|
|
465
|
+
* @property {string} type - Type value. Example: "text".
|
|
466
|
+
* @property {ITextSubmissionValue[]} value - One-element array holding exactly one representation.
|
|
467
|
+
* @example
|
|
468
|
+
{
|
|
469
|
+
"marker": "your_message",
|
|
470
|
+
"type": "text",
|
|
471
|
+
"value": [{ "plainValue": "Hello" }]
|
|
472
|
+
}
|
|
473
|
+
* @description The array holds one object carrying exactly one of `plainValue`,
|
|
474
|
+
* `htmlValue` or `mdValue`. Editor `params` are refused, and so is sending two
|
|
475
|
+
* representations at once.
|
|
476
|
+
*/
|
|
477
|
+
interface IBodyPostTypeText {
|
|
478
|
+
marker: string;
|
|
479
|
+
type: 'text';
|
|
480
|
+
value: ITextSubmissionValue[];
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* @interface ITextSubmissionValuePlain
|
|
484
|
+
* @property {string} plainValue - Plain-text representation. Example: "Hello".
|
|
485
|
+
* @description Plain-text branch of a submitted text value.
|
|
486
|
+
*/
|
|
487
|
+
interface ITextSubmissionValuePlain {
|
|
488
|
+
plainValue: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* @interface ITextSubmissionValueHtml
|
|
492
|
+
* @property {string} htmlValue - HTML representation. Example: "<p>Hello</p>".
|
|
493
|
+
* @description HTML branch of a submitted text value.
|
|
494
|
+
*/
|
|
495
|
+
interface ITextSubmissionValueHtml {
|
|
496
|
+
htmlValue: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @interface ITextSubmissionValueMd
|
|
500
|
+
* @property {string} mdValue - Markdown representation. Must not be empty. Example: "**Hello**".
|
|
501
|
+
* @description Markdown branch of a submitted text value.
|
|
502
|
+
*/
|
|
503
|
+
interface ITextSubmissionValueMd {
|
|
504
|
+
mdValue: string;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Exactly one representation of a submitted text value.
|
|
508
|
+
*/
|
|
509
|
+
type ITextSubmissionValue = ITextSubmissionValuePlain | ITextSubmissionValueHtml | ITextSubmissionValueMd;
|
|
510
|
+
/**
|
|
511
|
+
* Represents a `spam` (captcha) field of a form SUBMISSION.
|
|
512
|
+
* @interface IBodyPostTypeSpam
|
|
513
|
+
* @property {string} marker - marker name. Example: "spam".
|
|
514
|
+
* @property {string} type - Type value. Example: "spam".
|
|
515
|
+
* @property {ICaptchaValue} value - The captcha event, not the bare token.
|
|
516
|
+
* @example
|
|
517
|
+
{
|
|
518
|
+
"marker": "spam",
|
|
519
|
+
"type": "spam",
|
|
520
|
+
"value": { "event": { "token": "<reCAPTCHA v3 token>", "siteKey": "6Ldjk7Yt…" } }
|
|
521
|
+
}
|
|
522
|
+
* @description The field carries a reCAPTCHA v3 token obtained in the browser.
|
|
523
|
+
* A bare string is refused with the same sentence as a wrong token —
|
|
524
|
+
* `Captcha Validation Failed, captcha type is: google` — so a malformed value
|
|
525
|
+
* is indistinguishable from a bot.
|
|
526
|
+
*/
|
|
527
|
+
interface IBodyPostTypeSpam {
|
|
528
|
+
marker: string;
|
|
529
|
+
type: 'spam';
|
|
530
|
+
value: ICaptchaValue;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* @interface ICaptchaEvent
|
|
534
|
+
* @property {string} token - The token issued by the captcha provider in the browser.
|
|
535
|
+
* @property {string} siteKey - The site key the token was issued for. Example: "6Ldjk7Yt…".
|
|
536
|
+
* @description The captcha payload of a `spam` field.
|
|
537
|
+
*/
|
|
538
|
+
interface ICaptchaEvent {
|
|
539
|
+
token: string;
|
|
540
|
+
siteKey: string;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* @interface ICaptchaValue
|
|
544
|
+
* @property {ICaptchaEvent} event - The captcha payload.
|
|
545
|
+
* @description Wrapper the platform expects around the captcha payload.
|
|
546
|
+
*/
|
|
547
|
+
interface ICaptchaValue {
|
|
548
|
+
event: ICaptchaEvent;
|
|
549
|
+
}
|
|
423
550
|
/**
|
|
424
551
|
* Represents the structure of the body for posting form data.
|
|
425
552
|
* @interface IBodyPostFormData
|
|
@@ -428,7 +555,7 @@ type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeTe
|
|
|
428
555
|
* @property {string} moduleEntityIdentifier - Text identifier (marker) of the module entity. Example: "blog".
|
|
429
556
|
* @property {string | null} replayTo - Email to reply to. Example: "some@email.com".
|
|
430
557
|
* @property {string} status - Status of the form. Example: "sent".
|
|
431
|
-
* @property {
|
|
558
|
+
* @property {FormDataPostType[]} formData - Array of form data objects. A submission's value shapes differ from the read shapes — see FormDataPostType.
|
|
432
559
|
* @example
|
|
433
560
|
[
|
|
434
561
|
{
|
|
@@ -455,7 +582,7 @@ interface IBodyPostFormData {
|
|
|
455
582
|
moduleEntityIdentifier: string;
|
|
456
583
|
replayTo: string | null;
|
|
457
584
|
status: string;
|
|
458
|
-
formData:
|
|
585
|
+
formData: FormDataPostType[];
|
|
459
586
|
fileQuery?: IUploadingQuery;
|
|
460
587
|
}
|
|
461
588
|
/**
|
|
@@ -711,4 +838,4 @@ interface IListOptionValue {
|
|
|
711
838
|
value: string;
|
|
712
839
|
extended: IListOptionExtended;
|
|
713
840
|
}
|
|
714
|
-
export type { FormDataStatus, FormDataType, IBodyPostFormData, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
841
|
+
export type { FormDataPostType, FormDataStatus, FormDataType, IBodyPostFormData, IBodyPostTypeList, IBodyPostTypeSpam, IBodyPostTypeText, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, ICaptchaEvent, ICaptchaValue, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextSubmissionValue, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
@@ -26,10 +26,11 @@ export default class SearchApi extends AsyncModules implements ISearchApi {
|
|
|
26
26
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
27
27
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
28
28
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
29
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
29
30
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
30
31
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
31
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
32
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
32
33
|
* @see {@link https://js-sdk.oneentry.cloud/docs/search/globalSearch globalSearch} documentation.
|
|
33
34
|
*/
|
|
34
|
-
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number): Promise<IGlobalSearchResponse | IError>;
|
|
35
|
+
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number, langCode?: string): Promise<IGlobalSearchResponse | IError>;
|
|
35
36
|
}
|
package/esm/search/searchApi.js
CHANGED
|
@@ -26,19 +26,23 @@ export default class SearchApi extends AsyncModules {
|
|
|
26
26
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
27
27
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
28
28
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
29
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
29
30
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
30
31
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
31
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
32
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
32
33
|
* @see {@link https://js-sdk.oneentry.cloud/docs/search/globalSearch globalSearch} documentation.
|
|
33
34
|
*/
|
|
34
|
-
async globalSearch(query, types, visibility, offset, limit) {
|
|
35
|
+
async globalSearch(query, types, visibility, offset, limit, langCode = this.state.lang) {
|
|
35
36
|
// `types` is sent comma-separated — the array stringifies to exactly that.
|
|
37
|
+
// `langCode` is not optional decoration: the index is per language, and
|
|
38
|
+
// without it a word of a second locale answers an empty group (CMS-912).
|
|
36
39
|
const params = {
|
|
37
40
|
q: query,
|
|
38
41
|
types,
|
|
39
42
|
visibility,
|
|
40
43
|
offset,
|
|
41
44
|
limit,
|
|
45
|
+
langCode,
|
|
42
46
|
};
|
|
43
47
|
const data = await this._fetchGet(`?` + this._queryParamsToString(params));
|
|
44
48
|
const validated = await this._validateResponse(data, schema('GlobalSearchResponseSchema'));
|
|
@@ -13,11 +13,12 @@ interface ISearchApi {
|
|
|
13
13
|
* @param {'all' | 'visible' | 'hidden'} [visibility] - Visibility filter of the searched records. Default: "all".
|
|
14
14
|
* @param {number} [offset] - Drilldown mode offset. Pass it only together with a single accessible type in `types`.
|
|
15
15
|
* @param {number} [limit] - Drilldown mode page size. Pass it only together with a single accessible type in `types`, otherwise the API answers 400 "Drilldown mode (limit/offset) requires exactly one accessible type in `types`". Without it every group is returned in full.
|
|
16
|
+
* @param {string} [langCode] - Language code. Default: "en_US". The search index is per language: a word of a second locale is found only when its own langCode is sent (CMS-912).
|
|
16
17
|
* @returns {Promise<IGlobalSearchResponse | IError>} Returns the query and the found records grouped by entity type.
|
|
17
18
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
18
|
-
* @description Searches names and attribute values of visible records across entity types.
|
|
19
|
+
* @description Searches names and attribute values of visible records across entity types. The index is per language — the request carries `langCode`, so a bilingual project finds a word of either locale.
|
|
19
20
|
*/
|
|
20
|
-
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number): Promise<IGlobalSearchResponse | IError>;
|
|
21
|
+
globalSearch(query: string, types?: TGlobalSearchEntityType[], visibility?: 'all' | 'visible' | 'hidden', offset?: number, limit?: number, langCode?: string): Promise<IGlobalSearchResponse | IError>;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Entity type a global search group or item belongs to.
|
package/esm/users/usersApi.js
CHANGED
|
@@ -109,9 +109,9 @@ export default class UsersApi extends AsyncModules {
|
|
|
109
109
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/updateUser updateUser} documentation.
|
|
110
110
|
*/
|
|
111
111
|
async updateUser(body, langCode = this.state.lang) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const result = await this._fetchPut('/me', this._normalizePostBody(
|
|
112
|
+
// The language goes onto our own copy; the caller's body is left alone (CMS-909).
|
|
113
|
+
const payload = 'langCode' in body ? body : { ...body, langCode };
|
|
114
|
+
const result = await this._fetchPut('/me', this._normalizePostBody(payload, langCode));
|
|
115
115
|
const validated = await this._validateResponse(result, schema('UpdateUserResponseSchema'));
|
|
116
116
|
return validated;
|
|
117
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneentry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.168",
|
|
4
4
|
"description": "OneEntry NPM package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"prepublishOnly": "node ../scripts/smoke-pack.js --files-only",
|
|
51
|
-
"postpublish": "node ../scripts/verify-published.js --named defineOneEntry --expect 1.0.
|
|
51
|
+
"postpublish": "node ../scripts/verify-published.js --named defineOneEntry --expect 1.0.168"
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"files": [
|