@foxnose/sdk 0.5.1 → 0.6.0
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 +124 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -4
- package/dist/index.d.ts +162 -4
- package/dist/index.js +124 -126
- 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
|
@@ -362,7 +362,7 @@ var DEFAULT_RETRY_CONFIG = {
|
|
|
362
362
|
statusCodes: [408, 425, 429, 500, 502, 503, 504],
|
|
363
363
|
methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
|
|
364
364
|
};
|
|
365
|
-
var SDK_VERSION = "0.
|
|
365
|
+
var SDK_VERSION = "0.6.0";
|
|
366
366
|
var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
|
|
367
367
|
function createConfig(options) {
|
|
368
368
|
if (!options.baseUrl) {
|
|
@@ -589,9 +589,7 @@ function warnDeprecatedMethod(oldName, newName, removal = "1.0") {
|
|
|
589
589
|
function nestedFieldMeta(opts) {
|
|
590
590
|
if (opts.extra) {
|
|
591
591
|
const reserved = ["component", "component_version", "auto_update"];
|
|
592
|
-
const collisions = reserved.filter(
|
|
593
|
-
(k) => Object.prototype.hasOwnProperty.call(opts.extra, k)
|
|
594
|
-
);
|
|
592
|
+
const collisions = reserved.filter((k) => Object.prototype.hasOwnProperty.call(opts.extra, k));
|
|
595
593
|
if (collisions.length > 0) {
|
|
596
594
|
throw new Error(
|
|
597
595
|
`nestedFieldMeta: 'extra' must not include reserved keys: ${collisions.join(", ")}`
|
|
@@ -650,6 +648,7 @@ function managementPaths(environmentKey) {
|
|
|
650
648
|
// Flux API key paths
|
|
651
649
|
fluxApiKeysRoot: () => `/v1/${environmentKey}/permissions/flux-api/api-keys`,
|
|
652
650
|
fluxApiKeyRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}`,
|
|
651
|
+
fluxApiKeyBearerTokenRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}/bearer-token`,
|
|
653
652
|
// API management paths
|
|
654
653
|
apisRoot: () => `/v1/${environmentKey}/api`,
|
|
655
654
|
apiRoot: (apiKey) => `/v1/${environmentKey}/api/${apiKey}`,
|
|
@@ -818,6 +817,41 @@ var ManagementClient = class {
|
|
|
818
817
|
const k = resolveKey(key);
|
|
819
818
|
await this.request("DELETE", `${this.paths.fluxApiKeyRoot(k)}/`, { parseJson: false });
|
|
820
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Issue a bearer token for a Flux API key, or replace the existing one.
|
|
822
|
+
*
|
|
823
|
+
* A bearer token exists for clients that accept a single token value and send
|
|
824
|
+
* it as `Authorization: Bearer <token>` with no way to choose the scheme —
|
|
825
|
+
* hosted MCP connectors, notably the Claude API's `mcp_servers`. Those clients
|
|
826
|
+
* cannot send `Simple` or `Secure` at all.
|
|
827
|
+
*
|
|
828
|
+
* THE PLAINTEXT IS RETURNED ONLY HERE, AND ONLY ONCE. The service stores a
|
|
829
|
+
* hash, exactly as it does for `secret_key`, so a lost token is re-issued
|
|
830
|
+
* rather than recovered. Subsequent key reads expose only
|
|
831
|
+
* `bearer_token_prefix`.
|
|
832
|
+
*
|
|
833
|
+
* The key itself is untouched: `public_key`, `secret_key`, `role` and grants
|
|
834
|
+
* all survive, so `Simple` and `Secure` integrations keep working across a
|
|
835
|
+
* re-issue. That is what makes this the way to cut off a connector without
|
|
836
|
+
* recreating a key and reconfiguring everything that uses it.
|
|
837
|
+
*
|
|
838
|
+
* There is at most one token per key; calling this again replaces it.
|
|
839
|
+
*/
|
|
840
|
+
async issueFluxApiKeyBearerToken(key) {
|
|
841
|
+
const k = resolveKey(key);
|
|
842
|
+
return this.request("POST", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Revoke a Flux API key's bearer token. The key and its role keep working.
|
|
846
|
+
*
|
|
847
|
+
* Idempotent: succeeds whether or not a token was issued.
|
|
848
|
+
*/
|
|
849
|
+
async revokeFluxApiKeyBearerToken(key) {
|
|
850
|
+
const k = resolveKey(key);
|
|
851
|
+
await this.request("DELETE", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`, {
|
|
852
|
+
parseJson: false
|
|
853
|
+
});
|
|
854
|
+
}
|
|
821
855
|
// ------------------------------------------------------------------ //
|
|
822
856
|
// API management operations
|
|
823
857
|
// ------------------------------------------------------------------ //
|
|
@@ -839,17 +873,17 @@ var ManagementClient = class {
|
|
|
839
873
|
const key = resolveKey(apiKey);
|
|
840
874
|
await this.request("DELETE", `${this.paths.apiRoot(key)}/`, { parseJson: false });
|
|
841
875
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
const body = {
|
|
876
|
+
/**
|
|
877
|
+
* Build the request body shared by all four API-collection-association
|
|
878
|
+
* writers: {@link addApiCollection}, {@link updateApiCollection}, and
|
|
879
|
+
* their deprecated `*ApiFolder*` twins. All four accept {@link
|
|
880
|
+
* ApiFolderOptions}, so this is the one place that maps its camelCase
|
|
881
|
+
* fields to wire snake_case — adding a field here, rather than to each
|
|
882
|
+
* method separately, is what keeps the deprecated twins from silently
|
|
883
|
+
* swallowing a field the type says they accept.
|
|
884
|
+
*/
|
|
885
|
+
buildApiFolderPayload(options) {
|
|
886
|
+
const body = {};
|
|
853
887
|
if (options?.allowedMethods !== void 0) {
|
|
854
888
|
body.allowed_methods = options.allowedMethods;
|
|
855
889
|
}
|
|
@@ -865,6 +899,25 @@ var ManagementClient = class {
|
|
|
865
899
|
if (options?.descriptionSchema !== void 0) {
|
|
866
900
|
body.description_schema = options.descriptionSchema;
|
|
867
901
|
}
|
|
902
|
+
if (options?.unscopedLevels !== void 0) {
|
|
903
|
+
body.unscoped_levels = options.unscopedLevels;
|
|
904
|
+
}
|
|
905
|
+
if (options?.unscopedAncestors !== void 0) {
|
|
906
|
+
body.unscoped_ancestors = options.unscopedAncestors;
|
|
907
|
+
}
|
|
908
|
+
return body;
|
|
909
|
+
}
|
|
910
|
+
// ------------------------------------------------------------------ //
|
|
911
|
+
// API ↔ Collection association (canonical)
|
|
912
|
+
// ------------------------------------------------------------------ //
|
|
913
|
+
async listApiCollections(apiKey, params) {
|
|
914
|
+
const key = resolveKey(apiKey);
|
|
915
|
+
return this.request("GET", `${this.paths.apiCollectionsRoot(key)}/`, { params });
|
|
916
|
+
}
|
|
917
|
+
async addApiCollection(apiKey, collectionKey, options) {
|
|
918
|
+
const aKey = resolveKey(apiKey);
|
|
919
|
+
const cKey = resolveKey(collectionKey);
|
|
920
|
+
const body = { folder: cKey, ...this.buildApiFolderPayload(options) };
|
|
868
921
|
return this.request("POST", `${this.paths.apiCollectionsRoot(aKey)}/`, {
|
|
869
922
|
jsonBody: body
|
|
870
923
|
});
|
|
@@ -877,22 +930,7 @@ var ManagementClient = class {
|
|
|
877
930
|
async updateApiCollection(apiKey, collectionKey, options) {
|
|
878
931
|
const aKey = resolveKey(apiKey);
|
|
879
932
|
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
|
-
}
|
|
933
|
+
const body = this.buildApiFolderPayload(options);
|
|
896
934
|
return this.request("PUT", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
|
|
897
935
|
jsonBody: body
|
|
898
936
|
});
|
|
@@ -900,11 +938,9 @@ var ManagementClient = class {
|
|
|
900
938
|
async removeApiCollection(apiKey, collectionKey) {
|
|
901
939
|
const aKey = resolveKey(apiKey);
|
|
902
940
|
const cKey = resolveKey(collectionKey);
|
|
903
|
-
await this.request(
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
{ parseJson: false }
|
|
907
|
-
);
|
|
941
|
+
await this.request("DELETE", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
|
|
942
|
+
parseJson: false
|
|
943
|
+
});
|
|
908
944
|
}
|
|
909
945
|
// ------------------------------------------------------------------ //
|
|
910
946
|
// API ↔ Folder association (deprecated; hits legacy /folders/ URL)
|
|
@@ -920,22 +956,7 @@ var ManagementClient = class {
|
|
|
920
956
|
warnDeprecatedMethod("addApiFolder", "addApiCollection");
|
|
921
957
|
const aKey = resolveKey(apiKey);
|
|
922
958
|
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
|
-
}
|
|
959
|
+
const body = { folder: fKey, ...this.buildApiFolderPayload(options) };
|
|
939
960
|
return this.request("POST", `${this.paths.apiFoldersRoot(aKey)}/`, { jsonBody: body });
|
|
940
961
|
}
|
|
941
962
|
/** @deprecated Use {@link getApiCollection} instead. */
|
|
@@ -950,22 +971,7 @@ var ManagementClient = class {
|
|
|
950
971
|
warnDeprecatedMethod("updateApiFolder", "updateApiCollection");
|
|
951
972
|
const aKey = resolveKey(apiKey);
|
|
952
973
|
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
|
-
}
|
|
974
|
+
const body = this.buildApiFolderPayload(options);
|
|
969
975
|
return this.request("PUT", `${this.paths.apiFoldersRoot(aKey)}/${fKey}/`, {
|
|
970
976
|
jsonBody: body
|
|
971
977
|
});
|
|
@@ -1192,39 +1198,28 @@ var ManagementClient = class {
|
|
|
1192
1198
|
if (options?.includeSchema !== void 0) {
|
|
1193
1199
|
params.include_schema = options.includeSchema;
|
|
1194
1200
|
}
|
|
1195
|
-
return this.request(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
{
|
|
1199
|
-
params: Object.keys(params).length > 0 ? params : void 0
|
|
1200
|
-
}
|
|
1201
|
-
);
|
|
1201
|
+
return this.request("GET", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1202
|
+
params: Object.keys(params).length > 0 ? params : void 0
|
|
1203
|
+
});
|
|
1202
1204
|
}
|
|
1203
1205
|
async updateCollectionVersion(collectionKey, versionKey, payload) {
|
|
1204
1206
|
const cKey = resolveKey(collectionKey);
|
|
1205
1207
|
const vKey = resolveKey(versionKey);
|
|
1206
|
-
return this.request(
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
{ jsonBody: payload }
|
|
1210
|
-
);
|
|
1208
|
+
return this.request("PUT", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1209
|
+
jsonBody: payload
|
|
1210
|
+
});
|
|
1211
1211
|
}
|
|
1212
1212
|
async deleteCollectionVersion(collectionKey, versionKey) {
|
|
1213
1213
|
const cKey = resolveKey(collectionKey);
|
|
1214
1214
|
const vKey = resolveKey(versionKey);
|
|
1215
|
-
await this.request(
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
{ parseJson: false }
|
|
1219
|
-
);
|
|
1215
|
+
await this.request("DELETE", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
|
|
1216
|
+
parseJson: false
|
|
1217
|
+
});
|
|
1220
1218
|
}
|
|
1221
1219
|
async publishCollectionVersion(collectionKey, versionKey) {
|
|
1222
1220
|
const cKey = resolveKey(collectionKey);
|
|
1223
1221
|
const vKey = resolveKey(versionKey);
|
|
1224
|
-
return this.request(
|
|
1225
|
-
"POST",
|
|
1226
|
-
`${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`
|
|
1227
|
-
);
|
|
1222
|
+
return this.request("POST", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`);
|
|
1228
1223
|
}
|
|
1229
1224
|
/**
|
|
1230
1225
|
* Advance pinned nested fields on a Collection to a target Component version.
|
|
@@ -1287,11 +1282,7 @@ var ManagementClient = class {
|
|
|
1287
1282
|
if (options.toVersions !== void 0) {
|
|
1288
1283
|
body.to_versions = options.toVersions;
|
|
1289
1284
|
}
|
|
1290
|
-
return this.request(
|
|
1291
|
-
"POST",
|
|
1292
|
-
`${this.paths.collectionSyncComponent(cKey)}/`,
|
|
1293
|
-
{ jsonBody: body }
|
|
1294
|
-
);
|
|
1285
|
+
return this.request("POST", `${this.paths.collectionSyncComponent(cKey)}/`, { jsonBody: body });
|
|
1295
1286
|
}
|
|
1296
1287
|
// ------------------------------------------------------------------ //
|
|
1297
1288
|
// Collection schema field operations (canonical)
|
|
@@ -1299,47 +1290,37 @@ var ManagementClient = class {
|
|
|
1299
1290
|
async listCollectionFields(collectionKey, versionKey, params) {
|
|
1300
1291
|
const cKey = resolveKey(collectionKey);
|
|
1301
1292
|
const vKey = resolveKey(versionKey);
|
|
1302
|
-
return this.request(
|
|
1303
|
-
"GET",
|
|
1304
|
-
`${this.paths.collectionSchemaTree(cKey, vKey)}/`,
|
|
1305
|
-
{ params }
|
|
1306
|
-
);
|
|
1293
|
+
return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, { params });
|
|
1307
1294
|
}
|
|
1308
1295
|
async createCollectionField(collectionKey, versionKey, payload) {
|
|
1309
1296
|
const cKey = resolveKey(collectionKey);
|
|
1310
1297
|
const vKey = resolveKey(versionKey);
|
|
1311
|
-
return this.request(
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
{ jsonBody: payload }
|
|
1315
|
-
);
|
|
1298
|
+
return this.request("POST", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, {
|
|
1299
|
+
jsonBody: payload
|
|
1300
|
+
});
|
|
1316
1301
|
}
|
|
1317
1302
|
async getCollectionField(collectionKey, versionKey, fieldPath) {
|
|
1318
1303
|
const cKey = resolveKey(collectionKey);
|
|
1319
1304
|
const vKey = resolveKey(versionKey);
|
|
1320
|
-
return this.request(
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
{ params: { path: fieldPath } }
|
|
1324
|
-
);
|
|
1305
|
+
return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1306
|
+
params: { path: fieldPath }
|
|
1307
|
+
});
|
|
1325
1308
|
}
|
|
1326
1309
|
async updateCollectionField(collectionKey, versionKey, fieldPath, payload) {
|
|
1327
1310
|
const cKey = resolveKey(collectionKey);
|
|
1328
1311
|
const vKey = resolveKey(versionKey);
|
|
1329
|
-
return this.request(
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
);
|
|
1312
|
+
return this.request("PUT", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1313
|
+
params: { path: fieldPath },
|
|
1314
|
+
jsonBody: payload
|
|
1315
|
+
});
|
|
1334
1316
|
}
|
|
1335
1317
|
async deleteCollectionField(collectionKey, versionKey, fieldPath) {
|
|
1336
1318
|
const cKey = resolveKey(collectionKey);
|
|
1337
1319
|
const vKey = resolveKey(versionKey);
|
|
1338
|
-
await this.request(
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
);
|
|
1320
|
+
await this.request("DELETE", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
|
|
1321
|
+
params: { path: fieldPath },
|
|
1322
|
+
parseJson: false
|
|
1323
|
+
});
|
|
1343
1324
|
}
|
|
1344
1325
|
// ------------------------------------------------------------------ //
|
|
1345
1326
|
// Folder operations (deprecated; hit legacy /folders/ URL)
|
|
@@ -2043,6 +2024,11 @@ function buildSearchBody(req) {
|
|
|
2043
2024
|
return body;
|
|
2044
2025
|
}
|
|
2045
2026
|
function mergeExtra(validated, extra) {
|
|
2027
|
+
if ("truncate_text" in extra) {
|
|
2028
|
+
throw new Error(
|
|
2029
|
+
"'truncate_text' is a query parameter, not a body field. Pass it via the 'queryParams' option instead."
|
|
2030
|
+
);
|
|
2031
|
+
}
|
|
2046
2032
|
const conflicts = [];
|
|
2047
2033
|
for (const key of Object.keys(extra)) {
|
|
2048
2034
|
if (SEARCH_REQUEST_KNOWN_KEYS.has(key)) {
|
|
@@ -2106,9 +2092,9 @@ var FluxClient = class {
|
|
|
2106
2092
|
const path = this.buildPath(folderPath, `/${resourceKey}`);
|
|
2107
2093
|
return this.transport.request("GET", path, { params });
|
|
2108
2094
|
}
|
|
2109
|
-
async search(folderPath, body) {
|
|
2095
|
+
async search(folderPath, body, options) {
|
|
2110
2096
|
const path = this.buildPath(folderPath, "/_search");
|
|
2111
|
-
return this.transport.request("POST", path, { jsonBody: body });
|
|
2097
|
+
return this.transport.request("POST", path, { jsonBody: body, params: options?.params });
|
|
2112
2098
|
}
|
|
2113
2099
|
/**
|
|
2114
2100
|
* Create a resource in a collection and publish it immediately.
|
|
@@ -2152,7 +2138,16 @@ var FluxClient = class {
|
|
|
2152
2138
|
}
|
|
2153
2139
|
/** Semantic search using auto-generated embeddings. */
|
|
2154
2140
|
async vectorSearch(folderPath, options) {
|
|
2155
|
-
const {
|
|
2141
|
+
const {
|
|
2142
|
+
query,
|
|
2143
|
+
fields,
|
|
2144
|
+
top_k = 10,
|
|
2145
|
+
similarity_threshold,
|
|
2146
|
+
limit,
|
|
2147
|
+
offset,
|
|
2148
|
+
queryParams,
|
|
2149
|
+
...rest
|
|
2150
|
+
} = options;
|
|
2156
2151
|
const extra = stripUndefined(rest);
|
|
2157
2152
|
const vs = { query, fields, top_k, similarity_threshold };
|
|
2158
2153
|
const req = {
|
|
@@ -2162,7 +2157,7 @@ var FluxClient = class {
|
|
|
2162
2157
|
offset
|
|
2163
2158
|
};
|
|
2164
2159
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2165
|
-
return this.search(folderPath, body);
|
|
2160
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2166
2161
|
}
|
|
2167
2162
|
/** Search using custom pre-computed embeddings. */
|
|
2168
2163
|
async vectorFieldSearch(folderPath, options) {
|
|
@@ -2173,6 +2168,7 @@ var FluxClient = class {
|
|
|
2173
2168
|
similarity_threshold,
|
|
2174
2169
|
limit,
|
|
2175
2170
|
offset,
|
|
2171
|
+
queryParams,
|
|
2176
2172
|
...rest
|
|
2177
2173
|
} = options;
|
|
2178
2174
|
const extra = stripUndefined(rest);
|
|
@@ -2184,7 +2180,7 @@ var FluxClient = class {
|
|
|
2184
2180
|
offset
|
|
2185
2181
|
};
|
|
2186
2182
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2187
|
-
return this.search(folderPath, body);
|
|
2183
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2188
2184
|
}
|
|
2189
2185
|
/** Blended text + vector search with configurable weights. */
|
|
2190
2186
|
async hybridSearch(folderPath, options) {
|
|
@@ -2199,6 +2195,7 @@ var FluxClient = class {
|
|
|
2199
2195
|
rerank_results = true,
|
|
2200
2196
|
limit,
|
|
2201
2197
|
offset,
|
|
2198
|
+
queryParams,
|
|
2202
2199
|
...rest
|
|
2203
2200
|
} = options;
|
|
2204
2201
|
const extra = stripUndefined(rest);
|
|
@@ -2213,7 +2210,7 @@ var FluxClient = class {
|
|
|
2213
2210
|
offset
|
|
2214
2211
|
};
|
|
2215
2212
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2216
|
-
return this.search(folderPath, body);
|
|
2213
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2217
2214
|
}
|
|
2218
2215
|
/** Text search with results boosted by vector similarity. */
|
|
2219
2216
|
async boostedSearch(folderPath, options) {
|
|
@@ -2229,6 +2226,7 @@ var FluxClient = class {
|
|
|
2229
2226
|
max_boost_results = 20,
|
|
2230
2227
|
limit,
|
|
2231
2228
|
offset,
|
|
2229
|
+
queryParams,
|
|
2232
2230
|
...rest
|
|
2233
2231
|
} = options;
|
|
2234
2232
|
const extra = stripUndefined(rest);
|
|
@@ -2265,7 +2263,7 @@ var FluxClient = class {
|
|
|
2265
2263
|
offset
|
|
2266
2264
|
};
|
|
2267
2265
|
const body = mergeExtra(buildSearchBody(req), extra);
|
|
2268
|
-
return this.search(folderPath, body);
|
|
2266
|
+
return this.search(folderPath, body, { params: queryParams });
|
|
2269
2267
|
}
|
|
2270
2268
|
async getRouter() {
|
|
2271
2269
|
const path = `/${this.apiPrefix}/_router`;
|