@foxnose/sdk 0.5.1 → 0.6.1
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 +88 -0
- package/dist/index.cjs +126 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -4
- package/dist/index.d.ts +168 -4
- package/dist/index.js +126 -127
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -170,6 +170,73 @@ await client.updateResource('articles', created.resource_key, { title: 'Hello (e
|
|
|
170
170
|
client.close();
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
+
### Truncating long text fields
|
|
174
|
+
|
|
175
|
+
`truncate_text` is a query parameter on List Resources and Search that caps
|
|
176
|
+
every `text`-typed field to a maximum length. It is off by default, ignored
|
|
177
|
+
when `raw=true`, and the SDK does not validate it client-side — a value below
|
|
178
|
+
1 or a non-integer surfaces as a server `422 validation_error`.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// List Resources: truncate_text is a plain query param
|
|
182
|
+
const page = await client.listResources('articles', { truncate_text: 200 });
|
|
183
|
+
|
|
184
|
+
// Search: pass it via the third `options.params` argument, not the body
|
|
185
|
+
const results = await client.search(
|
|
186
|
+
'articles',
|
|
187
|
+
{ find_text: { query: 'machine learning' } },
|
|
188
|
+
{ params: { truncate_text: 200 } },
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// Truncated fields are reported per-resource under `_sys.truncated`; fields
|
|
192
|
+
// within the limit get no entry. `locale` is null for non-localized fields.
|
|
193
|
+
console.log(page.results[0]._sys.truncated);
|
|
194
|
+
// [{ field: 'body', locale: null, original_length: 850 }]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`next` is a full absolute URL and preserves `truncate_text` across pages.
|
|
198
|
+
The SDK does not follow `next` automatically — `buildUrl` always resolves
|
|
199
|
+
paths against the configured `baseUrl`, so a server-returned absolute URL
|
|
200
|
+
cannot be fed back in directly. Extract the cursor yourself:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const cursor = page.next ? new URL(page.next).searchParams.get('next') : null;
|
|
204
|
+
if (cursor) {
|
|
205
|
+
const nextPage = await client.listResources('articles', {
|
|
206
|
+
truncate_text: 200,
|
|
207
|
+
next: cursor,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Cross-parent addressing
|
|
213
|
+
|
|
214
|
+
A strict-reference collection can be reached at additional, read-only
|
|
215
|
+
addresses that omit some number of ancestor keys from the path — fully-flat
|
|
216
|
+
(drops every ancestor key) or partially-flat (keeps the root-most ancestor
|
|
217
|
+
keys). `folderPath` is always an opaque string that the SDK slash-trims and
|
|
218
|
+
interpolates without parsing, so any address the API exposes works unchanged
|
|
219
|
+
with `listResources`, `getResource`, `search`, and `getSchema`:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// Standard nested path
|
|
223
|
+
await client.listResources('realty/accounts/acc_1/listings/lst_1/photos');
|
|
224
|
+
|
|
225
|
+
// Partially-flat: keeps the root-most ancestor key
|
|
226
|
+
await client.listResources('realty/accounts/acc_1/listings/photos');
|
|
227
|
+
|
|
228
|
+
// Fully-flat: drops every ancestor key
|
|
229
|
+
await client.listResources('realty/accounts/listings/photos');
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
These addresses are read-only; the server rejects writes on a flat path.
|
|
233
|
+
Before relying on a given address, check `enabled`, `available`, and
|
|
234
|
+
`read_methods` on the connection's `flat_routes` (see
|
|
235
|
+
`ManagementClient.getApiCollection`) rather than assuming every read method
|
|
236
|
+
is available at every level — the API has known discrepancies here (Get
|
|
237
|
+
Resource reported at level 0; Search absent from `read_methods` at every
|
|
238
|
+
level) that the SDK types as sent, without correcting.
|
|
239
|
+
|
|
173
240
|
### Vector Search
|
|
174
241
|
|
|
175
242
|
The Flux client provides typed convenience methods for all vector search modes:
|
|
@@ -213,6 +280,14 @@ const results = await client.vectorSearch('articles', {
|
|
|
213
280
|
sort: '-published_at',
|
|
214
281
|
where: { category: 'science' },
|
|
215
282
|
});
|
|
283
|
+
|
|
284
|
+
// queryParams forwards to the query string of the underlying search() call —
|
|
285
|
+
// it is named queryParams, not params, because unknown keys on this options
|
|
286
|
+
// object are otherwise merged into the JSON body.
|
|
287
|
+
const truncated = await client.vectorSearch('articles', {
|
|
288
|
+
query: 'climate change',
|
|
289
|
+
queryParams: { truncate_text: 200 },
|
|
290
|
+
});
|
|
216
291
|
```
|
|
217
292
|
|
|
218
293
|
You can also use `buildSearchBody()` for full control with the raw `search()` method:
|
|
@@ -432,8 +507,21 @@ pnpm typecheck
|
|
|
432
507
|
|
|
433
508
|
# Format
|
|
434
509
|
pnpm format
|
|
510
|
+
|
|
511
|
+
# Check formatting without rewriting (this is what CI runs)
|
|
512
|
+
pnpm format:check
|
|
435
513
|
```
|
|
436
514
|
|
|
515
|
+
### Checks before pushing
|
|
516
|
+
|
|
517
|
+
CI gates on `pnpm lint`, `pnpm format:check`, `pnpm typecheck`, `pnpm test:coverage` and `pnpm build`. To run the same checks locally on every `git push`, enable the repo's hook directory once per clone:
|
|
518
|
+
|
|
519
|
+
```bash
|
|
520
|
+
git config core.hooksPath .githooks
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
`.githooks/pre-push` then runs lint, format, typecheck and tests, and aborts the push if any fail. It is opt-in per clone and can be skipped with `git push --no-verify`, so it is a fast feedback loop rather than a guarantee — CI remains the real gate.
|
|
524
|
+
|
|
437
525
|
## License
|
|
438
526
|
|
|
439
527
|
[Apache-2.0](LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -219,6 +219,7 @@ function getHeader(headers, name) {
|
|
|
219
219
|
}
|
|
220
220
|
return void 0;
|
|
221
221
|
}
|
|
222
|
+
var CONTENT_VALIDATION_CODES = /* @__PURE__ */ new Set(["content_validation_failed", "data_validation_error"]);
|
|
222
223
|
function buildAPIError(options) {
|
|
223
224
|
const { statusCode, errorCode, detail, responseHeaders, responseBody } = options;
|
|
224
225
|
const body = isPlainObject(responseBody) ? responseBody : void 0;
|
|
@@ -264,7 +265,7 @@ function buildAPIError(options) {
|
|
|
264
265
|
if (statusCode === 409 && errorCode === "external_id_conflict") {
|
|
265
266
|
return new ExternalIdConflictError(options);
|
|
266
267
|
}
|
|
267
|
-
if (statusCode === 422 && errorCode
|
|
268
|
+
if (statusCode === 422 && CONTENT_VALIDATION_CODES.has(errorCode)) {
|
|
268
269
|
const d = isPlainObject(detail) ? detail : {};
|
|
269
270
|
const errors = Array.isArray(d.errors) ? d.errors : typeof d.json_path === "string" ? [d] : [];
|
|
270
271
|
return new ContentValidationFailedError({
|
|
@@ -362,7 +363,7 @@ var DEFAULT_RETRY_CONFIG = {
|
|
|
362
363
|
statusCodes: [408, 425, 429, 500, 502, 503, 504],
|
|
363
364
|
methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
|
|
364
365
|
};
|
|
365
|
-
var SDK_VERSION = "0.
|
|
366
|
+
var SDK_VERSION = "0.6.1";
|
|
366
367
|
var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
|
|
367
368
|
function createConfig(options) {
|
|
368
369
|
if (!options.baseUrl) {
|
|
@@ -589,9 +590,7 @@ function warnDeprecatedMethod(oldName, newName, removal = "1.0") {
|
|
|
589
590
|
function nestedFieldMeta(opts) {
|
|
590
591
|
if (opts.extra) {
|
|
591
592
|
const reserved = ["component", "component_version", "auto_update"];
|
|
592
|
-
const collisions = reserved.filter(
|
|
593
|
-
(k) => Object.prototype.hasOwnProperty.call(opts.extra, k)
|
|
594
|
-
);
|
|
593
|
+
const collisions = reserved.filter((k) => Object.prototype.hasOwnProperty.call(opts.extra, k));
|
|
595
594
|
if (collisions.length > 0) {
|
|
596
595
|
throw new Error(
|
|
597
596
|
`nestedFieldMeta: 'extra' must not include reserved keys: ${collisions.join(", ")}`
|
|
@@ -650,6 +649,7 @@ function managementPaths(environmentKey) {
|
|
|
650
649
|
// Flux API key paths
|
|
651
650
|
fluxApiKeysRoot: () => `/v1/${environmentKey}/permissions/flux-api/api-keys`,
|
|
652
651
|
fluxApiKeyRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}`,
|
|
652
|
+
fluxApiKeyBearerTokenRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}/bearer-token`,
|
|
653
653
|
// API management paths
|
|
654
654
|
apisRoot: () => `/v1/${environmentKey}/api`,
|
|
655
655
|
apiRoot: (apiKey) => `/v1/${environmentKey}/api/${apiKey}`,
|
|
@@ -818,6 +818,41 @@ var ManagementClient = class {
|
|
|
818
818
|
const k = resolveKey(key);
|
|
819
819
|
await this.request("DELETE", `${this.paths.fluxApiKeyRoot(k)}/`, { parseJson: false });
|
|
820
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Issue a bearer token for a Flux API key, or replace the existing one.
|
|
823
|
+
*
|
|
824
|
+
* A bearer token exists for clients that accept a single token value and send
|
|
825
|
+
* it as `Authorization: Bearer <token>` with no way to choose the scheme —
|
|
826
|
+
* hosted MCP connectors, notably the Claude API's `mcp_servers`. Those clients
|
|
827
|
+
* cannot send `Simple` or `Secure` at all.
|
|
828
|
+
*
|
|
829
|
+
* THE PLAINTEXT IS RETURNED ONLY HERE, AND ONLY ONCE. The service stores a
|
|
830
|
+
* hash, exactly as it does for `secret_key`, so a lost token is re-issued
|
|
831
|
+
* rather than recovered. Subsequent key reads expose only
|
|
832
|
+
* `bearer_token_prefix`.
|
|
833
|
+
*
|
|
834
|
+
* The key itself is untouched: `public_key`, `secret_key`, `role` and grants
|
|
835
|
+
* all survive, so `Simple` and `Secure` integrations keep working across a
|
|
836
|
+
* re-issue. That is what makes this the way to cut off a connector without
|
|
837
|
+
* recreating a key and reconfiguring everything that uses it.
|
|
838
|
+
*
|
|
839
|
+
* There is at most one token per key; calling this again replaces it.
|
|
840
|
+
*/
|
|
841
|
+
async issueFluxApiKeyBearerToken(key) {
|
|
842
|
+
const k = resolveKey(key);
|
|
843
|
+
return this.request("POST", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Revoke a Flux API key's bearer token. The key and its role keep working.
|
|
847
|
+
*
|
|
848
|
+
* Idempotent: succeeds whether or not a token was issued.
|
|
849
|
+
*/
|
|
850
|
+
async revokeFluxApiKeyBearerToken(key) {
|
|
851
|
+
const k = resolveKey(key);
|
|
852
|
+
await this.request("DELETE", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`, {
|
|
853
|
+
parseJson: false
|
|
854
|
+
});
|
|
855
|
+
}
|
|
821
856
|
// ------------------------------------------------------------------ //
|
|
822
857
|
// API management operations
|
|
823
858
|
// ------------------------------------------------------------------ //
|
|
@@ -839,17 +874,17 @@ var ManagementClient = class {
|
|
|
839
874
|
const key = resolveKey(apiKey);
|
|
840
875
|
await this.request("DELETE", `${this.paths.apiRoot(key)}/`, { parseJson: false });
|
|
841
876
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
const body = {
|
|
877
|
+
/**
|
|
878
|
+
* Build the request body shared by all four API-collection-association
|
|
879
|
+
* writers: {@link addApiCollection}, {@link updateApiCollection}, and
|
|
880
|
+
* their deprecated `*ApiFolder*` twins. All four accept {@link
|
|
881
|
+
* ApiFolderOptions}, so this is the one place that maps its camelCase
|
|
882
|
+
* fields to wire snake_case — adding a field here, rather than to each
|
|
883
|
+
* method separately, is what keeps the deprecated twins from silently
|
|
884
|
+
* swallowing a field the type says they accept.
|
|
885
|
+
*/
|
|
886
|
+
buildApiFolderPayload(options) {
|
|
887
|
+
const body = {};
|
|
853
888
|
if (options?.allowedMethods !== void 0) {
|
|
854
889
|
body.allowed_methods = options.allowedMethods;
|
|
855
890
|
}
|
|
@@ -865,6 +900,25 @@ var ManagementClient = class {
|
|
|
865
900
|
if (options?.descriptionSchema !== void 0) {
|
|
866
901
|
body.description_schema = options.descriptionSchema;
|
|
867
902
|
}
|
|
903
|
+
if (options?.unscopedLevels !== void 0) {
|
|
904
|
+
body.unscoped_levels = options.unscopedLevels;
|
|
905
|
+
}
|
|
906
|
+
if (options?.unscopedAncestors !== void 0) {
|
|
907
|
+
body.unscoped_ancestors = options.unscopedAncestors;
|
|
908
|
+
}
|
|
909
|
+
return body;
|
|
910
|
+
}
|
|
911
|
+
// ------------------------------------------------------------------ //
|
|
912
|
+
// API ↔ Collection association (canonical)
|
|
913
|
+
// ------------------------------------------------------------------ //
|
|
914
|
+
async listApiCollections(apiKey, params) {
|
|
915
|
+
const key = resolveKey(apiKey);
|
|
916
|
+
return this.request("GET", `${this.paths.apiCollectionsRoot(key)}/`, { params });
|
|
917
|
+
}
|
|
918
|
+
async addApiCollection(apiKey, collectionKey, options) {
|
|
919
|
+
const aKey = resolveKey(apiKey);
|
|
920
|
+
const cKey = resolveKey(collectionKey);
|
|
921
|
+
const body = { folder: cKey, ...this.buildApiFolderPayload(options) };
|
|
868
922
|
return this.request("POST", `${this.paths.apiCollectionsRoot(aKey)}/`, {
|
|
869
923
|
jsonBody: body
|
|
870
924
|
});
|
|
@@ -877,22 +931,7 @@ var ManagementClient = class {
|
|
|
877
931
|
async updateApiCollection(apiKey, collectionKey, options) {
|
|
878
932
|
const aKey = resolveKey(apiKey);
|
|
879
933
|
const cKey = resolveKey(collectionKey);
|
|
880
|
-
const body =
|
|
881
|
-
if (options?.allowedMethods !== void 0) {
|
|
882
|
-
body.allowed_methods = options.allowedMethods;
|
|
883
|
-
}
|
|
884
|
-
if (options?.descriptionGetOne !== void 0) {
|
|
885
|
-
body.description_get_one = options.descriptionGetOne;
|
|
886
|
-
}
|
|
887
|
-
if (options?.descriptionGetMany !== void 0) {
|
|
888
|
-
body.description_get_many = options.descriptionGetMany;
|
|
889
|
-
}
|
|
890
|
-
if (options?.descriptionSearch !== void 0) {
|
|
891
|
-
body.description_search = options.descriptionSearch;
|
|
892
|
-
}
|
|
893
|
-
if (options?.descriptionSchema !== void 0) {
|
|
894
|
-
body.description_schema = options.descriptionSchema;
|
|
895
|
-
}
|
|
934
|
+
const body = this.buildApiFolderPayload(options);
|
|
896
935
|
return this.request("PUT", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
|
|
897
936
|
jsonBody: body
|
|
898
937
|
});
|
|
@@ -900,11 +939,9 @@ var ManagementClient = class {
|
|
|
900
939
|
async removeApiCollection(apiKey, collectionKey) {
|
|
901
940
|
const aKey = resolveKey(apiKey);
|
|
902
941
|
const cKey = resolveKey(collectionKey);
|
|
903
|
-
await this.request(
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
{ parseJson: false }
|
|
907
|
-
);
|
|
942
|
+
await this.request("DELETE", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
|
|
943
|
+
parseJson: false
|
|
944
|
+
});
|
|
908
945
|
}
|
|
909
946
|
// ------------------------------------------------------------------ //
|
|
910
947
|
// API ↔ Folder association (deprecated; hits legacy /folders/ URL)
|
|
@@ -920,22 +957,7 @@ var ManagementClient = class {
|
|
|
920
957
|
warnDeprecatedMethod("addApiFolder", "addApiCollection");
|
|
921
958
|
const aKey = resolveKey(apiKey);
|
|
922
959
|
const fKey = resolveKey(folderKey);
|
|
923
|
-
const body = { folder: fKey };
|
|
924
|
-
if (options?.allowedMethods !== void 0) {
|
|
925
|
-
body.allowed_methods = options.allowedMethods;
|
|
926
|
-
}
|
|
927
|
-
if (options?.descriptionGetOne !== void 0) {
|
|
928
|
-
body.description_get_one = options.descriptionGetOne;
|
|
929
|
-
}
|
|
930
|
-
if (options?.descriptionGetMany !== void 0) {
|
|
931
|
-
body.description_get_many = options.descriptionGetMany;
|
|
932
|
-
}
|
|
933
|
-
if (options?.descriptionSearch !== void 0) {
|
|
934
|
-
body.description_search = options.descriptionSearch;
|
|
935
|
-
}
|
|
936
|
-
if (options?.descriptionSchema !== void 0) {
|
|
937
|
-
body.description_schema = options.descriptionSchema;
|
|
938
|
-
}
|
|
960
|
+
const body = { folder: fKey, ...this.buildApiFolderPayload(options) };
|
|
939
961
|
return this.request("POST", `${this.paths.apiFoldersRoot(aKey)}/`, { jsonBody: body });
|
|
940
962
|
}
|
|
941
963
|
/** @deprecated Use {@link getApiCollection} instead. */
|
|
@@ -950,22 +972,7 @@ var ManagementClient = class {
|
|
|
950
972
|
warnDeprecatedMethod("updateApiFolder", "updateApiCollection");
|
|
951
973
|
const aKey = resolveKey(apiKey);
|
|
952
974
|
const fKey = resolveKey(folderKey);
|
|
953
|
-
const body =
|
|
954
|
-
if (options?.allowedMethods !== void 0) {
|
|
955
|
-
body.allowed_methods = options.allowedMethods;
|
|
956
|
-
}
|
|
957
|
-
if (options?.descriptionGetOne !== void 0) {
|
|
958
|
-
body.description_get_one = options.descriptionGetOne;
|
|
959
|
-
}
|
|
960
|
-
if (options?.descriptionGetMany !== void 0) {
|
|
961
|
-
body.description_get_many = options.descriptionGetMany;
|
|
962
|
-
}
|
|
963
|
-
if (options?.descriptionSearch !== void 0) {
|
|
964
|
-
body.description_search = options.descriptionSearch;
|
|
965
|
-
}
|
|
966
|
-
if (options?.descriptionSchema !== void 0) {
|
|
967
|
-
body.description_schema = options.descriptionSchema;
|
|
968
|
-
}
|
|
975
|
+
const body = this.buildApiFolderPayload(options);
|
|
969
976
|
return this.request("PUT", `${this.paths.apiFoldersRoot(aKey)}/${fKey}/`, {
|
|
970
977
|
jsonBody: body
|
|
971
978
|
});
|
|
@@ -1192,39 +1199,28 @@ var ManagementClient = class {
|
|
|
1192
1199
|
if (options?.includeSchema !== void 0) {
|
|
1193
1200
|
params.include_schema = options.includeSchema;
|
|
1194
1201
|
}
|
|
1195
|
-
return this.request(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
{
|
|
1199
|
-
params: Object.keys(params).length > 0 ? params : void 0
|
|
1200
|
-
}
|
|
1201
|
-
);
|
|
1202
|
+
return this.request("GET", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1203
|
+
params: Object.keys(params).length > 0 ? params : void 0
|
|
1204
|
+
});
|
|
1202
1205
|
}
|
|
1203
1206
|
async updateCollectionVersion(collectionKey, versionKey, payload) {
|
|
1204
1207
|
const cKey = resolveKey(collectionKey);
|
|
1205
1208
|
const vKey = resolveKey(versionKey);
|
|
1206
|
-
return this.request(
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
{ jsonBody: payload }
|
|
1210
|
-
);
|
|
1209
|
+
return this.request("PUT", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1210
|
+
jsonBody: payload
|
|
1211
|
+
});
|
|
1211
1212
|
}
|
|
1212
1213
|
async deleteCollectionVersion(collectionKey, versionKey) {
|
|
1213
1214
|
const cKey = resolveKey(collectionKey);
|
|
1214
1215
|
const vKey = resolveKey(versionKey);
|
|
1215
|
-
await this.request(
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
{ parseJson: false }
|
|
1219
|
-
);
|
|
1216
|
+
await this.request("DELETE", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1217
|
+
parseJson: false
|
|
1218
|
+
});
|
|
1220
1219
|
}
|
|
1221
1220
|
async publishCollectionVersion(collectionKey, versionKey) {
|
|
1222
1221
|
const cKey = resolveKey(collectionKey);
|
|
1223
1222
|
const vKey = resolveKey(versionKey);
|
|
1224
|
-
return this.request(
|
|
1225
|
-
"POST",
|
|
1226
|
-
`${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`
|
|
1227
|
-
);
|
|
1223
|
+
return this.request("POST", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`);
|
|
1228
1224
|
}
|
|
1229
1225
|
/**
|
|
1230
1226
|
* Advance pinned nested fields on a Collection to a target Component version.
|
|
@@ -1287,11 +1283,7 @@ var ManagementClient = class {
|
|
|
1287
1283
|
if (options.toVersions !== void 0) {
|
|
1288
1284
|
body.to_versions = options.toVersions;
|
|
1289
1285
|
}
|
|
1290
|
-
return this.request(
|
|
1291
|
-
"POST",
|
|
1292
|
-
`${this.paths.collectionSyncComponent(cKey)}/`,
|
|
1293
|
-
{ jsonBody: body }
|
|
1294
|
-
);
|
|
1286
|
+
return this.request("POST", `${this.paths.collectionSyncComponent(cKey)}/`, { jsonBody: body });
|
|
1295
1287
|
}
|
|
1296
1288
|
// ------------------------------------------------------------------ //
|
|
1297
1289
|
// Collection schema field operations (canonical)
|
|
@@ -1299,47 +1291,37 @@ var ManagementClient = class {
|
|
|
1299
1291
|
async listCollectionFields(collectionKey, versionKey, params) {
|
|
1300
1292
|
const cKey = resolveKey(collectionKey);
|
|
1301
1293
|
const vKey = resolveKey(versionKey);
|
|
1302
|
-
return this.request(
|
|
1303
|
-
"GET",
|
|
1304
|
-
`${this.paths.collectionSchemaTree(cKey, vKey)}/`,
|
|
1305
|
-
{ params }
|
|
1306
|
-
);
|
|
1294
|
+
return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, { params });
|
|
1307
1295
|
}
|
|
1308
1296
|
async createCollectionField(collectionKey, versionKey, payload) {
|
|
1309
1297
|
const cKey = resolveKey(collectionKey);
|
|
1310
1298
|
const vKey = resolveKey(versionKey);
|
|
1311
|
-
return this.request(
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
{ jsonBody: payload }
|
|
1315
|
-
);
|
|
1299
|
+
return this.request("POST", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, {
|
|
1300
|
+
jsonBody: payload
|
|
1301
|
+
});
|
|
1316
1302
|
}
|
|
1317
1303
|
async getCollectionField(collectionKey, versionKey, fieldPath) {
|
|
1318
1304
|
const cKey = resolveKey(collectionKey);
|
|
1319
1305
|
const vKey = resolveKey(versionKey);
|
|
1320
|
-
return this.request(
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
{ params: { path: fieldPath } }
|
|
1324
|
-
);
|
|
1306
|
+
return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1307
|
+
params: { path: fieldPath }
|
|
1308
|
+
});
|
|
1325
1309
|
}
|
|
1326
1310
|
async updateCollectionField(collectionKey, versionKey, fieldPath, payload) {
|
|
1327
1311
|
const cKey = resolveKey(collectionKey);
|
|
1328
1312
|
const vKey = resolveKey(versionKey);
|
|
1329
|
-
return this.request(
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
);
|
|
1313
|
+
return this.request("PUT", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1314
|
+
params: { path: fieldPath },
|
|
1315
|
+
jsonBody: payload
|
|
1316
|
+
});
|
|
1334
1317
|
}
|
|
1335
1318
|
async deleteCollectionField(collectionKey, versionKey, fieldPath) {
|
|
1336
1319
|
const cKey = resolveKey(collectionKey);
|
|
1337
1320
|
const vKey = resolveKey(versionKey);
|
|
1338
|
-
await this.request(
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
);
|
|
1321
|
+
await this.request("DELETE", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1322
|
+
params: { path: fieldPath },
|
|
1323
|
+
parseJson: false
|
|
1324
|
+
});
|
|
1343
1325
|
}
|
|
1344
1326
|
// ------------------------------------------------------------------ //
|
|
1345
1327
|
// Folder operations (deprecated; hit legacy /folders/ URL)
|
|
@@ -2043,6 +2025,11 @@ function buildSearchBody(req) {
|
|
|
2043
2025
|
return body;
|
|
2044
2026
|
}
|
|
2045
2027
|
function mergeExtra(validated, extra) {
|
|
2028
|
+
if ("truncate_text" in extra) {
|
|
2029
|
+
throw new Error(
|
|
2030
|
+
"'truncate_text' is a query parameter, not a body field. Pass it via the 'queryParams' option instead."
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2046
2033
|
const conflicts = [];
|
|
2047
2034
|
for (const key of Object.keys(extra)) {
|
|
2048
2035
|
if (SEARCH_REQUEST_KNOWN_KEYS.has(key)) {
|
|
@@ -2106,9 +2093,9 @@ var FluxClient = class {
|
|
|
2106
2093
|
const path = this.buildPath(folderPath, `/${resourceKey}`);
|
|
2107
2094
|
return this.transport.request("GET", path, { params });
|
|
2108
2095
|
}
|
|
2109
|
-
async search(folderPath, body) {
|
|
2096
|
+
async search(folderPath, body, options) {
|
|
2110
2097
|
const path = this.buildPath(folderPath, "/_search");
|
|
2111
|
-
return this.transport.request("POST", path, { jsonBody: body });
|
|
2098
|
+
return this.transport.request("POST", path, { jsonBody: body, params: options?.params });
|
|
2112
2099
|
}
|
|
2113
2100
|
/**
|
|
2114
2101
|
* Create a resource in a collection and publish it immediately.
|
|
@@ -2152,7 +2139,16 @@ var FluxClient = class {
|
|
|
2152
2139
|
}
|
|
2153
2140
|
/** Semantic search using auto-generated embeddings. */
|
|
2154
2141
|
async vectorSearch(folderPath, options) {
|
|
2155
|
-
const {
|
|
2142
|
+
const {
|
|
2143
|
+
query,
|
|
2144
|
+
fields,
|
|
2145
|
+
top_k = 10,
|
|
2146
|
+
similarity_threshold,
|
|
2147
|
+
limit,
|
|
2148
|
+
offset,
|
|
2149
|
+
queryParams,
|
|
2150
|
+
...rest
|
|
2151
|
+
} = options;
|
|
2156
2152
|
const extra = stripUndefined(rest);
|
|
2157
2153
|
const vs = { query, fields, top_k, similarity_threshold };
|
|
2158
2154
|
const req = {
|
|
@@ -2162,7 +2158,7 @@ var FluxClient = class {
|
|
|
2162
2158
|
offset
|
|
2163
2159
|
};
|
|
2164
2160
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2165
|
-
return this.search(folderPath, body);
|
|
2161
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2166
2162
|
}
|
|
2167
2163
|
/** Search using custom pre-computed embeddings. */
|
|
2168
2164
|
async vectorFieldSearch(folderPath, options) {
|
|
@@ -2173,6 +2169,7 @@ var FluxClient = class {
|
|
|
2173
2169
|
similarity_threshold,
|
|
2174
2170
|
limit,
|
|
2175
2171
|
offset,
|
|
2172
|
+
queryParams,
|
|
2176
2173
|
...rest
|
|
2177
2174
|
} = options;
|
|
2178
2175
|
const extra = stripUndefined(rest);
|
|
@@ -2184,7 +2181,7 @@ var FluxClient = class {
|
|
|
2184
2181
|
offset
|
|
2185
2182
|
};
|
|
2186
2183
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2187
|
-
return this.search(folderPath, body);
|
|
2184
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2188
2185
|
}
|
|
2189
2186
|
/** Blended text + vector search with configurable weights. */
|
|
2190
2187
|
async hybridSearch(folderPath, options) {
|
|
@@ -2199,6 +2196,7 @@ var FluxClient = class {
|
|
|
2199
2196
|
rerank_results = true,
|
|
2200
2197
|
limit,
|
|
2201
2198
|
offset,
|
|
2199
|
+
queryParams,
|
|
2202
2200
|
...rest
|
|
2203
2201
|
} = options;
|
|
2204
2202
|
const extra = stripUndefined(rest);
|
|
@@ -2213,7 +2211,7 @@ var FluxClient = class {
|
|
|
2213
2211
|
offset
|
|
2214
2212
|
};
|
|
2215
2213
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2216
|
-
return this.search(folderPath, body);
|
|
2214
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2217
2215
|
}
|
|
2218
2216
|
/** Text search with results boosted by vector similarity. */
|
|
2219
2217
|
async boostedSearch(folderPath, options) {
|
|
@@ -2229,6 +2227,7 @@ var FluxClient = class {
|
|
|
2229
2227
|
max_boost_results = 20,
|
|
2230
2228
|
limit,
|
|
2231
2229
|
offset,
|
|
2230
|
+
queryParams,
|
|
2232
2231
|
...rest
|
|
2233
2232
|
} = options;
|
|
2234
2233
|
const extra = stripUndefined(rest);
|
|
@@ -2265,7 +2264,7 @@ var FluxClient = class {
|
|
|
2265
2264
|
offset
|
|
2266
2265
|
};
|
|
2267
2266
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2268
|
-
return this.search(folderPath, body);
|
|
2267
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2269
2268
|
}
|
|
2270
2269
|
async getRouter() {
|
|
2271
2270
|
const path = `/${this.apiPrefix}/_router`;
|