@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/dist/index.js CHANGED
@@ -308,7 +308,7 @@ var DEFAULT_RETRY_CONFIG = {
308
308
  statusCodes: [408, 425, 429, 500, 502, 503, 504],
309
309
  methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
310
310
  };
311
- var SDK_VERSION = "0.5.1";
311
+ var SDK_VERSION = "0.6.0";
312
312
  var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
313
313
  function createConfig(options) {
314
314
  if (!options.baseUrl) {
@@ -535,9 +535,7 @@ function warnDeprecatedMethod(oldName, newName, removal = "1.0") {
535
535
  function nestedFieldMeta(opts) {
536
536
  if (opts.extra) {
537
537
  const reserved = ["component", "component_version", "auto_update"];
538
- const collisions = reserved.filter(
539
- (k) => Object.prototype.hasOwnProperty.call(opts.extra, k)
540
- );
538
+ const collisions = reserved.filter((k) => Object.prototype.hasOwnProperty.call(opts.extra, k));
541
539
  if (collisions.length > 0) {
542
540
  throw new Error(
543
541
  `nestedFieldMeta: 'extra' must not include reserved keys: ${collisions.join(", ")}`
@@ -596,6 +594,7 @@ function managementPaths(environmentKey) {
596
594
  // Flux API key paths
597
595
  fluxApiKeysRoot: () => `/v1/${environmentKey}/permissions/flux-api/api-keys`,
598
596
  fluxApiKeyRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}`,
597
+ fluxApiKeyBearerTokenRoot: (apiKey) => `/v1/${environmentKey}/permissions/flux-api/api-keys/${apiKey}/bearer-token`,
599
598
  // API management paths
600
599
  apisRoot: () => `/v1/${environmentKey}/api`,
601
600
  apiRoot: (apiKey) => `/v1/${environmentKey}/api/${apiKey}`,
@@ -764,6 +763,41 @@ var ManagementClient = class {
764
763
  const k = resolveKey(key);
765
764
  await this.request("DELETE", `${this.paths.fluxApiKeyRoot(k)}/`, { parseJson: false });
766
765
  }
766
+ /**
767
+ * Issue a bearer token for a Flux API key, or replace the existing one.
768
+ *
769
+ * A bearer token exists for clients that accept a single token value and send
770
+ * it as `Authorization: Bearer <token>` with no way to choose the scheme —
771
+ * hosted MCP connectors, notably the Claude API's `mcp_servers`. Those clients
772
+ * cannot send `Simple` or `Secure` at all.
773
+ *
774
+ * THE PLAINTEXT IS RETURNED ONLY HERE, AND ONLY ONCE. The service stores a
775
+ * hash, exactly as it does for `secret_key`, so a lost token is re-issued
776
+ * rather than recovered. Subsequent key reads expose only
777
+ * `bearer_token_prefix`.
778
+ *
779
+ * The key itself is untouched: `public_key`, `secret_key`, `role` and grants
780
+ * all survive, so `Simple` and `Secure` integrations keep working across a
781
+ * re-issue. That is what makes this the way to cut off a connector without
782
+ * recreating a key and reconfiguring everything that uses it.
783
+ *
784
+ * There is at most one token per key; calling this again replaces it.
785
+ */
786
+ async issueFluxApiKeyBearerToken(key) {
787
+ const k = resolveKey(key);
788
+ return this.request("POST", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`);
789
+ }
790
+ /**
791
+ * Revoke a Flux API key's bearer token. The key and its role keep working.
792
+ *
793
+ * Idempotent: succeeds whether or not a token was issued.
794
+ */
795
+ async revokeFluxApiKeyBearerToken(key) {
796
+ const k = resolveKey(key);
797
+ await this.request("DELETE", `${this.paths.fluxApiKeyBearerTokenRoot(k)}/`, {
798
+ parseJson: false
799
+ });
800
+ }
767
801
  // ------------------------------------------------------------------ //
768
802
  // API management operations
769
803
  // ------------------------------------------------------------------ //
@@ -785,17 +819,17 @@ var ManagementClient = class {
785
819
  const key = resolveKey(apiKey);
786
820
  await this.request("DELETE", `${this.paths.apiRoot(key)}/`, { parseJson: false });
787
821
  }
788
- // ------------------------------------------------------------------ //
789
- // API ↔ Collection association (canonical)
790
- // ------------------------------------------------------------------ //
791
- async listApiCollections(apiKey, params) {
792
- const key = resolveKey(apiKey);
793
- return this.request("GET", `${this.paths.apiCollectionsRoot(key)}/`, { params });
794
- }
795
- async addApiCollection(apiKey, collectionKey, options) {
796
- const aKey = resolveKey(apiKey);
797
- const cKey = resolveKey(collectionKey);
798
- const body = { folder: cKey };
822
+ /**
823
+ * Build the request body shared by all four API-collection-association
824
+ * writers: {@link addApiCollection}, {@link updateApiCollection}, and
825
+ * their deprecated `*ApiFolder*` twins. All four accept {@link
826
+ * ApiFolderOptions}, so this is the one place that maps its camelCase
827
+ * fields to wire snake_case — adding a field here, rather than to each
828
+ * method separately, is what keeps the deprecated twins from silently
829
+ * swallowing a field the type says they accept.
830
+ */
831
+ buildApiFolderPayload(options) {
832
+ const body = {};
799
833
  if (options?.allowedMethods !== void 0) {
800
834
  body.allowed_methods = options.allowedMethods;
801
835
  }
@@ -811,6 +845,25 @@ var ManagementClient = class {
811
845
  if (options?.descriptionSchema !== void 0) {
812
846
  body.description_schema = options.descriptionSchema;
813
847
  }
848
+ if (options?.unscopedLevels !== void 0) {
849
+ body.unscoped_levels = options.unscopedLevels;
850
+ }
851
+ if (options?.unscopedAncestors !== void 0) {
852
+ body.unscoped_ancestors = options.unscopedAncestors;
853
+ }
854
+ return body;
855
+ }
856
+ // ------------------------------------------------------------------ //
857
+ // API ↔ Collection association (canonical)
858
+ // ------------------------------------------------------------------ //
859
+ async listApiCollections(apiKey, params) {
860
+ const key = resolveKey(apiKey);
861
+ return this.request("GET", `${this.paths.apiCollectionsRoot(key)}/`, { params });
862
+ }
863
+ async addApiCollection(apiKey, collectionKey, options) {
864
+ const aKey = resolveKey(apiKey);
865
+ const cKey = resolveKey(collectionKey);
866
+ const body = { folder: cKey, ...this.buildApiFolderPayload(options) };
814
867
  return this.request("POST", `${this.paths.apiCollectionsRoot(aKey)}/`, {
815
868
  jsonBody: body
816
869
  });
@@ -823,22 +876,7 @@ var ManagementClient = class {
823
876
  async updateApiCollection(apiKey, collectionKey, options) {
824
877
  const aKey = resolveKey(apiKey);
825
878
  const cKey = resolveKey(collectionKey);
826
- const body = {};
827
- if (options?.allowedMethods !== void 0) {
828
- body.allowed_methods = options.allowedMethods;
829
- }
830
- if (options?.descriptionGetOne !== void 0) {
831
- body.description_get_one = options.descriptionGetOne;
832
- }
833
- if (options?.descriptionGetMany !== void 0) {
834
- body.description_get_many = options.descriptionGetMany;
835
- }
836
- if (options?.descriptionSearch !== void 0) {
837
- body.description_search = options.descriptionSearch;
838
- }
839
- if (options?.descriptionSchema !== void 0) {
840
- body.description_schema = options.descriptionSchema;
841
- }
879
+ const body = this.buildApiFolderPayload(options);
842
880
  return this.request("PUT", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
843
881
  jsonBody: body
844
882
  });
@@ -846,11 +884,9 @@ var ManagementClient = class {
846
884
  async removeApiCollection(apiKey, collectionKey) {
847
885
  const aKey = resolveKey(apiKey);
848
886
  const cKey = resolveKey(collectionKey);
849
- await this.request(
850
- "DELETE",
851
- `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`,
852
- { parseJson: false }
853
- );
887
+ await this.request("DELETE", `${this.paths.apiCollectionsRoot(aKey)}/${cKey}/`, {
888
+ parseJson: false
889
+ });
854
890
  }
855
891
  // ------------------------------------------------------------------ //
856
892
  // API ↔ Folder association (deprecated; hits legacy /folders/ URL)
@@ -866,22 +902,7 @@ var ManagementClient = class {
866
902
  warnDeprecatedMethod("addApiFolder", "addApiCollection");
867
903
  const aKey = resolveKey(apiKey);
868
904
  const fKey = resolveKey(folderKey);
869
- const body = { folder: fKey };
870
- if (options?.allowedMethods !== void 0) {
871
- body.allowed_methods = options.allowedMethods;
872
- }
873
- if (options?.descriptionGetOne !== void 0) {
874
- body.description_get_one = options.descriptionGetOne;
875
- }
876
- if (options?.descriptionGetMany !== void 0) {
877
- body.description_get_many = options.descriptionGetMany;
878
- }
879
- if (options?.descriptionSearch !== void 0) {
880
- body.description_search = options.descriptionSearch;
881
- }
882
- if (options?.descriptionSchema !== void 0) {
883
- body.description_schema = options.descriptionSchema;
884
- }
905
+ const body = { folder: fKey, ...this.buildApiFolderPayload(options) };
885
906
  return this.request("POST", `${this.paths.apiFoldersRoot(aKey)}/`, { jsonBody: body });
886
907
  }
887
908
  /** @deprecated Use {@link getApiCollection} instead. */
@@ -896,22 +917,7 @@ var ManagementClient = class {
896
917
  warnDeprecatedMethod("updateApiFolder", "updateApiCollection");
897
918
  const aKey = resolveKey(apiKey);
898
919
  const fKey = resolveKey(folderKey);
899
- const body = {};
900
- if (options?.allowedMethods !== void 0) {
901
- body.allowed_methods = options.allowedMethods;
902
- }
903
- if (options?.descriptionGetOne !== void 0) {
904
- body.description_get_one = options.descriptionGetOne;
905
- }
906
- if (options?.descriptionGetMany !== void 0) {
907
- body.description_get_many = options.descriptionGetMany;
908
- }
909
- if (options?.descriptionSearch !== void 0) {
910
- body.description_search = options.descriptionSearch;
911
- }
912
- if (options?.descriptionSchema !== void 0) {
913
- body.description_schema = options.descriptionSchema;
914
- }
920
+ const body = this.buildApiFolderPayload(options);
915
921
  return this.request("PUT", `${this.paths.apiFoldersRoot(aKey)}/${fKey}/`, {
916
922
  jsonBody: body
917
923
  });
@@ -1138,39 +1144,28 @@ var ManagementClient = class {
1138
1144
  if (options?.includeSchema !== void 0) {
1139
1145
  params.include_schema = options.includeSchema;
1140
1146
  }
1141
- return this.request(
1142
- "GET",
1143
- `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`,
1144
- {
1145
- params: Object.keys(params).length > 0 ? params : void 0
1146
- }
1147
- );
1147
+ return this.request("GET", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
1148
+ params: Object.keys(params).length > 0 ? params : void 0
1149
+ });
1148
1150
  }
1149
1151
  async updateCollectionVersion(collectionKey, versionKey, payload) {
1150
1152
  const cKey = resolveKey(collectionKey);
1151
1153
  const vKey = resolveKey(versionKey);
1152
- return this.request(
1153
- "PUT",
1154
- `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`,
1155
- { jsonBody: payload }
1156
- );
1154
+ return this.request("PUT", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
1155
+ jsonBody: payload
1156
+ });
1157
1157
  }
1158
1158
  async deleteCollectionVersion(collectionKey, versionKey) {
1159
1159
  const cKey = resolveKey(collectionKey);
1160
1160
  const vKey = resolveKey(versionKey);
1161
- await this.request(
1162
- "DELETE",
1163
- `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`,
1164
- { parseJson: false }
1165
- );
1161
+ await this.request("DELETE", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/`, {
1162
+ parseJson: false
1163
+ });
1166
1164
  }
1167
1165
  async publishCollectionVersion(collectionKey, versionKey) {
1168
1166
  const cKey = resolveKey(collectionKey);
1169
1167
  const vKey = resolveKey(versionKey);
1170
- return this.request(
1171
- "POST",
1172
- `${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`
1173
- );
1168
+ return this.request("POST", `${this.paths.collectionVersionsBase(cKey)}/${vKey}/publish/`);
1174
1169
  }
1175
1170
  /**
1176
1171
  * Advance pinned nested fields on a Collection to a target Component version.
@@ -1233,11 +1228,7 @@ var ManagementClient = class {
1233
1228
  if (options.toVersions !== void 0) {
1234
1229
  body.to_versions = options.toVersions;
1235
1230
  }
1236
- return this.request(
1237
- "POST",
1238
- `${this.paths.collectionSyncComponent(cKey)}/`,
1239
- { jsonBody: body }
1240
- );
1231
+ return this.request("POST", `${this.paths.collectionSyncComponent(cKey)}/`, { jsonBody: body });
1241
1232
  }
1242
1233
  // ------------------------------------------------------------------ //
1243
1234
  // Collection schema field operations (canonical)
@@ -1245,47 +1236,37 @@ var ManagementClient = class {
1245
1236
  async listCollectionFields(collectionKey, versionKey, params) {
1246
1237
  const cKey = resolveKey(collectionKey);
1247
1238
  const vKey = resolveKey(versionKey);
1248
- return this.request(
1249
- "GET",
1250
- `${this.paths.collectionSchemaTree(cKey, vKey)}/`,
1251
- { params }
1252
- );
1239
+ return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, { params });
1253
1240
  }
1254
1241
  async createCollectionField(collectionKey, versionKey, payload) {
1255
1242
  const cKey = resolveKey(collectionKey);
1256
1243
  const vKey = resolveKey(versionKey);
1257
- return this.request(
1258
- "POST",
1259
- `${this.paths.collectionSchemaTree(cKey, vKey)}/`,
1260
- { jsonBody: payload }
1261
- );
1244
+ return this.request("POST", `${this.paths.collectionSchemaTree(cKey, vKey)}/`, {
1245
+ jsonBody: payload
1246
+ });
1262
1247
  }
1263
1248
  async getCollectionField(collectionKey, versionKey, fieldPath) {
1264
1249
  const cKey = resolveKey(collectionKey);
1265
1250
  const vKey = resolveKey(versionKey);
1266
- return this.request(
1267
- "GET",
1268
- `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`,
1269
- { params: { path: fieldPath } }
1270
- );
1251
+ return this.request("GET", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
1252
+ params: { path: fieldPath }
1253
+ });
1271
1254
  }
1272
1255
  async updateCollectionField(collectionKey, versionKey, fieldPath, payload) {
1273
1256
  const cKey = resolveKey(collectionKey);
1274
1257
  const vKey = resolveKey(versionKey);
1275
- return this.request(
1276
- "PUT",
1277
- `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`,
1278
- { params: { path: fieldPath }, jsonBody: payload }
1279
- );
1258
+ return this.request("PUT", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
1259
+ params: { path: fieldPath },
1260
+ jsonBody: payload
1261
+ });
1280
1262
  }
1281
1263
  async deleteCollectionField(collectionKey, versionKey, fieldPath) {
1282
1264
  const cKey = resolveKey(collectionKey);
1283
1265
  const vKey = resolveKey(versionKey);
1284
- await this.request(
1285
- "DELETE",
1286
- `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`,
1287
- { params: { path: fieldPath }, parseJson: false }
1288
- );
1266
+ await this.request("DELETE", `${this.paths.collectionSchemaTree(cKey, vKey)}/field/`, {
1267
+ params: { path: fieldPath },
1268
+ parseJson: false
1269
+ });
1289
1270
  }
1290
1271
  // ------------------------------------------------------------------ //
1291
1272
  // Folder operations (deprecated; hit legacy /folders/ URL)
@@ -1989,6 +1970,11 @@ function buildSearchBody(req) {
1989
1970
  return body;
1990
1971
  }
1991
1972
  function mergeExtra(validated, extra) {
1973
+ if ("truncate_text" in extra) {
1974
+ throw new Error(
1975
+ "'truncate_text' is a query parameter, not a body field. Pass it via the 'queryParams' option instead."
1976
+ );
1977
+ }
1992
1978
  const conflicts = [];
1993
1979
  for (const key of Object.keys(extra)) {
1994
1980
  if (SEARCH_REQUEST_KNOWN_KEYS.has(key)) {
@@ -2052,9 +2038,9 @@ var FluxClient = class {
2052
2038
  const path = this.buildPath(folderPath, `/${resourceKey}`);
2053
2039
  return this.transport.request("GET", path, { params });
2054
2040
  }
2055
- async search(folderPath, body) {
2041
+ async search(folderPath, body, options) {
2056
2042
  const path = this.buildPath(folderPath, "/_search");
2057
- return this.transport.request("POST", path, { jsonBody: body });
2043
+ return this.transport.request("POST", path, { jsonBody: body, params: options?.params });
2058
2044
  }
2059
2045
  /**
2060
2046
  * Create a resource in a collection and publish it immediately.
@@ -2098,7 +2084,16 @@ var FluxClient = class {
2098
2084
  }
2099
2085
  /** Semantic search using auto-generated embeddings. */
2100
2086
  async vectorSearch(folderPath, options) {
2101
- const { query, fields, top_k = 10, similarity_threshold, limit, offset, ...rest } = options;
2087
+ const {
2088
+ query,
2089
+ fields,
2090
+ top_k = 10,
2091
+ similarity_threshold,
2092
+ limit,
2093
+ offset,
2094
+ queryParams,
2095
+ ...rest
2096
+ } = options;
2102
2097
  const extra = stripUndefined(rest);
2103
2098
  const vs = { query, fields, top_k, similarity_threshold };
2104
2099
  const req = {
@@ -2108,7 +2103,7 @@ var FluxClient = class {
2108
2103
  offset
2109
2104
  };
2110
2105
  const body = mergeExtra(buildSearchBody(req), extra);
2111
- return this.search(folderPath, body);
2106
+ return this.search(folderPath, body, { params: queryParams });
2112
2107
  }
2113
2108
  /** Search using custom pre-computed embeddings. */
2114
2109
  async vectorFieldSearch(folderPath, options) {
@@ -2119,6 +2114,7 @@ var FluxClient = class {
2119
2114
  similarity_threshold,
2120
2115
  limit,
2121
2116
  offset,
2117
+ queryParams,
2122
2118
  ...rest
2123
2119
  } = options;
2124
2120
  const extra = stripUndefined(rest);
@@ -2130,7 +2126,7 @@ var FluxClient = class {
2130
2126
  offset
2131
2127
  };
2132
2128
  const body = mergeExtra(buildSearchBody(req), extra);
2133
- return this.search(folderPath, body);
2129
+ return this.search(folderPath, body, { params: queryParams });
2134
2130
  }
2135
2131
  /** Blended text + vector search with configurable weights. */
2136
2132
  async hybridSearch(folderPath, options) {
@@ -2145,6 +2141,7 @@ var FluxClient = class {
2145
2141
  rerank_results = true,
2146
2142
  limit,
2147
2143
  offset,
2144
+ queryParams,
2148
2145
  ...rest
2149
2146
  } = options;
2150
2147
  const extra = stripUndefined(rest);
@@ -2159,7 +2156,7 @@ var FluxClient = class {
2159
2156
  offset
2160
2157
  };
2161
2158
  const body = mergeExtra(buildSearchBody(req), extra);
2162
- return this.search(folderPath, body);
2159
+ return this.search(folderPath, body, { params: queryParams });
2163
2160
  }
2164
2161
  /** Text search with results boosted by vector similarity. */
2165
2162
  async boostedSearch(folderPath, options) {
@@ -2175,6 +2172,7 @@ var FluxClient = class {
2175
2172
  max_boost_results = 20,
2176
2173
  limit,
2177
2174
  offset,
2175
+ queryParams,
2178
2176
  ...rest
2179
2177
  } = options;
2180
2178
  const extra = stripUndefined(rest);
@@ -2211,7 +2209,7 @@ var FluxClient = class {
2211
2209
  offset
2212
2210
  };
2213
2211
  const body = mergeExtra(buildSearchBody(req), extra);
2214
- return this.search(folderPath, body);
2212
+ return this.search(folderPath, body, { params: queryParams });
2215
2213
  }
2216
2214
  async getRouter() {
2217
2215
  const path = `/${this.apiPrefix}/_router`;