oneentry 1.0.165 → 1.0.167

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.
Files changed (59) hide show
  1. package/README.md +5 -1
  2. package/changelog.md +36 -0
  3. package/dist/base/utils.d.ts +5 -2
  4. package/dist/base/validation.d.ts +7 -5
  5. package/dist/base/validation.js +7 -4
  6. package/dist/file-uploading/fileUploadingApi.d.ts +27 -1
  7. package/dist/file-uploading/fileUploadingApi.js +42 -0
  8. package/dist/file-uploading/fileUploadingInterfaces.d.ts +102 -1
  9. package/dist/file-uploading/fileUploadingSchemas.d.ts +73 -0
  10. package/dist/file-uploading/fileUploadingSchemas.js +47 -1
  11. package/dist/forms-data/formsDataApi.d.ts +1 -1
  12. package/dist/forms-data/formsDataApi.js +1 -1
  13. package/dist/forms-data/formsDataInterfaces.d.ts +9 -2
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.js +3 -0
  16. package/dist/orders/ordersApi.d.ts +14 -0
  17. package/dist/orders/ordersApi.js +19 -0
  18. package/dist/orders/ordersInterfaces.d.ts +11 -0
  19. package/dist/payments/paymentsApi.d.ts +14 -1
  20. package/dist/payments/paymentsApi.js +18 -0
  21. package/dist/payments/paymentsInterfaces.d.ts +43 -1
  22. package/dist/payments/paymentsSchemas.d.ts +32 -0
  23. package/dist/payments/paymentsSchemas.js +20 -1
  24. package/dist/types.d.ts +1 -0
  25. package/dist/user-groups/userGroupsApi.d.ts +81 -0
  26. package/dist/user-groups/userGroupsApi.js +145 -0
  27. package/dist/user-groups/userGroupsInterfaces.d.ts +100 -0
  28. package/dist/user-groups/userGroupsInterfaces.js +2 -0
  29. package/dist/user-groups/userGroupsSchemas.d.ts +55 -0
  30. package/dist/user-groups/userGroupsSchemas.js +35 -0
  31. package/esm/base/utils.d.ts +5 -2
  32. package/esm/base/validation.d.ts +7 -5
  33. package/esm/base/validation.js +7 -4
  34. package/esm/file-uploading/fileUploadingApi.d.ts +27 -1
  35. package/esm/file-uploading/fileUploadingApi.js +42 -0
  36. package/esm/file-uploading/fileUploadingInterfaces.d.ts +102 -1
  37. package/esm/file-uploading/fileUploadingSchemas.d.ts +73 -0
  38. package/esm/file-uploading/fileUploadingSchemas.js +46 -0
  39. package/esm/forms-data/formsDataApi.d.ts +1 -1
  40. package/esm/forms-data/formsDataApi.js +1 -1
  41. package/esm/forms-data/formsDataInterfaces.d.ts +9 -2
  42. package/esm/index.d.ts +4 -0
  43. package/esm/index.js +3 -0
  44. package/esm/orders/ordersApi.d.ts +14 -0
  45. package/esm/orders/ordersApi.js +19 -0
  46. package/esm/orders/ordersInterfaces.d.ts +11 -0
  47. package/esm/payments/paymentsApi.d.ts +14 -1
  48. package/esm/payments/paymentsApi.js +18 -0
  49. package/esm/payments/paymentsInterfaces.d.ts +43 -1
  50. package/esm/payments/paymentsSchemas.d.ts +32 -0
  51. package/esm/payments/paymentsSchemas.js +19 -0
  52. package/esm/types.d.ts +1 -0
  53. package/esm/user-groups/userGroupsApi.d.ts +81 -0
  54. package/esm/user-groups/userGroupsApi.js +106 -0
  55. package/esm/user-groups/userGroupsInterfaces.d.ts +100 -0
  56. package/esm/user-groups/userGroupsInterfaces.js +1 -0
  57. package/esm/user-groups/userGroupsSchemas.d.ts +55 -0
  58. package/esm/user-groups/userGroupsSchemas.js +32 -0
  59. package/package.json +2 -2
package/README.md CHANGED
@@ -65,6 +65,7 @@ const {
65
65
  Templates,
66
66
  TemplatePreviews,
67
67
  UserActivity,
68
+ UserGroups,
68
69
  Users,
69
70
  WS,
70
71
  } = defineOneEntry('your-url', config)
@@ -95,6 +96,8 @@ The second parameter of the constructor takes the 'config'. It contains the foll
95
96
 
96
97
  - 'traficLimit' - Some methods use more than one request to the CMS so that the data you receive is complete and easy to work with. Pass the value "true" for this parameter to save traffic and decide for yourself what data you need. The default value "false".
97
98
 
99
+ - 'rawData' - Pass "true" to keep an attribute's nested "additionalFields" exactly as the API sends them — an array of field objects, each carrying its own "marker" — instead of the marker-keyed map the SDK builds by default. This is the only transformation the flag turns off: locale unwrapping, sorting by "position", single-file unwrapping and number casting still apply. The "getAdditionalFields" helper returns the same marker map in both modes, so reading fields through it is unaffected. The default value "false".
100
+
98
101
  - 'auth' - An object with authorization settings. By default, the SDK is configured to work with tokens inside the user's session and does not require any additional work from you. At the same time, the SDK does not store the session state between sessions. If you are satisfied with such settings, do not pass the variable 'auth' at all.
99
102
 
100
103
  The 'auth' contains the following settings:
@@ -169,7 +172,7 @@ const api = defineOneEntry('your-url', {
169
172
  langCode: 'my-langCode',
170
173
  auth: {
171
174
  customAuth: false,
172
- userToken: 'rerfesh.token',
175
+ refreshToken: 'user.refresh.token',
173
176
  providerMarker: 'email',
174
177
  saveFunction: saveTokenFromLocalStorage,
175
178
  },
@@ -302,6 +305,7 @@ Now you can use the following links to jump to specific entries documentation:
302
305
  - [Templates](https://js-sdk.oneentry.cloud/docs/category/templates)
303
306
  - [TemplatePreviews](https://js-sdk.oneentry.cloud/docs/category/templatepreviews)
304
307
  - [UserActivity](https://js-sdk.oneentry.cloud/docs/category/useractivity)
308
+ - [UserGroups](https://js-sdk.oneentry.cloud/docs/category/usergroups)
305
309
  - [Users](https://js-sdk.oneentry.cloud/docs/category/users-1)
306
310
  - [WS](https://js-sdk.oneentry.cloud/docs/category/web-socket)
307
311
  - [Advanced examples](https://js-sdk.oneentry.cloud/docs/category/usage-examples)
package/changelog.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # SDK Change Log
2
2
 
3
+ ## v.1.0.167
4
+
5
+ ### What's New
6
+
7
+ - **`UserGroups` — a whole section of the Content API that the SDK did not reach.** Five read methods over the user-group tree: `getUserGroups` (flat list), `getRootUserGroups` (top level, `parentId: null`), `getUserGroupById`, `getUserGroupByMarker` and `getChildUserGroupsByMarker`. Nesting is walked with the last one rather than through `parentId`, which is the same shape the menus API already taught: the parent link is there, but the children are what you read.
8
+
9
+ One field is worth knowing before you type it: **`childrenCount` arrives as a string** (`"0"`), not a number. The platform DTO declares it a number, the API sends a string, and the interface follows the API — so `Number(group.childrenCount)` is on you. `version` is not sent by every stand and is optional.
10
+
11
+ - **`FileUploading.searchFileContent` — public search across the content of files attached to records.** Takes a query of at least 3 characters plus optional filters by extension, owner section and link locale, and `onlyTruncated` for files whose extracted text hit the size ceiling. Pagination is `offset` and `limit`, the latter capped at 50 — a larger value is rejected with `400 "limit must not be greater than 50"`.
12
+
13
+ Two things decide how you render the result. The unit is a **file, not a fragment**: one `snippet` per file, even when the document matches on twenty pages, and `snippet.pageFrom` says where it starts. And the match inside the snippet is wrapped in the control characters `U+0002` / `U+0003`, not in HTML — paste it into markup unchanged and the reader sees nothing, so replace them with your own highlighting. The result is narrowed by access: only files of visible records in sections enabled in project settings, personal sections only down to the caller's own records, and the admins section never. A separate `403` means the feature is not in the project tariff.
14
+
15
+ - **`Orders.getOrderById` — an order by its own id, without the storage marker.** `getOrderByMarkerAndId` needs both, and the marker is exactly what is missing when the id arrives from outside: a payment provider's return URL, a link in a notification, an order number a customer read out. The route is the same one the storage method ends at, so the returned entity is `IOrderByMarkerEntity` as before — no new type.
16
+
17
+ - **`Payments.getPaymentStagesByOrderId` — the payment progress of an order.** An order can be paid in parts rather than in one payment; `partial` says which case it is, `completed` says whether anything is left, and each stage in `stages` carries its own `marker`, `sessionId`, `productId`, `title`, `value` and a `status` of `planned` or `completed`.
18
+
19
+ ### What's Fixed
20
+
21
+ - **`IConfig.rawData` was documented as something it is not.** Both the README and the JSDoc said it returns "raw API responses without any transformation", which reads as an off switch for normalization. It is not: the flag is read in exactly one place and decides only whether an attribute's nested `additionalFields` stays the array the API sends or becomes the marker-keyed map the SDK builds. Locale unwrapping, sorting by `position`, single-file unwrapping and number casting apply either way, and `getAdditionalFields` returns the same map in both modes. Anyone who set it expecting untouched payloads got normalized data and a puzzle. Documentation only.
22
+
23
+ - **Two config examples named fields that do not exist.** The README's `auth` example passed `userToken` — the field is `refreshToken`, and the value was misspelled `'rerfesh.token'` on top of it. The `IConfig` JSDoc example passed `multipleRequests`, which is `traficLimit`. Both were copy-paste targets, so the error propagated: `userToken` reached nine locales of the documentation site. Documentation only.
24
+
25
+ - **`docs/VALIDATION.md` described a validation layer the SDK no longer has.** It listed 5 validated modules and 6 schema files; there are 22 of each, covering 71 methods, and the auth-provider list named six methods that are not validated at all. Worse, its "Contributing" section told you to import the schema statically and call `this._validateResponse(result, Schema)` — a static `*Schemas` import anywhere in the graph puts Zod back into every consumer's bundle, which is the one thing `createSchemaLoader` exists to prevent, and the method has been async and loader-taking for several releases. The page now matches the code, and the performance section says schemas are loaded on demand rather than tree-shaken.
26
+
27
+ ### What's Deleted
28
+
29
+ - **The dead `strict` option of `validateResponse`.** The options object declared `strict?: boolean` and the JSDoc described it as "Whether to use strict mode", but the implementation never read it — strictness is decided by which of the two helpers runs, and `_validateResponse` picks between them by `config.validation.strictMode`. No caller passed it and the function is not exported from the package root, so the field is gone rather than wired up.
30
+
31
+ ## v.1.0.166
32
+
33
+ ### What's Fixed
34
+
35
+ - **FormData > `IFormsDataFilter.entityIdentifier` accepts a number.** The field was typed `string`, but an entity is not always addressed by a text marker: product-scoped records — reviews and ratings — are filtered by the **numeric product id**, and that is what the endpoint expects. So the one filter every storefront writes, `{ entityIdentifier: product.id, status: ['approved'] }`, did not compile: `TS2322: Type 'number' is not assignable to type 'string'`. The call worked perfectly at runtime, which made the error read as a mistake in the caller rather than in the type — the usual fix was a cast, and a cast on a field whose real contract nobody had written down. The declaration is now `string | number`, documented with the full contract: a text marker for content entities (`"blog"`), the numeric id for products (`2954`), the login for users and admins.
36
+
37
+ Only the **request** is widened. The API normalizes the value and sends it back as a string — the SDK's own fixture stores a product id as `entityIdentifier: "2954"` — so `IFormByMarkerDataEntity`, `IFormDataSearchEntity`, `IPostFormResponseData` and `IUpdateFormsData` keep `entityIdentifier: string`, and reading code needs no narrowing. Types only; no runtime change, and `_stripEmptyDates` never touched this field.
38
+
3
39
  ## v.1.0.165
4
40
 
5
41
  ### What's New
@@ -5,7 +5,10 @@
5
5
  * @property {string} [deviceMetadata] - Device-metadata string sent as the `x-device-metadata` header on POST requests and token refresh, overriding the environment-derived fingerprint. The API binds refresh tokens to this header, so server-side flows that issue tokens on behalf of a browser (e.g. an OAuth code exchange) must pass the browser's string here — otherwise the token is bound to the server's fingerprint and cannot be refreshed from the browser. Obtain the string in the browser via `getDeviceMetadata()`. Can also be set later via `setDeviceMetadata`.
6
6
  * @property {string} [langCode] - specify the default language to avoid specifying it in every request.
7
7
  * @property {boolean} [traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
8
- * @property {boolean} [rawData] - Set to true to receive raw API responses without any transformation.
8
+ * @property {boolean} [rawData] - Set to true to keep an attribute's nested `additionalFields` as the
9
+ * array the API sends, instead of the marker-keyed map the SDK builds by default. It turns off only that
10
+ * transformation — locale unwrapping, sorting by `position`, single-file unwrapping and number casting
11
+ * still apply. `getAdditionalFields` returns the same marker map in either mode.
9
12
  * @property {object} [validation] - Validation settings for API responses.
10
13
  * @property {boolean} [auth] - An object with authorization settings.
11
14
  * @property {boolean} [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.
@@ -22,7 +25,7 @@
22
25
  * const config = {
23
26
  * token: 'project.token.here',
24
27
  * langCode: 'en_US',
25
- * multipleRequests: true,
28
+ * traficLimit: true,
26
29
  * auth: {
27
30
  * customAuth: false,
28
31
  * refreshToken: 'user.refresh.token',
@@ -99,16 +99,18 @@ export declare const AuthEntitySchema: z.ZodObject<{
99
99
  */
100
100
  export declare function createPaginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): any;
101
101
  /**
102
- * Validation helper function
102
+ * Validation helper function.
103
+ *
104
+ * This is the strict half of the pair: it reports a failure instead of hiding it.
105
+ * Strictness is the choice of function, not an option — `validateResponseSafe` is the
106
+ * lenient one, and `_validateResponse` picks between them by `config.validation.strictMode`.
103
107
  * @param {z.ZodSchema<T>} schema - Zod schema to validate against
104
108
  * @param {unknown} data - Data to validate
105
- * @param {object} options - Validation options
106
- * @param {boolean} options.strict - Whether to use strict mode
107
- * @param {boolean} options.logErrors - Whether to log errors
109
+ * @param {object} [options] - Validation options
110
+ * @param {boolean} [options.logErrors] - Whether to log errors
108
111
  * @returns {object} Validated data or error
109
112
  */
110
113
  export declare function validateResponse<T>(schema: z.ZodSchema<T>, data: unknown, options?: {
111
- strict?: boolean;
112
114
  logErrors?: boolean;
113
115
  }): {
114
116
  success: true;
@@ -175,12 +175,15 @@ function createPaginatedSchema(itemSchema) {
175
175
  });
176
176
  }
177
177
  /**
178
- * Validation helper function
178
+ * Validation helper function.
179
+ *
180
+ * This is the strict half of the pair: it reports a failure instead of hiding it.
181
+ * Strictness is the choice of function, not an option — `validateResponseSafe` is the
182
+ * lenient one, and `_validateResponse` picks between them by `config.validation.strictMode`.
179
183
  * @param {z.ZodSchema<T>} schema - Zod schema to validate against
180
184
  * @param {unknown} data - Data to validate
181
- * @param {object} options - Validation options
182
- * @param {boolean} options.strict - Whether to use strict mode
183
- * @param {boolean} options.logErrors - Whether to log errors
185
+ * @param {object} [options] - Validation options
186
+ * @param {boolean} [options.logErrors] - Whether to log errors
184
187
  * @returns {object} Validated data or error
185
188
  */
186
189
  function validateResponse(schema, data, options) {
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
- import type { IFileUploading, IUploadingQuery, IUploadingReturn } from './fileUploadingInterfaces';
4
+ import type { IFileSearchResponse, IFileUploading, IUploadingQuery, IUploadingReturn } from './fileUploadingInterfaces';
5
5
  /**
6
6
  * Controllers for working with file uploading
7
7
  * @handle /api/content/files
@@ -67,6 +67,32 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
67
67
  * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/delete delete} documentation.
68
68
  */
69
69
  delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
70
+ /**
71
+ * Public search across the content of files attached to records.
72
+ * @handleName searchFileContent
73
+ * @param {string} query - Search query, at least 3 characters — shorter is rejected with 400. Example: "transportation".
74
+ * @param {string} [langCode] - Language of the query. Example: "en_US".
75
+ * @param {string[]} [extensions] - Filter by file extension, sent comma-separated. Example: ["pdf", "docx"].
76
+ * @param {string[]} [ownerTables] - Filter by the section the attached record belongs to, sent comma-separated. Example: ["products", "pages"].
77
+ * @param {string[]} [localeCodes] - Filter by the locale of the link, not of the file content. Example: ["en_US"].
78
+ * @param {boolean} [onlyTruncated] - Return only files whose extracted text was cut at the size ceiling.
79
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
80
+ * @param {number} [limit] - Parameter for pagination. Default: 10, maximum 50 — a larger value is rejected with 400 "limit must not be greater than 50".
81
+ * @returns {Promise<IFileSearchResponse | IError>} Returns the found files with their matching fragments.
82
+ * @throws {IError} When isShell=false and an error occurs during the fetch
83
+ * @description The unit of the result is a **file, not a fragment**: one `snippet` per file,
84
+ * even when the document matches on many pages. Matches inside the snippet are wrapped in the
85
+ * control characters `U+0002` and `U+0003` rather than HTML, so replace them before rendering.
86
+ * The result is narrowed by access: only files of visible records of the sections enabled in the
87
+ * project settings, personal sections only down to the caller's own records, and the admins
88
+ * section is never returned. A separate 403 means the feature is not part of the project tariff.
89
+ * @example
90
+ * ```ts
91
+ * const found = await api.FileUploading.searchFileContent('transportation', 'en_US', ['pdf']);
92
+ * ```
93
+ * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/searchFileContent searchFileContent} documentation.
94
+ */
95
+ searchFileContent(query: string, langCode?: string, extensions?: string[], ownerTables?: string[], localeCodes?: string[], onlyTruncated?: boolean, offset?: number, limit?: number): Promise<IFileSearchResponse | IError>;
70
96
  /**
71
97
  * Create a File object from a URL.
72
98
  * @param {string} url - The URL to fetch the file from.
@@ -125,6 +125,48 @@ class FileUploadingApi extends asyncModules_1.default {
125
125
  const result = await this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query));
126
126
  return result;
127
127
  }
128
+ /**
129
+ * Public search across the content of files attached to records.
130
+ * @handleName searchFileContent
131
+ * @param {string} query - Search query, at least 3 characters — shorter is rejected with 400. Example: "transportation".
132
+ * @param {string} [langCode] - Language of the query. Example: "en_US".
133
+ * @param {string[]} [extensions] - Filter by file extension, sent comma-separated. Example: ["pdf", "docx"].
134
+ * @param {string[]} [ownerTables] - Filter by the section the attached record belongs to, sent comma-separated. Example: ["products", "pages"].
135
+ * @param {string[]} [localeCodes] - Filter by the locale of the link, not of the file content. Example: ["en_US"].
136
+ * @param {boolean} [onlyTruncated] - Return only files whose extracted text was cut at the size ceiling.
137
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
138
+ * @param {number} [limit] - Parameter for pagination. Default: 10, maximum 50 — a larger value is rejected with 400 "limit must not be greater than 50".
139
+ * @returns {Promise<IFileSearchResponse | IError>} Returns the found files with their matching fragments.
140
+ * @throws {IError} When isShell=false and an error occurs during the fetch
141
+ * @description The unit of the result is a **file, not a fragment**: one `snippet` per file,
142
+ * even when the document matches on many pages. Matches inside the snippet are wrapped in the
143
+ * control characters `U+0002` and `U+0003` rather than HTML, so replace them before rendering.
144
+ * The result is narrowed by access: only files of visible records of the sections enabled in the
145
+ * project settings, personal sections only down to the caller's own records, and the admins
146
+ * section is never returned. A separate 403 means the feature is not part of the project tariff.
147
+ * @example
148
+ * ```ts
149
+ * const found = await api.FileUploading.searchFileContent('transportation', 'en_US', ['pdf']);
150
+ * ```
151
+ * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/searchFileContent searchFileContent} documentation.
152
+ */
153
+ async searchFileContent(query, langCode = this.state.lang, extensions, ownerTables, localeCodes, onlyTruncated, offset, limit) {
154
+ // Array filters are sent comma-separated — an array stringifies to exactly that.
155
+ const params = {
156
+ q: query,
157
+ langCode,
158
+ extensions,
159
+ ownerTables,
160
+ localeCodes,
161
+ onlyTruncated,
162
+ offset,
163
+ limit,
164
+ };
165
+ const result = await this._fetchGet(`/search?` + this._queryParamsToString(params));
166
+ // Validate response if validation is enabled
167
+ const validated = await this._validateResponse(result, schema('FileSearchResponseSchema'));
168
+ return this._normalizeData(validated);
169
+ }
128
170
  /**
129
171
  * Create a File object from a URL.
130
172
  * @param {string} url - The URL to fetch the file from.
@@ -71,6 +71,22 @@ interface IFileUploading {
71
71
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
72
72
  */
73
73
  getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response | IError>;
74
+ /**
75
+ * Public search across the content of files attached to records.
76
+ * @handleName searchFileContent
77
+ * @param {string} query - Search query, at least 3 characters. Example: "transportation".
78
+ * @param {string} [langCode] - Language of the query. Example: "en_US".
79
+ * @param {string[]} [extensions] - Filter by file extension, sent comma-separated. Example: ["pdf", "docx"].
80
+ * @param {string[]} [ownerTables] - Filter by the section the attached record belongs to. Example: ["products", "pages"].
81
+ * @param {string[]} [localeCodes] - Filter by the locale of the link, not of the file content. Example: ["en_US"].
82
+ * @param {boolean} [onlyTruncated] - Return only files whose extracted text was cut at the size ceiling.
83
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
84
+ * @param {number} [limit] - Parameter for pagination, 1 to 50. Default: 10.
85
+ * @returns {IFileSearchResponse} Returns the found files with their matching fragments.
86
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
87
+ * @description This method searches the content of files attached to records.
88
+ */
89
+ searchFileContent(query: string, langCode?: string, extensions?: string[], ownerTables?: string[], localeCodes?: string[], onlyTruncated?: boolean, offset?: number, limit?: number): Promise<IFileSearchResponse | IError>;
74
90
  }
75
91
  /**
76
92
  * Represents a file entity that may contain a file object or a path as a string.
@@ -113,4 +129,89 @@ interface IUploadingReturn {
113
129
  size: number;
114
130
  contentType: string;
115
131
  }
116
- export type { IFileEntity, IFileUploading, IUploadingQuery, IUploadingReturn };
132
+ /**
133
+ * The `IFileSearchOwner` interface describes one record a found file is attached to.
134
+ * @interface IFileSearchOwner
135
+ * @property {string} tableName - Section the record belongs to. Example: "products".
136
+ * @property {number} dataId - Identifier of the record. Example: 644.
137
+ * @property {string} title - Title of the record. Example: "COG — March 17, 2016".
138
+ * @property {string} langCode - Locale of the link, not of the file content. Example: "en_US".
139
+ * @description One record a found file is attached to. The same file can be attached to several records, and a record contributes one entry per locale.
140
+ */
141
+ interface IFileSearchOwner {
142
+ tableName: string;
143
+ dataId: number;
144
+ title: string;
145
+ langCode: string;
146
+ }
147
+ /**
148
+ * The `IFileSearchSnippet` interface describes the matching fragment of a file.
149
+ * @interface IFileSearchSnippet
150
+ * @property {string} text - The fragment itself. Every match inside it is wrapped in the control characters U+0002 and U+0003 — not HTML, so replace them before rendering. Example: "… Active \u0002Transportation\u0003 2…".
151
+ * @property {number | null} pageFrom - Page the fragment starts on, for paged formats. Example: 86.
152
+ * @description The matching fragment of a file. One fragment per file, even when the document matches on many pages.
153
+ */
154
+ interface IFileSearchSnippet {
155
+ text: string;
156
+ pageFrom: number | null;
157
+ }
158
+ /**
159
+ * The `IFileSearchItem` interface describes one found file.
160
+ * @interface IFileSearchItem
161
+ * @property {number} id - Identifier of the indexed file. Example: 1077.
162
+ * @property {string} storageKey - Key of the object in the storage; the file link is built from it. Example: "files/project/file/644/product/db1918c4.pdf".
163
+ * @property {string} extension - File extension. Example: "pdf".
164
+ * @property {string | null} title - Title from the document metadata, `null` when the document carries none. Example: "Microsoft Word - COG Agenda.docx".
165
+ * @property {string | null} langCode - Language of the file content, detected on indexing. Example: "en".
166
+ * @property {number | null} pageCount - Number of pages, for paged formats. Example: 244.
167
+ * @property {number} rank - Relevance of the match; the API sorts by it descending. Example: 0.0971.
168
+ * @property {IFileSearchSnippet | null} snippet - The matching fragment.
169
+ * @property {IFileSearchOwner[]} owners - Records the file is attached to, limited to those the caller may see.
170
+ * @property {number} ownersTotal - How many records visible to the caller reference the file. Example: 2.
171
+ * @description One found file. The unit of the result is a file, not a fragment.
172
+ */
173
+ interface IFileSearchItem {
174
+ id: number;
175
+ storageKey: string;
176
+ extension: string;
177
+ title: string | null;
178
+ langCode: string | null;
179
+ pageCount: number | null;
180
+ rank: number;
181
+ snippet: IFileSearchSnippet | null;
182
+ owners: IFileSearchOwner[];
183
+ ownersTotal: number;
184
+ }
185
+ /**
186
+ * The `IFileSearchQueryLanguage` interface describes how the query language was resolved.
187
+ * @interface IFileSearchQueryLanguage
188
+ * @property {string[]} resolved - Languages the query was actually run in. Example: ["english"].
189
+ * @property {string} source - How they were chosen: "explicit" when taken from `langCode`, otherwise detected. Example: "explicit".
190
+ * @property {string[]} candidates - Languages considered. Example: ["english"].
191
+ * @description How the query language was resolved for the search.
192
+ */
193
+ interface IFileSearchQueryLanguage {
194
+ resolved: string[];
195
+ source: string;
196
+ candidates: string[];
197
+ }
198
+ /**
199
+ * The `IFileSearchResponse` interface describes the result of a file content search.
200
+ * @interface IFileSearchResponse
201
+ * @property {number} total - Total number of matching files. Example: 166.
202
+ * @property {number} offset - Offset the page starts at. Example: 0.
203
+ * @property {number} limit - Page size. Example: 10.
204
+ * @property {IFileSearchQueryLanguage} queryLanguage - How the query language was resolved.
205
+ * @property {string[]} warnings - Warnings about the search, empty when there are none.
206
+ * @property {IFileSearchItem[]} items - The found files.
207
+ * @description The result of a file content search.
208
+ */
209
+ interface IFileSearchResponse {
210
+ total: number;
211
+ offset: number;
212
+ limit: number;
213
+ queryLanguage: IFileSearchQueryLanguage;
214
+ warnings: string[];
215
+ items: IFileSearchItem[];
216
+ }
217
+ export type { IFileEntity, IFileSearchItem, IFileSearchOwner, IFileSearchQueryLanguage, IFileSearchResponse, IFileSearchSnippet, IFileUploading, IUploadingQuery, IUploadingReturn, };
@@ -22,3 +22,76 @@ export declare const UploadResponseSchema: z.ZodArray<z.ZodObject<{
22
22
  size: z.ZodNumber;
23
23
  contentType: z.ZodString;
24
24
  }, z.core.$strip>>;
25
+ /**
26
+ * One record a found file is attached to
27
+ */
28
+ export declare const FileSearchOwnerSchema: z.ZodObject<{
29
+ tableName: z.ZodString;
30
+ dataId: z.ZodNumber;
31
+ title: z.ZodString;
32
+ langCode: z.ZodString;
33
+ }, z.core.$strip>;
34
+ /**
35
+ * Matching fragment of a found file
36
+ */
37
+ export declare const FileSearchSnippetSchema: z.ZodObject<{
38
+ text: z.ZodString;
39
+ pageFrom: z.ZodNullable<z.ZodNumber>;
40
+ }, z.core.$strip>;
41
+ /**
42
+ * One found file
43
+ */
44
+ export declare const FileSearchItemSchema: z.ZodObject<{
45
+ id: z.ZodNumber;
46
+ storageKey: z.ZodString;
47
+ extension: z.ZodString;
48
+ title: z.ZodNullable<z.ZodString>;
49
+ langCode: z.ZodNullable<z.ZodString>;
50
+ pageCount: z.ZodNullable<z.ZodNumber>;
51
+ rank: z.ZodNumber;
52
+ snippet: z.ZodNullable<z.ZodObject<{
53
+ text: z.ZodString;
54
+ pageFrom: z.ZodNullable<z.ZodNumber>;
55
+ }, z.core.$strip>>;
56
+ owners: z.ZodArray<z.ZodObject<{
57
+ tableName: z.ZodString;
58
+ dataId: z.ZodNumber;
59
+ title: z.ZodString;
60
+ langCode: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ ownersTotal: z.ZodNumber;
63
+ }, z.core.$strip>;
64
+ /**
65
+ * File content search response
66
+ */
67
+ export declare const FileSearchResponseSchema: z.ZodObject<{
68
+ total: z.ZodNumber;
69
+ offset: z.ZodNumber;
70
+ limit: z.ZodNumber;
71
+ queryLanguage: z.ZodObject<{
72
+ resolved: z.ZodArray<z.ZodString>;
73
+ source: z.ZodString;
74
+ candidates: z.ZodArray<z.ZodString>;
75
+ }, z.core.$strip>;
76
+ warnings: z.ZodArray<z.ZodString>;
77
+ items: z.ZodArray<z.ZodObject<{
78
+ id: z.ZodNumber;
79
+ storageKey: z.ZodString;
80
+ extension: z.ZodString;
81
+ title: z.ZodNullable<z.ZodString>;
82
+ langCode: z.ZodNullable<z.ZodString>;
83
+ pageCount: z.ZodNullable<z.ZodNumber>;
84
+ rank: z.ZodNumber;
85
+ snippet: z.ZodNullable<z.ZodObject<{
86
+ text: z.ZodString;
87
+ pageFrom: z.ZodNullable<z.ZodNumber>;
88
+ }, z.core.$strip>>;
89
+ owners: z.ZodArray<z.ZodObject<{
90
+ tableName: z.ZodString;
91
+ dataId: z.ZodNumber;
92
+ title: z.ZodString;
93
+ langCode: z.ZodString;
94
+ }, z.core.$strip>>;
95
+ ownersTotal: z.ZodNumber;
96
+ }, z.core.$strip>>;
97
+ }, z.core.$strip>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UploadResponseSchema = exports.UploadingReturnSchema = void 0;
3
+ exports.FileSearchResponseSchema = exports.FileSearchItemSchema = exports.FileSearchSnippetSchema = exports.FileSearchOwnerSchema = exports.UploadResponseSchema = exports.UploadingReturnSchema = void 0;
4
4
  /**
5
5
  * Validation schemas for FileUploading module
6
6
  * @description Zod schemas for validating file uploading-related API responses
@@ -20,3 +20,49 @@ exports.UploadingReturnSchema = zod_1.z.object({
20
20
  * Upload response schema (array of upload results)
21
21
  */
22
22
  exports.UploadResponseSchema = zod_1.z.array(exports.UploadingReturnSchema);
23
+ /**
24
+ * One record a found file is attached to
25
+ */
26
+ exports.FileSearchOwnerSchema = zod_1.z.object({
27
+ tableName: zod_1.z.string(),
28
+ dataId: zod_1.z.number(),
29
+ title: zod_1.z.string(),
30
+ langCode: zod_1.z.string(),
31
+ });
32
+ /**
33
+ * Matching fragment of a found file
34
+ */
35
+ exports.FileSearchSnippetSchema = zod_1.z.object({
36
+ text: zod_1.z.string(),
37
+ pageFrom: zod_1.z.number().nullable(),
38
+ });
39
+ /**
40
+ * One found file
41
+ */
42
+ exports.FileSearchItemSchema = zod_1.z.object({
43
+ id: zod_1.z.number(),
44
+ storageKey: zod_1.z.string(),
45
+ extension: zod_1.z.string(),
46
+ title: zod_1.z.string().nullable(),
47
+ langCode: zod_1.z.string().nullable(),
48
+ pageCount: zod_1.z.number().nullable(),
49
+ rank: zod_1.z.number(),
50
+ snippet: exports.FileSearchSnippetSchema.nullable(),
51
+ owners: zod_1.z.array(exports.FileSearchOwnerSchema),
52
+ ownersTotal: zod_1.z.number(),
53
+ });
54
+ /**
55
+ * File content search response
56
+ */
57
+ exports.FileSearchResponseSchema = zod_1.z.object({
58
+ total: zod_1.z.number(),
59
+ offset: zod_1.z.number(),
60
+ limit: zod_1.z.number(),
61
+ queryLanguage: zod_1.z.object({
62
+ resolved: zod_1.z.array(zod_1.z.string()),
63
+ source: zod_1.z.string(),
64
+ candidates: zod_1.z.array(zod_1.z.string()),
65
+ }),
66
+ warnings: zod_1.z.array(zod_1.z.string()),
67
+ items: zod_1.z.array(exports.FileSearchItemSchema),
68
+ });
@@ -90,7 +90,7 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
90
90
  "dateFrom": "2025-01-01",
91
91
  "dateTo": ""
92
92
  }
93
- * @param {string} [body.entityIdentifier] - Text identifier (marker) of the entity the records belong to. Example: "blog".
93
+ * @param {string | number} [body.entityIdentifier] - Identifier of the entity the records belong to: a text marker for content entities ("blog"), the **numeric id for products** (2954), the login for users and admins. Example: "blog".
94
94
  * @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
95
95
  * @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
96
96
  * @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
@@ -197,7 +197,7 @@ class FormsDataApi extends asyncModules_1.default {
197
197
  "dateFrom": "2025-01-01",
198
198
  "dateTo": ""
199
199
  }
200
- * @param {string} [body.entityIdentifier] - Text identifier (marker) of the entity the records belong to. Example: "blog".
200
+ * @param {string | number} [body.entityIdentifier] - Identifier of the entity the records belong to: a text marker for content entities ("blog"), the **numeric id for products** (2954), the login for users and admins. Example: "blog".
201
201
  * @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
202
202
  * @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
203
203
  * @param {FormDataStatus[]} [body.status] - Moderation statuses to keep: "sent", "moderation", "approved", "banned", "deleted". Must be an array; anything outside the set is rejected with `400 each value in status must be a valid enum value`. Example: ["approved"].
@@ -109,7 +109,7 @@ type FormDataStatus = 'sent' | 'moderation' | 'approved' | 'banned' | 'deleted';
109
109
  /**
110
110
  * Represents the filter body of `getFormsDataByMarker`.
111
111
  * @interface IFormsDataFilter
112
- * @property {string} [entityIdentifier] - Text identifier (marker) of the entity the records belong to; an empty string means "no filter". Example: "blog".
112
+ * @property {string | number} [entityIdentifier] - Identifier of the entity the records belong to; an empty string means "no filter". Text marker for content entities ("blog"), the **numeric id for products** (2954), the login for users and admins. Example: "blog".
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"].
@@ -123,7 +123,14 @@ type FormDataStatus = 'sent' | 'moderation' | 'approved' | 'banned' | 'deleted';
123
123
  * leaking onto a public page, from one typo the compiler used to accept.
124
124
  */
125
125
  interface IFormsDataFilter {
126
- entityIdentifier?: string;
126
+ /**
127
+ * `string | number` because the entity is not always addressed by a marker:
128
+ * product-scoped records (reviews, ratings) are filtered by the **numeric
129
+ * product id**, which is what the API expects and what every storefront
130
+ * passes. The response normalizes it back to a string, so the read-side
131
+ * interfaces keep `entityIdentifier: string` — only the request is widened.
132
+ */
133
+ entityIdentifier?: string | number;
127
134
  parentId?: number;
128
135
  userIdentifier?: string;
129
136
  status?: FormDataStatus[];
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import SystemApi from './system/systemApi';
28
28
  import TemplatesApi from './templates/templatesApi';
29
29
  import TemplatePreviewsApi from './templates-preview/templatesPreviewApi';
30
30
  import UserActivityApi from './user-activity/userActivityApi';
31
+ import UserGroupsApi from './user-groups/userGroupsApi';
31
32
  import UsersApi from './users/usersApi';
32
33
  import WsApi from './web-socket/wsApi';
33
34
  export { getAdditionalFields, getAttributeFile, getAttributeFiles, isFileAttribute, isListAttribute, isNumberAttribute, isStringAttribute, } from './base/attributes';
@@ -62,6 +63,7 @@ export type * from './types';
62
63
  * @property {TemplatesApi} Templates - Templates API module.
63
64
  * @property {TemplatePreviewsApi} TemplatePreviews - Template previews API module.
64
65
  * @property {UserActivityApi} UserActivity - User activity API module.
66
+ * @property {UserGroupsApi} UserGroups - User groups API module.
65
67
  * @property {UsersApi} Users - Users API module.
66
68
  * @property {WsApi} WS - WebSocket API module.
67
69
  */
@@ -118,6 +120,8 @@ interface IDefineApi {
118
120
  TemplatePreviews: TemplatePreviewsApi;
119
121
  /** User/guest activity tracking: trackUserActivity */
120
122
  UserActivity: UserActivityApi;
123
+ /** User groups tree: getUserGroups, getRootUserGroups, getUserGroupByMarker, getChildUserGroupsByMarker */
124
+ UserGroups: UserGroupsApi;
121
125
  /** Current authenticated user: getUser, updateUser */
122
126
  Users: UsersApi;
123
127
  /** WebSocket real-time updates */
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ const systemApi_1 = __importDefault(require("./system/systemApi"));
35
35
  const templatesApi_1 = __importDefault(require("./templates/templatesApi"));
36
36
  const templatesPreviewApi_1 = __importDefault(require("./templates-preview/templatesPreviewApi"));
37
37
  const userActivityApi_1 = __importDefault(require("./user-activity/userActivityApi"));
38
+ const userGroupsApi_1 = __importDefault(require("./user-groups/userGroupsApi"));
38
39
  const usersApi_1 = __importDefault(require("./users/usersApi"));
39
40
  const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
40
41
  var attributes_1 = require("./base/attributes");
@@ -107,6 +108,7 @@ function defineOneEntry(url, config) {
107
108
  const Templates = new templatesApi_1.default(stateModule);
108
109
  const TemplatePreviews = new templatesPreviewApi_1.default(stateModule);
109
110
  const UserActivity = new userActivityApi_1.default(stateModule);
111
+ const UserGroups = new userGroupsApi_1.default(stateModule);
110
112
  const Users = new usersApi_1.default(stateModule);
111
113
  const WS = new wsApi_1.default(stateModule);
112
114
  return {
@@ -136,6 +138,7 @@ function defineOneEntry(url, config) {
136
138
  Templates,
137
139
  TemplatePreviews,
138
140
  UserActivity,
141
+ UserGroups,
139
142
  Users,
140
143
  WS,
141
144
  };
@@ -70,6 +70,20 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
70
70
  * @see {@link https://js-sdk.oneentry.cloud/docs/orders/getOrderByMarkerAndId getOrderByMarkerAndId} documentation.
71
71
  */
72
72
  getOrderByMarkerAndId(marker: string, id: number, langCode?: string): Promise<IOrderByMarkerEntity | IError>;
73
+ /**
74
+ * Getting a single order created by the user, by its own id.
75
+ * @handleName getOrderById
76
+ * @param {number} id - ID of the order object. Example: 12345.
77
+ * @param {string} [langCode] - Language code. Default: "en_US".
78
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
79
+ * @throws {IError} When isShell=false and an error occurs during the fetch
80
+ * @description This method requires user authorization. Unlike `getOrderByMarkerAndId`,
81
+ * it does not need the storage marker — use it when only the order id is at hand, for
82
+ * example on the return URL of a payment provider or in a link from a notification.
83
+ * @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}.
84
+ * @see {@link https://js-sdk.oneentry.cloud/docs/orders/getOrderById getOrderById} documentation.
85
+ */
86
+ getOrderById(id: number, langCode?: string): Promise<IOrderByMarkerEntity | IError>;
73
87
  /**
74
88
  * Preview order calculation with discounts and coupons (without saving).
75
89
  * @handleName previewOrder
@@ -124,6 +124,25 @@ class OrdersApi extends asyncModules_1.default {
124
124
  const validated = await this._validateResponse(result, schema('OrderEntitySchema'));
125
125
  return this._normalizeData(validated);
126
126
  }
127
+ /**
128
+ * Getting a single order created by the user, by its own id.
129
+ * @handleName getOrderById
130
+ * @param {number} id - ID of the order object. Example: 12345.
131
+ * @param {string} [langCode] - Language code. Default: "en_US".
132
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
133
+ * @throws {IError} When isShell=false and an error occurs during the fetch
134
+ * @description This method requires user authorization. Unlike `getOrderByMarkerAndId`,
135
+ * it does not need the storage marker — use it when only the order id is at hand, for
136
+ * example on the return URL of a payment provider or in a link from a notification.
137
+ * @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}.
138
+ * @see {@link https://js-sdk.oneentry.cloud/docs/orders/getOrderById getOrderById} documentation.
139
+ */
140
+ async getOrderById(id, langCode = this.state.lang) {
141
+ const result = await this._withOrdersUrl(() => this._fetchGet(`/${id}?langCode=${langCode}`));
142
+ // Validate response if validation is enabled
143
+ const validated = await this._validateResponse(result, schema('OrderEntitySchema'));
144
+ return this._normalizeData(validated);
145
+ }
127
146
  /**
128
147
  * Preview order calculation with discounts and coupons (without saving).
129
148
  * @handleName previewOrder