@crombolo/delivery-client 0.24.1 → 0.26.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.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * A typed client for a crombolo site's Delivery API (`/umbraco/delivery/api/v2`).
2
+ * A typed client for a crombolo site's Delivery API (`/crombolo/delivery/api/v2`).
3
3
  * The shapes are the JSON the API writes; `crombolo generate --delivery` writes
4
4
  * a site's content types as a `DeliveryTypes` map to pass in as the generic.
5
5
  * docs/delivery-api.md, "Typed apps".
@@ -246,6 +246,11 @@ export interface SearchOptions {
246
246
  export interface DeliveryClientOptions {
247
247
  /** The site's address, such as `https://cms.example.com`. */
248
248
  baseUrl: string;
249
+ /**
250
+ * The API's path on the site, `/crombolo/delivery/api/v2` unless given:
251
+ * `/umbraco/delivery/api/v2` for a site from before the move (0.25 or older) or an Umbraco site.
252
+ */
253
+ apiPath?: string;
249
254
  /** Sent as `Api-Key`, for a site whose API is not public. Keep it out of browser code. */
250
255
  apiKey?: string;
251
256
  /** The culture every request asks for unless it names its own. */
@@ -290,5 +295,7 @@ export interface DeliveryClient<Schema extends DeliverySchema = DeliverySchema>
290
295
  host?: string;
291
296
  }): Promise<RouteAnswer<Schema>>;
292
297
  }
298
+ /** Where a crombolo site serves it; Umbraco's own path, `/umbraco/delivery/api/v2`, answers too. */
299
+ export declare const DELIVERY_API_PATH = "/crombolo/delivery/api/v2";
293
300
  export declare function createDeliveryClient<Schema extends DeliverySchema = DeliverySchema>(options: DeliveryClientOptions): DeliveryClient<Schema>;
294
301
  export {};
package/dist/index.js CHANGED
@@ -13,11 +13,11 @@ class DeliveryError extends Error {
13
13
  this.body = body;
14
14
  }
15
15
  }
16
- var API_PATH = "/umbraco/delivery/api/v2";
16
+ var DELIVERY_API_PATH = "/crombolo/delivery/api/v2";
17
17
  var list = (value) => value === undefined ? [] : Array.isArray(value) ? value : [value];
18
18
  var itemPath = (idOrPath) => idOrPath.replace(/^\/+/, "").split("/").map((segment) => encodeURIComponent(segment)).join("/");
19
19
  function createDeliveryClient(options) {
20
- const base = `${options.baseUrl.replace(/\/+$/, "")}${API_PATH}`;
20
+ const base = `${options.baseUrl.replace(/\/+$/, "")}${options.apiPath ?? DELIVERY_API_PATH}`;
21
21
  const send = options.fetch ?? ((input, init) => fetch(input, init));
22
22
  async function get(path, params, request, missing) {
23
23
  const query = new URLSearchParams(params).toString();
@@ -80,6 +80,7 @@ function createDeliveryClient(options) {
80
80
  };
81
81
  }
82
82
  export {
83
+ DELIVERY_API_PATH,
83
84
  DeliveryError,
84
85
  createDeliveryClient,
85
86
  isExpanded
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/delivery-client",
3
- "version": "0.24.1",
3
+ "version": "0.26.0",
4
4
  "description": "A typed client for a crombolo site's Delivery API, for apps in the browser, Node or Bun. No dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",