lytx 0.3.1 → 0.3.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/README.md CHANGED
@@ -72,6 +72,7 @@ export default app satisfies ExportedHandler<Env>;
72
72
  - `trackingRoutePrefix` (prefix all tracking routes, e.g. `/collect`)
73
73
  - `tagRoutes.scriptPath` + `tagRoutes.eventPath` (custom v2 route paths)
74
74
  - `auth.emailPasswordEnabled`, `auth.requireEmailVerification`, `auth.socialProviders.google`, `auth.socialProviders.github`
75
+ - `ai.provider`, `ai.baseURL`, `ai.model`, `ai.apiKey` (runtime AI vendor/model overrides)
75
76
  - `features.reportBuilderEnabled` + `features.askAiEnabled`
76
77
  - `names.*` (typed resource binding names for D1/KV/Queue/DO)
77
78
  - `domains.app` + `domains.tracking` (typed host/domain values)
package/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export type {
51
51
  LytxDbAdapter,
52
52
  LytxEventStore,
53
53
  LytxDbConfig,
54
+ LytxAiConfig,
54
55
  } from "./src/config/createLytxAppConfig";
55
56
  export function createLytxApp(
56
57
  config?: CreateLytxAppConfig,
package/index.ts CHANGED
@@ -73,6 +73,7 @@ export type {
73
73
  LytxDbAdapter,
74
74
  LytxEventStore,
75
75
  LytxDbConfig,
76
+ LytxAiConfig,
76
77
  } from "./src/config/createLytxAppConfig";
77
78
  export { DEFAULT_LYTX_RESOURCE_NAMES, resolveLytxResourceNames } from "./src/config/resourceNames";
78
79
  export type { LytxResourceNames, LytxResourceNamingOptions, LytxResourceStagePosition } from "./src/config/resourceNames";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lytx",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -57,6 +57,17 @@ const domainSchema = z
57
57
 
58
58
  const envKeySchema = z.string().trim().min(1, "Env var value cannot be empty");
59
59
 
60
+ const aiRuntimeConfigSchema = z
61
+ .object({
62
+ provider: envKeySchema.optional(),
63
+ baseURL: z.string().trim().url("ai.baseURL must be a valid URL").optional(),
64
+ model: envKeySchema.optional(),
65
+ apiKey: envKeySchema.optional(),
66
+ })
67
+ .strict();
68
+
69
+ export type LytxAiConfig = z.input<typeof aiRuntimeConfigSchema>;
70
+
60
71
  const createLytxAppConfigSchema = z
61
72
  .object({
62
73
  enableRequestLogging: z.boolean().optional(),
@@ -65,6 +76,7 @@ const createLytxAppConfigSchema = z
65
76
  useQueueIngestion: z.boolean().optional(),
66
77
  includeLegacyTagRoutes: z.boolean().optional(),
67
78
  trackingRoutePrefix: routePrefixSchema.optional(),
79
+ ai: aiRuntimeConfigSchema.optional(),
68
80
  auth: z
69
81
  .object({
70
82
  emailPasswordEnabled: z.boolean().optional(),
package/src/worker.tsx CHANGED
@@ -165,10 +165,10 @@ export function createLytxApp(config: CreateLytxAppConfig = {}) {
165
165
  setAuthRuntimeConfig(parsed_config.auth);
166
166
  setEmailFromAddress(parsed_config.env?.EMAIL_FROM);
167
167
  setAiRuntimeOverrides({
168
- apiKey: parsed_config.env?.AI_API_KEY,
169
- model: parsed_config.env?.AI_MODEL,
170
- baseURL: parsed_config.env?.AI_BASE_URL,
171
- provider: parsed_config.env?.AI_PROVIDER,
168
+ apiKey: parsed_config.ai?.apiKey ?? parsed_config.env?.AI_API_KEY,
169
+ model: parsed_config.ai?.model ?? parsed_config.env?.AI_MODEL,
170
+ baseURL: parsed_config.ai?.baseURL ?? parsed_config.env?.AI_BASE_URL,
171
+ provider: parsed_config.ai?.provider ?? parsed_config.env?.AI_PROVIDER,
172
172
  });
173
173
  const authProviders = getAuthProviderAvailability();
174
174
  const emailPasswordEnabled = parsed_config.auth?.emailPasswordEnabled ?? true;