oneentry 1.0.166 → 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.
- package/README.md +5 -1
- package/changelog.md +28 -0
- package/dist/base/utils.d.ts +5 -2
- package/dist/base/validation.d.ts +7 -5
- package/dist/base/validation.js +7 -4
- package/dist/file-uploading/fileUploadingApi.d.ts +27 -1
- package/dist/file-uploading/fileUploadingApi.js +42 -0
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +102 -1
- package/dist/file-uploading/fileUploadingSchemas.d.ts +73 -0
- package/dist/file-uploading/fileUploadingSchemas.js +47 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/orders/ordersApi.d.ts +14 -0
- package/dist/orders/ordersApi.js +19 -0
- package/dist/orders/ordersInterfaces.d.ts +11 -0
- package/dist/payments/paymentsApi.d.ts +14 -1
- package/dist/payments/paymentsApi.js +18 -0
- package/dist/payments/paymentsInterfaces.d.ts +43 -1
- package/dist/payments/paymentsSchemas.d.ts +32 -0
- package/dist/payments/paymentsSchemas.js +20 -1
- package/dist/types.d.ts +1 -0
- package/dist/user-groups/userGroupsApi.d.ts +81 -0
- package/dist/user-groups/userGroupsApi.js +145 -0
- package/dist/user-groups/userGroupsInterfaces.d.ts +100 -0
- package/dist/user-groups/userGroupsInterfaces.js +2 -0
- package/dist/user-groups/userGroupsSchemas.d.ts +55 -0
- package/dist/user-groups/userGroupsSchemas.js +35 -0
- package/esm/base/utils.d.ts +5 -2
- package/esm/base/validation.d.ts +7 -5
- package/esm/base/validation.js +7 -4
- package/esm/file-uploading/fileUploadingApi.d.ts +27 -1
- package/esm/file-uploading/fileUploadingApi.js +42 -0
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +102 -1
- package/esm/file-uploading/fileUploadingSchemas.d.ts +73 -0
- package/esm/file-uploading/fileUploadingSchemas.js +46 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +3 -0
- package/esm/orders/ordersApi.d.ts +14 -0
- package/esm/orders/ordersApi.js +19 -0
- package/esm/orders/ordersInterfaces.d.ts +11 -0
- package/esm/payments/paymentsApi.d.ts +14 -1
- package/esm/payments/paymentsApi.js +18 -0
- package/esm/payments/paymentsInterfaces.d.ts +43 -1
- package/esm/payments/paymentsSchemas.d.ts +32 -0
- package/esm/payments/paymentsSchemas.js +19 -0
- package/esm/types.d.ts +1 -0
- package/esm/user-groups/userGroupsApi.d.ts +81 -0
- package/esm/user-groups/userGroupsApi.js +106 -0
- package/esm/user-groups/userGroupsInterfaces.d.ts +100 -0
- package/esm/user-groups/userGroupsInterfaces.js +1 -0
- package/esm/user-groups/userGroupsSchemas.d.ts +55 -0
- package/esm/user-groups/userGroupsSchemas.js +32 -0
- package/package.json +2 -2
|
@@ -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
|
-
|
|
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
|
+
});
|
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
|
package/esm/orders/ordersApi.js
CHANGED
|
@@ -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
|
}
|
|
@@ -66,6 +66,16 @@ interface IPaymentsApi {
|
|
|
66
66
|
* @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}.
|
|
67
67
|
*/
|
|
68
68
|
getAccountById(id: number): Promise<IAccountsEntity | IError>;
|
|
69
|
+
/**
|
|
70
|
+
* Get the payment progress of an order: its stages and whether they are paid.
|
|
71
|
+
* @handleName getPaymentStagesByOrderId
|
|
72
|
+
* @param {number} id - ID of the order object. Example: 1.
|
|
73
|
+
* @returns {IPaymentProgress} Returns the payment progress of the order.
|
|
74
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
75
|
+
* @description This method gets the payment stages of an order. This method requires user authorization.
|
|
76
|
+
* @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}.
|
|
77
|
+
*/
|
|
78
|
+
getPaymentStagesByOrderId(id: number): Promise<IPaymentProgress | IError>;
|
|
69
79
|
}
|
|
70
80
|
/**
|
|
71
81
|
* @interface ISessionsEntity
|
|
@@ -186,4 +196,36 @@ interface IPaymentAccountTestSettings {
|
|
|
186
196
|
signingSecretKey?: string;
|
|
187
197
|
useWebHookValidation?: boolean;
|
|
188
198
|
}
|
|
189
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The `IPaymentProgress` interface describes the payment progress of an order.
|
|
201
|
+
* @interface IPaymentProgress
|
|
202
|
+
* @property {boolean} completed - True when every stage of the order has been paid. Example: false.
|
|
203
|
+
* @property {boolean} partial - True when the order is paid in stages rather than in one payment. Example: true.
|
|
204
|
+
* @property {IPaymentStage[]} stages - The stages themselves, in the order the API returns them.
|
|
205
|
+
* @description This interface describes the payment progress of an order — whether it is fully paid, whether it is split into stages, and the stages themselves.
|
|
206
|
+
*/
|
|
207
|
+
interface IPaymentProgress {
|
|
208
|
+
completed: boolean;
|
|
209
|
+
partial: boolean;
|
|
210
|
+
stages: IPaymentStage[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The `IPaymentStage` interface describes one payment stage of an order.
|
|
214
|
+
* @interface IPaymentStage
|
|
215
|
+
* @property {string} marker - Marker of the attribute that set the price of the stage. Example: "part_a".
|
|
216
|
+
* @property {number} sessionId - Identifier of the payment session bound to the stage. Example: 100.
|
|
217
|
+
* @property {number} productId - Identifier of the product the stage belongs to. Example: 200.
|
|
218
|
+
* @property {string} title - Title of the stage. Example: "Part A".
|
|
219
|
+
* @property {number} value - Price of the stage. Example: 150.
|
|
220
|
+
* @property {"planned" | "completed"} status - Stage status: "planned" — not paid yet, "completed" — paid. Example: "planned".
|
|
221
|
+
* @description This interface describes one payment stage of an order.
|
|
222
|
+
*/
|
|
223
|
+
interface IPaymentStage {
|
|
224
|
+
marker: string;
|
|
225
|
+
sessionId: number;
|
|
226
|
+
productId: number;
|
|
227
|
+
title: string;
|
|
228
|
+
value: number;
|
|
229
|
+
status: 'planned' | 'completed';
|
|
230
|
+
}
|
|
231
|
+
export type { IAccountsEntity, IIntent, IPaymentAccountSettings, IPaymentAccountTestSettings, IPaymentProgress, IPaymentsApi, IPaymentStage, ISessionEntity, ISessionsEntity, };
|
|
@@ -92,3 +92,35 @@ export declare const PaymentAccountsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
92
92
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
93
93
|
updatedDate: z.ZodString;
|
|
94
94
|
}, z.core.$strip>>;
|
|
95
|
+
/**
|
|
96
|
+
* Payment stage schema
|
|
97
|
+
*/
|
|
98
|
+
export declare const PaymentStageSchema: z.ZodObject<{
|
|
99
|
+
marker: z.ZodString;
|
|
100
|
+
sessionId: z.ZodNumber;
|
|
101
|
+
productId: z.ZodNumber;
|
|
102
|
+
title: z.ZodString;
|
|
103
|
+
value: z.ZodNumber;
|
|
104
|
+
status: z.ZodEnum<{
|
|
105
|
+
completed: "completed";
|
|
106
|
+
planned: "planned";
|
|
107
|
+
}>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
/**
|
|
110
|
+
* Payment progress schema — stages of one order plus their aggregate state
|
|
111
|
+
*/
|
|
112
|
+
export declare const PaymentProgressSchema: z.ZodObject<{
|
|
113
|
+
completed: z.ZodBoolean;
|
|
114
|
+
partial: z.ZodBoolean;
|
|
115
|
+
stages: z.ZodArray<z.ZodObject<{
|
|
116
|
+
marker: z.ZodString;
|
|
117
|
+
sessionId: z.ZodNumber;
|
|
118
|
+
productId: z.ZodNumber;
|
|
119
|
+
title: z.ZodString;
|
|
120
|
+
value: z.ZodNumber;
|
|
121
|
+
status: z.ZodEnum<{
|
|
122
|
+
completed: "completed";
|
|
123
|
+
planned: "planned";
|
|
124
|
+
}>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
@@ -51,3 +51,22 @@ export const PaymentAccountSchema = z.object({
|
|
|
51
51
|
* Payment accounts response schema
|
|
52
52
|
*/
|
|
53
53
|
export const PaymentAccountsResponseSchema = z.array(PaymentAccountSchema);
|
|
54
|
+
/**
|
|
55
|
+
* Payment stage schema
|
|
56
|
+
*/
|
|
57
|
+
export const PaymentStageSchema = z.object({
|
|
58
|
+
marker: z.string(),
|
|
59
|
+
sessionId: z.number(),
|
|
60
|
+
productId: z.number(),
|
|
61
|
+
title: z.string(),
|
|
62
|
+
value: z.number(),
|
|
63
|
+
status: z.enum(['planned', 'completed']),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Payment progress schema — stages of one order plus their aggregate state
|
|
67
|
+
*/
|
|
68
|
+
export const PaymentProgressSchema = z.object({
|
|
69
|
+
completed: z.boolean(),
|
|
70
|
+
partial: z.boolean(),
|
|
71
|
+
stages: z.array(PaymentStageSchema),
|
|
72
|
+
});
|
package/esm/types.d.ts
CHANGED
|
@@ -31,5 +31,6 @@ export type * from './system/systemInterfaces.js';
|
|
|
31
31
|
export type * from './templates/templatesInterfaces.js';
|
|
32
32
|
export type * from './templates-preview/templatesPreviewInterfaces.js';
|
|
33
33
|
export type * from './user-activity/userActivityInterfaces.js';
|
|
34
|
+
export type * from './user-groups/userGroupsInterfaces.js';
|
|
34
35
|
export type * from './users/usersInterfaces.js';
|
|
35
36
|
export type * from './web-socket/wsInterfaces.js';
|