oneentry 1.0.159 → 1.0.161
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 +2 -0
- package/changelog.md +56 -1
- package/dist/admins/adminsApi.d.ts +15 -1
- package/dist/admins/adminsApi.js +29 -0
- package/dist/admins/adminsInterfaces.d.ts +37 -1
- package/dist/base/lazySchema.d.ts +15 -0
- package/dist/base/lazySchema.js +20 -0
- package/dist/discounts/discountsApi.d.ts +14 -1
- package/dist/discounts/discountsApi.js +21 -0
- package/dist/discounts/discountsInterfaces.d.ts +27 -1
- package/dist/filters/filtersInterfaces.d.ts +2 -2
- package/dist/filters/filtersSchemas.d.ts +1 -1
- package/dist/filters/filtersSchemas.js +4 -1
- package/dist/forms-data/formsDataApi.d.ts +14 -1
- package/dist/forms-data/formsDataApi.js +21 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/orders/ordersApi.d.ts +15 -1
- package/dist/orders/ordersApi.js +22 -0
- package/dist/orders/ordersInterfaces.d.ts +27 -1
- package/dist/pages/pagesApi.d.ts +14 -1
- package/dist/pages/pagesApi.js +21 -0
- package/dist/pages/pagesInterfaces.d.ts +38 -1
- package/dist/payments/paymentsInterfaces.d.ts +2 -2
- package/dist/products/productsInterfaces.d.ts +1 -1
- package/dist/search/searchApi.d.ts +35 -0
- package/dist/search/searchApi.js +86 -0
- package/dist/search/searchInterfaces.d.ts +94 -0
- package/dist/search/searchInterfaces.js +2 -0
- package/dist/search/searchSchemas.d.ts +73 -0
- package/dist/search/searchSchemas.js +44 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.js +2 -0
- package/dist/users/usersApi.d.ts +15 -1
- package/dist/users/usersApi.js +22 -0
- package/dist/users/usersInterfaces.d.ts +39 -1
- package/dist/web-socket/lazySocket.d.ts +18 -0
- package/dist/web-socket/lazySocket.js +70 -0
- package/esm/admins/adminsApi.d.ts +66 -0
- package/esm/admins/adminsApi.js +90 -0
- package/esm/admins/adminsInterfaces.d.ts +137 -0
- package/esm/admins/adminsInterfaces.js +1 -0
- package/esm/admins/adminsSchemas.d.ts +48 -0
- package/esm/admins/adminsSchemas.js +31 -0
- package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
- package/esm/attribute-sets/attributeSetsApi.js +97 -0
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
- package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
- package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
- package/esm/auth-provider/authProviderApi.d.ts +262 -0
- package/esm/auth-provider/authProviderApi.js +362 -0
- package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
- package/esm/auth-provider/authProviderSchemas.js +92 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
- package/esm/auth-provider/authProvidersInterfaces.js +1 -0
- package/esm/base/asyncModules.d.ts +123 -0
- package/esm/base/asyncModules.js +382 -0
- package/esm/base/lazySchema.d.ts +15 -0
- package/esm/base/lazySchema.js +17 -0
- package/esm/base/stateModule.d.ts +35 -0
- package/esm/base/stateModule.js +51 -0
- package/esm/base/syncModules.d.ts +245 -0
- package/esm/base/syncModules.js +555 -0
- package/esm/base/timeIntervals.d.ts +95 -0
- package/esm/base/timeIntervals.js +317 -0
- package/esm/base/utils.d.ts +354 -0
- package/esm/base/utils.js +1 -0
- package/esm/base/validation.d.ts +98 -0
- package/esm/base/validation.js +118 -0
- package/esm/blocks/blocksApi.d.ts +252 -0
- package/esm/blocks/blocksApi.js +394 -0
- package/esm/blocks/blocksInterfaces.d.ts +361 -0
- package/esm/blocks/blocksInterfaces.js +1 -0
- package/esm/blocks/blocksSchemas.d.ts +213 -0
- package/esm/blocks/blocksSchemas.js +40 -0
- package/esm/discounts/discountsApi.d.ts +94 -0
- package/esm/discounts/discountsApi.js +136 -0
- package/esm/discounts/discountsInterfaces.d.ts +293 -0
- package/esm/discounts/discountsInterfaces.js +1 -0
- package/esm/events/eventsApi.d.ts +108 -0
- package/esm/events/eventsApi.js +141 -0
- package/esm/events/eventsInterfaces.d.ts +176 -0
- package/esm/events/eventsInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
- package/esm/file-uploading/fileUploadingApi.js +127 -0
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
- package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
- package/esm/file-uploading/fileUploadingSchemas.js +19 -0
- package/esm/filters/filtersApi.d.ts +32 -0
- package/esm/filters/filtersApi.js +36 -0
- package/esm/filters/filtersInterfaces.d.ts +56 -0
- package/esm/filters/filtersInterfaces.js +1 -0
- package/esm/filters/filtersSchemas.d.ts +32 -0
- package/esm/filters/filtersSchemas.js +29 -0
- package/esm/forms/formsApi.d.ts +44 -0
- package/esm/forms/formsApi.js +54 -0
- package/esm/forms/formsInterfaces.d.ts +237 -0
- package/esm/forms/formsInterfaces.js +1 -0
- package/esm/forms/formsSchemas.d.ts +56 -0
- package/esm/forms/formsSchemas.js +32 -0
- package/esm/forms-data/formsDataApi.d.ts +124 -0
- package/esm/forms-data/formsDataApi.js +210 -0
- package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
- package/esm/forms-data/formsDataInterfaces.js +1 -0
- package/esm/forms-data/formsDataSchemas.d.ts +107 -0
- package/esm/forms-data/formsDataSchemas.js +83 -0
- package/esm/general-types/generalTypesApi.d.ts +29 -0
- package/esm/general-types/generalTypesApi.js +34 -0
- package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
- package/esm/general-types/generalTypesInterfaces.js +1 -0
- package/esm/general-types/generalTypesSchemas.d.ts +68 -0
- package/esm/general-types/generalTypesSchemas.js +42 -0
- package/esm/index.d.ts +143 -0
- package/esm/index.js +124 -0
- package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
- package/esm/integration-collections/integrationCollectionsApi.js +224 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
- package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
- package/esm/locales/localesApi.d.ts +28 -0
- package/esm/locales/localesApi.js +33 -0
- package/esm/locales/localesInterfaces.d.ts +40 -0
- package/esm/locales/localesInterfaces.js +1 -0
- package/esm/locales/localesSchemas.d.ts +32 -0
- package/esm/locales/localesSchemas.js +23 -0
- package/esm/menus/menusApi.d.ts +30 -0
- package/esm/menus/menusApi.js +35 -0
- package/esm/menus/menusInterfaces.d.ts +87 -0
- package/esm/menus/menusInterfaces.js +2 -0
- package/esm/menus/menusSchemas.d.ts +16 -0
- package/esm/menus/menusSchemas.js +25 -0
- package/esm/orders/ordersApi.d.ts +213 -0
- package/esm/orders/ordersApi.js +288 -0
- package/esm/orders/ordersInterfaces.d.ts +763 -0
- package/esm/orders/ordersInterfaces.js +1 -0
- package/esm/orders/ordersSchemas.d.ts +312 -0
- package/esm/orders/ordersSchemas.js +171 -0
- package/esm/package.json +4 -0
- package/esm/pages/pagesApi.d.ts +173 -0
- package/esm/pages/pagesApi.js +414 -0
- package/esm/pages/pagesInterfaces.d.ts +344 -0
- package/esm/pages/pagesInterfaces.js +1 -0
- package/esm/pages/pagesSchemas.d.ts +121 -0
- package/esm/pages/pagesSchemas.js +60 -0
- package/esm/payments/paymentsApi.d.ts +88 -0
- package/esm/payments/paymentsApi.js +122 -0
- package/esm/payments/paymentsInterfaces.d.ts +189 -0
- package/esm/payments/paymentsInterfaces.js +1 -0
- package/esm/payments/paymentsSchemas.d.ts +94 -0
- package/esm/payments/paymentsSchemas.js +53 -0
- package/esm/product-statuses/productStatusesApi.d.ts +50 -0
- package/esm/product-statuses/productStatusesApi.js +68 -0
- package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/esm/product-statuses/productStatusesInterfaces.js +1 -0
- package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/esm/product-statuses/productStatusesSchemas.js +27 -0
- package/esm/products/productsApi.d.ts +366 -0
- package/esm/products/productsApi.js +468 -0
- package/esm/products/productsInterfaces.d.ts +723 -0
- package/esm/products/productsInterfaces.js +1 -0
- package/esm/products/productsSchemas.d.ts +234 -0
- package/esm/products/productsSchemas.js +121 -0
- package/esm/search/searchApi.d.ts +35 -0
- package/esm/search/searchApi.js +47 -0
- package/esm/search/searchInterfaces.d.ts +94 -0
- package/esm/search/searchInterfaces.js +1 -0
- package/esm/search/searchSchemas.d.ts +73 -0
- package/esm/search/searchSchemas.js +41 -0
- package/esm/sitemap/sitemapApi.d.ts +37 -0
- package/esm/sitemap/sitemapApi.js +41 -0
- package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
- package/esm/sitemap/sitemapInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
- package/esm/subscriptions/subscriptionsApi.js +90 -0
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
- package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
- package/esm/subscriptions/subscriptionsSchemas.js +38 -0
- package/esm/system/systemApi.d.ts +46 -0
- package/esm/system/systemApi.js +53 -0
- package/esm/system/systemInterfaces.d.ts +29 -0
- package/esm/system/systemInterfaces.js +1 -0
- package/esm/templates/templatesApi.d.ts +53 -0
- package/esm/templates/templatesApi.js +78 -0
- package/esm/templates/templatesInterfaces.d.ts +68 -0
- package/esm/templates/templatesInterfaces.js +1 -0
- package/esm/templates/templatesSchemas.d.ts +48 -0
- package/esm/templates/templatesSchemas.js +28 -0
- package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
- package/esm/templates-preview/templatesPreviewApi.js +50 -0
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
- package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
- package/esm/types.d.ts +35 -0
- package/esm/types.js +1 -0
- package/esm/user-activity/userActivityApi.d.ts +31 -0
- package/esm/user-activity/userActivityApi.js +37 -0
- package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
- package/esm/user-activity/userActivityInterfaces.js +1 -0
- package/esm/users/usersApi.d.ts +249 -0
- package/esm/users/usersApi.js +312 -0
- package/esm/users/usersInterfaces.d.ts +419 -0
- package/esm/users/usersInterfaces.js +1 -0
- package/esm/users/usersSchemas.d.ts +72 -0
- package/esm/users/usersSchemas.js +55 -0
- package/esm/web-socket/lazySocket.d.ts +18 -0
- package/esm/web-socket/lazySocket.js +67 -0
- package/esm/web-socket/wsApi.d.ts +27 -0
- package/esm/web-socket/wsApi.js +43 -0
- package/esm/web-socket/wsInterfaces.d.ts +16 -0
- package/esm/web-socket/wsInterfaces.js +1 -0
- package/package.json +47 -2
- package/types.d.ts +1 -0
- package/types.js +1 -0
package/dist/users/usersApi.js
CHANGED
|
@@ -325,5 +325,27 @@ class UsersApi extends asyncModules_1.default {
|
|
|
325
325
|
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
326
326
|
return this._normalizeData(validated);
|
|
327
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Semantic (vector) search for users.
|
|
330
|
+
* @handleName getUsersByVectorSearch
|
|
331
|
+
* @param {IUsersVectorSearch} body - Vector search body. Example: `{ queryText: "john" }`.
|
|
332
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
333
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
334
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
335
|
+
* @returns {Promise<IUsersResponse | IError>} Returns an object with an array of found users and total count.
|
|
336
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
337
|
+
* @description This method performs a semantic (vector) search for users. It requires user authorization.
|
|
338
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
339
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getUsersByVectorSearch getUsersByVectorSearch} documentation.
|
|
340
|
+
*/
|
|
341
|
+
async getUsersByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
342
|
+
const query = {
|
|
343
|
+
langCode,
|
|
344
|
+
offset,
|
|
345
|
+
limit,
|
|
346
|
+
};
|
|
347
|
+
const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
|
|
348
|
+
return this._normalizeData(result, langCode);
|
|
349
|
+
}
|
|
328
350
|
}
|
|
329
351
|
exports.default = UsersApi;
|
|
@@ -210,6 +210,44 @@ interface IUsersApi {
|
|
|
210
210
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
211
211
|
*/
|
|
212
212
|
removeWishlistItem(productId: number): Promise<IWishlistResponse | IError>;
|
|
213
|
+
/**
|
|
214
|
+
* Semantic (vector) search for users.
|
|
215
|
+
* @handleName getUsersByVectorSearch
|
|
216
|
+
* @param {IUsersVectorSearch} body - Vector search body. Example: `{ queryText: "john" }`.
|
|
217
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
218
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
219
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
220
|
+
* @returns {Promise<IUsersResponse | IError>} A promise resolving to a users response (items + total), or an error.
|
|
221
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
222
|
+
* @description This method performs a semantic (vector) search for users. It requires user authorization.
|
|
223
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
224
|
+
*/
|
|
225
|
+
getUsersByVectorSearch(body: IUsersVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IUsersResponse | IError>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Body for semantic (vector) user search.
|
|
229
|
+
* @interface IUsersVectorSearch
|
|
230
|
+
* @property {string} queryText - Natural-language search query. Example: "john".
|
|
231
|
+
* @property {number} [vectorDistanceThreshold] - Override of the cosine distance threshold (0..2). Example: 0.3.
|
|
232
|
+
* @property {number} [maxHits] - Top-K candidates fetched before pagination. Default: 100. Max: 500. Example: 10.
|
|
233
|
+
* @property {boolean} [debug] - When true, each returned item gets a `distance` field. Example: false.
|
|
234
|
+
* @description Body for the users vector/search endpoint.
|
|
235
|
+
*/
|
|
236
|
+
interface IUsersVectorSearch {
|
|
237
|
+
queryText: string;
|
|
238
|
+
vectorDistanceThreshold?: number;
|
|
239
|
+
maxHits?: number;
|
|
240
|
+
debug?: boolean;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @interface IUsersResponse
|
|
244
|
+
* @property {IUserEntity[]} items - Array of found user objects.
|
|
245
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
246
|
+
* @description This interface defines the structure of a response containing multiple user entities, including the total count and an array of user items.
|
|
247
|
+
*/
|
|
248
|
+
interface IUsersResponse {
|
|
249
|
+
items: IUserEntity[];
|
|
250
|
+
total: number;
|
|
213
251
|
}
|
|
214
252
|
/**
|
|
215
253
|
* @interface IUserEntity
|
|
@@ -378,4 +416,4 @@ interface IWishlistSet {
|
|
|
378
416
|
interface IWishlistAddItem {
|
|
379
417
|
productId: number;
|
|
380
418
|
}
|
|
381
|
-
export type { ICartAddItem, ICartItem, ICartResponse, ICartSet, IUserBody, IUserEntity, IUsersApi, IWishlistAddItem, IWishlistItem, IWishlistResponse, IWishlistSet, };
|
|
419
|
+
export type { ICartAddItem, ICartItem, ICartResponse, ICartSet, IUserBody, IUserEntity, IUsersApi, IUsersResponse, IUsersVectorSearch, IWishlistAddItem, IWishlistItem, IWishlistResponse, IWishlistSet, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Socket } from 'socket.io-client';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a not-yet-loaded Socket.io socket in a synchronous stand-in.
|
|
4
|
+
*
|
|
5
|
+
* `WS.connect()` is synchronous and returns a `Socket`, so `socket.io-client` would have to
|
|
6
|
+
* be imported statically — putting ~41 kB into every bundle, including those that never open
|
|
7
|
+
* a socket. This keeps the signature by returning a proxy immediately: calls made on it are
|
|
8
|
+
* queued and replayed onto the real socket as soon as the chunk resolves, and every later
|
|
9
|
+
* call passes straight through.
|
|
10
|
+
* @param {() => Promise<Socket>} createSocket - Loads Socket.io and creates the socket.
|
|
11
|
+
* @returns {Socket} Stand-in usable exactly like the socket it will become.
|
|
12
|
+
* @description Listener registration is what matters for ordering, and it is safe: the queue is
|
|
13
|
+
* replayed in the same tick the socket is created, before the connection can deliver anything.
|
|
14
|
+
* The one visible difference is that methods returning a value (e.g. `listeners()`) cannot answer
|
|
15
|
+
* before the chunk arrives — they return the proxy instead. Reading state (`id`, `connected`, …)
|
|
16
|
+
* is accurate, and awaiting `socket.io` or other nested objects is only possible once loaded.
|
|
17
|
+
*/
|
|
18
|
+
export default function createLazySocket(createSocket: () => Promise<Socket>): Socket;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = createLazySocket;
|
|
4
|
+
/**
|
|
5
|
+
* Properties readable before the real socket exists.
|
|
6
|
+
* @description Their values match what Socket.io itself reports for a socket that
|
|
7
|
+
* has been created but has not connected yet, so reading them early is not a lie.
|
|
8
|
+
*/
|
|
9
|
+
const PENDING_STATE = {
|
|
10
|
+
id: undefined,
|
|
11
|
+
connected: false,
|
|
12
|
+
disconnected: true,
|
|
13
|
+
active: false,
|
|
14
|
+
recovered: false,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wraps a not-yet-loaded Socket.io socket in a synchronous stand-in.
|
|
18
|
+
*
|
|
19
|
+
* `WS.connect()` is synchronous and returns a `Socket`, so `socket.io-client` would have to
|
|
20
|
+
* be imported statically — putting ~41 kB into every bundle, including those that never open
|
|
21
|
+
* a socket. This keeps the signature by returning a proxy immediately: calls made on it are
|
|
22
|
+
* queued and replayed onto the real socket as soon as the chunk resolves, and every later
|
|
23
|
+
* call passes straight through.
|
|
24
|
+
* @param {() => Promise<Socket>} createSocket - Loads Socket.io and creates the socket.
|
|
25
|
+
* @returns {Socket} Stand-in usable exactly like the socket it will become.
|
|
26
|
+
* @description Listener registration is what matters for ordering, and it is safe: the queue is
|
|
27
|
+
* replayed in the same tick the socket is created, before the connection can deliver anything.
|
|
28
|
+
* The one visible difference is that methods returning a value (e.g. `listeners()`) cannot answer
|
|
29
|
+
* before the chunk arrives — they return the proxy instead. Reading state (`id`, `connected`, …)
|
|
30
|
+
* is accurate, and awaiting `socket.io` or other nested objects is only possible once loaded.
|
|
31
|
+
*/
|
|
32
|
+
function createLazySocket(createSocket) {
|
|
33
|
+
let socket;
|
|
34
|
+
const queued = [];
|
|
35
|
+
const loading = createSocket().then((created) => {
|
|
36
|
+
// Replay before returning: the connection cannot emit anything until this tick ends,
|
|
37
|
+
// so no event registered through the proxy can be missed.
|
|
38
|
+
for (const { method, args } of queued) {
|
|
39
|
+
created[method](...args);
|
|
40
|
+
}
|
|
41
|
+
queued.length = 0;
|
|
42
|
+
socket = created;
|
|
43
|
+
return created;
|
|
44
|
+
});
|
|
45
|
+
// A failed chunk load must not surface as an unhandled rejection
|
|
46
|
+
loading.catch((error) => {
|
|
47
|
+
// eslint-disable-next-line no-undef, no-console
|
|
48
|
+
console.error('OneEntry SDK: failed to load socket.io-client', error);
|
|
49
|
+
});
|
|
50
|
+
const proxy = new Proxy({}, {
|
|
51
|
+
get(_target, property) {
|
|
52
|
+
if (socket) {
|
|
53
|
+
const value = socket[property];
|
|
54
|
+
return typeof value === 'function' ? value.bind(socket) : value;
|
|
55
|
+
}
|
|
56
|
+
// Never look thenable: returning a function for `then` would make `await socket` hang
|
|
57
|
+
if (property === 'then' || typeof property === 'symbol') {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (property in PENDING_STATE) {
|
|
61
|
+
return PENDING_STATE[property];
|
|
62
|
+
}
|
|
63
|
+
return (...args) => {
|
|
64
|
+
queued.push({ method: property, args });
|
|
65
|
+
return proxy;
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return proxy;
|
|
70
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { IFilterParams } from '../products/productsInterfaces.js';
|
|
5
|
+
import type { IAdminEntity, IAdmins, IAdminsResponse, IAdminsVectorSearch } from './adminsInterfaces.js';
|
|
6
|
+
/**
|
|
7
|
+
* Controllers for working with users - admins.
|
|
8
|
+
* @class AdminsApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {IAdmins}
|
|
11
|
+
* @description This module provides methods for working with users - admins, including retrieving information about all admins.
|
|
12
|
+
*/
|
|
13
|
+
export default class AdminsApi extends AsyncModules implements IAdmins {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
private _adminsUrl;
|
|
17
|
+
/**
|
|
18
|
+
* Initializes the AdminsApi with the provided state module.
|
|
19
|
+
* @class
|
|
20
|
+
* @class AdminsApi
|
|
21
|
+
* @param {StateModule} state - The state module containing configuration data.
|
|
22
|
+
* @description Constructor initializes the AdminsApi with a given state.
|
|
23
|
+
*/
|
|
24
|
+
constructor(state: StateModule);
|
|
25
|
+
/**
|
|
26
|
+
* Get all admins objects with filters.
|
|
27
|
+
* @handleName getAdminsInfo
|
|
28
|
+
* @param {IFilterParams[]} [body] - Array of filter objects with search conditions. Default: [].
|
|
29
|
+
* @example
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"attributeMarker": "num",
|
|
33
|
+
"conditionMarker": "mth",
|
|
34
|
+
"conditionValue": 1
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"attributeMarker": "num",
|
|
38
|
+
"conditionMarker": "lth",
|
|
39
|
+
"conditionValue": 3
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
43
|
+
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
44
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
45
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
46
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
47
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
48
|
+
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
49
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
50
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
51
|
+
*/
|
|
52
|
+
getAdminsInfo(body?: IFilterParams[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
|
|
53
|
+
/**
|
|
54
|
+
* Semantic (vector) search for admins.
|
|
55
|
+
* @handleName getAdminsByVectorSearch
|
|
56
|
+
* @param {IAdminsVectorSearch} body - Vector search body. Example: `{ queryText: "content manager" }`.
|
|
57
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
58
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
59
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
60
|
+
* @returns {Promise<IAdminsResponse | IError>} Returns an object with an array of found admins and total count.
|
|
61
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
62
|
+
* @description This method performs a semantic (vector) search for admins.
|
|
63
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsByVectorSearch getAdminsByVectorSearch} documentation.
|
|
64
|
+
*/
|
|
65
|
+
getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IAdminsResponse | IError>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import createSchemaLoader from '../base/lazySchema.js';
|
|
3
|
+
const schema = createSchemaLoader(() => import('./adminsSchemas.js'));
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with users - admins.
|
|
6
|
+
* @class AdminsApi
|
|
7
|
+
* @augments AsyncModules
|
|
8
|
+
* @implements {IAdmins}
|
|
9
|
+
* @description This module provides methods for working with users - admins, including retrieving information about all admins.
|
|
10
|
+
*/
|
|
11
|
+
export default class AdminsApi extends AsyncModules {
|
|
12
|
+
/**
|
|
13
|
+
* Initializes the AdminsApi with the provided state module.
|
|
14
|
+
* @class
|
|
15
|
+
* @class AdminsApi
|
|
16
|
+
* @param {StateModule} state - The state module containing configuration data.
|
|
17
|
+
* @description Constructor initializes the AdminsApi with a given state.
|
|
18
|
+
*/
|
|
19
|
+
constructor(state) {
|
|
20
|
+
super(state);
|
|
21
|
+
this._url = state.url + '/api/content/admins/all';
|
|
22
|
+
this._adminsUrl = state.url + '/api/content/admins';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all admins objects with filters.
|
|
26
|
+
* @handleName getAdminsInfo
|
|
27
|
+
* @param {IFilterParams[]} [body] - Array of filter objects with search conditions. Default: [].
|
|
28
|
+
* @example
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
"attributeMarker": "num",
|
|
32
|
+
"conditionMarker": "mth",
|
|
33
|
+
"conditionValue": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"attributeMarker": "num",
|
|
37
|
+
"conditionMarker": "lth",
|
|
38
|
+
"conditionValue": 3
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
42
|
+
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
43
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
44
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
45
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
46
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
47
|
+
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
48
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
49
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
50
|
+
*/
|
|
51
|
+
async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
|
|
52
|
+
const query = {
|
|
53
|
+
langCode,
|
|
54
|
+
offset,
|
|
55
|
+
limit,
|
|
56
|
+
};
|
|
57
|
+
const response = await this._fetchPost(`?` + this._queryParamsToString(query), body);
|
|
58
|
+
// Validate response if validation is enabled
|
|
59
|
+
const validated = await this._validateResponse(response, schema('AdminsResponseSchema'));
|
|
60
|
+
return this._normalizeData(validated, langCode);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Semantic (vector) search for admins.
|
|
64
|
+
* @handleName getAdminsByVectorSearch
|
|
65
|
+
* @param {IAdminsVectorSearch} body - Vector search body. Example: `{ queryText: "content manager" }`.
|
|
66
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
67
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
68
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
69
|
+
* @returns {Promise<IAdminsResponse | IError>} Returns an object with an array of found admins and total count.
|
|
70
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
71
|
+
* @description This method performs a semantic (vector) search for admins.
|
|
72
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsByVectorSearch getAdminsByVectorSearch} documentation.
|
|
73
|
+
*/
|
|
74
|
+
async getAdminsByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
75
|
+
const query = {
|
|
76
|
+
langCode,
|
|
77
|
+
offset,
|
|
78
|
+
limit,
|
|
79
|
+
};
|
|
80
|
+
const savedUrl = this._url;
|
|
81
|
+
this._url = this._adminsUrl;
|
|
82
|
+
try {
|
|
83
|
+
const response = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
|
|
84
|
+
return this._normalizeData(response, langCode);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
this._url = savedUrl;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { IAttributeValues, IError } from '../base/utils.js';
|
|
2
|
+
import type { IFormConfig } from '../forms/formsInterfaces.js';
|
|
3
|
+
import type { IFilterParams } from '../products/productsInterfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* @interface IAdmins
|
|
6
|
+
* @description This interface defines the contract for any class that implements it
|
|
7
|
+
*/
|
|
8
|
+
interface IAdmins {
|
|
9
|
+
/**
|
|
10
|
+
* Get all admins objects with filters.
|
|
11
|
+
* @handleName getAdminsInfo
|
|
12
|
+
* @param {IFilterParams[]} [body] - Array of filter objects with search conditions. Default: [].
|
|
13
|
+
* @example
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
"attributeMarker": "num",
|
|
17
|
+
"conditionMarker": "mth",
|
|
18
|
+
"conditionValue": 1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"attributeMarker": "num",
|
|
22
|
+
"conditionMarker": "lth",
|
|
23
|
+
"conditionValue": 3
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
27
|
+
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
28
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
29
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
30
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
31
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
32
|
+
* @returns {IAdminEntity[]} Returns an array of admin objects.
|
|
33
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
34
|
+
*/
|
|
35
|
+
getAdminsInfo(body?: IFilterParams[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
|
|
36
|
+
/**
|
|
37
|
+
* Semantic (vector) search for admins.
|
|
38
|
+
* @handleName getAdminsByVectorSearch
|
|
39
|
+
* @param {IAdminsVectorSearch} body - Vector search body. Example: `{ queryText: "content manager" }`.
|
|
40
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
41
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
42
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
43
|
+
* @returns {IAdminsResponse} Returns an object with an array of found admins and total count.
|
|
44
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
45
|
+
*/
|
|
46
|
+
getAdminsByVectorSearch(body: IAdminsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IAdminsResponse | IError>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Body for semantic (vector) admin search.
|
|
50
|
+
* @interface IAdminsVectorSearch
|
|
51
|
+
* @property {string} queryText - Natural-language search query. Example: "content manager".
|
|
52
|
+
* @property {number} [vectorDistanceThreshold] - Override of the cosine distance threshold (0..2). Example: 0.3.
|
|
53
|
+
* @property {number} [maxHits] - Top-K candidates fetched before pagination. Default: 100. Max: 500. Example: 10.
|
|
54
|
+
* @property {boolean} [debug] - When true, each returned item gets a `distance` field. Example: false.
|
|
55
|
+
* @description Body for the admins vector/search endpoint.
|
|
56
|
+
*/
|
|
57
|
+
interface IAdminsVectorSearch {
|
|
58
|
+
queryText: string;
|
|
59
|
+
vectorDistanceThreshold?: number;
|
|
60
|
+
maxHits?: number;
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @interface IAdminsResponse
|
|
65
|
+
* @property {IAdminEntity[]} items - Array of found admin objects.
|
|
66
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
67
|
+
* @description This interface defines the structure of a response containing multiple admin entities, including the total count and an array of admin items.
|
|
68
|
+
*/
|
|
69
|
+
interface IAdminsResponse {
|
|
70
|
+
items: IAdminEntity[];
|
|
71
|
+
total: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Interface representing a Position entity.
|
|
75
|
+
* @interface IPosition
|
|
76
|
+
* @property {number} id - The unique identifier of the position. Example: 1764.
|
|
77
|
+
* @property {boolean} [isLocked] - Indicates whether the position is locked or not. Example: false.
|
|
78
|
+
* @property {number} objectId - The unique identifier of the object. Example: 120.
|
|
79
|
+
* @property {number} [objectCategoryId] - The unique identifier of the object's category. Example: 5.
|
|
80
|
+
* @property {string} objectType - The type of the object. Example: "admin".
|
|
81
|
+
* @property {number} position - The position of the object. Example: 192.
|
|
82
|
+
* @description This interface outlines the properties associated with a position within a system.
|
|
83
|
+
*/
|
|
84
|
+
interface IPosition {
|
|
85
|
+
id: number;
|
|
86
|
+
isLocked?: boolean;
|
|
87
|
+
objectId: number;
|
|
88
|
+
objectCategoryId?: number;
|
|
89
|
+
objectType: string;
|
|
90
|
+
position: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Interface representing an Admin Entity.
|
|
94
|
+
* @interface IAdminEntity
|
|
95
|
+
* @property {number} id - The identifier of the object. Example: 1764.
|
|
96
|
+
* @property {number | null} attributeSetId - The identifier of the attribute set being used. Example: 120.
|
|
97
|
+
* @property {string} identifier - The textual identifier for the record field. Example: "admin1".
|
|
98
|
+
* @property {string | null} attributeSetIdentifier - The identifier of the attribute set. Example: "admins".
|
|
99
|
+
* @property {number | null} position - Position number (for sorting). Example: 1.
|
|
100
|
+
* @property {boolean} isSync - Page indexing flag (true or false). Example: true.
|
|
101
|
+
* @property {IAttributeValues} attributeValues - Array of attribute values from the index (presented as a pair of user attribute identifier: attribute value).
|
|
102
|
+
* @example
|
|
103
|
+
[
|
|
104
|
+
{
|
|
105
|
+
"marker": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"value": "Some value"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
* @property {IFormConfig[]} [moduleFormConfigs] - Array of module form configurations associated with the admin.
|
|
112
|
+
* @description This interface captures the essential details and additional attributes of an admin entity.
|
|
113
|
+
*/
|
|
114
|
+
interface IAdminEntity {
|
|
115
|
+
id: number;
|
|
116
|
+
attributeSetId: number | null;
|
|
117
|
+
identifier: string;
|
|
118
|
+
attributeSetIdentifier: string | null;
|
|
119
|
+
position: number | null;
|
|
120
|
+
isSync: boolean;
|
|
121
|
+
attributeValues: IAttributeValues;
|
|
122
|
+
moduleFormConfigs?: IFormConfig[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Interface representing a query for fetching admin data.
|
|
126
|
+
* @interface IAdminQuery
|
|
127
|
+
* @property {string} langCode - Language code. Default: "en_US".
|
|
128
|
+
* @property {number} limit - Parameter for pagination. Default: 30.
|
|
129
|
+
* @property {number} offset - Parameter for pagination. Default: 0.
|
|
130
|
+
* @description This interface defines the parameters required for querying admin data, including optional defaults.
|
|
131
|
+
*/
|
|
132
|
+
interface IAdminQuery {
|
|
133
|
+
langCode: string;
|
|
134
|
+
limit: number;
|
|
135
|
+
offset: number;
|
|
136
|
+
}
|
|
137
|
+
export type { IAdminEntity, IAdminQuery, IAdmins, IAdminsResponse, IAdminsVectorSearch, IPosition, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for Admins module
|
|
3
|
+
* @description Zod schemas for validating admins-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const AdminEntitySchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodNumber;
|
|
8
|
+
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
9
|
+
identifier: z.ZodString;
|
|
10
|
+
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
11
|
+
position: z.ZodNullable<z.ZodNumber>;
|
|
12
|
+
isSync: z.ZodBoolean;
|
|
13
|
+
attributeValues: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodType<{
|
|
14
|
+
type: string;
|
|
15
|
+
value: unknown;
|
|
16
|
+
position?: number;
|
|
17
|
+
additionalFields?: Record<string, unknown> | unknown[];
|
|
18
|
+
}, unknown, z.core.$ZodTypeInternals<{
|
|
19
|
+
type: string;
|
|
20
|
+
value: unknown;
|
|
21
|
+
position?: number;
|
|
22
|
+
additionalFields?: Record<string, unknown> | unknown[];
|
|
23
|
+
}, unknown>>>>;
|
|
24
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/**
|
|
27
|
+
* Admins response schema (array of admin entities)
|
|
28
|
+
*/
|
|
29
|
+
export declare const AdminsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodNumber;
|
|
31
|
+
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
32
|
+
identifier: z.ZodString;
|
|
33
|
+
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
34
|
+
position: z.ZodNullable<z.ZodNumber>;
|
|
35
|
+
isSync: z.ZodBoolean;
|
|
36
|
+
attributeValues: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodType<{
|
|
37
|
+
type: string;
|
|
38
|
+
value: unknown;
|
|
39
|
+
position?: number;
|
|
40
|
+
additionalFields?: Record<string, unknown> | unknown[];
|
|
41
|
+
}, unknown, z.core.$ZodTypeInternals<{
|
|
42
|
+
type: string;
|
|
43
|
+
value: unknown;
|
|
44
|
+
position?: number;
|
|
45
|
+
additionalFields?: Record<string, unknown> | unknown[];
|
|
46
|
+
}, unknown>>>>;
|
|
47
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for Admins module
|
|
3
|
+
* @description Zod schemas for validating admins-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Admin entity schema
|
|
8
|
+
* Includes all fields returned by the API
|
|
9
|
+
*/
|
|
10
|
+
const AttributeValueSchema = z.object({
|
|
11
|
+
type: z.string(),
|
|
12
|
+
value: z.unknown(),
|
|
13
|
+
position: z.number().optional(),
|
|
14
|
+
additionalFields: z
|
|
15
|
+
.union([z.record(z.string(), z.unknown()), z.array(z.unknown())])
|
|
16
|
+
.optional(),
|
|
17
|
+
});
|
|
18
|
+
export const AdminEntitySchema = z.object({
|
|
19
|
+
id: z.number(),
|
|
20
|
+
attributeSetId: z.number().nullable(),
|
|
21
|
+
identifier: z.string(),
|
|
22
|
+
attributeSetIdentifier: z.string().nullable(),
|
|
23
|
+
position: z.number().nullable(),
|
|
24
|
+
isSync: z.boolean(),
|
|
25
|
+
attributeValues: z.record(z.string(), z.record(z.string(), AttributeValueSchema)),
|
|
26
|
+
moduleFormConfigs: z.array(z.any()).optional(),
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Admins response schema (array of admin entities)
|
|
30
|
+
*/
|
|
31
|
+
export const AdminsResponseSchema = z.array(AdminEntitySchema);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { IAttributeSetsEntity, IAttributesSets, IAttributesSetsEntity, IAttributesSetsResponse } from './attributeSetsInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with attributes - AttributesSetsApi.
|
|
7
|
+
* @class AttributesSetsApi
|
|
8
|
+
* @augments AsyncModules
|
|
9
|
+
* @implements {IAttributesSets}
|
|
10
|
+
* @description This class provides methods to interact with attribute sets, including fetching attributes, getting attributes by marker, and retrieving single attributes by marker and set.
|
|
11
|
+
*/
|
|
12
|
+
export default class AttributesSetsApi extends AsyncModules implements IAttributesSets {
|
|
13
|
+
protected state: StateModule;
|
|
14
|
+
protected _url: string;
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the AttributesSetsApi with the provided state module.
|
|
17
|
+
* @class
|
|
18
|
+
* @class AttributesSetsApi
|
|
19
|
+
* @param {StateModule} state - The state module containing configuration data.
|
|
20
|
+
* @description Constructor initializes the AttributesSetsApi with a given state.
|
|
21
|
+
*/
|
|
22
|
+
constructor(state: StateModule);
|
|
23
|
+
/**
|
|
24
|
+
* Getting all attribute sets objects.
|
|
25
|
+
* @handleName getAttributes
|
|
26
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
27
|
+
* @param {number} [offset] - parameter offset of record selection. Default: 0.
|
|
28
|
+
* @param {number} [limit] - parameter limiting the selection of records. Default: 30.
|
|
29
|
+
* @param {number} [typeId] - identifier of the attribute set type. Default: null.
|
|
30
|
+
* @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
|
|
31
|
+
* @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
|
|
32
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributes getAttributes} documentation.
|
|
34
|
+
*/
|
|
35
|
+
getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
|
|
36
|
+
/**
|
|
37
|
+
* Getting all attributes with data from the attribute set.
|
|
38
|
+
* @handleName getAttributesByMarker
|
|
39
|
+
* @param {string} marker - Attribute marker. Example: "productAttributes".
|
|
40
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
41
|
+
* @returns {Promise<IAttributesSetsEntity[] | IError>} Returns an array of Attributes objects.
|
|
42
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
43
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
44
|
+
*/
|
|
45
|
+
getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributesSetsEntity[] | IError>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a single attribute with data from the attribute sets.
|
|
48
|
+
* @handleName getSingleAttributeByMarkerSet
|
|
49
|
+
* @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
|
|
50
|
+
* @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
|
|
51
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
52
|
+
* @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
|
|
53
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
55
|
+
*/
|
|
56
|
+
getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
|
|
57
|
+
/**
|
|
58
|
+
* Getting a single object from a set of attributes by marker.
|
|
59
|
+
* @handleName getAttributeSetByMarker
|
|
60
|
+
* @param {string} marker - marker of the attribute set object. Example: "productAttributes".
|
|
61
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
62
|
+
* @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
|
|
63
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
64
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
65
|
+
*/
|
|
66
|
+
getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
|
|
67
|
+
}
|