@lepsto/sdk-app 87.1.0 → 87.2.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.
@@ -3,6 +3,7 @@ export type { LesslyClientBase } from './runtime/createLesslyApp.js';
3
3
  export { connectStream } from './runtime/connectStream.js';
4
4
  export { LesslyApiError, isAccessDenied } from './runtime/errors.js';
5
5
  export { accessReason } from './runtime/access-reason.js';
6
+ export { platformApiBaseUrl } from './runtime/platform-base-url.js';
6
7
  export { operations } from './runtime/operations.js';
7
8
  export { compositions } from './runtime/compositions.js';
8
9
  export type { LesslyAppOptions, HttpMethod, Binding, BindingsMap, ParamSpec, ParamIn, ToolLevel, ToolComposition, Operation, } from './runtime/types.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The platform API origin for the host this document is served on — `https://api.<registrable
3
+ * domain>` — so an App built ONCE keeps pointing at the right API after the platform moves from
4
+ * `lessly` to `lepsto`, with no rebuild on the cutover night. On a `lessly` host the result is
5
+ * byte-identical to the value Apps hardcode today, so adopting it is inert until the move.
6
+ *
7
+ * Additive and entirely opt-in: `LesslyAppOptions.baseUrl` stays REQUIRED and this SDK never
8
+ * calls this helper on a caller's behalf. It is something an App may pass in
9
+ * (`createLesslyApp({ baseUrl: platformApiBaseUrl(), ... })`), not a default.
10
+ *
11
+ * @param fallback returned instead of throwing when the host is not a recognised platform host,
12
+ * or when there is no `location` at all (SSR, Node, tests).
13
+ * @throws when the host is unrecognised (or absent) and no `fallback` was passed. The message
14
+ * names what was found and what is accepted.
15
+ */
16
+ export declare function platformApiBaseUrl(fallback?: string): string;
package/dist/index.cjs CHANGED
@@ -12612,6 +12612,27 @@ function accessReason(op) {
12612
12612
  return "Not available for your role. Ask an admin of this product.";
12613
12613
  }
12614
12614
 
12615
+ // src/runtime/platform-base-url.ts
12616
+ var PLATFORM_DOMAINS = ["lessly.dev", "lessly.com", "lepsto.dev", "lepsto.com"];
12617
+ function registrableDomain(hostname) {
12618
+ const host = hostname.toLowerCase().replace(/\.$/, "");
12619
+ return PLATFORM_DOMAINS.find((domain) => host === domain || host.endsWith(`.${domain}`));
12620
+ }
12621
+ function currentHostname() {
12622
+ const hostname = globalThis.location?.hostname;
12623
+ return typeof hostname === "string" && hostname !== "" ? hostname : void 0;
12624
+ }
12625
+ function platformApiBaseUrl(fallback) {
12626
+ const hostname = currentHostname();
12627
+ const domain = hostname === void 0 ? void 0 : registrableDomain(hostname);
12628
+ if (domain !== void 0) return `https://api.${domain}`;
12629
+ if (fallback !== void 0) return fallback;
12630
+ const found = hostname === void 0 ? "no globalThis.location.hostname is available (SSR, Node or a test environment)" : `host "${hostname}" is not a platform host`;
12631
+ throw new Error(
12632
+ `@lepsto/sdk-app: cannot derive the platform API base URL \u2014 ${found}. Accepted registrable domains (and any subdomain of them): ${PLATFORM_DOMAINS.join(", ")}. Pass a fallback to platformApiBaseUrl(), or an explicit baseUrl to createLesslyApp().`
12633
+ );
12634
+ }
12635
+
12615
12636
  // src/runtime/operations.ts
12616
12637
  var operations2 = operations;
12617
12638
 
@@ -12625,5 +12646,6 @@ exports.connectStream = connectStream;
12625
12646
  exports.createLesslyApp = createLesslyApp;
12626
12647
  exports.isAccessDenied = isAccessDenied;
12627
12648
  exports.operations = operations2;
12649
+ exports.platformApiBaseUrl = platformApiBaseUrl;
12628
12650
  //# sourceMappingURL=index.cjs.map
12629
12651
  //# sourceMappingURL=index.cjs.map