@getanyapi/sdk 0.35.3 → 0.36.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.d.cts CHANGED
@@ -259,8 +259,13 @@ interface CatalogEntry {
259
259
  /** Detail-only successful end-to-end latency. Null when no sample is available. */
260
260
  latency?: DiscoveryLatency | null;
261
261
  }
262
+ /**
263
+ * Ranked catalog search accepts any non-empty combination of query, category and
264
+ * platform, so a scope with no query at all ("every reddit API") is expressible.
265
+ * At least one of the three is required; see `AnyAPI.search`.
266
+ */
262
267
  interface SearchOptions {
263
- query: string;
268
+ query?: string;
264
269
  category?: string;
265
270
  platform?: string;
266
271
  limit?: number;
@@ -369,7 +374,13 @@ declare class AnyAPI$1 implements ClientCore {
369
374
  me(): Promise<AccountProfile>;
370
375
  /** Browse catalog SKUs, optionally scoped by category. GET /v1/apis. */
371
376
  catalog(options?: CatalogOptions): Promise<CatalogEntry[]>;
372
- /** Ranked catalog search. GET /catalog/search. Browse never accepts a query. */
377
+ /**
378
+ * Ranked catalog search. GET /catalog/search. Browse never accepts a query.
379
+ *
380
+ * The gateway needs at least one of query, category or platform, in any
381
+ * combination, so a scope with no query at all is a valid search. An absent or
382
+ * empty query omits `q` entirely, because an empty `q` is a different request.
383
+ */
373
384
  search(options: SearchOptions): Promise<CatalogSearchResults>;
374
385
  /** Describe a single SKU by slug. GET /v1/apis/{slug}. 404 -> NotFoundError. See SPEC 2.7. */
375
386
  describe(slug: string): Promise<CatalogEntry>;
package/dist/index.d.ts CHANGED
@@ -259,8 +259,13 @@ interface CatalogEntry {
259
259
  /** Detail-only successful end-to-end latency. Null when no sample is available. */
260
260
  latency?: DiscoveryLatency | null;
261
261
  }
262
+ /**
263
+ * Ranked catalog search accepts any non-empty combination of query, category and
264
+ * platform, so a scope with no query at all ("every reddit API") is expressible.
265
+ * At least one of the three is required; see `AnyAPI.search`.
266
+ */
262
267
  interface SearchOptions {
263
- query: string;
268
+ query?: string;
264
269
  category?: string;
265
270
  platform?: string;
266
271
  limit?: number;
@@ -369,7 +374,13 @@ declare class AnyAPI$1 implements ClientCore {
369
374
  me(): Promise<AccountProfile>;
370
375
  /** Browse catalog SKUs, optionally scoped by category. GET /v1/apis. */
371
376
  catalog(options?: CatalogOptions): Promise<CatalogEntry[]>;
372
- /** Ranked catalog search. GET /catalog/search. Browse never accepts a query. */
377
+ /**
378
+ * Ranked catalog search. GET /catalog/search. Browse never accepts a query.
379
+ *
380
+ * The gateway needs at least one of query, category or platform, in any
381
+ * combination, so a scope with no query at all is a valid search. An absent or
382
+ * empty query omits `q` entirely, because an empty `q` is a different request.
383
+ */
373
384
  search(options: SearchOptions): Promise<CatalogSearchResults>;
374
385
  /** Describe a single SKU by slug. GET /v1/apis/{slug}. 404 -> NotFoundError. See SPEC 2.7. */
375
386
  describe(slug: string): Promise<CatalogEntry>;
package/dist/index.js CHANGED
@@ -782,9 +782,22 @@ var AnyAPI = class {
782
782
  );
783
783
  return mapCatalogList(raw);
784
784
  }
785
- /** Ranked catalog search. GET /catalog/search. Browse never accepts a query. */
785
+ /**
786
+ * Ranked catalog search. GET /catalog/search. Browse never accepts a query.
787
+ *
788
+ * The gateway needs at least one of query, category or platform, in any
789
+ * combination, so a scope with no query at all is a valid search. An absent or
790
+ * empty query omits `q` entirely, because an empty `q` is a different request.
791
+ */
786
792
  async search(options) {
787
- const search = new URLSearchParams({ q: options.query });
793
+ if (!options.query && !options.category && !options.platform) {
794
+ throw new AnyAPIError(
795
+ "search needs at least one of query, category, or platform",
796
+ 0
797
+ );
798
+ }
799
+ const search = new URLSearchParams();
800
+ if (options.query) search.set("q", options.query);
788
801
  if (options.category) search.set("category", options.category);
789
802
  if (options.platform) search.set("platform", options.platform);
790
803
  if (options.limit !== void 0) search.set("limit", String(options.limit));