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
@@ -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;
@@ -169,12 +169,15 @@ export function createPaginatedSchema(itemSchema) {
169
169
  });
170
170
  }
171
171
  /**
172
- * Validation helper function
172
+ * Validation helper function.
173
+ *
174
+ * This is the strict half of the pair: it reports a failure instead of hiding it.
175
+ * Strictness is the choice of function, not an option — `validateResponseSafe` is the
176
+ * lenient one, and `_validateResponse` picks between them by `config.validation.strictMode`.
173
177
  * @param {z.ZodSchema<T>} schema - Zod schema to validate against
174
178
  * @param {unknown} data - Data to validate
175
- * @param {object} options - Validation options
176
- * @param {boolean} options.strict - Whether to use strict mode
177
- * @param {boolean} options.logErrors - Whether to log errors
179
+ * @param {object} [options] - Validation options
180
+ * @param {boolean} [options.logErrors] - Whether to log errors
178
181
  * @returns {object} Validated data or error
179
182
  */
180
183
  export function validateResponse(schema, data, options) {
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules.js';
2
2
  import type StateModule from '../base/stateModule.js';
3
3
  import type { IError } from '../base/utils.js';
4
- import type { IFileUploading, IUploadingQuery, IUploadingReturn } from './fileUploadingInterfaces.js';
4
+ import type { IFileSearchResponse, IFileUploading, IUploadingQuery, IUploadingReturn } from './fileUploadingInterfaces.js';
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.
@@ -87,6 +87,48 @@ export default class FileUploadingApi extends AsyncModules {
87
87
  const result = await this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query));
88
88
  return result;
89
89
  }
90
+ /**
91
+ * Public search across the content of files attached to records.
92
+ * @handleName searchFileContent
93
+ * @param {string} query - Search query, at least 3 characters — shorter is rejected with 400. Example: "transportation".
94
+ * @param {string} [langCode] - Language of the query. Example: "en_US".
95
+ * @param {string[]} [extensions] - Filter by file extension, sent comma-separated. Example: ["pdf", "docx"].
96
+ * @param {string[]} [ownerTables] - Filter by the section the attached record belongs to, sent comma-separated. Example: ["products", "pages"].
97
+ * @param {string[]} [localeCodes] - Filter by the locale of the link, not of the file content. Example: ["en_US"].
98
+ * @param {boolean} [onlyTruncated] - Return only files whose extracted text was cut at the size ceiling.
99
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
100
+ * @param {number} [limit] - Parameter for pagination. Default: 10, maximum 50 — a larger value is rejected with 400 "limit must not be greater than 50".
101
+ * @returns {Promise<IFileSearchResponse | IError>} Returns the found files with their matching fragments.
102
+ * @throws {IError} When isShell=false and an error occurs during the fetch
103
+ * @description The unit of the result is a **file, not a fragment**: one `snippet` per file,
104
+ * even when the document matches on many pages. Matches inside the snippet are wrapped in the
105
+ * control characters `U+0002` and `U+0003` rather than HTML, so replace them before rendering.
106
+ * The result is narrowed by access: only files of visible records of the sections enabled in the
107
+ * project settings, personal sections only down to the caller's own records, and the admins
108
+ * section is never returned. A separate 403 means the feature is not part of the project tariff.
109
+ * @example
110
+ * ```ts
111
+ * const found = await api.FileUploading.searchFileContent('transportation', 'en_US', ['pdf']);
112
+ * ```
113
+ * @see {@link https://js-sdk.oneentry.cloud/docs/file-uploading/searchFileContent searchFileContent} documentation.
114
+ */
115
+ async searchFileContent(query, langCode = this.state.lang, extensions, ownerTables, localeCodes, onlyTruncated, offset, limit) {
116
+ // Array filters are sent comma-separated — an array stringifies to exactly that.
117
+ const params = {
118
+ q: query,
119
+ langCode,
120
+ extensions,
121
+ ownerTables,
122
+ localeCodes,
123
+ onlyTruncated,
124
+ offset,
125
+ limit,
126
+ };
127
+ const result = await this._fetchGet(`/search?` + this._queryParamsToString(params));
128
+ // Validate response if validation is enabled
129
+ const validated = await this._validateResponse(result, schema('FileSearchResponseSchema'));
130
+ return this._normalizeData(validated);
131
+ }
90
132
  /**
91
133
  * Create a File object from a URL.
92
134
  * @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>;
@@ -17,3 +17,49 @@ export const UploadingReturnSchema = z.object({
17
17
  * Upload response schema (array of upload results)
18
18
  */
19
19
  export const UploadResponseSchema = z.array(UploadingReturnSchema);
20
+ /**
21
+ * One record a found file is attached to
22
+ */
23
+ export const FileSearchOwnerSchema = z.object({
24
+ tableName: z.string(),
25
+ dataId: z.number(),
26
+ title: z.string(),
27
+ langCode: z.string(),
28
+ });
29
+ /**
30
+ * Matching fragment of a found file
31
+ */
32
+ export const FileSearchSnippetSchema = z.object({
33
+ text: z.string(),
34
+ pageFrom: z.number().nullable(),
35
+ });
36
+ /**
37
+ * One found file
38
+ */
39
+ export const FileSearchItemSchema = z.object({
40
+ id: z.number(),
41
+ storageKey: z.string(),
42
+ extension: z.string(),
43
+ title: z.string().nullable(),
44
+ langCode: z.string().nullable(),
45
+ pageCount: z.number().nullable(),
46
+ rank: z.number(),
47
+ snippet: FileSearchSnippetSchema.nullable(),
48
+ owners: z.array(FileSearchOwnerSchema),
49
+ ownersTotal: z.number(),
50
+ });
51
+ /**
52
+ * File content search response
53
+ */
54
+ export const FileSearchResponseSchema = z.object({
55
+ total: z.number(),
56
+ offset: z.number(),
57
+ limit: z.number(),
58
+ queryLanguage: z.object({
59
+ resolved: z.array(z.string()),
60
+ source: z.string(),
61
+ candidates: z.array(z.string()),
62
+ }),
63
+ warnings: z.array(z.string()),
64
+ items: z.array(FileSearchItemSchema),
65
+ });
@@ -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"].
@@ -159,7 +159,7 @@ export default class FormsDataApi extends AsyncModules {
159
159
  "dateFrom": "2025-01-01",
160
160
  "dateTo": ""
161
161
  }
162
- * @param {string} [body.entityIdentifier] - Text identifier (marker) of the entity the records belong to. Example: "blog".
162
+ * @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".
163
163
  * @param {number} [body.parentId] - Identifier of the parent record, to fetch replies to one submission. Example: 10.
164
164
  * @param {string} [body.userIdentifier] - Text identifier of the sender. Example: "admin".
165
165
  * @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/esm/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import SystemApi from './system/systemApi.js';
28
28
  import TemplatesApi from './templates/templatesApi.js';
29
29
  import TemplatePreviewsApi from './templates-preview/templatesPreviewApi.js';
30
30
  import UserActivityApi from './user-activity/userActivityApi.js';
31
+ import UserGroupsApi from './user-groups/userGroupsApi.js';
31
32
  import UsersApi from './users/usersApi.js';
32
33
  import WsApi from './web-socket/wsApi.js';
33
34
  export { getAdditionalFields, getAttributeFile, getAttributeFiles, isFileAttribute, isListAttribute, isNumberAttribute, isStringAttribute, } from './base/attributes.js';
@@ -62,6 +63,7 @@ export type * from './types.js';
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/esm/index.js CHANGED
@@ -28,6 +28,7 @@ import SystemApi from './system/systemApi.js';
28
28
  import TemplatesApi from './templates/templatesApi.js';
29
29
  import TemplatePreviewsApi from './templates-preview/templatesPreviewApi.js';
30
30
  import UserActivityApi from './user-activity/userActivityApi.js';
31
+ import UserGroupsApi from './user-groups/userGroupsApi.js';
31
32
  import UsersApi from './users/usersApi.js';
32
33
  import WsApi from './web-socket/wsApi.js';
33
34
  export { getAdditionalFields, getAttributeFile, getAttributeFiles, isFileAttribute, isListAttribute, isNumberAttribute, isStringAttribute, } from './base/attributes.js';
@@ -90,6 +91,7 @@ export function defineOneEntry(url, config) {
90
91
  const Templates = new TemplatesApi(stateModule);
91
92
  const TemplatePreviews = new TemplatePreviewsApi(stateModule);
92
93
  const UserActivity = new UserActivityApi(stateModule);
94
+ const UserGroups = new UserGroupsApi(stateModule);
93
95
  const Users = new UsersApi(stateModule);
94
96
  const WS = new WsApi(stateModule);
95
97
  return {
@@ -119,6 +121,7 @@ export function defineOneEntry(url, config) {
119
121
  Templates,
120
122
  TemplatePreviews,
121
123
  UserActivity,
124
+ UserGroups,
122
125
  Users,
123
126
  WS,
124
127
  };
@@ -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
@@ -86,6 +86,25 @@ export default class OrdersApi extends AsyncModules {
86
86
  const validated = await this._validateResponse(result, schema('OrderEntitySchema'));
87
87
  return this._normalizeData(validated);
88
88
  }
89
+ /**
90
+ * Getting a single order created by the user, by its own id.
91
+ * @handleName getOrderById
92
+ * @param {number} id - ID of the order object. Example: 12345.
93
+ * @param {string} [langCode] - Language code. Default: "en_US".
94
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
95
+ * @throws {IError} When isShell=false and an error occurs during the fetch
96
+ * @description This method requires user authorization. Unlike `getOrderByMarkerAndId`,
97
+ * it does not need the storage marker — use it when only the order id is at hand, for
98
+ * example on the return URL of a payment provider or in a link from a notification.
99
+ * @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}.
100
+ * @see {@link https://js-sdk.oneentry.cloud/docs/orders/getOrderById getOrderById} documentation.
101
+ */
102
+ async getOrderById(id, langCode = this.state.lang) {
103
+ const result = await this._withOrdersUrl(() => this._fetchGet(`/${id}?langCode=${langCode}`));
104
+ // Validate response if validation is enabled
105
+ const validated = await this._validateResponse(result, schema('OrderEntitySchema'));
106
+ return this._normalizeData(validated);
107
+ }
89
108
  /**
90
109
  * Preview order calculation with discounts and coupons (without saving).
91
110
  * @handleName previewOrder
@@ -52,6 +52,17 @@ interface IOrdersApi {
52
52
  * @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}.
53
53
  */
54
54
  getOrderByMarkerAndId(marker: string, id: number, langCode?: string): Promise<IOrderByMarkerEntity | IError>;
55
+ /**
56
+ * Getting a single order created by the user, by its own id.
57
+ * @handleName getOrderById
58
+ * @param {number} id - ID of the order object. Example: 12345.
59
+ * @param {string} [langCode] - Language code. Default: "en_US".
60
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
61
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
62
+ * @description This method gets a single order by its own id, without the storage marker. This method requires user authorization.
63
+ * @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}.
64
+ */
65
+ getOrderById(id: number, langCode?: string): Promise<IOrderByMarkerEntity | IError>;
55
66
  /**
56
67
  * Creation of an order in the order storage.
57
68
  * @handleName createOrder
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules.js';
2
2
  import type StateModule from '../base/stateModule.js';
3
3
  import type { IError } from '../base/utils.js';
4
- import type { IAccountsEntity, IPaymentsApi, ISessionEntity, ISessionsEntity } from './paymentsInterfaces.js';
4
+ import type { IAccountsEntity, IPaymentProgress, IPaymentsApi, ISessionEntity, ISessionsEntity } from './paymentsInterfaces.js';
5
5
  /**
6
6
  * Controllers for working with payments
7
7
  * @handle /api/content/payments
@@ -85,4 +85,17 @@ export default class PaymentsApi extends AsyncModules implements IPaymentsApi {
85
85
  * @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccountById getAccountById} documentation.
86
86
  */
87
87
  getAccountById(id: number): Promise<IAccountsEntity | IError>;
88
+ /**
89
+ * Get the payment progress of an order: its stages and whether they are paid.
90
+ * @handleName getPaymentStagesByOrderId
91
+ * @param {number} id - ID of the order object. Example: 1.
92
+ * @returns {Promise<IPaymentProgress | IError>} Returns the payment progress of the order.
93
+ * @throws {IError} When isShell=false and an error occurs during the fetch
94
+ * @description An order can be paid in stages rather than in one payment — `partial` says
95
+ * which case it is, `completed` says whether nothing is left to pay, and every stage carries
96
+ * its own `status`. This method requires user authorization.
97
+ * @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}.
98
+ * @see {@link https://js-sdk.oneentry.cloud/docs/payments/getPaymentStagesByOrderId getPaymentStagesByOrderId} documentation.
99
+ */
100
+ getPaymentStagesByOrderId(id: number): Promise<IPaymentProgress | IError>;
88
101
  }
@@ -119,4 +119,22 @@ export default class PaymentsApi extends AsyncModules {
119
119
  const result = await this._fetchGet(`/accounts/${id}`);
120
120
  return this._normalizeData(result);
121
121
  }
122
+ /**
123
+ * Get the payment progress of an order: its stages and whether they are paid.
124
+ * @handleName getPaymentStagesByOrderId
125
+ * @param {number} id - ID of the order object. Example: 1.
126
+ * @returns {Promise<IPaymentProgress | IError>} Returns the payment progress of the order.
127
+ * @throws {IError} When isShell=false and an error occurs during the fetch
128
+ * @description An order can be paid in stages rather than in one payment — `partial` says
129
+ * which case it is, `completed` says whether nothing is left to pay, and every stage carries
130
+ * its own `status`. This method requires user authorization.
131
+ * @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}.
132
+ * @see {@link https://js-sdk.oneentry.cloud/docs/payments/getPaymentStagesByOrderId getPaymentStagesByOrderId} documentation.
133
+ */
134
+ async getPaymentStagesByOrderId(id) {
135
+ const result = await this._fetchGet(`/stages/order/${id}`);
136
+ // Validate response if validation is enabled
137
+ const validated = await this._validateResponse(result, schema('PaymentProgressSchema'));
138
+ return this._normalizeData(validated);
139
+ }
122
140
  }