oneentry 1.0.175 → 1.0.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/changelog.md +140 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +96 -29
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +73 -1
- package/dist/base/asyncModules.js +233 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +42 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +96 -29
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +73 -1
- package/esm/base/asyncModules.js +233 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +42 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- package/package.json +2 -2
|
@@ -85,9 +85,9 @@ interface IFormsData {
|
|
|
85
85
|
/**
|
|
86
86
|
* Body for semantic (vector) form data search.
|
|
87
87
|
* @interface IFormsDataVectorSearch
|
|
88
|
-
* @property {string} queryText - Natural-language search query
|
|
89
|
-
* @property {number} [vectorDistanceThreshold] - Override of the cosine distance threshold (0..2)
|
|
90
|
-
* @property {number} [maxHits] - Number of top candidates fetched before pagination. Default: 100. Maximum: 500. Example: 10.
|
|
88
|
+
* @property {string} queryText - Natural-language search query, 1 to 512 characters: an empty one answers `400 queryText should not be empty`, a longer one `400 queryText must be shorter than or equal to 512 characters`. Example: "order confirmation".
|
|
89
|
+
* @property {number} [vectorDistanceThreshold] - Override of the cosine distance threshold (0..2); a negative value answers `400`. Example: 0.3.
|
|
90
|
+
* @property {number} [maxHits] - Number of top candidates fetched before pagination, from 1. Default: 100. Maximum: 500. Example: 10.
|
|
91
91
|
* @property {boolean} [debug] - When `true`, each returned item gets a `distance` field. Example: false.
|
|
92
92
|
* @description Body for the form-data vector/search endpoint.
|
|
93
93
|
*/
|
|
@@ -113,14 +113,14 @@ type FormDataStatus = 'sent' | 'moderation' | 'approved' | 'banned' | 'deleted';
|
|
|
113
113
|
* @property {number} [parentId] - Identifier of the parent record — the way to fetch replies to one comment. Example: 10.
|
|
114
114
|
* @property {string} [userIdentifier] - Text identifier of the sender; an empty string means "no filter". Example: "admin".
|
|
115
115
|
* @property {FormDataStatus[]} [status] - Moderation statuses to keep. Must be an array — a bare string is rejected with `400`. An empty array means "no filter". Example: ["approved"].
|
|
116
|
-
* @property {string} [dateFrom] - Lower bound of the submission date, `YYYY-MM-DD`; an empty string means "no bound" — `getFormsDataByMarker` strips it from the body, since the endpoint rejects an empty date with a `400`. A non-empty value the API cannot parse still fails the request. Example: "2025-01-01".
|
|
117
|
-
* @property {string} [dateTo] - Upper bound of the submission date, `YYYY-MM-DD`; an empty string means "no bound", handled like `dateFrom`. Example: "2025-12-31".
|
|
116
|
+
* @property {string} [dateFrom] - Lower bound of the submission date, `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`; an empty string means "no bound" — `getFormsDataByMarker` strips it from the body, since the endpoint rejects an empty date with a `400`. A non-empty value the API cannot parse still fails the request. Example: "2025-01-01".
|
|
117
|
+
* @property {string} [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".
|
|
118
118
|
* @description Filter for reading form submissions. Every field is optional and an omitted one is simply not applied.
|
|
119
119
|
*
|
|
120
|
-
* Typed rather than left as `object` on purpose: the API **
|
|
121
|
-
* does not know, so `statuses: ['approved']` (note the "s")
|
|
122
|
-
*
|
|
123
|
-
*
|
|
120
|
+
* Typed rather than left as `object` on purpose: the API **refuses** a field it
|
|
121
|
+
* does not know, so `statuses: ['approved']` (note the "s") answers
|
|
122
|
+
* `400 property statuses should not exist` — the compiler catches the typo
|
|
123
|
+
* before the request does.
|
|
124
124
|
*/
|
|
125
125
|
interface IFormsDataFilter {
|
|
126
126
|
/**
|
|
@@ -225,9 +225,14 @@ interface IFormDataEntity {
|
|
|
225
225
|
"id": 1,
|
|
226
226
|
"formIdentifier": "form",
|
|
227
227
|
"time": "2025-06-06T19:07:45.993Z",
|
|
228
|
-
"formData":
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
"formData": [
|
|
229
|
+
{
|
|
230
|
+
"marker": "name",
|
|
231
|
+
"type": "string",
|
|
232
|
+
"value": "Test"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"attributeSetIdentifier": "form"
|
|
231
236
|
}
|
|
232
237
|
]
|
|
233
238
|
* @property {number} total - Total number of found records. Example: 100.
|
|
@@ -241,13 +246,13 @@ interface IFormsDataEntity {
|
|
|
241
246
|
* Represents the structure of a form data entity.
|
|
242
247
|
* @interface IFormByMarkerDataEntity
|
|
243
248
|
* @property {number} id - ID of the form data record. Example: 12345.
|
|
244
|
-
* @property {null | number} parentId - ID of the parent form data record; `null` for a top-level record. Example: 123.
|
|
249
|
+
* @property {null | number} [parentId] - ID of the parent form data record; `null` for a top-level record. Returned only with `isExtended` = 1. Example: 123.
|
|
245
250
|
* @property {string} formIdentifier - Marker of the form. Example: "contact_form".
|
|
246
|
-
* @property {number} depth - Example: 1.
|
|
247
|
-
* @property {string | null} ip - IP address the form was submitted from. Example: '127.0.0.1'.
|
|
248
|
-
* @property {string | null} fingerprint - Device fingerprint of the sender. Example: 'fingerprint'.
|
|
249
|
-
* @property {string | null} status - Moderation status of the record: "sent", "moderation", "approved", "banned" or "deleted"; `null` when the form does not moderate. Example: 'approved'.
|
|
250
|
-
* @property {string | null} userIdentifier - Text identifier (marker) of the user. Example: "admin".
|
|
251
|
+
* @property {number} [depth] - Nesting depth of the record. Returned only with `isExtended` = 1. Example: 1.
|
|
252
|
+
* @property {string | null} [ip] - IP address the form was submitted from. Not returned by the by-marker list. Example: '127.0.0.1'.
|
|
253
|
+
* @property {string | null} [fingerprint] - Device fingerprint of the sender. Not returned by the by-marker list. Example: 'fingerprint'.
|
|
254
|
+
* @property {string | null} [status] - Moderation status of the record: "sent", "moderation", "approved", "banned" or "deleted"; `null` when the form does not moderate. Returned only with `isExtended` = 1. Example: 'approved'.
|
|
255
|
+
* @property {string | null} [userIdentifier] - Text identifier (marker) of the user. Returned only with `isExtended` = 1. Example: "admin".
|
|
251
256
|
* @property {FormDataType[]} formData - Submitted fields, **already unwrapped from the locale**: the API returns `{ "en_US": [ … ] }` and the SDK hands over the array for the requested `langCode`. Read `formData` directly — `formData[langCode]` is `undefined`.
|
|
252
257
|
* @example
|
|
253
258
|
[
|
|
@@ -260,7 +265,7 @@ interface IFormsDataEntity {
|
|
|
260
265
|
* @property {string | null} attributeSetIdentifier - Marker of the attribute set used by the form. Example: "product_attributes".
|
|
261
266
|
* @property {Date | string} time - Date and time the form data was last changed. Example: "2023-10-01T12:00:00Z".
|
|
262
267
|
* @property {string} entityIdentifier - Marker of the entity the record belongs to. Example: "test".
|
|
263
|
-
* @property {boolean} isUserAdmin - Whether the record was submitted by an admin. Example: true.
|
|
268
|
+
* @property {boolean} [isUserAdmin] - Whether the record was submitted by an admin. Returned only with `isExtended` = 1. Example: true.
|
|
264
269
|
* @property {number} formModuleConfigId - ID of the form module configuration. Example: 2.
|
|
265
270
|
* @property {string} [moduleIdentifier] - Marker of the module. Example: "blog".
|
|
266
271
|
* @property {number} entityId - ID of the entity the record belongs to. Example: 2.
|
|
@@ -287,7 +292,7 @@ interface IFormByMarkerDataEntity {
|
|
|
287
292
|
/**
|
|
288
293
|
* Represents a collection of form data entities.
|
|
289
294
|
* @interface IFormsByMarkerDataEntity
|
|
290
|
-
* @property {IFormByMarkerDataEntity[]} items - Form data records.
|
|
295
|
+
* @property {IFormByMarkerDataEntity[]} items - Form data records. The example shows a record with `isExtended` = 1; without it `parentId`, `depth`, `status`, `userIdentifier` and `isUserAdmin` are not returned.
|
|
291
296
|
* @example
|
|
292
297
|
[
|
|
293
298
|
{
|
|
@@ -295,7 +300,6 @@ interface IFormByMarkerDataEntity {
|
|
|
295
300
|
"parentId": null,
|
|
296
301
|
"formIdentifier": "test-form",
|
|
297
302
|
"depth": 0,
|
|
298
|
-
"ip": null,
|
|
299
303
|
"status": null,
|
|
300
304
|
"userIdentifier": null,
|
|
301
305
|
"formData": [
|
|
@@ -419,7 +423,7 @@ interface IUpdateFormsData {
|
|
|
419
423
|
/**
|
|
420
424
|
* Contains an array of data form objects with the following values
|
|
421
425
|
*/
|
|
422
|
-
type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | Record<string, unknown>;
|
|
426
|
+
type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | IBodyTypeEntity | IBodyTypeTimeInterval | Record<string, unknown>;
|
|
423
427
|
/**
|
|
424
428
|
* Value shapes accepted by a SUBMISSION (`POST /form-data`).
|
|
425
429
|
*
|
|
@@ -588,13 +592,13 @@ interface IBodyPostFormData {
|
|
|
588
592
|
* Represents a form data entity with a simple value.
|
|
589
593
|
* @interface IBodyTypeStringNumberFloat
|
|
590
594
|
* @property {string} marker - marker name. Example: "some_marker".
|
|
591
|
-
* @property {string} type - Type value. "string" | "number" | "float". Example: "string".
|
|
592
|
-
* @property {string | number | null} value - Value of the form data entity.
|
|
595
|
+
* @property {string} type - Type value. "string" | "integer" | "number" | "float". Example: "string".
|
|
596
|
+
* @property {string | number | null} value - Value of the form data entity. A submission may send a number or a string; responses return numeric fields **as strings** — `3` comes back as `"3"`, `2.565` as `"2.565"` — or `null` when the field is empty. Convert with `Number(value)` before arithmetic. Example: "string".
|
|
593
597
|
* @description Represents a form data entity with a marker, type, and value.
|
|
594
598
|
*/
|
|
595
599
|
interface IBodyTypeStringNumberFloat {
|
|
596
600
|
marker: string;
|
|
597
|
-
type: 'string' | 'number' | 'float';
|
|
601
|
+
type: 'string' | 'integer' | 'number' | 'float';
|
|
598
602
|
value: string | number | null;
|
|
599
603
|
}
|
|
600
604
|
/**
|
|
@@ -633,43 +637,46 @@ interface ITimeDateValue {
|
|
|
633
637
|
* @interface IBodyTypeText
|
|
634
638
|
* @property {string} marker - marker name. Example: "some_marker".
|
|
635
639
|
* @property {string} type - Type value. Example: "text".
|
|
636
|
-
* @property {
|
|
640
|
+
* @property {ITextValue | ITextValue[]} value - Text value. A read returns a one-element **array**, without `plainValue` and with `params.editorMode`; older records may hold a single object.
|
|
637
641
|
* @example
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
[
|
|
643
|
+
{
|
|
644
|
+
"htmlValue": "<p>Hello world</p>",
|
|
645
|
+
"params": {
|
|
646
|
+
"isImageCompressed": true,
|
|
647
|
+
"editorMode": "html"
|
|
648
|
+
}
|
|
644
649
|
}
|
|
645
|
-
|
|
646
|
-
* @description Represents a text value with HTML and plain text representations, along with parameters for editor and image compression settings.
|
|
650
|
+
]
|
|
651
|
+
* @description Represents a text value with HTML and plain text representations, along with parameters for editor and image compression settings. To submit a text field use {@link IBodyPostTypeText}.
|
|
647
652
|
*/
|
|
648
653
|
interface IBodyTypeText {
|
|
649
654
|
marker: string;
|
|
650
655
|
type: 'text';
|
|
651
|
-
value: ITextValue;
|
|
656
|
+
value: ITextValue | ITextValue[];
|
|
652
657
|
}
|
|
653
658
|
/**
|
|
654
659
|
* @interface ITextEditorParams
|
|
655
|
-
* @property {boolean} isEditorDisabled - Whether the rich-text editor is disabled. Example: false.
|
|
660
|
+
* @property {boolean} [isEditorDisabled] - Whether the rich-text editor is disabled. Older records only; current reads carry `editorMode` instead. Example: false.
|
|
656
661
|
* @property {boolean} isImageCompressed - Whether embedded images are compressed. Example: true.
|
|
662
|
+
* @property {string} [editorMode] - Editor the value was written in. Example: "html".
|
|
657
663
|
* @description Editor parameters attached to text-type form values.
|
|
658
664
|
*/
|
|
659
665
|
interface ITextEditorParams {
|
|
660
|
-
isEditorDisabled
|
|
666
|
+
isEditorDisabled?: boolean;
|
|
661
667
|
isImageCompressed: boolean;
|
|
668
|
+
editorMode?: string;
|
|
662
669
|
}
|
|
663
670
|
/**
|
|
664
671
|
* @interface ITextValue
|
|
665
672
|
* @property {string} htmlValue - HTML representation of the text. Example: "<p>Hello world</p>".
|
|
666
|
-
* @property {string} plainValue - Plain-text representation.
|
|
673
|
+
* @property {string} [plainValue] - Plain-text representation. Absent from current reads. Example: "Hello world".
|
|
667
674
|
* @property {ITextEditorParams} params - Editor configuration applied to this value.
|
|
668
675
|
* @description Value payload for `text` form fields.
|
|
669
676
|
*/
|
|
670
677
|
interface ITextValue {
|
|
671
678
|
htmlValue: string;
|
|
672
|
-
plainValue
|
|
679
|
+
plainValue?: string;
|
|
673
680
|
params: ITextEditorParams;
|
|
674
681
|
}
|
|
675
682
|
/**
|
|
@@ -677,36 +684,37 @@ interface ITextValue {
|
|
|
677
684
|
* @interface IBodyTypeTextWithHeader
|
|
678
685
|
* @property {string} marker - marker name. Example: "about".
|
|
679
686
|
* @property {string} type - Type value. Example: "textWithHeader".
|
|
680
|
-
* @property {
|
|
687
|
+
* @property {ITextWithHeaderValue | ITextWithHeaderValue[]} value - Text with a header. A read returns a one-element **array**, without `plainValue` and with `params.editorMode`; older records may hold a single object.
|
|
681
688
|
* @example
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
+
[
|
|
690
|
+
{
|
|
691
|
+
"header": "Headline",
|
|
692
|
+
"htmlValue": "<p>Hello World</p>",
|
|
693
|
+
"params": {
|
|
694
|
+
"isImageCompressed": true,
|
|
695
|
+
"editorMode": "html"
|
|
696
|
+
}
|
|
689
697
|
}
|
|
690
|
-
|
|
698
|
+
]
|
|
691
699
|
* @description Represents a text value with a header, HTML and plain text representations, along with parameters for editor and image compression settings.
|
|
692
700
|
*/
|
|
693
701
|
interface IBodyTypeTextWithHeader {
|
|
694
702
|
marker: string;
|
|
695
703
|
type: 'textWithHeader';
|
|
696
|
-
value: ITextWithHeaderValue;
|
|
704
|
+
value: ITextWithHeaderValue | ITextWithHeaderValue[];
|
|
697
705
|
}
|
|
698
706
|
/**
|
|
699
707
|
* @interface ITextWithHeaderValue
|
|
700
708
|
* @property {string} header - Headline text. Example: "Headline".
|
|
701
709
|
* @property {string} htmlValue - HTML body. Example: "<p>Hello world</p>".
|
|
702
|
-
* @property {string} plainValue - Plain-text body.
|
|
710
|
+
* @property {string} [plainValue] - Plain-text body. Absent from current reads. Example: "Hello world".
|
|
703
711
|
* @property {ITextEditorParams} params - Editor configuration applied to this value.
|
|
704
712
|
* @description Value payload for `textWithHeader` form fields.
|
|
705
713
|
*/
|
|
706
714
|
interface ITextWithHeaderValue {
|
|
707
715
|
header: string;
|
|
708
716
|
htmlValue: string;
|
|
709
|
-
plainValue
|
|
717
|
+
plainValue?: string;
|
|
710
718
|
params: ITextEditorParams;
|
|
711
719
|
}
|
|
712
720
|
/**
|
|
@@ -765,7 +773,7 @@ interface IImageValue {
|
|
|
765
773
|
* @interface IBodyTypeFile
|
|
766
774
|
* @property {string} marker - marker name. Example: "picture".
|
|
767
775
|
* @property {'file'} type - Type value. Example: "file".
|
|
768
|
-
* @property {object} value - The attached file. Three shapes are accepted and may be mixed in one array: a `File`/`Blob` (also a `FileList`), which the SDK uploads first; the descriptor `FileUploading.upload` returns for a file **already in storage**, which is passed through as it is; or a hand-built {@link IFileValue}. In a SUBMISSION the value must be an **array** — a lone descriptor or {@link IFileValue} answers `400 formData's marker '<marker>' value must be an array`, while a lone `File`/`Blob` is fine because the SDK wraps the upload result. A READ returns a single attached file
|
|
776
|
+
* @property {object} value - The attached file. Three shapes are accepted and may be mixed in one array: a `File`/`Blob` (also a `FileList`), which the SDK uploads first; the descriptor `FileUploading.upload` returns for a file **already in storage**, which is passed through as it is; or a hand-built {@link IFileValue}. In a SUBMISSION the value must be an **array** — a lone descriptor or {@link IFileValue} answers `400 formData's marker '<marker>' value must be an array`, while a lone `File`/`Blob` is fine because the SDK wraps the upload result. A READ returns the files as an array too — a single attached file is a one-element array.
|
|
769
777
|
* @example
|
|
770
778
|
[
|
|
771
779
|
{
|
|
@@ -800,24 +808,41 @@ interface IFileValue {
|
|
|
800
808
|
* @interface IBodyTypeRadioButtonList
|
|
801
809
|
* @property {string} marker - marker name. Example: "selector".
|
|
802
810
|
* @property {string} type - Type value. Example: 'list'.
|
|
803
|
-
* @property {
|
|
811
|
+
* @property {IListOptionValue[] | string[] | string} value - Chosen option(s). A read of a submission returns the option **values as stored**: `list` — an array of strings (`["1"]`), `radioButton` — one string (`"1"`). The `[{ title, value, extended }]` form is the shape of a page attribute.
|
|
804
812
|
* @example
|
|
805
|
-
[
|
|
806
|
-
|
|
807
|
-
"title": "red",
|
|
808
|
-
"value": "1",
|
|
809
|
-
"extended": {
|
|
810
|
-
"value": "red",
|
|
811
|
-
"type": "string"
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
]
|
|
815
|
-
* @description Represents a list or radio button selection with multiple options, each containing a title, value, and extended information.
|
|
813
|
+
["1"]
|
|
814
|
+
* @description Represents a list or radio button selection. Look the titles up in the form's attribute (`Forms.getFormByMarker`) by the stored value.
|
|
816
815
|
*/
|
|
817
816
|
interface IBodyTypeRadioButtonList {
|
|
818
817
|
marker: string;
|
|
819
818
|
type: 'list' | 'radioButton';
|
|
820
|
-
value: IListOptionValue[];
|
|
819
|
+
value: IListOptionValue[] | string[] | string;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Represents an `entity` form data field — links to other entities.
|
|
823
|
+
* @interface IBodyTypeEntity
|
|
824
|
+
* @property {string} marker - marker name. Example: "related".
|
|
825
|
+
* @property {'entity'} type - Type value. Example: "entity".
|
|
826
|
+
* @property {number[]} value - Identifiers of the linked entities. Example: [2954, 2957].
|
|
827
|
+
* @description A form field that stores links to other entities (for example products) by id.
|
|
828
|
+
*/
|
|
829
|
+
interface IBodyTypeEntity {
|
|
830
|
+
marker: string;
|
|
831
|
+
type: 'entity';
|
|
832
|
+
value: number[];
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Represents a `timeInterval` form data field.
|
|
836
|
+
* @interface IBodyTypeTimeInterval
|
|
837
|
+
* @property {string} marker - marker name. Example: "booking".
|
|
838
|
+
* @property {'timeInterval'} type - Type value. Example: "timeInterval".
|
|
839
|
+
* @property {string[][]} value - Intervals as `[start, end]` pairs of ISO dates. Example: [["2025-02-11T16:00:00.000Z", "2025-02-13T16:00:00.000Z"]].
|
|
840
|
+
* @description A form field that stores one or more time intervals.
|
|
841
|
+
*/
|
|
842
|
+
interface IBodyTypeTimeInterval {
|
|
843
|
+
marker: string;
|
|
844
|
+
type: 'timeInterval';
|
|
845
|
+
value: string[][];
|
|
821
846
|
}
|
|
822
847
|
/**
|
|
823
848
|
* @interface IListOptionExtended
|
|
@@ -841,4 +866,4 @@ interface IListOptionValue {
|
|
|
841
866
|
value: string;
|
|
842
867
|
extended: IListOptionExtended;
|
|
843
868
|
}
|
|
844
|
-
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, };
|
|
869
|
+
export type { FormDataPostType, FormDataStatus, FormDataType, IBodyPostFormData, IBodyPostTypeList, IBodyPostTypeSpam, IBodyPostTypeText, IBodyTypeEntity, IBodyTypeFile, IBodyTypeImageGroupOfImages, IBodyTypeRadioButtonList, IBodyTypeStringNumberFloat, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeTimeDate, IBodyTypeTimeInterval, ICaptchaEvent, ICaptchaValue, IFileValue, IFormByMarkerDataEntity, IFormDataEntity, IFormDataSearchEntity, IFormsByMarkerDataEntity, IFormsData, IFormsDataEntity, IFormsDataFilter, IFormsDataSearchResponse, IFormsDataVectorSearch, IImageValue, IImageValueParams, IListOptionExtended, IListOptionValue, IPostFormResponse, IPostFormResponseData, ITextEditorParams, ITextSubmissionValue, ITextSubmissionValueHtml, ITextSubmissionValueMd, ITextSubmissionValuePlain, ITextValue, ITextWithHeaderValue, ITimeDateValue, IUpdateFormsData, };
|
|
@@ -19,7 +19,7 @@ interface IGeneralTypes {
|
|
|
19
19
|
* Represents a general type entity.
|
|
20
20
|
* @interface IGeneralTypesEntity
|
|
21
21
|
* @property {number} id - ID of the type. Example: 1.
|
|
22
|
-
* @property {BlockType} type - Type name: a `BlockType` value such as `"product"` or `"service"`. Example: "product"
|
|
22
|
+
* @property {BlockType} type - Type name: a `BlockType` value such as `"product"`, `"catalog_page"`, `"product_block"` or `"service"`. Example: "product".
|
|
23
23
|
* @description Represents a general type entity with an identifier and a type.
|
|
24
24
|
*/
|
|
25
25
|
interface IGeneralTypesEntity {
|
package/esm/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ import WsApi from './web-socket/wsApi.js';
|
|
|
34
34
|
export { getAdditionalFields, getAttributeFile, getAttributeFiles, isFileAttribute, isListAttribute, isNumberAttribute, isStringAttribute, } from './base/attributes.js';
|
|
35
35
|
export { expandAttributeTimeIntervals, expandTimeIntervals, isTimeIntervalAttribute, } from './base/timeIntervals.js';
|
|
36
36
|
export type * from './types.js';
|
|
37
|
+
export type { IDefineApi };
|
|
37
38
|
/**
|
|
38
39
|
* IDefineApi interface
|
|
39
40
|
* @interface IDefineApi
|
|
@@ -132,17 +133,17 @@ interface IDefineApi {
|
|
|
132
133
|
* @function defineOneEntry
|
|
133
134
|
* @param {string} url - URl of your project.
|
|
134
135
|
* @param {IConfig} config - Custom configuration settings
|
|
135
|
-
* @param {string}
|
|
136
|
+
* @param {string} config.token - App token of the project. Required: `defineOneEntry` throws without it.
|
|
136
137
|
* @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
|
|
137
138
|
* @param {string} [config.deviceMetadata] - Optional device-metadata string sent as the `x-device-metadata` header instead of the environment-derived fingerprint. Refresh tokens are bound to this header, so a server issuing tokens for a browser (OAuth code exchange) must pass the browser's string (from `getDeviceMetadata()`), or the token will not be refreshable from that browser.
|
|
138
|
-
* @param {string} [config.langCode] - Optional
|
|
139
|
+
* @param {string} [config.langCode] - Optional default language. Default: 'en_US'.
|
|
139
140
|
* @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set it to `true` to save traffic and decide for yourself what data you need: the SDK then skips its follow-up requests, and some results change shape (e.g. `searchPage` returns short `{ id, title }` cards). Default: false.
|
|
140
|
-
* @param {
|
|
141
|
+
* @param {object} [config.auth] - An object with authorization settings.
|
|
141
142
|
* @param {boolean} [config.auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal.
|
|
142
|
-
* @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created.
|
|
143
|
+
* @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created. On the server, also pass the `deviceMetadata` saved with the token: the API binds refresh tokens to it.
|
|
143
144
|
* @param {string} [config.auth.providerMarker] - The marker of the authorization provider.
|
|
144
|
-
* @param {string} [config.auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated.
|
|
145
|
+
* @param {function(string): void} [config.auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated.
|
|
145
146
|
* @returns {IDefineApi} List of methods set.
|
|
146
|
-
* @description Define API.
|
|
147
|
+
* @description Define API. The returned client holds one session (tokens, guest id) shared by all its modules: on a server, create a client per request for user calls — a client shared between requests serves the signed-in user's data to every visitor. `logout` does not change the guest id.
|
|
147
148
|
*/
|
|
148
149
|
export declare function defineOneEntry(url: string, config: IConfig): IDefineApi;
|
package/esm/index.js
CHANGED
|
@@ -33,23 +33,55 @@ import UsersApi from './users/usersApi.js';
|
|
|
33
33
|
import WsApi from './web-socket/wsApi.js';
|
|
34
34
|
export { getAdditionalFields, getAttributeFile, getAttributeFiles, isFileAttribute, isListAttribute, isNumberAttribute, isStringAttribute, } from './base/attributes.js';
|
|
35
35
|
export { expandAttributeTimeIntervals, expandTimeIntervals, isTimeIntervalAttribute, } from './base/timeIntervals.js';
|
|
36
|
+
/**
|
|
37
|
+
* Checks the project URL every request path is appended to.
|
|
38
|
+
* @param {string} raw - The URL as passed, trimmed.
|
|
39
|
+
* @param {string} base - The URL with trailing `/` and `/api/content` removed.
|
|
40
|
+
* @returns {boolean} True for an http(s) origin (optionally with a path) or a same-origin proxy path.
|
|
41
|
+
* @description A backslash is read as `/` by browsers: `/\\evil.example` was a "path" that sent
|
|
42
|
+
* every request — and the app token — to another host. A query or fragment swallowed every
|
|
43
|
+
* path appended to it, and credentials in the URL make `fetch` throw on each call.
|
|
44
|
+
*/
|
|
45
|
+
function _isProjectUrl(raw, base) {
|
|
46
|
+
if (/[\\?#\s]/.test(base)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (raw.startsWith('/')) {
|
|
50
|
+
// `/` and `/api/content` leave an empty base: the site's own origin
|
|
51
|
+
return !raw.startsWith('//') && (base === '' || base.startsWith('/'));
|
|
52
|
+
}
|
|
53
|
+
// `https:evil.example` parses with that host, but a browser resolves it as a path
|
|
54
|
+
if (!/^https?:\/\//i.test(base)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const parsed = new URL(base);
|
|
59
|
+
return ((parsed.protocol === 'http:' || parsed.protocol === 'https:') &&
|
|
60
|
+
!!parsed.hostname &&
|
|
61
|
+
!parsed.username &&
|
|
62
|
+
!parsed.password);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
36
68
|
/**
|
|
37
69
|
* Define API.
|
|
38
70
|
* @function defineOneEntry
|
|
39
71
|
* @param {string} url - URl of your project.
|
|
40
72
|
* @param {IConfig} config - Custom configuration settings
|
|
41
|
-
* @param {string}
|
|
73
|
+
* @param {string} config.token - App token of the project. Required: `defineOneEntry` throws without it.
|
|
42
74
|
* @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
|
|
43
75
|
* @param {string} [config.deviceMetadata] - Optional device-metadata string sent as the `x-device-metadata` header instead of the environment-derived fingerprint. Refresh tokens are bound to this header, so a server issuing tokens for a browser (OAuth code exchange) must pass the browser's string (from `getDeviceMetadata()`), or the token will not be refreshable from that browser.
|
|
44
|
-
* @param {string} [config.langCode] - Optional
|
|
76
|
+
* @param {string} [config.langCode] - Optional default language. Default: 'en_US'.
|
|
45
77
|
* @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set it to `true` to save traffic and decide for yourself what data you need: the SDK then skips its follow-up requests, and some results change shape (e.g. `searchPage` returns short `{ id, title }` cards). Default: false.
|
|
46
|
-
* @param {
|
|
78
|
+
* @param {object} [config.auth] - An object with authorization settings.
|
|
47
79
|
* @param {boolean} [config.auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal.
|
|
48
|
-
* @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created.
|
|
80
|
+
* @param {string} [config.auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created. On the server, also pass the `deviceMetadata` saved with the token: the API binds refresh tokens to it.
|
|
49
81
|
* @param {string} [config.auth.providerMarker] - The marker of the authorization provider.
|
|
50
|
-
* @param {string} [config.auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated.
|
|
82
|
+
* @param {function(string): void} [config.auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated.
|
|
51
83
|
* @returns {IDefineApi} List of methods set.
|
|
52
|
-
* @description Define API.
|
|
84
|
+
* @description Define API. The returned client holds one session (tokens, guest id) shared by all its modules: on a server, create a client per request for user calls — a client shared between requests serves the signed-in user's data to every visitor. `logout` does not change the guest id.
|
|
53
85
|
*/
|
|
54
86
|
export function defineOneEntry(url, config) {
|
|
55
87
|
if (typeof url !== 'string' || url.trim() === '') {
|
|
@@ -64,7 +96,18 @@ export function defineOneEntry(url, config) {
|
|
|
64
96
|
'Pass it via config, e.g. ' +
|
|
65
97
|
'defineOneEntry("https://your-project.oneentry.cloud", { token: "your-app-token" }).');
|
|
66
98
|
}
|
|
67
|
-
|
|
99
|
+
// Trailing slashes and a copied `/api/content` suffix used to double up in every path
|
|
100
|
+
// (`//api/content/…`, `/api/content/api/content/…`) and fail each call with a 404
|
|
101
|
+
const baseUrl = url
|
|
102
|
+
.trim()
|
|
103
|
+
.replace(/\/+$/, '')
|
|
104
|
+
.replace(/\/api\/content$/i, '');
|
|
105
|
+
if (!_isProjectUrl(url.trim(), baseUrl)) {
|
|
106
|
+
throw new Error('OneEntry SDK: project URL must be an http(s) URL without credentials, query or fragment, ' +
|
|
107
|
+
'or a same-origin proxy path starting with "/", e.g. ' +
|
|
108
|
+
'defineOneEntry("https://your-project.oneentry.cloud", { token: "your-app-token" }).');
|
|
109
|
+
}
|
|
110
|
+
const stateModule = new StateModule(baseUrl, config);
|
|
68
111
|
const Admins = new AdminsApi(stateModule);
|
|
69
112
|
const AttributesSets = new AttributesSetsApi(stateModule);
|
|
70
113
|
const AuthProvider = new AuthProviderApi(stateModule);
|
|
@@ -86,11 +86,13 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
|
|
|
86
86
|
* @handleName getICollectionRowsByMarker
|
|
87
87
|
* @param {string} marker - Marker of the collection. Example: "collection1".
|
|
88
88
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
89
|
+
* @param {ICollectionQuery} [userQuery] - Pagination and entity filter, as in `getICollectionRowsById`. Without it the API returns the first 30 records only. Example: `{ limit: 100, offset: 0 }`.
|
|
89
90
|
* @returns {Promise<ICollectionRowsResponce | IError>} Returns CollectionRowEntity object.
|
|
90
91
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
92
|
+
* @description Records of the collection, one page at a time: `limit` defaults to 30 and `total` holds the full count.
|
|
91
93
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollectionRowsByMarker getICollectionRowsByMarker} documentation.
|
|
92
94
|
*/
|
|
93
|
-
getICollectionRowsByMarker(marker: string, langCode?: string): Promise<ICollectionRowsResponce | IError>;
|
|
95
|
+
getICollectionRowsByMarker(marker: string, langCode?: string, userQuery?: ICollectionQuery): Promise<ICollectionRowsResponce | IError>;
|
|
94
96
|
/**
|
|
95
97
|
* Getting one record from the collection.
|
|
96
98
|
* @handleName getICollectionRowByMarkerAndId
|
|
@@ -121,7 +123,7 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
|
|
|
121
123
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
122
124
|
* @returns {Promise<ICollectionRow | IError>} Returns object of type ICollectionRow.
|
|
123
125
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
124
|
-
* @description Create a record in the collection.
|
|
126
|
+
* @description Create a record in the collection. The row is stored under the language key of `formData` when it is wrapped (`{ "en_US": [...] }`), not under `langCode` of the call; the returned `formData` is an array either way.
|
|
125
127
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/createICollectionRow createICollectionRow} documentation.
|
|
126
128
|
*/
|
|
127
129
|
createICollectionRow(marker: string, body: ICollectionFormObject, langCode?: string): Promise<ICollectionRow | IError>;
|
|
@@ -147,7 +149,7 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
|
|
|
147
149
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
148
150
|
* @returns {Promise<ICollectionRow | IError>} Returns object of type ICollectionRow.
|
|
149
151
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
150
|
-
* @description Edit a record in the collection.
|
|
152
|
+
* @description Edit a record in the collection. `formData` **replaces** every field of the row: fields left out of the body are removed, not kept.
|
|
151
153
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/updateICollectionRow updateICollectionRow} documentation.
|
|
152
154
|
*/
|
|
153
155
|
updateICollectionRow(marker: string, id: number, body: {
|
|
@@ -159,10 +161,19 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
|
|
|
159
161
|
* @handleName deleteICollectionRowByMarkerAndId
|
|
160
162
|
* @param {string} marker - Marker of the collection. Example: "collection1".
|
|
161
163
|
* @param {number} id - ID of the collection row. Example: 12.
|
|
162
|
-
* @returns {Promise<boolean | IError>} Returns true
|
|
164
|
+
* @returns {Promise<boolean | IError>} Returns `true` once the row is deleted; a row that is not there (or already deleted) answers IError `404 Row not found`, not `false`. Permission "collections.row.delete" is required.
|
|
163
165
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
164
166
|
* @description Deletion of collection record object
|
|
165
167
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/deleteICollectionRowByMarkerAndId deleteICollectionRowByMarkerAndId} documentation.
|
|
166
168
|
*/
|
|
167
169
|
deleteICollectionRowByMarkerAndId(marker: string, id: number): Promise<boolean | IError>;
|
|
170
|
+
/**
|
|
171
|
+
* Unwraps `formData` of a created or updated row that is still keyed by a language.
|
|
172
|
+
* @param {any} row - The normalized row.
|
|
173
|
+
* @returns {any} The row with `formData` as an array.
|
|
174
|
+
* @description The row is stored under the language key of the body, and the answer
|
|
175
|
+
* keeps that key: `createICollectionRow(…, 'ru_RU')` with `{ en_US: [...] }` returned
|
|
176
|
+
* `formData` as an object, while `ICollectionRow.formData` is an array.
|
|
177
|
+
*/
|
|
178
|
+
private _rowFormDataAsArray;
|
|
168
179
|
}
|
|
@@ -56,7 +56,8 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
56
56
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollectionById getICollectionById} documentation.
|
|
57
57
|
*/
|
|
58
58
|
async getICollectionById(id, langCode = this.state.lang) {
|
|
59
|
-
const result = await this._fetchGet(`/${id}?` +
|
|
59
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?` +
|
|
60
|
+
this._queryParamsToString({ langCode }));
|
|
60
61
|
// Validate response if validation is enabled
|
|
61
62
|
const validated = await this._validateResponse(result, schema('CollectionEntitySchema'));
|
|
62
63
|
return this._normalizeData(validated, langCode);
|
|
@@ -84,7 +85,7 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
84
85
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollectionRowsById getICollectionRowsById} documentation.
|
|
85
86
|
*/
|
|
86
87
|
async getICollectionRowsById(id, langCode = this.state.lang, userQuery) {
|
|
87
|
-
const result = await this._fetchGet(`/${id}/rows?` +
|
|
88
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}/rows?` +
|
|
88
89
|
this._queryParamsToString({
|
|
89
90
|
...this._defaultQuery,
|
|
90
91
|
...userQuery,
|
|
@@ -108,7 +109,7 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
108
109
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/validateICollectionMarker validateICollectionMarker} documentation.
|
|
109
110
|
*/
|
|
110
111
|
async validateICollectionMarker(marker) {
|
|
111
|
-
const result = await this._fetchGet(`/marker-validation/${marker}`);
|
|
112
|
+
const result = await this._fetchGet(`/marker-validation/${this._pathSegment(marker)}`);
|
|
112
113
|
// Validate response if validation is enabled
|
|
113
114
|
const validated = await this._validateResponse(result, schema('CollectionIsValidSchema'));
|
|
114
115
|
return this._normalizeData(validated);
|
|
@@ -118,12 +119,19 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
118
119
|
* @handleName getICollectionRowsByMarker
|
|
119
120
|
* @param {string} marker - Marker of the collection. Example: "collection1".
|
|
120
121
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
122
|
+
* @param {ICollectionQuery} [userQuery] - Pagination and entity filter, as in `getICollectionRowsById`. Without it the API returns the first 30 records only. Example: `{ limit: 100, offset: 0 }`.
|
|
121
123
|
* @returns {Promise<ICollectionRowsResponce | IError>} Returns CollectionRowEntity object.
|
|
122
124
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
125
|
+
* @description Records of the collection, one page at a time: `limit` defaults to 30 and `total` holds the full count.
|
|
123
126
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollectionRowsByMarker getICollectionRowsByMarker} documentation.
|
|
124
127
|
*/
|
|
125
|
-
async getICollectionRowsByMarker(marker, langCode = this.state.lang) {
|
|
126
|
-
const result = await this._fetchGet(`/marker/${marker}/rows
|
|
128
|
+
async getICollectionRowsByMarker(marker, langCode = this.state.lang, userQuery) {
|
|
129
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/rows?` +
|
|
130
|
+
this._queryParamsToString({
|
|
131
|
+
...this._defaultQuery,
|
|
132
|
+
...userQuery,
|
|
133
|
+
langCode,
|
|
134
|
+
}));
|
|
127
135
|
// Validate response if validation is enabled
|
|
128
136
|
const validated = await this._validateResponse(result, schema('CollectionRowsResponseSchema'));
|
|
129
137
|
return this._normalizeData(validated, langCode);
|
|
@@ -139,7 +147,7 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
139
147
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/getICollectionRowByMarkerAndId getICollectionRowByMarkerAndId} documentation.
|
|
140
148
|
*/
|
|
141
149
|
async getICollectionRowByMarkerAndId(marker, id, langCode = this.state.lang) {
|
|
142
|
-
const result = await this._fetchGet(`/marker/${marker}/rows/${id}?langCode=${langCode}`);
|
|
150
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/rows/${this._pathSegment(String(id))}?langCode=${encodeURIComponent(langCode)}`);
|
|
143
151
|
// Validate response if validation is enabled
|
|
144
152
|
const validated = await this._validateResponse(result, schema('CollectionRowSchema'));
|
|
145
153
|
return this._normalizeData(validated, langCode);
|
|
@@ -163,14 +171,14 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
163
171
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
164
172
|
* @returns {Promise<ICollectionRow | IError>} Returns object of type ICollectionRow.
|
|
165
173
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
166
|
-
* @description Create a record in the collection.
|
|
174
|
+
* @description Create a record in the collection. The row is stored under the language key of `formData` when it is wrapped (`{ "en_US": [...] }`), not under `langCode` of the call; the returned `formData` is an array either way.
|
|
167
175
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/createICollectionRow createICollectionRow} documentation.
|
|
168
176
|
*/
|
|
169
177
|
async createICollectionRow(marker, body, langCode = this.state.lang) {
|
|
170
|
-
const response = await this._fetchPost(`/marker/${marker}/rows?langCode=${langCode}`, body);
|
|
178
|
+
const response = await this._fetchPost(`/marker/${this._pathSegment(marker)}/rows?langCode=${encodeURIComponent(langCode)}`, body);
|
|
171
179
|
// Validate response if validation is enabled
|
|
172
180
|
const validated = await this._validateResponse(response, schema('CollectionRowSchema'));
|
|
173
|
-
return this._normalizeData(validated, langCode);
|
|
181
|
+
return this._rowFormDataAsArray(this._normalizeData(validated, langCode));
|
|
174
182
|
}
|
|
175
183
|
/**
|
|
176
184
|
* Edit a record in the collection.
|
|
@@ -194,27 +202,47 @@ export default class IntegrationCollectionsApi extends AsyncModules {
|
|
|
194
202
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
195
203
|
* @returns {Promise<ICollectionRow | IError>} Returns object of type ICollectionRow.
|
|
196
204
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
197
|
-
* @description Edit a record in the collection.
|
|
205
|
+
* @description Edit a record in the collection. `formData` **replaces** every field of the row: fields left out of the body are removed, not kept.
|
|
198
206
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/updateICollectionRow updateICollectionRow} documentation.
|
|
199
207
|
*/
|
|
200
208
|
async updateICollectionRow(marker, id, body, langCode = this.state.lang) {
|
|
201
|
-
const response = await this._fetchPut(`/marker/${marker}/rows/${id}?` +
|
|
209
|
+
const response = await this._fetchPut(`/marker/${this._pathSegment(marker)}/rows/${this._pathSegment(String(id))}?` +
|
|
210
|
+
`langCode=${encodeURIComponent(langCode)}`, body);
|
|
202
211
|
// Validate response if validation is enabled
|
|
203
212
|
const validated = await this._validateResponse(response, schema('CollectionRowSchema'));
|
|
204
|
-
return this._normalizeData(validated, langCode);
|
|
213
|
+
return this._rowFormDataAsArray(this._normalizeData(validated, langCode));
|
|
205
214
|
}
|
|
206
215
|
/**
|
|
207
216
|
* Deletion of collection record object
|
|
208
217
|
* @handleName deleteICollectionRowByMarkerAndId
|
|
209
218
|
* @param {string} marker - Marker of the collection. Example: "collection1".
|
|
210
219
|
* @param {number} id - ID of the collection row. Example: 12.
|
|
211
|
-
* @returns {Promise<boolean | IError>} Returns true
|
|
220
|
+
* @returns {Promise<boolean | IError>} Returns `true` once the row is deleted; a row that is not there (or already deleted) answers IError `404 Row not found`, not `false`. Permission "collections.row.delete" is required.
|
|
212
221
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
213
222
|
* @description Deletion of collection record object
|
|
214
223
|
* @see {@link https://js-sdk.oneentry.cloud/docs/integration-collections/deleteICollectionRowByMarkerAndId deleteICollectionRowByMarkerAndId} documentation.
|
|
215
224
|
*/
|
|
216
225
|
async deleteICollectionRowByMarkerAndId(marker, id) {
|
|
217
|
-
const result = await this._fetchDelete(`/marker/${marker}/rows/${id}`);
|
|
226
|
+
const result = await this._fetchDelete(`/marker/${this._pathSegment(marker)}/rows/${this._pathSegment(String(id))}`);
|
|
218
227
|
return result;
|
|
219
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Unwraps `formData` of a created or updated row that is still keyed by a language.
|
|
231
|
+
* @param {any} row - The normalized row.
|
|
232
|
+
* @returns {any} The row with `formData` as an array.
|
|
233
|
+
* @description The row is stored under the language key of the body, and the answer
|
|
234
|
+
* keeps that key: `createICollectionRow(…, 'ru_RU')` with `{ en_US: [...] }` returned
|
|
235
|
+
* `formData` as an object, while `ICollectionRow.formData` is an array.
|
|
236
|
+
*/
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
+
_rowFormDataAsArray(row) {
|
|
239
|
+
const formData = row === null || row === void 0 ? void 0 : row.formData;
|
|
240
|
+
if (formData && typeof formData === 'object' && !Array.isArray(formData)) {
|
|
241
|
+
const keys = Object.keys(formData);
|
|
242
|
+
if (keys.length === 1 && Array.isArray(formData[keys[0]])) {
|
|
243
|
+
return { ...row, formData: formData[keys[0]] };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return row;
|
|
247
|
+
}
|
|
220
248
|
}
|