oneentry 1.0.166 → 1.0.168
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 +46 -0
- package/dist/auth-provider/authProviderApi.js +3 -2
- package/dist/base/asyncModules.d.ts +18 -0
- package/dist/base/asyncModules.js +34 -1
- package/dist/base/syncModules.d.ts +10 -3
- package/dist/base/syncModules.js +25 -14
- 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/discounts/discountsApi.d.ts +3 -3
- package/dist/discounts/discountsApi.js +1 -1
- package/dist/discounts/discountsInterfaces.d.ts +15 -3
- 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/forms-data/formsDataInterfaces.d.ts +130 -3
- 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/search/searchApi.d.ts +3 -2
- package/dist/search/searchApi.js +6 -2
- package/dist/search/searchInterfaces.d.ts +3 -2
- 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/dist/users/usersApi.js +3 -3
- package/esm/auth-provider/authProviderApi.js +3 -2
- package/esm/base/asyncModules.d.ts +18 -0
- package/esm/base/asyncModules.js +34 -1
- package/esm/base/syncModules.d.ts +10 -3
- package/esm/base/syncModules.js +25 -14
- 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/discounts/discountsApi.d.ts +3 -3
- package/esm/discounts/discountsApi.js +1 -1
- package/esm/discounts/discountsInterfaces.d.ts +15 -3
- 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/forms-data/formsDataInterfaces.d.ts +130 -3
- 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/search/searchApi.d.ts +3 -2
- package/esm/search/searchApi.js +6 -2
- package/esm/search/searchInterfaces.d.ts +3 -2
- 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/esm/users/usersApi.js +3 -3
- 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
|
-
|
|
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,51 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.168
|
|
4
|
+
|
|
5
|
+
### What's Fixed
|
|
6
|
+
|
|
7
|
+
- **`Search.globalSearch` could not ask for a language, so a second-locale word found nothing.** The search index is per language, and the method sent no `langCode` — not even the one given to `defineOneEntry`. On a bilingual project the Spanish word "agua" came back with an empty group while the same request with `langCode=es_ES` returned a full page. The method now takes `langCode` as its last parameter, defaulting to the client's own language, so an existing call needs no edit and starts asking in the right language by itself. Measured on a bilingual stand: "agua" 0 → 30+, the English control unchanged (CMS-912).
|
|
8
|
+
|
|
9
|
+
- **Methods that post a body no longer modify the object they are given.** `_normalizePostBody` wrapped `formData` and dropped an empty `phoneSMS` in place, and `signUp` and `updateUser` wrote `langCode` onto the caller's object. A body that is reused — a retry wrapper, two parallel calls, a shared default — came back already wrapped, was wrapped a second time, and the platform answered `400 "formData.en_US[0].marker" is required`: a validation error about a field the caller never sent. The normalizer now works on a copy, `notificationData` included, and the caller's object is identical after the call (CMS-909).
|
|
10
|
+
|
|
11
|
+
- **A dropped connection returned `{}`, which reads exactly like an empty answer.** With `isShell` on — the default — a network failure was handed back as the thrown `TypeError`, whose `message` and `stack` are not enumerable, so it serialized to an empty object. There was no way to tell "no connection" from "no data": on one site such a value entered the page cache and was served for minutes after the link came back, and a static build baked a site of 404s while reporting success. A failure that never reached the platform now returns `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0` is a value no HTTP answer uses. An error the platform itself sent is passed through untouched (CMS-780).
|
|
12
|
+
|
|
13
|
+
- **`Discounts.getBonusHistory` was declared to return an array; it returns a container.** The endpoint answers `{ items, total }` — an account with no transactions gives `{"items":[],"total":0}` — while the method and the `IDiscounts` interface both promised `IBonusTransactionEntity[]`. Code written from the type read `.length` off an object and found `undefined`. The return type is now `IBonusHistoryResponse`, exported alongside the rest. Found while covering the module with tests (CMS-531); types only, the wire format did not change.
|
|
14
|
+
|
|
15
|
+
- **The declared value shapes of a form submission were the ones the platform refuses.** A body written from the types got three `400`s in a row: a `list` field typed as `[{ title, value }]` (a page attribute's shape) answers `value[0] must be a string`, a `text` field typed as an object answers `value must be an array`, and `params` inside it answers `is not allowed`; a `spam` field had no type at all and a bare token is refused with the same sentence as a wrong one. `IBodyPostFormData.formData` now uses submission-specific types — `IBodyPostTypeList` (a list of strings), `IBodyPostTypeText` (a one-element array holding exactly one of `plainValue`, `htmlValue` or `mdValue`, no `params`) and `IBodyPostTypeSpam` (`{ event: { token, siteKey } }`) — with the read types left as they were. Types and documentation only; the wire format did not change (CMS-888).
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
|
|
19
|
+
- **`discounts` and `oauth` now have tests that run.** The discounts suite covered four of six methods; `getBonusBalance` and `getBonusHistory` were untested, and it was the new coverage that found the wrong return type above. The suite went from 5 cases to 8, and the bonus ones authenticate first — the balance belongs to the signed-in user and answers `401` under the app token alone. The `oauth` case was an empty shell: its body was commented out and the expectation rule disabled, so it passed while testing nothing. The happy path still cannot be covered from the test stand — it needs a provider of type `oauth` and a one-time code from that provider's consent screen, and the stand has neither — so what is pinned instead is the SDK's own half of the contract: a refusal comes back as an error value rather than an exception, and the caller's body is not modified. The limitation is written into the test rather than left as a silent pass (CMS-531, CMS-532).
|
|
20
|
+
|
|
21
|
+
## v.1.0.167
|
|
22
|
+
|
|
23
|
+
### What's New
|
|
24
|
+
|
|
25
|
+
- **`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.
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
- **`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"`.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
- **`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.
|
|
34
|
+
|
|
35
|
+
- **`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`.
|
|
36
|
+
|
|
37
|
+
### What's Fixed
|
|
38
|
+
|
|
39
|
+
- **`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.
|
|
40
|
+
|
|
41
|
+
- **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.
|
|
42
|
+
|
|
43
|
+
- **`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.
|
|
44
|
+
|
|
45
|
+
### What's Deleted
|
|
46
|
+
|
|
47
|
+
- **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.
|
|
48
|
+
|
|
3
49
|
## v.1.0.166
|
|
4
50
|
|
|
5
51
|
### What's Fixed
|
|
@@ -124,8 +124,9 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
124
124
|
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
125
125
|
*/
|
|
126
126
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
// `langCode` goes onto our own copy — the caller's body stays as it was
|
|
128
|
+
// given, so a retry or a second parallel call sends the same thing (CMS-909).
|
|
129
|
+
const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody({ ...body, langCode }, langCode));
|
|
129
130
|
// Validate response if validation is enabled
|
|
130
131
|
const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
|
|
131
132
|
return this._normalizeData(validated);
|
|
@@ -120,4 +120,22 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
120
120
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
121
121
|
*/
|
|
122
122
|
private browserResponse;
|
|
123
|
+
/**
|
|
124
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
125
|
+
*
|
|
126
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
127
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
128
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
129
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
130
|
+
* page cache and was served for minutes after the link came back, and
|
|
131
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
132
|
+
*
|
|
133
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
134
|
+
* and is passed through untouched. Everything else becomes
|
|
135
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
136
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
137
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
138
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
139
|
+
*/
|
|
140
|
+
private _toShellError;
|
|
123
141
|
}
|
|
@@ -410,12 +410,45 @@ class AsyncModules extends syncModules_1.default {
|
|
|
410
410
|
// Handle any errors that occur during the fetch process
|
|
411
411
|
// Determine whether to return or throw the error based on 'isShell' state
|
|
412
412
|
if (this.state.isShell) {
|
|
413
|
-
return e;
|
|
413
|
+
return this._toShellError(e);
|
|
414
414
|
}
|
|
415
415
|
else {
|
|
416
416
|
throw e;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Turns whatever was thrown into the error shape the SDK already returns.
|
|
422
|
+
*
|
|
423
|
+
* With `isShell` on, a failure is returned rather than thrown — and a dropped
|
|
424
|
+
* connection throws a `TypeError`, whose `message` and `stack` are not
|
|
425
|
+
* enumerable. Returned as it was, it serializes to `{}` and reads exactly
|
|
426
|
+
* like an empty answer: on the sanbenitocog pilot such a value entered the
|
|
427
|
+
* page cache and was served for minutes after the link came back, and
|
|
428
|
+
* `next build` baked a site of 404s while reporting success (CMS-780).
|
|
429
|
+
*
|
|
430
|
+
* An object that already carries a `statusCode` is the platform's own error
|
|
431
|
+
* and is passed through untouched. Everything else becomes
|
|
432
|
+
* `{ statusCode: 0, message, pageData: null, timestamp }` — `statusCode: 0`
|
|
433
|
+
* says "the request never reached the platform", which no HTTP answer uses.
|
|
434
|
+
* @param {unknown} e - Whatever the try block threw.
|
|
435
|
+
* @returns {IError} The error in the shape the SDK returns for platform errors.
|
|
436
|
+
*/
|
|
437
|
+
_toShellError(e) {
|
|
438
|
+
if (e && typeof e === 'object' && 'statusCode' in e) {
|
|
439
|
+
return e;
|
|
440
|
+
}
|
|
441
|
+
const message = e instanceof Error
|
|
442
|
+
? `${e.name}: ${e.message}`
|
|
443
|
+
: typeof e === 'string'
|
|
444
|
+
? e
|
|
445
|
+
: 'Request failed before a response was received';
|
|
446
|
+
return {
|
|
447
|
+
statusCode: 0,
|
|
448
|
+
message,
|
|
449
|
+
pageData: null,
|
|
450
|
+
timestamp: new Date().toISOString(),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
420
453
|
}
|
|
421
454
|
exports.default = AsyncModules;
|
|
@@ -81,10 +81,17 @@ export default abstract class SyncModules {
|
|
|
81
81
|
* 2. **formData localization**: the API expects formData as
|
|
82
82
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
83
83
|
* The method wraps the data into the required structure.
|
|
84
|
-
* If `formData` is absent from the body — return
|
|
85
|
-
*
|
|
84
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
85
|
+
*
|
|
86
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
87
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
88
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
89
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
90
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
91
|
+
* never sent (CMS-909).
|
|
92
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
86
93
|
* @param {string} [langCode] - The language code for normalization.
|
|
87
|
-
* @returns {any}
|
|
94
|
+
* @returns {any} A normalized copy of the body.
|
|
88
95
|
*/
|
|
89
96
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
90
97
|
/**
|
package/dist/base/syncModules.js
CHANGED
|
@@ -220,27 +220,38 @@ class SyncModules {
|
|
|
220
220
|
* 2. **formData localization**: the API expects formData as
|
|
221
221
|
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
222
222
|
* The method wraps the data into the required structure.
|
|
223
|
-
* If `formData` is absent from the body — return
|
|
224
|
-
*
|
|
223
|
+
* If `formData` is absent from the body — return a copy with only the phoneSMS cleanup applied.
|
|
224
|
+
*
|
|
225
|
+
* **The caller's object is never touched.** Methods that post a body are
|
|
226
|
+
* routinely called with one that is reused — a retry wrapper, two parallel
|
|
227
|
+
* calls, a shared default. Normalizing in place sends the already-wrapped
|
|
228
|
+
* value the second time, it is wrapped again, and the platform answers
|
|
229
|
+
* `400 "formData.en_US[0].marker" is required` about a field the caller
|
|
230
|
+
* never sent (CMS-909).
|
|
231
|
+
* @param {any} body - The body to normalize. Left unchanged.
|
|
225
232
|
* @param {string} [langCode] - The language code for normalization.
|
|
226
|
-
* @returns {any}
|
|
233
|
+
* @returns {any} A normalized copy of the body.
|
|
227
234
|
*/
|
|
228
235
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
236
|
+
const next = { ...body };
|
|
237
|
+
// API does not accept phoneSMS = '' — drop the field if empty. `notificationData`
|
|
238
|
+
// is copied too: deleting the key on the original would reach the caller.
|
|
239
|
+
if (next.notificationData && next.notificationData.phoneSMS === '') {
|
|
240
|
+
next.notificationData = { ...next.notificationData };
|
|
241
|
+
delete next.notificationData.phoneSMS;
|
|
232
242
|
}
|
|
233
243
|
// If formData is not provided — no further normalization needed.
|
|
234
|
-
if (!
|
|
235
|
-
return
|
|
244
|
+
if (!next.formData)
|
|
245
|
+
return next;
|
|
236
246
|
// Wrap form fields in an object keyed by locale:
|
|
237
247
|
// [{ marker, value }] → { "en_US": [{ marker, value }] }
|
|
238
|
-
|
|
239
|
-
formData
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
// The fields themselves are reused by reference — they are not modified.
|
|
249
|
+
next.formData = {
|
|
250
|
+
[langCode]: Array.isArray(next.formData)
|
|
251
|
+
? next.formData
|
|
252
|
+
: [next.formData],
|
|
253
|
+
};
|
|
254
|
+
return next;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
246
257
|
* Normalizes the value of a single attribute in place.
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
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.
|
|
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;
|
package/dist/base/validation.js
CHANGED
|
@@ -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.
|
|
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 { IBonusBalanceEntity,
|
|
4
|
+
import type { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
7
|
* @handle /api/content/events
|
|
@@ -63,11 +63,11 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
63
63
|
* @param {number} [discountId] - Discount id filter.
|
|
64
64
|
* @param {number} [moduleId] - Module id filter.
|
|
65
65
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
66
|
-
* @returns {Promise<
|
|
66
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
67
67
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
68
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
69
69
|
*/
|
|
70
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
70
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
71
71
|
/**
|
|
72
72
|
* Validate discounts coupon
|
|
73
73
|
* @handleName validateDiscountsCoupon
|
|
@@ -85,7 +85,7 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
85
85
|
* @param {number} [discountId] - Discount id filter.
|
|
86
86
|
* @param {number} [moduleId] - Module id filter.
|
|
87
87
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
88
|
-
* @returns {Promise<
|
|
88
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
89
89
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
90
90
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
91
91
|
*/
|
|
@@ -55,10 +55,10 @@ interface IDiscountsApi {
|
|
|
55
55
|
* @param {number} [discountId] - Discount id filter.
|
|
56
56
|
* @param {number} [moduleId] - Module id filter.
|
|
57
57
|
* @param {boolean} [isAdmin] - Admin filter.
|
|
58
|
-
* @returns {Promise<
|
|
58
|
+
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
59
59
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
60
|
*/
|
|
61
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<
|
|
61
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
62
62
|
/**
|
|
63
63
|
* Semantic (vector) search for discounts.
|
|
64
64
|
* @handleName getDiscountsByVectorSearch
|
|
@@ -284,6 +284,18 @@ interface IBonusTransactionEntity {
|
|
|
284
284
|
expiresAt?: string;
|
|
285
285
|
createdAt?: string;
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* @interface IBonusHistoryResponse
|
|
289
|
+
* @property {IBonusTransactionEntity[]} items - The transactions of the current page.
|
|
290
|
+
* @property {number} total - How many transactions the filter matches in total.
|
|
291
|
+
* @description Container the bonus history arrives in. The endpoint answers
|
|
292
|
+
* `{ items, total }`, not a bare array — measured on the SDK test stand,
|
|
293
|
+
* 2026-09-28: an account with no transactions answers `{"items":[],"total":0}`.
|
|
294
|
+
*/
|
|
295
|
+
interface IBonusHistoryResponse {
|
|
296
|
+
items: IBonusTransactionEntity[];
|
|
297
|
+
total: number;
|
|
298
|
+
}
|
|
287
299
|
/**
|
|
288
300
|
* @interface IBonusBalanceEntity
|
|
289
301
|
* @description Represents the balance of bonus points.
|
|
@@ -292,4 +304,4 @@ interface IBonusTransactionEntity {
|
|
|
292
304
|
interface IBonusBalanceEntity {
|
|
293
305
|
balance: number;
|
|
294
306
|
}
|
|
295
|
-
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
307
|
+
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusHistoryResponse, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
@@ -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
|
-
|
|
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, };
|