kizlo 0.15.2 → 0.16.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.
Files changed (85) hide show
  1. package/dist/adapters/logger.d.ts +2 -5
  2. package/dist/adapters/logger.js +1 -1
  3. package/dist/adapters/types.d.ts +19 -0
  4. package/dist/adapters/types.js +17 -0
  5. package/dist/astro/server.d.ts +2 -2
  6. package/dist/astro/server.js +2 -2
  7. package/dist/category/index.js +2 -2
  8. package/dist/cli/commands/_setup.js +10 -10
  9. package/dist/cli/commands/dev.js +7 -7
  10. package/dist/cli/daemon/generate.js +19 -9
  11. package/dist/cli/daemon/jiti.js +4 -5
  12. package/dist/cli/daemon/watch.js +3 -2
  13. package/dist/cli/presets/template.js +1 -1
  14. package/dist/cli/utils.js +6 -6
  15. package/dist/cli/wp/bootstrap.js +15 -11
  16. package/dist/cli/wp/constants.js +1 -1
  17. package/dist/cli/wp/dev.js +6 -23
  18. package/dist/cli/wp/types.d.ts +2 -2
  19. package/dist/cli/wp/utils.d.ts +1 -1
  20. package/dist/cli/wp/utils.js +1 -1
  21. package/dist/client.d.ts +7 -7
  22. package/dist/client.js +1 -1
  23. package/dist/comment/index.js +2 -2
  24. package/dist/config.d.ts +8 -8
  25. package/dist/context.d.ts +5 -5
  26. package/dist/context.js +5 -5
  27. package/dist/index.d.ts +7 -6
  28. package/dist/index.js +5 -4
  29. package/dist/integrations/astro/integration.d.ts +12 -0
  30. package/dist/integrations/astro/integration.js +14 -0
  31. package/dist/integrations/astro/kizlo.client.d.ts +4 -4
  32. package/dist/integrations/astro/utils.d.ts +4 -5
  33. package/dist/integrations/astro/utils.js +5 -6
  34. package/dist/integrations/nextjs/integration.d.ts +15 -0
  35. package/dist/integrations/nextjs/integration.js +18 -0
  36. package/dist/integrations/nextjs/kizlo.client.d.ts +2 -2
  37. package/dist/integrations/nextjs/revalidate.d.ts +2 -3
  38. package/dist/integrations/nextjs/revalidate.js +4 -4
  39. package/dist/integrations/nextjs/utils.js +2 -2
  40. package/dist/integrations/node/integration.d.ts +12 -0
  41. package/dist/integrations/node/integration.js +14 -0
  42. package/dist/integrations/runtime-env.js +25 -0
  43. package/dist/integrations/tanstack-start/api.d.ts +1 -1
  44. package/dist/integrations/tanstack-start/integration.d.ts +12 -0
  45. package/dist/integrations/tanstack-start/integration.js +14 -0
  46. package/dist/integrations/tanstack-start/kizlo.client.d.ts +4 -4
  47. package/dist/integrations/tanstack-start/utils.d.ts +1 -1
  48. package/dist/integrations/tanstack-start/utils.js +3 -3
  49. package/dist/kizlo.d.ts +33 -70
  50. package/dist/kizlo.js +91 -75
  51. package/dist/menu/index.js +2 -2
  52. package/dist/nextjs/server.d.ts +2 -2
  53. package/dist/nextjs/server.js +2 -2
  54. package/dist/node.d.ts +2 -0
  55. package/dist/node.js +3 -0
  56. package/dist/package.js +1 -1
  57. package/dist/page/index.js +2 -2
  58. package/dist/post/index.js +2 -2
  59. package/dist/{router.d.ts → procedures.d.ts} +11 -11
  60. package/dist/procedures.js +23 -0
  61. package/dist/seo/index.js +2 -2
  62. package/dist/settings/index.js +2 -2
  63. package/dist/shared/constants.js +1 -9
  64. package/dist/shared/contract-generation.js +14 -0
  65. package/dist/shared/contract.d.ts +2 -2
  66. package/dist/shared/contract.js +2 -2
  67. package/dist/shared/integration.d.ts +91 -0
  68. package/dist/shared/integration.js +59 -0
  69. package/dist/shared/procedure.d.ts +8 -8
  70. package/dist/shared/result.d.ts +2 -2
  71. package/dist/shared/router.d.ts +2 -2
  72. package/dist/shared/router.js +2 -2
  73. package/dist/tag/index.js +2 -2
  74. package/dist/tanstack-start/server.d.ts +2 -2
  75. package/dist/tanstack-start/server.js +2 -2
  76. package/package.json +8 -2
  77. package/dist/integrations/astro/kizlo.server.d.ts +0 -10
  78. package/dist/integrations/astro/kizlo.server.js +0 -12
  79. package/dist/integrations/nextjs/kizlo.server.d.ts +0 -11
  80. package/dist/integrations/nextjs/kizlo.server.js +0 -15
  81. package/dist/integrations/tanstack-start/kizlo.server.d.ts +0 -14
  82. package/dist/integrations/tanstack-start/kizlo.server.js +0 -15
  83. package/dist/router.js +0 -23
  84. package/dist/shared/extension.d.ts +0 -58
  85. package/dist/shared/extension.js +0 -37
package/dist/config.d.ts CHANGED
@@ -28,16 +28,16 @@ interface KizloDevConfig {
28
28
  * Host port the local WordPress MySQL is published on (default 3307), bound to `127.0.0.1` so
29
29
  * you can point a SQL client (TablePlus, DBeaver, `mysql`) at the database to
30
30
  * inspect or edit tables directly. Connect with db `wordpress`, user `wordpress`,
31
- * password `wppass`. Pick a port that's free — change it if you run multiple projects
31
+ * password `wppass`. Pick a port that's free; change it if you run multiple projects
32
32
  * or already have MySQL on the default.
33
33
  */
34
34
  dbPort?: number;
35
35
  /**
36
- * Code-defined seed data for a **fresh** local WordPress — the same {@link Fixture}s the
36
+ * Code-defined seed data for a **fresh** local WordPress. These are the same {@link Fixture}s the
37
37
  * test environment uses, so you can populate your local site from versioned code instead of a
38
- * blank install. Each fixture also declares the plugins it needs — wp.org slugs / zip
38
+ * blank install. Each fixture also declares the plugins it needs as wp.org slugs or zip
39
39
  * sources to install, or `{ path }` local directories bind-mounted live so your edits
40
- * show up without a reinstall — which `kizlo dev` ensures every run. Each fixture's
40
+ * show up without a reinstall, which `kizlo dev` ensures every run. Each fixture's
41
41
  * `seed` runs once over REST (and may drop to wp-cli) on the first `kizlo dev` and
42
42
  * after `kizlo dev reset`; an existing install is left alone.
43
43
  */
@@ -65,7 +65,7 @@ interface KizloTestConfig {
65
65
  * takes effect on the next `kizlo test reset` and Kizlo says so when the two disagree.
66
66
  */
67
67
  version?: string;
68
- /** Extension fixtures to install + seed. */
68
+ /** Integration fixtures to install + seed. */
69
69
  fixtures?: Fixture[];
70
70
  /**
71
71
  * Package manager used to launch the test script (default: auto-detected from
@@ -74,14 +74,14 @@ interface KizloTestConfig {
74
74
  packageManager?: "npm" | "pnpm" | "yarn" | "bun";
75
75
  /**
76
76
  * Override the test command entirely. Default: `<packageManager> test` (the
77
- * project's own `test` script — never hardcoded to vitest).
77
+ * project's own `test` script, never hardcoded to Vitest).
78
78
  */
79
79
  command?: string;
80
80
  }
81
81
  interface KizloGlobalConfig {
82
82
  /**
83
83
  * Kizlo's home directory. Kizlo owns the layout inside it: your server
84
- * (`server/`, whose `index.ts` exports `router` plus your extensions), the
84
+ * (`server/`, whose `index.ts` exports `procedures` plus your integrations), the
85
85
  * browser `client.ts`, and the generated contract.
86
86
  * @default 'src/lib/kizlo' (or 'lib/kizlo' without a src dir)
87
87
  */
@@ -111,7 +111,7 @@ interface KizloGlobalConfig {
111
111
  worktrees?: boolean;
112
112
  /**
113
113
  * Directory to write the WordPress client into, as `<wordpressClientDir>/wordpress.ts`. For a package or
114
- * workspace that ships procedures but no Kizlo server: there is no router to build a contract from,
114
+ * workspace that ships procedures but no Kizlo server: there is no procedure tree to build a contract from,
115
115
  * yet those procedures still call the generated tree, so they need the client on its own.
116
116
  *
117
117
  * Independent of `dir`. An app leaves this unset and gets its client inside `dir` alongside the
package/dist/context.d.ts CHANGED
@@ -5,11 +5,11 @@ import { AuthUser } from "./adapters/auth.js";
5
5
  import { PreviewTokenPayload } from "./shared/schema.js";
6
6
  import { ConnInfo } from "./adapters/geo.js";
7
7
  import { Logger } from "./adapters/logger.js";
8
+ import { ServiceAdapters } from "./adapters/types.js";
8
9
  import { CookiesStorage } from "./cookie.js";
9
10
  import { EmailService } from "./email/service.js";
10
11
  import { SettingsService } from "./settings/service.js";
11
- import { ServiceAdapters } from "./kizlo.js";
12
- import { ExtensionPluginRequirement } from "@kizlo/shared";
12
+ import { IntegrationPluginRequirement } from "@kizlo/shared";
13
13
 
14
14
  //#region src/context.d.ts
15
15
  interface ContextConfig {
@@ -17,15 +17,15 @@ interface ContextConfig {
17
17
  adapters?: ServiceAdapters;
18
18
  credentials: WordPressCredentials;
19
19
  wordpressEndpoints?: object;
20
- /** WordPress plugins the registered extensions need, checked against what each response reports. */
21
- extensionPlugins?: ExtensionPluginRequirement[];
20
+ /** WordPress plugins the registered integrations need, checked against what each response reports. */
21
+ integrationPlugins?: IntegrationPluginRequirement[];
22
22
  }
23
23
  type AuthUserFn = () => Promise<AuthUser | null>;
24
24
  type ConnInfoFn = () => Promise<ConnInfo | null>;
25
25
  type VerifyCaptchaFn = (token: string) => Promise<boolean>;
26
26
  type VerifyPreviewTokenFn = (token: string) => Promise<PreviewTokenPayload | null>;
27
27
  /**
28
- * The context every procedure, middleware, event, and webhook handler receives — the fixed base
28
+ * The context every procedure, middleware, event, and webhook handler receives. The fixed base
29
29
  * the server builds. A procedure's handler receives this base plus whatever its middleware injected
30
30
  * via `next({ context })`.
31
31
  */
package/dist/context.js CHANGED
@@ -6,7 +6,7 @@ import { EmailService } from "./email/service.js";
6
6
  import { SettingsService } from "./settings/service.js";
7
7
  import { createWordPressClient } from "./wordpress/endpoint.js";
8
8
  import { WordPressTransport } from "./wordpress/transport.js";
9
- import { EXTENSION_VERSIONS_HEADER, PLUGIN_VERSION_HEADER, base64Decode, extensionUpdateMessage, isPluginVersionSupported, parseExtensionVersions, pluginUpdateMessage, satisfiesVersion, tryCatchSync } from "@kizlo/shared";
9
+ import { INTEGRATION_VERSIONS_HEADER, PLUGIN_VERSION_HEADER, base64Decode, integrationUpdateMessage, isPluginVersionSupported, parseIntegrationVersions, pluginUpdateMessage, satisfiesVersion, tryCatchSync } from "@kizlo/shared";
10
10
  import { parseCookie, stringifySetCookie } from "cookie";
11
11
 
12
12
  //#region src/context.ts
@@ -75,12 +75,12 @@ var Context = class {
75
75
  return;
76
76
  }
77
77
  if (!isPluginVersionSupported(installed)) this.warn(pluginUpdateMessage(installed));
78
- const plugins = this.config.extensionPlugins;
78
+ const plugins = this.config.integrationPlugins;
79
79
  if (!plugins?.length) return;
80
- const active = parseExtensionVersions(result.headers.get(EXTENSION_VERSIONS_HEADER));
80
+ const active = parseIntegrationVersions(result.headers.get(INTEGRATION_VERSIONS_HEADER));
81
81
  for (const plugin of plugins) {
82
- if (satisfiesVersion(active[plugin.slug], plugin.version)) continue;
83
- this.warn(extensionUpdateMessage(plugin, active[plugin.slug]));
82
+ if (satisfiesVersion(active[plugin.name], plugin.version)) continue;
83
+ this.warn(integrationUpdateMessage(plugin, active[plugin.name]));
84
84
  }
85
85
  }
86
86
  /** Bold yellow, boxed in dashes so it stands out in a busy dev console. */
package/dist/index.d.ts CHANGED
@@ -12,19 +12,20 @@ import { AnyContext, AnyNestedClient, CookiesAdapter, CookiesDeleteAll, CookiesG
12
12
  import { createCookiesAdapter } from "./adapters/cookies.js";
13
13
  import { ConnInfo, GeoAdapter, GeoGetConnInfo, createGeoAdapter, geoMock } from "./adapters/geo.js";
14
14
  import { geoVercelNext } from "./adapters/geo.vercel.js";
15
- import { ConsoleLogAdapterOptions, Environment, LogLevel, LogPayload, Logger, LoggerAdapter, consoleLog, createLoggerAdapter, noopAdapter } from "./adapters/logger.js";
15
+ import { ConsoleLogAdapterOptions, LogLevel, LogPayload, Logger, LoggerAdapter, consoleLog, createLoggerAdapter, noopAdapter } from "./adapters/logger.js";
16
+ import { ServiceAdapters, mergeServiceAdapters } from "./adapters/types.js";
16
17
  import { AuthorsSettings, AuthorsSettingsInput, BrandSettings, BrandSettingsInput, CrawlingSettings, CrawlingSettingsInput, HeadlessSettings, HeadlessSettingsInput, IdentitySettings, IdentitySettingsInput, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, PersonSettings, PersonSettingsInput, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, Settings, SiteSettings, SiteSettingsInput, SocialProfile, TaxonomySettings, TaxonomySettingsInput, UploadsSettings, UploadsSettingsInput, WebhookSettings, WebhookSettingsInput } from "./settings/service.interface.js";
17
18
  import { IconDescriptor, ManifestIcon, ResolvedIcons, resolveIcons } from "./brand/icons.js";
18
19
  import { CookiesStorage } from "./cookie.js";
19
20
  import { SettingsService } from "./settings/service.js";
20
21
  import { AuthUserFn, ConnInfoFn, Context, ContextConfig, ProcedureContext, VerifyCaptchaFn, VerifyPreviewTokenFn } from "./context.js";
21
- import { ROUTER_MAP, RouterMap } from "./router.js";
22
+ import { CORE_PROCEDURES, CoreProcedures } from "./procedures.js";
22
23
  import { AnyEventSchema, AnyEvents, EventHandler, EventHandlerFn, InferEventUnion, WebhookOptions, createEventHandler, createWebhookRouter } from "./webhook/index.js";
23
24
  import { COMMON_ERRORS, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, DefinedErrorMapLike, ErrorDefinition, KizloError, KizloErrorOptions, ThrowableErrorFn, ThrowableErrorMap, WithCommonErrorMap, createThrowableErrorMap, defineErrorMap, isKizloError, toKizloError } from "./shared/error.js";
24
25
  import { AnyMiddleware, ExtractMiddlewareContextOutput, InferMiddlewares, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, createMiddleware } from "./shared/middleware.js";
25
- import { AnyProcedure, AnyProcedureRouter, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureErrors, ProcedureHandler, ProcedureOptions, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, RouterDepthTuple, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType } from "./shared/procedure.js";
26
- import { AnyExtension, Extension, ExtensionInitFn, ExtensionInitOptions, ExtensionInitResult, ExtensionRequirements, ExtractExtensionRouter, InferExtensionRouter, assertExtensionEndpoints, createExtension, missingEndpoints } from "./shared/extension.js";
27
- import { AnyKizloConfig, CreateKizloOptions, EnvReader, Kizlo, KizloConfig, KizloConnect, RootRouter, S2SClient, ServiceAdapters, createKizlo, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
26
+ import { AnyProcedure, AnyProcedureTree, BaseHandlerOptions, ExtractParams, ExtractProcedureByScope, InvocationScope, OpenapiPart, Procedure, ProcedureErrors, ProcedureHandler, ProcedureOptions, ProcedureTreeDepthTuple, ResolveParamsPart, ResolvedSchemaInput, ResolvedSchemaOutput, SchemaIO, buildProcedure, combineDetailed, createProcedure, handleUnexpectedError, schemaType } from "./shared/procedure.js";
27
+ import { AnyIntegration, EnvReader, EnvRecord, EnvSource, ExtractIntegrationProcedures, InferIntegrationProcedures, Integration, IntegrationRequirements, KizloEnv, WordPressEnv, assertIntegrationEndpoints, assertIntegrationEnv, createIntegration, missingEndpoints, missingEnv, readEnv } from "./shared/integration.js";
28
+ import { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
28
29
  import { WEB_MANIFEST_ROUTE, WebManifest, buildWebManifest, createManifestRoute } from "./brand/manifest.js";
29
30
  import "./brand/index.js";
30
31
  import { KizloClient, KizloClientConfig, createKizloClient } from "./client.js";
@@ -37,4 +38,4 @@ import { ShaAlgorithm, compare, hash, hmac } from "./shared/crypto.js";
37
38
  import { Identifier, parseIdentifier } from "./shared/identifier.js";
38
39
  import { createOrpcRouter } from "./shared/router.js";
39
40
  import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
40
- export { ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyExtension, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureRouter, AuthAdapter, AuthGetUser, AuthUser, AuthUserFn, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CaptchaAdapter, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, Environment, ErrorDefinition, EventHandler, EventHandlerFn, Extension, ExtensionInitFn, ExtensionInitOptions, ExtensionInitResult, ExtensionRequirements, ExtractExtensionRouter, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferExtensionRouter, InferMiddlewares, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloConnect, KizloError, KizloErrorOptions, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, PersonSettings, PersonSettingsInput, PluginSource, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureOptions, ROUTER_MAP, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, Robots, RobotsRule, RootRouter, RouterDepthTuple, RouterMap, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointInput, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertExtensionEndpoints, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createExtension, createGeoAdapter, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, missingEndpoints, noopAdapter, parseIdentifier, parseSitemapSlug, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, wpEndpoint, xmlResponse };
41
+ export { ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetUser, AuthUser, AuthUserFn, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CoreProcedures, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, EnvRecord, EnvSource, ErrorDefinition, EventHandler, EventHandlerFn, ExtractIntegrationProcedures, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, PersonSettings, PersonSettingsInput, PluginSource, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointInput, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressEnv, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, wpEndpoint, xmlResponse };
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { createCookiesAdapter } from "./adapters/cookies.js";
5
5
  import { createGeoAdapter, geoMock } from "./adapters/geo.js";
6
6
  import { geoVercelNext } from "./adapters/geo.vercel.js";
7
7
  import { consoleLog, createLoggerAdapter, noopAdapter } from "./adapters/logger.js";
8
+ import { mergeServiceAdapters } from "./adapters/types.js";
8
9
  import { resolveIcons } from "./brand/icons.js";
9
10
  import { WEB_MANIFEST_ROUTE, buildWebManifest, createManifestRoute } from "./brand/manifest.js";
10
11
  import { defineFixture, isLocalPlugin } from "./cli/wp/types.js";
@@ -25,11 +26,11 @@ import { parseIdentifier } from "./shared/identifier.js";
25
26
  import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
26
27
  import { CONTENT_TYPES, ContentType, ListSitemapUrlInput, ListSitemapUrlInputBase, Robots, RobotsRule, Seo, SeoHead, SeoSchema, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList } from "./seo/schema.js";
27
28
  import { deserializeSeo, parseSitemapSlug, renderJsonLd, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
28
- import { ROUTER_MAP } from "./router.js";
29
- import { assertExtensionEndpoints, createExtension, missingEndpoints } from "./shared/extension.js";
29
+ import { CORE_PROCEDURES } from "./procedures.js";
30
+ import { assertIntegrationEndpoints, assertIntegrationEnv, createIntegration, missingEndpoints, missingEnv, readEnv } from "./shared/integration.js";
30
31
  import { createEventHandler, createWebhookRouter } from "./webhook/index.js";
31
- import { Kizlo, createKizlo, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
32
+ import { Kizlo, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection } from "./kizlo.js";
32
33
  import { SITEMAP_BASE, SITEMAP_INDEX_SLUG, createSitemapRedirectRoute, createSitemapRoute } from "./seo/sitemap.js";
33
34
  import { createMiddleware } from "./shared/middleware.js";
34
35
 
35
- export { COMMON_ERRORS, CONTENT_TYPES, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, PreviewTokenData, PreviewTokenPayload, ROUTER_MAP, Robots, RobotsRule, SITEMAP_BASE, SITEMAP_INDEX_SLUG, Seo, SeoHead, SeoSchema, SettingsService, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList, WEB_MANIFEST_ROUTE, WP_Error, WordPressTransport, altcha, arkose, assertExtensionEndpoints, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createExtension, createGeoAdapter, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, missingEndpoints, noopAdapter, parseIdentifier, parseSitemapSlug, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, wpEndpoint, xmlResponse };
36
+ export { COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, ContentType, Context, CookiesStorage, CurrencyFormat, IdentifierInput, Kizlo, KizloClient, KizloError, LIST_ORDER, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, PreviewTokenData, PreviewTokenPayload, Robots, RobotsRule, SITEMAP_BASE, SITEMAP_INDEX_SLUG, Seo, SeoHead, SeoSchema, SettingsService, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList, WEB_MANIFEST_ROUTE, WP_Error, WordPressTransport, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, toKizloError, turnstile, wpEndpoint, xmlResponse };
@@ -0,0 +1,12 @@
1
+ import { EnvSource, Integration } from "../../shared/integration.js";
2
+ import "../../index.js";
3
+
4
+ //#region src/integrations/astro/integration.d.ts
5
+ interface AstroOptions {
6
+ /** Astro's server environment reader, usually `getSecret` from `astro:env/server`. */
7
+ env: EnvSource;
8
+ }
9
+ /** Integrate Kizlo with Astro's server environment. */
10
+ declare function astro(options: AstroOptions): Integration<"astro", Record<never, never>>;
11
+ //#endregion
12
+ export { AstroOptions, astro };
@@ -0,0 +1,14 @@
1
+ import { createIntegration } from "../../shared/integration.js";
2
+ import { runtimeEnv } from "../runtime-env.js";
3
+
4
+ //#region src/integrations/astro/integration.ts
5
+ /** Integrate Kizlo with Astro's server environment. */
6
+ function astro(options) {
7
+ return createIntegration({
8
+ id: "astro",
9
+ env: runtimeEnv(options.env, "PUBLIC_KIZLO_BASE_URL")
10
+ });
11
+ }
12
+
13
+ //#endregion
14
+ export { astro };
@@ -1,15 +1,15 @@
1
- import { AnyProcedureRouter } from "../../shared/procedure.js";
1
+ import { AnyProcedureTree } from "../../shared/procedure.js";
2
2
  import { KizloClient } from "../../client.js";
3
3
 
4
4
  //#region src/integrations/astro/kizlo.client.d.ts
5
5
  interface KizloClientOptions {
6
6
  /**
7
- * Backend URL. In the browser, pass `import.meta.env.PUBLIC_KIZLO_API_URL` at the call site so Vite
7
+ * Backend URL. In the browser, pass `import.meta.env.PUBLIC_KIZLO_BASE_URL` at the call site so Vite
8
8
  * inlines it into the client bundle (see the template's `client.ts`); when omitted it falls back to
9
- * `PUBLIC_KIZLO_API_URL` from `process.env`.
9
+ * `PUBLIC_KIZLO_BASE_URL` from `process.env`.
10
10
  */
11
11
  url?: string;
12
12
  }
13
- declare function createKizloClient<T extends AnyProcedureRouter>(contract: T, options?: KizloClientOptions): KizloClient<T>;
13
+ declare function createKizloClient<T extends AnyProcedureTree>(contract: T, options?: KizloClientOptions): KizloClient<T>;
14
14
  //#endregion
15
15
  export { KizloClientOptions, createKizloClient };
@@ -1,6 +1,6 @@
1
1
  //#region src/integrations/astro/utils.d.ts
2
2
  /**
3
- * Minimal shape of Astro's `APIContext` this integration needs — just the standard web `Request`.
3
+ * Minimal shape of Astro's `APIContext` this integration needs: just the standard web `Request`.
4
4
  * Typed structurally so the package never has to depend on `astro` (which stays an optional peer).
5
5
  */
6
6
  interface AstroRouteContext {
@@ -9,10 +9,9 @@ interface AstroRouteContext {
9
9
  /** An Astro endpoint handler (`export const GET = …`): takes the route context, returns a `Response`. */
10
10
  type AstroRoute = (context: AstroRouteContext) => Promise<Response> | Response;
11
11
  /**
12
- * The public Kizlo API base URL, read from `process.env` as a last-resort fallback for a client built
13
- * without an explicit `url`. The server factory (`createKizlo`) reads env the Astro-native way through
14
- * `astro:env/server`, and client-side code passes `import.meta.env.PUBLIC_KIZLO_API_URL` at the call
15
- * site (see the template's `client.ts`); this fallback only matters if neither is supplied.
12
+ * The public Kizlo API base URL, read from `process.env` as a last-resort fallback when this client
13
+ * factory runs on the server without an explicit `url`. Browser code passes
14
+ * `import.meta.env.PUBLIC_KIZLO_BASE_URL` at the call site so Vite can inline it.
16
15
  */
17
16
  declare function getServerBaseUrl(): string;
18
17
  //#endregion
@@ -2,14 +2,13 @@ import { KizloError } from "../../shared/error.js";
2
2
 
3
3
  //#region src/integrations/astro/utils.ts
4
4
  /**
5
- * The public Kizlo API base URL, read from `process.env` as a last-resort fallback for a client built
6
- * without an explicit `url`. The server factory (`createKizlo`) reads env the Astro-native way through
7
- * `astro:env/server`, and client-side code passes `import.meta.env.PUBLIC_KIZLO_API_URL` at the call
8
- * site (see the template's `client.ts`); this fallback only matters if neither is supplied.
5
+ * The public Kizlo API base URL, read from `process.env` as a last-resort fallback when this client
6
+ * factory runs on the server without an explicit `url`. Browser code passes
7
+ * `import.meta.env.PUBLIC_KIZLO_BASE_URL` at the call site so Vite can inline it.
9
8
  */
10
9
  function getServerBaseUrl() {
11
- const baseUrl = process.env.PUBLIC_KIZLO_API_URL?.trim();
12
- if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define PUBLIC_KIZLO_API_URL in your .env file." });
10
+ const baseUrl = process.env.PUBLIC_KIZLO_BASE_URL?.trim();
11
+ if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define PUBLIC_KIZLO_BASE_URL in your .env file." });
13
12
  return baseUrl;
14
13
  }
15
14
 
@@ -0,0 +1,15 @@
1
+ import { EnvSource, Integration } from "../../shared/integration.js";
2
+ import "../../index.js";
3
+ import { NextRevalidateOptions } from "./revalidate.js";
4
+
5
+ //#region src/integrations/nextjs/integration.d.ts
6
+ interface NextjsOptions {
7
+ /** Environment source. Defaults to `process.env`. */
8
+ env?: EnvSource;
9
+ /** Configure automatic cache revalidation, or disable it with `false`. */
10
+ revalidate?: boolean | NextRevalidateOptions;
11
+ }
12
+ /** Integrate Kizlo with the Next.js server runtime. */
13
+ declare function nextjs(options?: NextjsOptions): Integration<"nextjs", Record<never, never>>;
14
+ //#endregion
15
+ export { NextjsOptions, nextjs };
@@ -0,0 +1,18 @@
1
+ import { createIntegration } from "../../shared/integration.js";
2
+ import { runtimeEnv } from "../runtime-env.js";
3
+ import { nextRevalidation } from "./revalidate.js";
4
+
5
+ //#region src/integrations/nextjs/integration.ts
6
+ /** Integrate Kizlo with the Next.js server runtime. */
7
+ function nextjs(options = {}) {
8
+ const source = options.env ?? process.env;
9
+ const revalidation = options.revalidate;
10
+ return createIntegration({
11
+ id: "nextjs",
12
+ env: runtimeEnv(source, "NEXT_PUBLIC_KIZLO_BASE_URL"),
13
+ events: revalidation === false ? void 0 : nextRevalidation(typeof revalidation === "object" ? revalidation : void 0).events
14
+ });
15
+ }
16
+
17
+ //#endregion
18
+ export { nextjs };
@@ -1,10 +1,10 @@
1
- import { AnyProcedureRouter } from "../../shared/procedure.js";
1
+ import { AnyProcedureTree } from "../../shared/procedure.js";
2
2
  import { KizloClient } from "../../client.js";
3
3
 
4
4
  //#region src/integrations/nextjs/kizlo.client.d.ts
5
5
  interface KizloClientOptions {
6
6
  url?: string;
7
7
  }
8
- declare function createKizloClient<T extends AnyProcedureRouter>(contract: T, options?: KizloClientOptions): KizloClient<T>;
8
+ declare function createKizloClient<T extends AnyProcedureTree>(contract: T, options?: KizloClientOptions): KizloClient<T>;
9
9
  //#endregion
10
10
  export { KizloClientOptions, createKizloClient };
@@ -1,6 +1,5 @@
1
1
  import { KizloEvent } from "../../webhook/schema.js";
2
- import { AnyProcedureRouter } from "../../shared/procedure.js";
3
- import { Extension } from "../../shared/extension.js";
2
+ import { Integration } from "../../shared/integration.js";
4
3
  import "../../index.js";
5
4
  import { Pathname } from "@kizlo/shared";
6
5
 
@@ -26,6 +25,6 @@ interface NextRevalidateOptions {
26
25
  */
27
26
  sitemap?: false | RevalidateTarget | RevalidateTarget[];
28
27
  }
29
- declare function nextRevalidation(options?: NextRevalidateOptions): Extension<"nextjs-revalidation", AnyProcedureRouter>;
28
+ declare function nextRevalidation(options?: NextRevalidateOptions): Integration<"nextjs-revalidation", Record<never, never>>;
30
29
  //#endregion
31
30
  export { NextRevalidateOptions, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, nextRevalidation };
@@ -1,4 +1,4 @@
1
- import { createExtension } from "../../shared/extension.js";
1
+ import { createIntegration } from "../../shared/integration.js";
2
2
  import { POST_EVENT_TYPES, SETTINGS_EVENT_TYPES, TERM_EVENT_TYPES } from "../../webhook/schema.js";
3
3
  import { createEventHandler } from "../../webhook/index.js";
4
4
  import { ROBOTS_CACHE_TAG } from "./robots.js";
@@ -13,9 +13,9 @@ const CONTENT_EVENT_TYPES = new Set([...POST_EVENT_TYPES, ...TERM_EVENT_TYPES]);
13
13
  const NON_FRONTEND_SETTINGS_EVENT_TYPES = new Set(["settings.crawling.updated", "settings.integration.updated"]);
14
14
  const FRONTEND_SETTINGS_EVENT_TYPES = new Set(SETTINGS_EVENT_TYPES.filter((type) => !NON_FRONTEND_SETTINGS_EVENT_TYPES.has(type)));
15
15
  function nextRevalidation(options) {
16
- return createExtension({
16
+ return createIntegration({
17
17
  id: "nextjs-revalidation",
18
- init: () => ({ events: [createEventHandler(async (event) => {
18
+ events: [createEventHandler(async (event) => {
19
19
  if (!event) return;
20
20
  const revalidatePath = options?.revalidatePath ?? (await import("next/cache")).revalidatePath;
21
21
  const revalidateTag = options?.revalidateTag ?? (await import("next/cache")).revalidateTag;
@@ -32,7 +32,7 @@ function nextRevalidation(options) {
32
32
  revalidateTag(SITEMAP_CACHE_TAG, { expire: 0 });
33
33
  for (const target of resolveSitemapTargets(options?.sitemap)) revalidatePath(normalizePath(target.path), target.type);
34
34
  }
35
- })] })
35
+ })]
36
36
  });
37
37
  }
38
38
  function resolveSitemapTargets(option) {
@@ -42,8 +42,8 @@ function createCachedTextRoute(handler, cacheTag, contentType) {
42
42
  };
43
43
  }
44
44
  function getServerBaseUrl() {
45
- const baseUrl = process.env.NEXT_PUBLIC_KIZLO_API_URL;
46
- if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define NEXT_PUBLIC_KIZLO_API_URL in your .env file." });
45
+ const baseUrl = process.env.NEXT_PUBLIC_KIZLO_BASE_URL;
46
+ if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define NEXT_PUBLIC_KIZLO_BASE_URL in your .env file." });
47
47
  return baseUrl;
48
48
  }
49
49
 
@@ -0,0 +1,12 @@
1
+ import { EnvSource, Integration } from "../../shared/integration.js";
2
+ import "../../index.js";
3
+
4
+ //#region src/integrations/node/integration.d.ts
5
+ interface NodeOptions {
6
+ /** Node environment source. Defaults to `process.env`. */
7
+ env?: EnvSource;
8
+ }
9
+ /** Integrate Kizlo with the Node.js runtime environment. */
10
+ declare function node(options?: NodeOptions): Integration<"node", Record<never, never>>;
11
+ //#endregion
12
+ export { NodeOptions, node };
@@ -0,0 +1,14 @@
1
+ import { createIntegration } from "../../shared/integration.js";
2
+ import { runtimeEnv } from "../runtime-env.js";
3
+
4
+ //#region src/integrations/node/integration.ts
5
+ /** Integrate Kizlo with the Node.js runtime environment. */
6
+ function node(options = {}) {
7
+ return createIntegration({
8
+ id: "node",
9
+ env: runtimeEnv(options.env ?? process.env, "KIZLO_BASE_URL")
10
+ });
11
+ }
12
+
13
+ //#endregion
14
+ export { node };
@@ -0,0 +1,25 @@
1
+ import { readEnv } from "../shared/integration.js";
2
+
3
+ //#region src/integrations/runtime-env.ts
4
+ /** Map a runtime's environment names onto the values Kizlo consumes. */
5
+ function runtimeEnv(source, baseUrlKey) {
6
+ return {
7
+ baseUrl: readEnv(source, baseUrlKey),
8
+ mode: readEnv(source, "KIZLO_MODE"),
9
+ remote: {
10
+ siteSecret: readEnv(source, "KIZLO_WP_SECRET"),
11
+ wordpressUrl: readEnv(source, "KIZLO_WP_URL"),
12
+ wordpressUsername: readEnv(source, "KIZLO_WP_USERNAME"),
13
+ wordpressPassword: readEnv(source, "KIZLO_WP_APP_PASSWORD")
14
+ },
15
+ local: {
16
+ siteSecret: readEnv(source, "KIZLO_LOCAL_WP_SECRET"),
17
+ wordpressUrl: readEnv(source, "KIZLO_LOCAL_WP_URL"),
18
+ wordpressUsername: readEnv(source, "KIZLO_LOCAL_WP_USERNAME"),
19
+ wordpressPassword: readEnv(source, "KIZLO_LOCAL_WP_APP_PASSWORD")
20
+ }
21
+ };
22
+ }
23
+
24
+ //#endregion
25
+ export { runtimeEnv };
@@ -1,7 +1,7 @@
1
1
  import { ServerRoute } from "./utils.js";
2
2
 
3
3
  //#region src/integrations/tanstack-start/api.d.ts
4
- /** The Kizlo request handler a server entry exports (`createKizlo().handler`): a web `Request` in, `Response` out. */
4
+ /** The Kizlo request handler a server entry exports (`createKizlo(...).handler`): a web `Request` in, `Response` out. */
5
5
  type KizloHandler = (request: Request) => Promise<Response> | Response;
6
6
  /** Every HTTP method TanStack Start registers per server route, each mapped to the same handler. */
7
7
  type ApiHandlers = Record<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD", ServerRoute>;
@@ -0,0 +1,12 @@
1
+ import { EnvSource, Integration } from "../../shared/integration.js";
2
+ import "../../index.js";
3
+
4
+ //#region src/integrations/tanstack-start/integration.d.ts
5
+ interface TanstackStartOptions {
6
+ /** Environment source. Defaults to `process.env`. */
7
+ env?: EnvSource;
8
+ }
9
+ /** Integrate Kizlo with the TanStack Start server runtime. */
10
+ declare function tanstackStart(options?: TanstackStartOptions): Integration<"tanstack-start", Record<never, never>>;
11
+ //#endregion
12
+ export { TanstackStartOptions, tanstackStart };
@@ -0,0 +1,14 @@
1
+ import { createIntegration } from "../../shared/integration.js";
2
+ import { runtimeEnv } from "../runtime-env.js";
3
+
4
+ //#region src/integrations/tanstack-start/integration.ts
5
+ /** Integrate Kizlo with the TanStack Start server runtime. */
6
+ function tanstackStart(options = {}) {
7
+ return createIntegration({
8
+ id: "tanstack-start",
9
+ env: runtimeEnv(options.env ?? process.env, "VITE_KIZLO_BASE_URL")
10
+ });
11
+ }
12
+
13
+ //#endregion
14
+ export { tanstackStart };
@@ -1,12 +1,12 @@
1
- import { AnyProcedureRouter } from "../../shared/procedure.js";
1
+ import { AnyProcedureTree } from "../../shared/procedure.js";
2
2
  import { KizloClient } from "../../client.js";
3
3
 
4
4
  //#region src/integrations/tanstack-start/kizlo.client.d.ts
5
5
  interface KizloClientOptions {
6
6
  /**
7
- * Backend URL. Pass `import.meta.env.VITE_KIZLO_API_URL` at the call site (see the template's
7
+ * Backend URL. Pass `import.meta.env.VITE_KIZLO_BASE_URL` at the call site (see the template's
8
8
  * `client.ts`) so Vite inlines it into the browser bundle; when omitted it falls back to
9
- * `VITE_KIZLO_API_URL` from `process.env`.
9
+ * `VITE_KIZLO_BASE_URL` from `process.env`.
10
10
  */
11
11
  url?: string;
12
12
  }
@@ -15,6 +15,6 @@ interface KizloClientOptions {
15
15
  * over HTTP, so it runs the same in the browser and during SSR. Server routes and server functions use
16
16
  * the server-to-server client from {@link createKizlo} instead.
17
17
  */
18
- declare function createKizloClient<T extends AnyProcedureRouter>(contract: T, options?: KizloClientOptions): KizloClient<T>;
18
+ declare function createKizloClient<T extends AnyProcedureTree>(contract: T, options?: KizloClientOptions): KizloClient<T>;
19
19
  //#endregion
20
20
  export { KizloClientOptions, createKizloClient };
@@ -11,7 +11,7 @@ interface ServerRouteContext {
11
11
  type ServerRoute = (context: ServerRouteContext) => Promise<Response> | Response;
12
12
  /**
13
13
  * The public Kizlo API base URL, read from `process.env` as a last-resort fallback for a client built
14
- * without an explicit `url`. Client-side code passes `import.meta.env.VITE_KIZLO_API_URL` at the call
14
+ * without an explicit `url`. Client-side code passes `import.meta.env.VITE_KIZLO_BASE_URL` at the call
15
15
  * site (see the template's `client.ts`) so Vite inlines it into the browser bundle; this fallback only
16
16
  * matters when neither is supplied.
17
17
  */
@@ -3,13 +3,13 @@ import { KizloError } from "../../shared/error.js";
3
3
  //#region src/integrations/tanstack-start/utils.ts
4
4
  /**
5
5
  * The public Kizlo API base URL, read from `process.env` as a last-resort fallback for a client built
6
- * without an explicit `url`. Client-side code passes `import.meta.env.VITE_KIZLO_API_URL` at the call
6
+ * without an explicit `url`. Client-side code passes `import.meta.env.VITE_KIZLO_BASE_URL` at the call
7
7
  * site (see the template's `client.ts`) so Vite inlines it into the browser bundle; this fallback only
8
8
  * matters when neither is supplied.
9
9
  */
10
10
  function getServerBaseUrl() {
11
- const baseUrl = process.env.VITE_KIZLO_API_URL?.trim();
12
- if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define VITE_KIZLO_API_URL in your .env file." });
11
+ const baseUrl = process.env.VITE_KIZLO_BASE_URL?.trim();
12
+ if (!baseUrl) throw new KizloError("MISSING_ENV_VARIABLE", { message: "Please define VITE_KIZLO_BASE_URL in your .env file." });
13
13
  return baseUrl;
14
14
  }
15
15