@llmops/core 0.2.14 → 0.3.0-beta.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.
- package/dist/db/index.d.cts +1 -1
- package/dist/{index-Dm1Gi0cH.d.cts → index-CunWjFE4.d.cts} +35 -35
- package/dist/index.cjs +347 -4
- package/dist/index.d.cts +195 -2
- package/dist/index.d.mts +194 -1
- package/dist/index.mjs +344 -5
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as variantsSchema, A as ProviderConfig, B as VariantVersionsTable, C as Environment, D as Insertable, E as EnvironmentsTable, F as TargetingRule, G as configsSchema, H as WorkspaceSettings, I as TargetingRulesTable, J as llmRequestsSchema, K as environmentSecretsSchema, L as Updateable, M as SCHEMA_METADATA, N as Selectable, O as LLMRequest, P as TableName, Q as variantVersionsSchema, R as Variant, S as Database, T as EnvironmentSecretsTable, U as WorkspaceSettingsTable, V as VariantsTable, W as configVariantsSchema, X as schemas, Y as providerConfigsSchema, Z as targetingRulesSchema, _ as validateTableData, a as createDatabaseFromConnection, b as ConfigVariantsTable, c as executeWithSchema, d as getMigrations, et as workspaceSettingsSchema, f as matchType, g as validatePartialTableData, h as parseTableData, i as createDatabase, j as ProviderConfigsTable, k as LLMRequestsTable, l as MigrationOptions, m as parsePartialTableData, n as DatabaseOptions, o as detectDatabaseType, p as runAutoMigrations, q as environmentsSchema, r as DatabaseType, s as createNeonDialect, t as DatabaseConnection, u as MigrationResult, v as Config, w as EnvironmentSecret, x as ConfigsTable, y as ConfigVariant, z as VariantVersion } from "./index-
|
|
1
|
+
import { $ as variantsSchema, A as ProviderConfig, B as VariantVersionsTable, C as Environment, D as Insertable, E as EnvironmentsTable, F as TargetingRule, G as configsSchema, H as WorkspaceSettings, I as TargetingRulesTable, J as llmRequestsSchema, K as environmentSecretsSchema, L as Updateable, M as SCHEMA_METADATA, N as Selectable, O as LLMRequest, P as TableName, Q as variantVersionsSchema, R as Variant, S as Database, T as EnvironmentSecretsTable, U as WorkspaceSettingsTable, V as VariantsTable, W as configVariantsSchema, X as schemas, Y as providerConfigsSchema, Z as targetingRulesSchema, _ as validateTableData, a as createDatabaseFromConnection, b as ConfigVariantsTable, c as executeWithSchema, d as getMigrations, et as workspaceSettingsSchema, f as matchType, g as validatePartialTableData, h as parseTableData, i as createDatabase, j as ProviderConfigsTable, k as LLMRequestsTable, l as MigrationOptions, m as parsePartialTableData, n as DatabaseOptions, o as detectDatabaseType, p as runAutoMigrations, q as environmentsSchema, r as DatabaseType, s as createNeonDialect, t as DatabaseConnection, u as MigrationResult, v as Config, w as EnvironmentSecret, x as ConfigsTable, y as ConfigVariant, z as VariantVersion } from "./index-CunWjFE4.cjs";
|
|
2
2
|
import { Kysely } from "kysely";
|
|
3
3
|
import * as zod0 from "zod";
|
|
4
4
|
import z$1, { z } from "zod";
|
|
@@ -6,6 +6,7 @@ import gateway from "@llmops/gateway";
|
|
|
6
6
|
import pino from "pino";
|
|
7
7
|
import * as better_auth0 from "better-auth";
|
|
8
8
|
import { BetterAuthOptions } from "better-auth";
|
|
9
|
+
import { RulesLogic } from "json-logic-js";
|
|
9
10
|
|
|
10
11
|
//#region src/schemas/config.d.ts
|
|
11
12
|
declare const llmopsConfigSchema: z.ZodObject<{
|
|
@@ -1392,6 +1393,9 @@ declare const getProviderConfigById: z$1.ZodObject<{
|
|
|
1392
1393
|
declare const getProviderConfigByProviderId: z$1.ZodObject<{
|
|
1393
1394
|
providerId: z$1.ZodString;
|
|
1394
1395
|
}, z$1.core.$strip>;
|
|
1396
|
+
declare const getProviderConfigBySlug: z$1.ZodObject<{
|
|
1397
|
+
slug: z$1.ZodString;
|
|
1398
|
+
}, z$1.core.$strip>;
|
|
1395
1399
|
declare const deleteProviderConfig: z$1.ZodObject<{
|
|
1396
1400
|
id: z$1.ZodUUID;
|
|
1397
1401
|
}, z$1.core.$strip>;
|
|
@@ -1440,6 +1444,16 @@ declare const createProviderConfigsDataLayer: (db: Kysely<Database>) => {
|
|
|
1440
1444
|
providerId: string;
|
|
1441
1445
|
config: Record<string, unknown>;
|
|
1442
1446
|
} | undefined>;
|
|
1447
|
+
getProviderConfigBySlug: (params: z$1.infer<typeof getProviderConfigBySlug>) => Promise<{
|
|
1448
|
+
slug: string | null;
|
|
1449
|
+
name: string | null;
|
|
1450
|
+
id: string;
|
|
1451
|
+
createdAt: Date;
|
|
1452
|
+
updatedAt: Date;
|
|
1453
|
+
enabled: boolean;
|
|
1454
|
+
providerId: string;
|
|
1455
|
+
config: Record<string, unknown>;
|
|
1456
|
+
} | undefined>;
|
|
1443
1457
|
deleteProviderConfig: (params: z$1.infer<typeof deleteProviderConfig>) => Promise<{
|
|
1444
1458
|
slug: string | null;
|
|
1445
1459
|
name: string | null;
|
|
@@ -1974,6 +1988,18 @@ declare const createDataLayer: (db: Kysely<Database>) => Promise<{
|
|
|
1974
1988
|
providerId: string;
|
|
1975
1989
|
config: Record<string, unknown>;
|
|
1976
1990
|
} | undefined>;
|
|
1991
|
+
getProviderConfigBySlug: (params: zod0.infer<zod0.ZodObject<{
|
|
1992
|
+
slug: zod0.ZodString;
|
|
1993
|
+
}, better_auth0.$strip>>) => Promise<{
|
|
1994
|
+
slug: string | null;
|
|
1995
|
+
name: string | null;
|
|
1996
|
+
id: string;
|
|
1997
|
+
createdAt: Date;
|
|
1998
|
+
updatedAt: Date;
|
|
1999
|
+
enabled: boolean;
|
|
2000
|
+
providerId: string;
|
|
2001
|
+
config: Record<string, unknown>;
|
|
2002
|
+
} | undefined>;
|
|
1977
2003
|
deleteProviderConfig: (params: zod0.infer<zod0.ZodObject<{
|
|
1978
2004
|
id: zod0.ZodUUID;
|
|
1979
2005
|
}, better_auth0.$strip>>) => Promise<{
|
|
@@ -2817,4 +2843,171 @@ interface AuthClientOptions {
|
|
|
2817
2843
|
*/
|
|
2818
2844
|
declare const getAuthClientOptions: (options: AuthClientOptions) => BetterAuthOptions;
|
|
2819
2845
|
//#endregion
|
|
2820
|
-
|
|
2846
|
+
//#region src/manifest/types.d.ts
|
|
2847
|
+
/**
|
|
2848
|
+
* Pre-computed variant version data needed for routing
|
|
2849
|
+
*/
|
|
2850
|
+
interface ManifestVariantVersion {
|
|
2851
|
+
id: string;
|
|
2852
|
+
variantId: string;
|
|
2853
|
+
version: number;
|
|
2854
|
+
provider: string;
|
|
2855
|
+
providerConfigId: string | null;
|
|
2856
|
+
modelName: string;
|
|
2857
|
+
jsonData: Record<string, unknown>;
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* A targeting rule entry in the manifest
|
|
2861
|
+
* Pre-resolved with all necessary data for routing
|
|
2862
|
+
*/
|
|
2863
|
+
interface ManifestTargetingRule {
|
|
2864
|
+
id: string;
|
|
2865
|
+
configVariantId: string;
|
|
2866
|
+
variantVersionId: string | null;
|
|
2867
|
+
weight: number;
|
|
2868
|
+
priority: number;
|
|
2869
|
+
enabled: boolean;
|
|
2870
|
+
conditions: RulesLogic | null;
|
|
2871
|
+
resolvedVersion: ManifestVariantVersion;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Config entry in the manifest
|
|
2875
|
+
*/
|
|
2876
|
+
interface ManifestConfig {
|
|
2877
|
+
id: string;
|
|
2878
|
+
slug: string;
|
|
2879
|
+
name: string | null;
|
|
2880
|
+
}
|
|
2881
|
+
/**
|
|
2882
|
+
* Environment entry in the manifest
|
|
2883
|
+
*/
|
|
2884
|
+
interface ManifestEnvironment {
|
|
2885
|
+
id: string;
|
|
2886
|
+
slug: string;
|
|
2887
|
+
name: string;
|
|
2888
|
+
isProd: boolean;
|
|
2889
|
+
}
|
|
2890
|
+
/**
|
|
2891
|
+
* The complete routing manifest
|
|
2892
|
+
* Stored in cache under key: "gateway:manifest"
|
|
2893
|
+
*/
|
|
2894
|
+
interface GatewayManifest {
|
|
2895
|
+
version: number;
|
|
2896
|
+
builtAt: string;
|
|
2897
|
+
configs: Record<string, ManifestConfig>;
|
|
2898
|
+
configsBySlug: Record<string, string>;
|
|
2899
|
+
environments: Record<string, ManifestEnvironment>;
|
|
2900
|
+
environmentsBySlug: Record<string, string>;
|
|
2901
|
+
routingTable: Record<string, Record<string, ManifestTargetingRule[]>>;
|
|
2902
|
+
secretToEnvironment: Record<string, string>;
|
|
2903
|
+
}
|
|
2904
|
+
/**
|
|
2905
|
+
* Context passed to JSONLogic for condition evaluation
|
|
2906
|
+
*/
|
|
2907
|
+
interface RoutingContext {
|
|
2908
|
+
headers?: Record<string, string>;
|
|
2909
|
+
user?: {
|
|
2910
|
+
id?: string;
|
|
2911
|
+
email?: string;
|
|
2912
|
+
groups?: string[];
|
|
2913
|
+
[key: string]: unknown;
|
|
2914
|
+
};
|
|
2915
|
+
request?: {
|
|
2916
|
+
path?: string;
|
|
2917
|
+
method?: string;
|
|
2918
|
+
ip?: string;
|
|
2919
|
+
};
|
|
2920
|
+
custom?: Record<string, unknown>;
|
|
2921
|
+
timestamp?: number;
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
* Result of routing a request
|
|
2925
|
+
*/
|
|
2926
|
+
interface RoutingResult {
|
|
2927
|
+
configId: string;
|
|
2928
|
+
environmentId: string;
|
|
2929
|
+
variantId: string;
|
|
2930
|
+
version: ManifestVariantVersion;
|
|
2931
|
+
rule: ManifestTargetingRule;
|
|
2932
|
+
}
|
|
2933
|
+
//#endregion
|
|
2934
|
+
//#region src/manifest/builder.d.ts
|
|
2935
|
+
/**
|
|
2936
|
+
* Builds the gateway routing manifest from database
|
|
2937
|
+
*/
|
|
2938
|
+
declare class ManifestBuilder {
|
|
2939
|
+
private db;
|
|
2940
|
+
constructor(db: Kysely<Database>);
|
|
2941
|
+
/**
|
|
2942
|
+
* Build the complete routing manifest from database
|
|
2943
|
+
*/
|
|
2944
|
+
build(): Promise<GatewayManifest>;
|
|
2945
|
+
}
|
|
2946
|
+
//#endregion
|
|
2947
|
+
//#region src/manifest/service.d.ts
|
|
2948
|
+
declare class ManifestService {
|
|
2949
|
+
private cache;
|
|
2950
|
+
private ttlMs;
|
|
2951
|
+
private builder;
|
|
2952
|
+
constructor(cache: CacheService, db: Kysely<Database>, ttlMs?: number);
|
|
2953
|
+
/**
|
|
2954
|
+
* Get the current manifest, building if necessary
|
|
2955
|
+
*/
|
|
2956
|
+
getManifest(): Promise<GatewayManifest>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Force invalidate the manifest (called on mutations)
|
|
2959
|
+
*/
|
|
2960
|
+
invalidate(): Promise<void>;
|
|
2961
|
+
/**
|
|
2962
|
+
* Invalidate and immediately rebuild (atomic refresh)
|
|
2963
|
+
*/
|
|
2964
|
+
refresh(): Promise<GatewayManifest>;
|
|
2965
|
+
/**
|
|
2966
|
+
* Get manifest version without fetching full manifest
|
|
2967
|
+
* Useful for checking if manifest is stale
|
|
2968
|
+
*/
|
|
2969
|
+
getVersion(): Promise<number | null>;
|
|
2970
|
+
/**
|
|
2971
|
+
* Check if manifest exists in cache
|
|
2972
|
+
*/
|
|
2973
|
+
hasManifest(): Promise<boolean>;
|
|
2974
|
+
}
|
|
2975
|
+
//#endregion
|
|
2976
|
+
//#region src/manifest/router.d.ts
|
|
2977
|
+
/**
|
|
2978
|
+
* Router for evaluating the gateway manifest and selecting variants
|
|
2979
|
+
*/
|
|
2980
|
+
declare class ManifestRouter {
|
|
2981
|
+
private manifest;
|
|
2982
|
+
constructor(manifest: GatewayManifest);
|
|
2983
|
+
/**
|
|
2984
|
+
* Resolve a config identifier (UUID or slug) to config ID
|
|
2985
|
+
*/
|
|
2986
|
+
resolveConfigId(configIdOrSlug: string): string | null;
|
|
2987
|
+
/**
|
|
2988
|
+
* Resolve environment from secret value
|
|
2989
|
+
*/
|
|
2990
|
+
resolveEnvironmentFromSecret(secretValue: string): string | null;
|
|
2991
|
+
/**
|
|
2992
|
+
* Get production environment ID
|
|
2993
|
+
*/
|
|
2994
|
+
getProductionEnvironmentId(): string | null;
|
|
2995
|
+
/**
|
|
2996
|
+
* Get environment by ID
|
|
2997
|
+
*/
|
|
2998
|
+
getEnvironment(environmentId: string): ManifestEnvironment;
|
|
2999
|
+
/**
|
|
3000
|
+
* Get config by ID
|
|
3001
|
+
*/
|
|
3002
|
+
getConfig(configId: string): ManifestConfig;
|
|
3003
|
+
/**
|
|
3004
|
+
* Route a request to the appropriate variant version (first match wins)
|
|
3005
|
+
*/
|
|
3006
|
+
route(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
3007
|
+
/**
|
|
3008
|
+
* Route with weighted random selection among matching rules of same priority
|
|
3009
|
+
*/
|
|
3010
|
+
routeWithWeights(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
3011
|
+
}
|
|
3012
|
+
//#endregion
|
|
3013
|
+
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, Config, ConfigVariant, ConfigVariantsTable, ConfigsTable, type CortexProviderConfig, CostResult, Database, DatabaseConnection, DatabaseOptions, DatabaseType, Environment, EnvironmentSecret, EnvironmentSecretsTable, EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, GatewayManifest, type GoogleProviderConfig, type HuggingFaceProviderConfig, Insertable, LLMOpsClient, LLMOpsConfig, type LLMOpsConfigInput, LLMRequest, type LLMRequestInsert, LLMRequestsTable, MS, ManifestBuilder, ManifestConfig, ManifestEnvironment, ManifestRouter, ManifestService, ManifestTargetingRule, ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, ModelsDevPricingProvider, type OpenAIProviderConfig, type OracleProviderConfig, Prettify, PricingProvider, ProviderConfig, type ProviderConfigMap, ProviderConfigsTable, type ProvidersConfig, RoutingContext, RoutingResult, SCHEMA_METADATA, type SagemakerProviderConfig, Selectable, type StabilityAIProviderConfig, SupportedProviders, TableName, TargetingRule, TargetingRulesTable, Updateable, UsageData, type ValidatedLLMOpsConfig, Variant, VariantJsonData, VariantVersion, VariantVersionsTable, VariantsTable, type VertexAIProviderConfig, type WorkersAIProviderConfig, WorkspaceSettings, WorkspaceSettingsTable, calculateCost, chatCompletionCreateParamsBaseSchema, configVariantsSchema, configsSchema, createDataLayer, createDatabase, createDatabaseFromConnection, createLLMRequestsDataLayer, createNeonDialect, createProviderConfigsDataLayer, createWorkspaceSettingsDataLayer, detectDatabaseType, dollarsToMicroDollars, environmentSecretsSchema, environmentsSchema, executeWithSchema, formatCost, gateway, generateId, getAuthClientOptions, getDefaultPricingProvider, getMigrations, llmRequestsSchema, llmopsConfigSchema, logger, matchType, microDollarsToDollars, parsePartialTableData, parseTableData, providerConfigsSchema, runAutoMigrations, schemas, targetingRulesSchema, validateLLMOpsConfig, validatePartialTableData, validateTableData, variantJsonDataSchema, variantVersionsSchema, variantsSchema, workspaceSettingsSchema };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { $ as variantsSchema, A as ProviderConfig, B as VariantVersionsTable, C
|
|
|
2
2
|
import gateway from "@llmops/gateway";
|
|
3
3
|
import { Kysely } from "kysely";
|
|
4
4
|
import pino from "pino";
|
|
5
|
+
import { RulesLogic } from "json-logic-js";
|
|
5
6
|
import * as zod33 from "zod";
|
|
6
7
|
import z$1, { z } from "zod";
|
|
7
8
|
import * as better_auth0 from "better-auth";
|
|
@@ -1392,6 +1393,9 @@ declare const getProviderConfigById: z$1.ZodObject<{
|
|
|
1392
1393
|
declare const getProviderConfigByProviderId: z$1.ZodObject<{
|
|
1393
1394
|
providerId: z$1.ZodString;
|
|
1394
1395
|
}, z$1.core.$strip>;
|
|
1396
|
+
declare const getProviderConfigBySlug: z$1.ZodObject<{
|
|
1397
|
+
slug: z$1.ZodString;
|
|
1398
|
+
}, z$1.core.$strip>;
|
|
1395
1399
|
declare const deleteProviderConfig: z$1.ZodObject<{
|
|
1396
1400
|
id: z$1.ZodUUID;
|
|
1397
1401
|
}, z$1.core.$strip>;
|
|
@@ -1440,6 +1444,16 @@ declare const createProviderConfigsDataLayer: (db: Kysely<Database>) => {
|
|
|
1440
1444
|
providerId: string;
|
|
1441
1445
|
config: Record<string, unknown>;
|
|
1442
1446
|
} | undefined>;
|
|
1447
|
+
getProviderConfigBySlug: (params: z$1.infer<typeof getProviderConfigBySlug>) => Promise<{
|
|
1448
|
+
slug: string | null;
|
|
1449
|
+
name: string | null;
|
|
1450
|
+
id: string;
|
|
1451
|
+
createdAt: Date;
|
|
1452
|
+
updatedAt: Date;
|
|
1453
|
+
enabled: boolean;
|
|
1454
|
+
providerId: string;
|
|
1455
|
+
config: Record<string, unknown>;
|
|
1456
|
+
} | undefined>;
|
|
1443
1457
|
deleteProviderConfig: (params: z$1.infer<typeof deleteProviderConfig>) => Promise<{
|
|
1444
1458
|
slug: string | null;
|
|
1445
1459
|
name: string | null;
|
|
@@ -1974,6 +1988,18 @@ declare const createDataLayer: (db: Kysely<Database>) => Promise<{
|
|
|
1974
1988
|
providerId: string;
|
|
1975
1989
|
config: Record<string, unknown>;
|
|
1976
1990
|
} | undefined>;
|
|
1991
|
+
getProviderConfigBySlug: (params: zod33.infer<zod33.ZodObject<{
|
|
1992
|
+
slug: zod33.ZodString;
|
|
1993
|
+
}, better_auth0.$strip>>) => Promise<{
|
|
1994
|
+
slug: string | null;
|
|
1995
|
+
name: string | null;
|
|
1996
|
+
id: string;
|
|
1997
|
+
createdAt: Date;
|
|
1998
|
+
updatedAt: Date;
|
|
1999
|
+
enabled: boolean;
|
|
2000
|
+
providerId: string;
|
|
2001
|
+
config: Record<string, unknown>;
|
|
2002
|
+
} | undefined>;
|
|
1977
2003
|
deleteProviderConfig: (params: zod33.infer<zod33.ZodObject<{
|
|
1978
2004
|
id: zod33.ZodUUID;
|
|
1979
2005
|
}, better_auth0.$strip>>) => Promise<{
|
|
@@ -2817,4 +2843,171 @@ interface AuthClientOptions {
|
|
|
2817
2843
|
*/
|
|
2818
2844
|
declare const getAuthClientOptions: (options: AuthClientOptions) => BetterAuthOptions;
|
|
2819
2845
|
//#endregion
|
|
2820
|
-
|
|
2846
|
+
//#region src/manifest/types.d.ts
|
|
2847
|
+
/**
|
|
2848
|
+
* Pre-computed variant version data needed for routing
|
|
2849
|
+
*/
|
|
2850
|
+
interface ManifestVariantVersion {
|
|
2851
|
+
id: string;
|
|
2852
|
+
variantId: string;
|
|
2853
|
+
version: number;
|
|
2854
|
+
provider: string;
|
|
2855
|
+
providerConfigId: string | null;
|
|
2856
|
+
modelName: string;
|
|
2857
|
+
jsonData: Record<string, unknown>;
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* A targeting rule entry in the manifest
|
|
2861
|
+
* Pre-resolved with all necessary data for routing
|
|
2862
|
+
*/
|
|
2863
|
+
interface ManifestTargetingRule {
|
|
2864
|
+
id: string;
|
|
2865
|
+
configVariantId: string;
|
|
2866
|
+
variantVersionId: string | null;
|
|
2867
|
+
weight: number;
|
|
2868
|
+
priority: number;
|
|
2869
|
+
enabled: boolean;
|
|
2870
|
+
conditions: RulesLogic | null;
|
|
2871
|
+
resolvedVersion: ManifestVariantVersion;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Config entry in the manifest
|
|
2875
|
+
*/
|
|
2876
|
+
interface ManifestConfig {
|
|
2877
|
+
id: string;
|
|
2878
|
+
slug: string;
|
|
2879
|
+
name: string | null;
|
|
2880
|
+
}
|
|
2881
|
+
/**
|
|
2882
|
+
* Environment entry in the manifest
|
|
2883
|
+
*/
|
|
2884
|
+
interface ManifestEnvironment {
|
|
2885
|
+
id: string;
|
|
2886
|
+
slug: string;
|
|
2887
|
+
name: string;
|
|
2888
|
+
isProd: boolean;
|
|
2889
|
+
}
|
|
2890
|
+
/**
|
|
2891
|
+
* The complete routing manifest
|
|
2892
|
+
* Stored in cache under key: "gateway:manifest"
|
|
2893
|
+
*/
|
|
2894
|
+
interface GatewayManifest {
|
|
2895
|
+
version: number;
|
|
2896
|
+
builtAt: string;
|
|
2897
|
+
configs: Record<string, ManifestConfig>;
|
|
2898
|
+
configsBySlug: Record<string, string>;
|
|
2899
|
+
environments: Record<string, ManifestEnvironment>;
|
|
2900
|
+
environmentsBySlug: Record<string, string>;
|
|
2901
|
+
routingTable: Record<string, Record<string, ManifestTargetingRule[]>>;
|
|
2902
|
+
secretToEnvironment: Record<string, string>;
|
|
2903
|
+
}
|
|
2904
|
+
/**
|
|
2905
|
+
* Context passed to JSONLogic for condition evaluation
|
|
2906
|
+
*/
|
|
2907
|
+
interface RoutingContext {
|
|
2908
|
+
headers?: Record<string, string>;
|
|
2909
|
+
user?: {
|
|
2910
|
+
id?: string;
|
|
2911
|
+
email?: string;
|
|
2912
|
+
groups?: string[];
|
|
2913
|
+
[key: string]: unknown;
|
|
2914
|
+
};
|
|
2915
|
+
request?: {
|
|
2916
|
+
path?: string;
|
|
2917
|
+
method?: string;
|
|
2918
|
+
ip?: string;
|
|
2919
|
+
};
|
|
2920
|
+
custom?: Record<string, unknown>;
|
|
2921
|
+
timestamp?: number;
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
* Result of routing a request
|
|
2925
|
+
*/
|
|
2926
|
+
interface RoutingResult {
|
|
2927
|
+
configId: string;
|
|
2928
|
+
environmentId: string;
|
|
2929
|
+
variantId: string;
|
|
2930
|
+
version: ManifestVariantVersion;
|
|
2931
|
+
rule: ManifestTargetingRule;
|
|
2932
|
+
}
|
|
2933
|
+
//#endregion
|
|
2934
|
+
//#region src/manifest/builder.d.ts
|
|
2935
|
+
/**
|
|
2936
|
+
* Builds the gateway routing manifest from database
|
|
2937
|
+
*/
|
|
2938
|
+
declare class ManifestBuilder {
|
|
2939
|
+
private db;
|
|
2940
|
+
constructor(db: Kysely<Database>);
|
|
2941
|
+
/**
|
|
2942
|
+
* Build the complete routing manifest from database
|
|
2943
|
+
*/
|
|
2944
|
+
build(): Promise<GatewayManifest>;
|
|
2945
|
+
}
|
|
2946
|
+
//#endregion
|
|
2947
|
+
//#region src/manifest/service.d.ts
|
|
2948
|
+
declare class ManifestService {
|
|
2949
|
+
private cache;
|
|
2950
|
+
private ttlMs;
|
|
2951
|
+
private builder;
|
|
2952
|
+
constructor(cache: CacheService, db: Kysely<Database>, ttlMs?: number);
|
|
2953
|
+
/**
|
|
2954
|
+
* Get the current manifest, building if necessary
|
|
2955
|
+
*/
|
|
2956
|
+
getManifest(): Promise<GatewayManifest>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Force invalidate the manifest (called on mutations)
|
|
2959
|
+
*/
|
|
2960
|
+
invalidate(): Promise<void>;
|
|
2961
|
+
/**
|
|
2962
|
+
* Invalidate and immediately rebuild (atomic refresh)
|
|
2963
|
+
*/
|
|
2964
|
+
refresh(): Promise<GatewayManifest>;
|
|
2965
|
+
/**
|
|
2966
|
+
* Get manifest version without fetching full manifest
|
|
2967
|
+
* Useful for checking if manifest is stale
|
|
2968
|
+
*/
|
|
2969
|
+
getVersion(): Promise<number | null>;
|
|
2970
|
+
/**
|
|
2971
|
+
* Check if manifest exists in cache
|
|
2972
|
+
*/
|
|
2973
|
+
hasManifest(): Promise<boolean>;
|
|
2974
|
+
}
|
|
2975
|
+
//#endregion
|
|
2976
|
+
//#region src/manifest/router.d.ts
|
|
2977
|
+
/**
|
|
2978
|
+
* Router for evaluating the gateway manifest and selecting variants
|
|
2979
|
+
*/
|
|
2980
|
+
declare class ManifestRouter {
|
|
2981
|
+
private manifest;
|
|
2982
|
+
constructor(manifest: GatewayManifest);
|
|
2983
|
+
/**
|
|
2984
|
+
* Resolve a config identifier (UUID or slug) to config ID
|
|
2985
|
+
*/
|
|
2986
|
+
resolveConfigId(configIdOrSlug: string): string | null;
|
|
2987
|
+
/**
|
|
2988
|
+
* Resolve environment from secret value
|
|
2989
|
+
*/
|
|
2990
|
+
resolveEnvironmentFromSecret(secretValue: string): string | null;
|
|
2991
|
+
/**
|
|
2992
|
+
* Get production environment ID
|
|
2993
|
+
*/
|
|
2994
|
+
getProductionEnvironmentId(): string | null;
|
|
2995
|
+
/**
|
|
2996
|
+
* Get environment by ID
|
|
2997
|
+
*/
|
|
2998
|
+
getEnvironment(environmentId: string): ManifestEnvironment;
|
|
2999
|
+
/**
|
|
3000
|
+
* Get config by ID
|
|
3001
|
+
*/
|
|
3002
|
+
getConfig(configId: string): ManifestConfig;
|
|
3003
|
+
/**
|
|
3004
|
+
* Route a request to the appropriate variant version (first match wins)
|
|
3005
|
+
*/
|
|
3006
|
+
route(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
3007
|
+
/**
|
|
3008
|
+
* Route with weighted random selection among matching rules of same priority
|
|
3009
|
+
*/
|
|
3010
|
+
routeWithWeights(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
3011
|
+
}
|
|
3012
|
+
//#endregion
|
|
3013
|
+
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, Config, ConfigVariant, type ConfigVariantsTable, type ConfigsTable, type CortexProviderConfig, CostResult, type Database, DatabaseConnection, DatabaseOptions, DatabaseType, Environment, EnvironmentSecret, type EnvironmentSecretsTable, type EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, type GatewayManifest, type GoogleProviderConfig, type HuggingFaceProviderConfig, Insertable, LLMOpsClient, LLMOpsConfig, type LLMOpsConfigInput, LLMRequest, type LLMRequestInsert, LLMRequestsTable, MS, ManifestBuilder, type ManifestConfig, type ManifestEnvironment, ManifestRouter, ManifestService, type ManifestTargetingRule, type ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, ModelsDevPricingProvider, type OpenAIProviderConfig, type OracleProviderConfig, Prettify, PricingProvider, ProviderConfig, type ProviderConfigMap, ProviderConfigsTable, type ProvidersConfig, type RoutingContext, type RoutingResult, SCHEMA_METADATA, type SagemakerProviderConfig, Selectable, type StabilityAIProviderConfig, SupportedProviders, type TableName, TargetingRule, type TargetingRulesTable, Updateable, UsageData, type ValidatedLLMOpsConfig, Variant, VariantJsonData, VariantVersion, VariantVersionsTable, type VariantsTable, type VertexAIProviderConfig, type WorkersAIProviderConfig, WorkspaceSettings, WorkspaceSettingsTable, calculateCost, chatCompletionCreateParamsBaseSchema, configVariantsSchema, configsSchema, createDataLayer, createDatabase, createDatabaseFromConnection, createLLMRequestsDataLayer, createNeonDialect, createProviderConfigsDataLayer, createWorkspaceSettingsDataLayer, detectDatabaseType, dollarsToMicroDollars, environmentSecretsSchema, environmentsSchema, executeWithSchema, formatCost, gateway, generateId, getAuthClientOptions, getDefaultPricingProvider, getMigrations, llmRequestsSchema, llmopsConfigSchema, logger, matchType, microDollarsToDollars, parsePartialTableData, parseTableData, providerConfigsSchema, runAutoMigrations, schemas, targetingRulesSchema, validateLLMOpsConfig, validatePartialTableData, validateTableData, variantJsonDataSchema, variantVersionsSchema, variantsSchema, workspaceSettingsSchema };
|