@sylphx/sdk 0.7.0 → 0.8.0-rc.2

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.
@@ -194,7 +194,7 @@ declare class InvalidConnectionUrlError extends Error {
194
194
  * import { createClient } from '@sylphx/sdk'
195
195
  *
196
196
  * const sylphx = createClient(process.env.SYLPHX_URL!)
197
- * // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.sylphx.com
197
+ * // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.api.sylphx.com
198
198
  * ```
199
199
  */
200
200
 
@@ -213,7 +213,7 @@ interface SylphxConfig {
213
213
  readonly env: 'dev' | 'stg' | 'prod' | 'prev';
214
214
  /** Resource slug (first DNS label), e.g. 'bold-river-a1b2c3' */
215
215
  readonly slug: string;
216
- /** Pre-computed API base URL, e.g. 'https://bold-river-a1b2c3.sylphx.com/v1' */
216
+ /** Pre-computed API base URL, e.g. 'https://bold-river-a1b2c3.api.sylphx.com/v1' */
217
217
  readonly baseUrl: string;
218
218
  /** Optional access token for authenticated requests */
219
219
  readonly accessToken?: string;
@@ -266,7 +266,7 @@ interface SylphxClientInput {
266
266
  * @example Connection URL (recommended)
267
267
  * ```typescript
268
268
  * const sylphx = createClient(process.env.NEXT_PUBLIC_SYLPHX_URL!)
269
- * // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.sylphx.com
269
+ * // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.api.sylphx.com
270
270
  * ```
271
271
  *
272
272
  * @example Explicit components
@@ -287,7 +287,7 @@ declare function createClient(input: string | SylphxClientInput): SylphxConfig;
287
287
  * @example Connection URL (recommended)
288
288
  * ```typescript
289
289
  * const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
290
- * // Parses: sylphx://sk_prod_{hex}@bold-river-a1b2c3.sylphx.com
290
+ * // Parses: sylphx://sk_prod_{hex}@bold-river-a1b2c3.api.sylphx.com
291
291
  * ```
292
292
  *
293
293
  * @example Explicit components
@@ -1392,7 +1392,7 @@ declare function getStreams(): StreamsClient;
1392
1392
  * Sylphx Server SDK
1393
1393
  *
1394
1394
  * Server-side operations using REST API for type safety.
1395
- * Uses connection URL (sylphx://sk_*@slug.sylphx.com) for authentication.
1395
+ * Uses connection URL (sylphx://sk_*@tenant-slug.api.sylphx.com) for authentication.
1396
1396
  *
1397
1397
  * @example
1398
1398
  * ```typescript
@@ -1632,8 +1632,10 @@ interface FeatureFlagDefinition {
1632
1632
  * import { getFeatureFlags } from '@sylphx/sdk/server'
1633
1633
  *
1634
1634
  * export default async function RootLayout({ children }) {
1635
+ * const sylphx = createServerClient(process.env.SYLPHX_URL!)
1635
1636
  * const flags = await getFeatureFlags({
1636
- * secretKey: process.env.SYLPHX_SECRET_KEY!,
1637
+ * secretKey: sylphx.secretKey!,
1638
+ * platformUrl: sylphx.baseUrl.replace(/\/v[0-9]+$/, ''),
1637
1639
  * })
1638
1640
  * return <FeatureFlagsProvider initialFlags={flags}>{children}</FeatureFlagsProvider>
1639
1641
  * }
@@ -1687,9 +1689,11 @@ interface GetAppConfigOptions {
1687
1689
  * import { getAppConfig } from '@sylphx/sdk/server'
1688
1690
  *
1689
1691
  * export default async function RootLayout({ children }) {
1692
+ * const sylphx = createServerClient(process.env.SYLPHX_URL!)
1690
1693
  * const config = await getAppConfig({
1691
- * secretKey: process.env.SYLPHX_SECRET_KEY!,
1694
+ * secretKey: sylphx.secretKey!,
1692
1695
  * appId: process.env.NEXT_PUBLIC_SYLPHX_APP_ID!,
1696
+ * platformUrl: sylphx.baseUrl.replace(/\/v[0-9]+$/, ''),
1693
1697
  * })
1694
1698
  *
1695
1699
  * return (
@@ -2112,7 +2112,7 @@ function parseConnectionUrl(url) {
2112
2112
  // src/config.ts
2113
2113
  var LEGACY_EMBEDDED_REF_PATTERN = /^(pk|sk)_(dev|stg|prod|prev)_[a-z0-9]{12}_[a-f0-9]+$/;
2114
2114
  var LEGACY_APP_KEY_PATTERN = /^app_(dev|stg|prod|prev)_/;
2115
- var MIGRATION_MESSAGE = "API key format has changed. Use a sylphx:// connection URL instead.\n\nNew format: sylphx://pk_prod_{hex}@your-slug.sylphx.com\n\nGenerate new credentials from the Sylphx Console \u2192 Your App \u2192 Environments.\nSee https://docs.sylphx.com/migration for details.";
2115
+ var MIGRATION_MESSAGE = "API key format has changed. Use a sylphx:// connection URL instead.\n\nNew format: sylphx://pk_prod_{hex}@your-slug.api.sylphx.com\n\nGenerate new credentials from the Sylphx Console \u2192 Your App \u2192 Environments.\nSee https://docs.sylphx.com/migration for details.";
2116
2116
  function rejectLegacyKeyFormat(input) {
2117
2117
  const trimmed = input.trim().toLowerCase();
2118
2118
  if (LEGACY_APP_KEY_PATTERN.test(trimmed)) {
@@ -2155,7 +2155,7 @@ function createServerClient(input) {
2155
2155
  function createConfigFromUrl(url) {
2156
2156
  if (!url || typeof url !== "string") {
2157
2157
  throw new SylphxError(
2158
- "[Sylphx] Connection URL is required. Set SYLPHX_URL or NEXT_PUBLIC_SYLPHX_URL environment variable.\n\nFormat: sylphx://pk_prod_{hex}@your-slug.sylphx.com",
2158
+ "[Sylphx] Connection URL is required. Set SYLPHX_URL or NEXT_PUBLIC_SYLPHX_URL environment variable.\n\nFormat: sylphx://pk_prod_{hex}@your-slug.api.sylphx.com",
2159
2159
  { code: "BAD_REQUEST" }
2160
2160
  );
2161
2161
  }
@@ -2164,7 +2164,7 @@ function createConfigFromUrl(url) {
2164
2164
  if (!trimmed.startsWith("sylphx://")) {
2165
2165
  if (CREDENTIAL_REGEX.test(trimmed)) {
2166
2166
  throw new SylphxError(
2167
- "[Sylphx] Received a bare credential instead of a connection URL.\n\nWrap it in a connection URL: sylphx://<credential>@<slug>.sylphx.com\nOr use createClient({ slug, publicKey }) for explicit components.",
2167
+ "[Sylphx] Received a bare credential instead of a connection URL.\n\nWrap it in a connection URL: sylphx://<credential>@<slug>.api.sylphx.com\nOr use createClient({ slug, publicKey }) for explicit components.",
2168
2168
  { code: "BAD_REQUEST" }
2169
2169
  );
2170
2170
  }
@@ -3164,8 +3164,8 @@ async function fetchOAuthProviders(options) {
3164
3164
  const baseURL = (options.platformUrl ?? `https://${DEFAULT_SDK_API_HOST}`).trim();
3165
3165
  const appId = validateAndSanitizeAppId(options.appId);
3166
3166
  return cachedFetch({
3167
- url: `${baseURL}/api/auth/providers`,
3168
- headers: { "X-App-Id": appId },
3167
+ url: `${baseURL}${SDK_API_PATH}/auth/oauth-providers`,
3168
+ headers: { "x-app-secret": appId },
3169
3169
  fallback: { providers: [] },
3170
3170
  label: "OAuth providers"
3171
3171
  });