@sylphx/sdk 0.11.0 → 0.11.1
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 +1588 -1226
- package/dist/index.mjs +2294 -1131
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.mjs +3 -0
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.mjs +57 -39
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.ts +15 -1
- package/dist/server/index.mjs +34 -3
- package/dist/server/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/server/index.d.ts
CHANGED
|
@@ -1441,6 +1441,20 @@ declare function getStreams(): StreamsClient;
|
|
|
1441
1441
|
* ```
|
|
1442
1442
|
*/
|
|
1443
1443
|
|
|
1444
|
+
declare const PLATFORM_CONSOLE_SLUG = "keen-wave-x3m9p2";
|
|
1445
|
+
declare const LEGACY_PLATFORM_PROJECT_ID = "00000000-0000-0000-0000-000000000001";
|
|
1446
|
+
declare const PLATFORM_TENANT_BAAS_URL = "https://keen-wave-x3m9p2.api.sylphx.com/v1";
|
|
1447
|
+
interface PlatformBaasUrlEnv {
|
|
1448
|
+
readonly [key: string]: string | undefined;
|
|
1449
|
+
readonly SYLPHX_BAAS_URL?: string;
|
|
1450
|
+
readonly SYLPHX_URL?: string;
|
|
1451
|
+
readonly SYLPHX_RUNTIME_URL?: string;
|
|
1452
|
+
}
|
|
1453
|
+
declare function isPlatformProjectIdentity(input: {
|
|
1454
|
+
readonly projectId?: string | null;
|
|
1455
|
+
readonly projectSlug?: string | null;
|
|
1456
|
+
}): boolean;
|
|
1457
|
+
declare function resolvePlatformBaasUrl(env?: PlatformBaasUrlEnv): string;
|
|
1444
1458
|
interface ServerConfig {
|
|
1445
1459
|
/**
|
|
1446
1460
|
* Your Secret Key (keep secure, server-only)
|
|
@@ -1876,4 +1890,4 @@ declare function getDatabaseConnection(options: AuthenticatedFetchOptions): Prom
|
|
|
1876
1890
|
*/
|
|
1877
1891
|
declare function getDatabaseStatus(options: AuthenticatedFetchOptions): Promise<DatabaseStatusInfo>;
|
|
1878
1892
|
|
|
1879
|
-
export { type AIClient, type AIClientOptions, type AppConfig, type AppMetadata, type ChannelHelper, type ChatCompletionChunk, type ChatCompletionOptions, type ChatCompletionResponse, type ChatCompletionStreamOptions, type ChatMessage, type ConsentType, type DatabaseConnectionInfo, type DatabaseStatusInfo, type EmbeddingOptions, type EmbeddingResponse, type EngagementLeaderboardEntry, type EngagementLeaderboardResult, type EnvironmentType, type FeatureFlagDefinition, type FunctionDeployOptions, type FunctionDeployResult, type FunctionInvokeOptions, type FunctionListOptions, type FunctionLogEntry, type FunctionLogsOptions, type FunctionRecord, type FunctionRuntime, type FunctionStatus, FunctionsClient, type GetAppConfigOptions, InvalidConnectionUrlError, type KeyType, type KeyValidationResult, type KvClient, type KvClientOptions, type KvRateLimitResult, type KvSetOptions, type KvZMember, type ModelInfo, type ModelsResponse, type OAuthProvider, type OAuthProviderInfo, type Plan, type ReferralLeaderboardEntry, type ReferralLeaderboardResult, type RestClient, type RestClientConfig as ServerClientConfig, type ServerConfig, type StreamHistoryOptions, type StreamMessage, type StreamsClient, type StreamsClientOptions, type SylphxClientInput, type SylphxConfig, type WebhookPayload, type WebhookVerifyOptions, type WebhookVerifyResult, createAI, createAuthenticatedServerClient, createClient, createKv, createServerClient, createServerRestClient, createStreams, createWebhookHandler, decodeUserId, detectEnvironment, detectKeyType, encodeUserId, getAI, getAppConfig, getAppMetadata, getConsentTypes, getCookieNamespace, getDatabaseConnection, getDatabaseStatus, getEngagementLeaderboard, getFeatureFlags, getJwks, getKv, getOAuthProviders, getOAuthProvidersWithInfo, getPlans, getReferralLeaderboard, getStreams, isAppId, isDevelopmentKey, isDevelopmentRuntime, isProductionKey, isSecretKey, resetJwksCache, validateAndSanitizeAppId, validateAndSanitizeKey, validateAndSanitizeSecretKey, validateAppId, validateKey, validateSecretKey, verifyAccessToken, verifyWebhook };
|
|
1893
|
+
export { type AIClient, type AIClientOptions, type AppConfig, type AppMetadata, type ChannelHelper, type ChatCompletionChunk, type ChatCompletionOptions, type ChatCompletionResponse, type ChatCompletionStreamOptions, type ChatMessage, type ConsentType, type DatabaseConnectionInfo, type DatabaseStatusInfo, type EmbeddingOptions, type EmbeddingResponse, type EngagementLeaderboardEntry, type EngagementLeaderboardResult, type EnvironmentType, type FeatureFlagDefinition, type FunctionDeployOptions, type FunctionDeployResult, type FunctionInvokeOptions, type FunctionListOptions, type FunctionLogEntry, type FunctionLogsOptions, type FunctionRecord, type FunctionRuntime, type FunctionStatus, FunctionsClient, type GetAppConfigOptions, InvalidConnectionUrlError, type KeyType, type KeyValidationResult, type KvClient, type KvClientOptions, type KvRateLimitResult, type KvSetOptions, type KvZMember, LEGACY_PLATFORM_PROJECT_ID, type ModelInfo, type ModelsResponse, type OAuthProvider, type OAuthProviderInfo, PLATFORM_CONSOLE_SLUG, PLATFORM_TENANT_BAAS_URL, type Plan, type PlatformBaasUrlEnv, type ReferralLeaderboardEntry, type ReferralLeaderboardResult, type RestClient, type RestClientConfig as ServerClientConfig, type ServerConfig, type StreamHistoryOptions, type StreamMessage, type StreamsClient, type StreamsClientOptions, type SylphxClientInput, type SylphxConfig, type WebhookPayload, type WebhookVerifyOptions, type WebhookVerifyResult, createAI, createAuthenticatedServerClient, createClient, createKv, createServerClient, createServerRestClient, createStreams, createWebhookHandler, decodeUserId, detectEnvironment, detectKeyType, encodeUserId, getAI, getAppConfig, getAppMetadata, getConsentTypes, getCookieNamespace, getDatabaseConnection, getDatabaseStatus, getEngagementLeaderboard, getFeatureFlags, getJwks, getKv, getOAuthProviders, getOAuthProvidersWithInfo, getPlans, getReferralLeaderboard, getStreams, isAppId, isDevelopmentKey, isDevelopmentRuntime, isPlatformProjectIdentity, isProductionKey, isSecretKey, resetJwksCache, resolvePlatformBaasUrl, validateAndSanitizeAppId, validateAndSanitizeKey, validateAndSanitizeSecretKey, validateAppId, validateKey, validateSecretKey, verifyAccessToken, verifyWebhook };
|
package/dist/server/index.mjs
CHANGED
|
@@ -2929,6 +2929,32 @@ function getStreams() {
|
|
|
2929
2929
|
}
|
|
2930
2930
|
|
|
2931
2931
|
// src/server/index.ts
|
|
2932
|
+
var PLATFORM_CONSOLE_SLUG = "keen-wave-x3m9p2";
|
|
2933
|
+
var LEGACY_PLATFORM_PROJECT_ID = "00000000-0000-0000-0000-000000000001";
|
|
2934
|
+
var PLATFORM_TENANT_BAAS_URL = `https://${PLATFORM_CONSOLE_SLUG}.${DEFAULT_SDK_API_HOST}${SDK_API_PATH}`;
|
|
2935
|
+
function isPlatformProjectIdentity(input) {
|
|
2936
|
+
return input.projectSlug === PLATFORM_CONSOLE_SLUG || input.projectId === LEGACY_PLATFORM_PROJECT_ID;
|
|
2937
|
+
}
|
|
2938
|
+
function resolvePlatformBaasUrl(env = process.env) {
|
|
2939
|
+
if (env.SYLPHX_BAAS_URL?.trim()) return normalizeV1BaseUrl(env.SYLPHX_BAAS_URL);
|
|
2940
|
+
const fromConnectionUrl = env.SYLPHX_URL?.trim() ? baasUrlFromConnectionUrl(env.SYLPHX_URL) : null;
|
|
2941
|
+
if (fromConnectionUrl) return fromConnectionUrl;
|
|
2942
|
+
if (env.SYLPHX_RUNTIME_URL?.trim()) return normalizeV1BaseUrl(env.SYLPHX_RUNTIME_URL);
|
|
2943
|
+
return PLATFORM_TENANT_BAAS_URL;
|
|
2944
|
+
}
|
|
2945
|
+
function normalizeV1BaseUrl(url) {
|
|
2946
|
+
const trimmed = url.trim().replace(/\/+$/, "");
|
|
2947
|
+
return trimmed.endsWith(SDK_API_PATH) ? trimmed : `${trimmed}${SDK_API_PATH}`;
|
|
2948
|
+
}
|
|
2949
|
+
function baasUrlFromConnectionUrl(connectionUrl) {
|
|
2950
|
+
try {
|
|
2951
|
+
const parsed = new URL(connectionUrl);
|
|
2952
|
+
if (parsed.protocol !== "sylphx:" || !parsed.host) return null;
|
|
2953
|
+
return normalizeV1BaseUrl(`https://${parsed.host}`);
|
|
2954
|
+
} catch {
|
|
2955
|
+
return null;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2932
2958
|
function createServerRestClient(config) {
|
|
2933
2959
|
const secretKey = validateAndSanitizeSecretKey(config.secretKey);
|
|
2934
2960
|
return createRestClient({
|
|
@@ -3129,13 +3155,13 @@ async function cachedFetch(params) {
|
|
|
3129
3155
|
try {
|
|
3130
3156
|
const controller = new AbortController();
|
|
3131
3157
|
const timer = setTimeout(() => controller.abort(), timeout);
|
|
3132
|
-
const
|
|
3158
|
+
const init = {
|
|
3133
3159
|
headers,
|
|
3134
3160
|
signal: controller.signal,
|
|
3135
|
-
// @ts-expect-error - Next.js extended fetch option
|
|
3136
3161
|
next: { revalidate }
|
|
3137
3162
|
// Next.js Data Cache with TTL
|
|
3138
|
-
}
|
|
3163
|
+
};
|
|
3164
|
+
const response = await fetch(url, init);
|
|
3139
3165
|
clearTimeout(timer);
|
|
3140
3166
|
if (!response.ok) {
|
|
3141
3167
|
console.warn(`[Sylphx] Failed to fetch ${label}:`, response.status);
|
|
@@ -3329,6 +3355,9 @@ async function getDatabaseStatus(options) {
|
|
|
3329
3355
|
export {
|
|
3330
3356
|
FunctionsClient,
|
|
3331
3357
|
InvalidConnectionUrlError,
|
|
3358
|
+
LEGACY_PLATFORM_PROJECT_ID,
|
|
3359
|
+
PLATFORM_CONSOLE_SLUG,
|
|
3360
|
+
PLATFORM_TENANT_BAAS_URL,
|
|
3332
3361
|
createAI,
|
|
3333
3362
|
createAuthenticatedServerClient,
|
|
3334
3363
|
createClient,
|
|
@@ -3360,9 +3389,11 @@ export {
|
|
|
3360
3389
|
isAppId,
|
|
3361
3390
|
isDevelopmentKey,
|
|
3362
3391
|
isDevelopmentRuntime,
|
|
3392
|
+
isPlatformProjectIdentity,
|
|
3363
3393
|
isProductionKey,
|
|
3364
3394
|
isSecretKey,
|
|
3365
3395
|
resetJwksCache,
|
|
3396
|
+
resolvePlatformBaasUrl,
|
|
3366
3397
|
validateAndSanitizeAppId,
|
|
3367
3398
|
validateAndSanitizeKey,
|
|
3368
3399
|
validateAndSanitizeSecretKey,
|