kizlo 0.29.0 → 0.30.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.
- package/dist/adapters/geo.cloudflare.d.ts +1 -1
- package/dist/adapters/geo.cloudflare.js +1 -1
- package/dist/adapters/request-context.d.ts +12 -0
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.js +1 -0
- package/dist/context.d.ts +13 -30
- package/dist/context.js +15 -6
- package/dist/index.d.ts +4 -4
- package/dist/integrations/nextjs/api.d.ts +13 -0
- package/dist/integrations/nextjs/api.js +17 -0
- package/dist/integrations/tanstack-start/react/cloudflare/cache-policy.js +15 -0
- package/dist/integrations/tanstack-start/react/cloudflare/cache.d.ts +34 -0
- package/dist/integrations/tanstack-start/react/cloudflare/cache.js +82 -0
- package/dist/integrations/tanstack-start/react/cookies.js +20 -0
- package/dist/integrations/tanstack-start/react/integration.d.ts +25 -0
- package/dist/integrations/tanstack-start/react/integration.js +18 -0
- package/dist/integrations/tanstack-start/react/middleware.d.ts +9 -0
- package/dist/integrations/tanstack-start/react/middleware.js +32 -0
- package/dist/integrations/tanstack-start/react/request-context.d.ts +8 -0
- package/dist/integrations/tanstack-start/react/request-context.js +24 -0
- package/dist/kizlo.d.ts +2 -1
- package/dist/kizlo.js +24 -16
- package/dist/nextjs/server.d.ts +2 -1
- package/dist/nextjs/server.js +2 -1
- package/dist/package.js +1 -1
- package/dist/post/schema.d.ts +2 -2
- package/dist/procedures.d.ts +10 -10
- package/dist/seo/schema.d.ts +5 -5
- package/dist/tanstack-start/react/cloudflare.d.ts +27 -0
- package/dist/tanstack-start/react/cloudflare.js +33 -0
- package/dist/tanstack-start/react/server.d.ts +14 -0
- package/dist/tanstack-start/react/server.js +13 -0
- package/package.json +16 -20
- package/dist/cloudflare/vinext.d.ts +0 -7
- package/dist/cloudflare/vinext.js +0 -44
- package/dist/cloudflare.d.ts +0 -3
- package/dist/cloudflare.js +0 -4
- package/dist/integrations/cloudflare/integration.d.ts +0 -8
- package/dist/integrations/cloudflare/integration.js +0 -16
- package/dist/integrations/cloudflare/request-context.d.ts +0 -9
- package/dist/integrations/cloudflare/request-context.js +0 -58
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeoAdapter } from "./geo.js";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/geo.cloudflare.d.ts
|
|
4
|
-
/** Read trusted Cloudflare connection headers in Next.js
|
|
4
|
+
/** Read trusted Cloudflare connection headers in Next.js. Only use behind Cloudflare ingress. */
|
|
5
5
|
declare function geoCloudflareNext(): GeoAdapter;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { geoCloudflareNext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cloudflareConnInfo } from "./cloudflare-connection.js";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/geo.cloudflare.ts
|
|
4
|
-
/** Read trusted Cloudflare connection headers in Next.js
|
|
4
|
+
/** Read trusted Cloudflare connection headers in Next.js. Only use behind Cloudflare ingress. */
|
|
5
5
|
function geoCloudflareNext() {
|
|
6
6
|
return { getConnInfo: async (request) => {
|
|
7
7
|
let headers = request?.headers;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/adapters/request-context.d.ts
|
|
2
|
+
/** Request-local values supplied by a runtime integration, never by global core state. */
|
|
3
|
+
interface RequestContextAdapter {
|
|
4
|
+
get(): {
|
|
5
|
+
request: Request;
|
|
6
|
+
values: object;
|
|
7
|
+
} | undefined;
|
|
8
|
+
/** Optional when the framework already owns request scoping. */
|
|
9
|
+
run?(request: Request, values: object | undefined, handle: () => Promise<Response>): Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { RequestContextAdapter };
|
package/dist/adapters/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CaptchaAdapter } from "./captcha.js";
|
|
|
3
3
|
import { CookiesAdapter } from "../shared/types.js";
|
|
4
4
|
import { GeoAdapter } from "./geo.js";
|
|
5
5
|
import { LoggerAdapter } from "./logger.js";
|
|
6
|
+
import { RequestContextAdapter } from "./request-context.js";
|
|
6
7
|
|
|
7
8
|
//#region src/adapters/types.d.ts
|
|
8
9
|
/** The service contracts Kizlo integrations can provide at runtime. */
|
|
@@ -12,6 +13,7 @@ interface ServiceAdapters {
|
|
|
12
13
|
geo?: GeoAdapter;
|
|
13
14
|
logger?: LoggerAdapter;
|
|
14
15
|
cookies?: CookiesAdapter;
|
|
16
|
+
requestContext?: RequestContextAdapter;
|
|
15
17
|
}
|
|
16
18
|
/** Merge adapter contributions in order without letting `undefined` erase an earlier value. */
|
|
17
19
|
declare function mergeServiceAdapters(...contributions: (ServiceAdapters | undefined)[]): ServiceAdapters;
|
package/dist/adapters/types.js
CHANGED
|
@@ -9,6 +9,7 @@ function mergeServiceAdapters(...contributions) {
|
|
|
9
9
|
if (contribution.geo !== void 0) adapters.geo = contribution.geo;
|
|
10
10
|
if (contribution.logger !== void 0) adapters.logger = contribution.logger;
|
|
11
11
|
if (contribution.cookies !== void 0) adapters.cookies = contribution.cookies;
|
|
12
|
+
if (contribution.requestContext !== void 0) adapters.requestContext = contribution.requestContext;
|
|
12
13
|
}
|
|
13
14
|
return adapters;
|
|
14
15
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ActiveWordPressClient, WordPressCredentials } from "./wordpress/types.js";
|
|
2
|
-
import { WordPressTransport } from "./wordpress/transport.js";
|
|
3
2
|
import "./wordpress/index.js";
|
|
4
3
|
import { AuthUser } from "./adapters/auth.js";
|
|
5
4
|
import { PreviewTokenPayload } from "./shared/schema.js";
|
|
@@ -31,8 +30,8 @@ type VerifyPreviewTokenFn = (token: string) => Promise<PreviewTokenPayload | nul
|
|
|
31
30
|
* the server builds. A procedure's handler receives this base plus whatever its middleware injected
|
|
32
31
|
* via `next({ context })`.
|
|
33
32
|
*/
|
|
34
|
-
interface
|
|
35
|
-
/** The
|
|
33
|
+
interface BuiltinProcedureContext {
|
|
34
|
+
/** The active HTTP `Request`, or `null` outside a request scope. */
|
|
36
35
|
request: Request | null;
|
|
37
36
|
/** Response headers to be sent (e.g. `Set-Cookie`), or `null` server-side. */
|
|
38
37
|
headers: Headers | null;
|
|
@@ -59,6 +58,10 @@ interface ProcedureContext {
|
|
|
59
58
|
/** How the procedure was called: `"client"` (over HTTP) or `"server"` (direct server invocation). */
|
|
60
59
|
invokedBy: "client" | "server";
|
|
61
60
|
}
|
|
61
|
+
/** Augment in the application to add typed, server-supplied request fields. */
|
|
62
|
+
interface ProcedureContext extends BuiltinProcedureContext {}
|
|
63
|
+
/** The application fields accepted by handler(request, values), excluding Kizlo-owned fields. */
|
|
64
|
+
type PlatformRequestCtx = Omit<ProcedureContext, keyof BuiltinProcedureContext> & object;
|
|
62
65
|
declare class Context {
|
|
63
66
|
private readonly config;
|
|
64
67
|
private readonly logger;
|
|
@@ -77,35 +80,15 @@ declare class Context {
|
|
|
77
80
|
private warnIfOutdated;
|
|
78
81
|
/** Bold yellow, boxed in dashes so it stands out in a busy dev console. */
|
|
79
82
|
private warn;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
verifyCaptcha: VerifyCaptchaFn;
|
|
83
|
-
getSession: SessionFn;
|
|
84
|
-
verifyPreviewToken: VerifyPreviewTokenFn;
|
|
85
|
-
cookies: CookiesStorage;
|
|
86
|
-
invokedBy: "client";
|
|
87
|
-
wordpress: WordPressTransport;
|
|
88
|
-
settings: SettingsService;
|
|
89
|
-
email: EmailService;
|
|
90
|
-
headers: Headers;
|
|
83
|
+
withRequestContext(request: Request, values: PlatformRequestCtx | undefined, handle: () => Promise<Response>): Promise<Response>;
|
|
84
|
+
createRestContext(request: Request, values?: PlatformRequestCtx): ProcedureContext & {
|
|
91
85
|
request: Request;
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
headers: Headers;
|
|
87
|
+
invokedBy: "client";
|
|
94
88
|
};
|
|
95
|
-
createServerContext(): {
|
|
96
|
-
getSession: SessionFn;
|
|
97
|
-
getConnInfo: ConnInfoFn;
|
|
98
|
-
verifyCaptcha: VerifyCaptchaFn;
|
|
99
|
-
verifyPreviewToken: VerifyPreviewTokenFn;
|
|
100
|
-
invokedBy: "server";
|
|
101
|
-
wordpress: WordPressTransport;
|
|
102
|
-
settings: SettingsService;
|
|
103
|
-
email: EmailService;
|
|
104
|
-
cookies: CookiesStorage;
|
|
89
|
+
createServerContext(): ProcedureContext & {
|
|
105
90
|
headers: null;
|
|
106
|
-
|
|
107
|
-
config: ContextConfig;
|
|
108
|
-
logger: Logger;
|
|
91
|
+
invokedBy: "server";
|
|
109
92
|
};
|
|
110
93
|
private createRestCookieStorage;
|
|
111
94
|
private createVerifyCaptchaFn;
|
|
@@ -115,4 +98,4 @@ declare class Context {
|
|
|
115
98
|
private createLogger;
|
|
116
99
|
}
|
|
117
100
|
//#endregion
|
|
118
|
-
export { ConnInfoFn, Context, ContextConfig, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn };
|
|
101
|
+
export { ConnInfoFn, Context, ContextConfig, PlatformRequestCtx, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn };
|
package/dist/context.js
CHANGED
|
@@ -102,9 +102,15 @@ var Context = class {
|
|
|
102
102
|
const border = "-".repeat(inner.length + 2);
|
|
103
103
|
console.warn(`\n\x1b[1m\x1b[33m${border}\n|${inner}|\n${border}\x1b[0m\n`);
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
withRequestContext(request, values, handle) {
|
|
106
|
+
if (values !== void 0 && (values === null || typeof values !== "object" || Array.isArray(values))) throw new TypeError("Request context must be an object.");
|
|
107
|
+
return this.config.adapters?.requestContext?.run?.(request, values, handle) ?? handle();
|
|
108
|
+
}
|
|
109
|
+
createRestContext(request, values) {
|
|
106
110
|
const headers = new Headers();
|
|
107
111
|
return {
|
|
112
|
+
...this.config.adapters?.requestContext?.get()?.values,
|
|
113
|
+
...values,
|
|
108
114
|
headers,
|
|
109
115
|
request: request.clone(),
|
|
110
116
|
config: this.config,
|
|
@@ -123,21 +129,24 @@ var Context = class {
|
|
|
123
129
|
};
|
|
124
130
|
}
|
|
125
131
|
createServerContext() {
|
|
132
|
+
const scope = this.config.adapters?.requestContext?.get();
|
|
133
|
+
const request = scope?.request ?? null;
|
|
126
134
|
const cookies = new CookiesStorage(this.config.adapters?.cookies);
|
|
127
135
|
return {
|
|
136
|
+
...scope?.values,
|
|
128
137
|
cookies,
|
|
129
138
|
headers: null,
|
|
130
|
-
request
|
|
139
|
+
request,
|
|
131
140
|
config: this.config,
|
|
132
141
|
logger: this.logger,
|
|
133
|
-
...this.config.adapters?.geo ? this.createServices(
|
|
142
|
+
...this.config.adapters?.geo ? this.createServices(request) : {
|
|
134
143
|
wordpress: this.wordpress,
|
|
135
144
|
settings: this.settings,
|
|
136
145
|
email: this.email
|
|
137
146
|
},
|
|
138
|
-
getSession: this.createGetSessionFn(
|
|
139
|
-
getConnInfo: this.createConnInfoFn(
|
|
140
|
-
verifyCaptcha: this.createVerifyCaptchaFn(
|
|
147
|
+
getSession: this.createGetSessionFn(request, cookies),
|
|
148
|
+
getConnInfo: this.createConnInfoFn(request),
|
|
149
|
+
verifyCaptcha: this.createVerifyCaptchaFn(request),
|
|
141
150
|
verifyPreviewToken: this.createVerifyPreviewTokenFn(),
|
|
142
151
|
invokedBy: "server"
|
|
143
152
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ import { ConsoleLogAdapterOptions, LogLevel, LogPayload, Logger, LoggerAdapter,
|
|
|
17
17
|
import { ServiceAdapters, mergeServiceAdapters } from "./adapters/types.js";
|
|
18
18
|
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";
|
|
19
19
|
import { IconDescriptor, ManifestIcon, ResolvedIcons, resolveIcons } from "./brand/icons.js";
|
|
20
|
+
import { CookiesStorage } from "./cookie.js";
|
|
21
|
+
import { SettingsService } from "./settings/service.js";
|
|
22
|
+
import { ConnInfoFn, Context, ContextConfig, PlatformRequestCtx, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn } from "./context.js";
|
|
20
23
|
import { Post, PostCustomFields, PostCustomFieldsSchema } from "./post/schema.js";
|
|
21
24
|
import { Page, PageCustomFields, PageCustomFieldsSchema } from "./page/schema.js";
|
|
22
25
|
import { Category, CategoryCustomFields, CategoryCustomFieldsSchema } from "./category/schema.js";
|
|
23
26
|
import { Tag, TagCustomFields, TagCustomFieldsSchema } from "./tag/schema.js";
|
|
24
27
|
import { CORE_PROCEDURES, CoreProcedures } from "./procedures.js";
|
|
25
|
-
import { CookiesStorage } from "./cookie.js";
|
|
26
|
-
import { SettingsService } from "./settings/service.js";
|
|
27
|
-
import { ConnInfoFn, Context, ContextConfig, ProcedureContext, SessionFn, VerifyCaptchaFn, VerifyPreviewTokenFn } from "./context.js";
|
|
28
28
|
import { AnyEventSchema, AnyEvents, EventHandler, EventHandlerFn, InferEventUnion, WebhookOptions, createEventHandler, createWebhookRouter } from "./webhook/index.js";
|
|
29
29
|
import { COMMON_ERRORS, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, DefinedErrorMapLike, ErrorDefinition, KizloError, KizloErrorOptions, ThrowableErrorFn, ThrowableErrorMap, WithCommonErrorMap, createThrowableErrorMap, defineErrorMap, isKizloError, toKizloError } from "./shared/error.js";
|
|
30
30
|
import { AnyMiddleware, ExtractMiddlewareContextOutput, InferMiddlewares, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, createMiddleware } from "./shared/middleware.js";
|
|
@@ -44,4 +44,4 @@ import { ShaAlgorithm, compare, hash, hmac } from "./shared/crypto.js";
|
|
|
44
44
|
import { Identifier, parseIdentifier } from "./shared/identifier.js";
|
|
45
45
|
import { createOrpcRouter } from "./shared/router.js";
|
|
46
46
|
import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
|
|
47
|
-
export { ActiveKizloClient, ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, 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, InferClientData, InferClientError, InferClientInput, InferClientResult, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloBrowserClient, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloProcedureRegistry, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, 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_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Schema, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressSchemaRegistry, 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, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoCloudflareNext, 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, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
|
47
|
+
export { ActiveKizloClient, ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, 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, InferClientData, InferClientError, InferClientInput, InferClientResult, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloBrowserClient, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloProcedureRegistry, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PlatformRequestCtx, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, 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_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Schema, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressSchemaRegistry, 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, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoCloudflareNext, 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, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/integrations/nextjs/api.d.ts
|
|
2
|
+
/** Map framework route methods to Kizlo without passing Next.js params as platform context. */
|
|
3
|
+
declare function toNextJsHandler(handler: (request: Request) => Response | Promise<Response>): {
|
|
4
|
+
GET: (request: Request) => Response | Promise<Response>;
|
|
5
|
+
POST: (request: Request) => Response | Promise<Response>;
|
|
6
|
+
PUT: (request: Request) => Response | Promise<Response>;
|
|
7
|
+
PATCH: (request: Request) => Response | Promise<Response>;
|
|
8
|
+
DELETE: (request: Request) => Response | Promise<Response>;
|
|
9
|
+
OPTIONS: (request: Request) => Response | Promise<Response>;
|
|
10
|
+
HEAD: (request: Request) => Response | Promise<Response>;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { toNextJsHandler };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/integrations/nextjs/api.ts
|
|
2
|
+
/** Map framework route methods to Kizlo without passing Next.js params as platform context. */
|
|
3
|
+
function toNextJsHandler(handler) {
|
|
4
|
+
const route = (request) => handler(request);
|
|
5
|
+
return {
|
|
6
|
+
GET: route,
|
|
7
|
+
POST: route,
|
|
8
|
+
PUT: route,
|
|
9
|
+
PATCH: route,
|
|
10
|
+
DELETE: route,
|
|
11
|
+
OPTIONS: route,
|
|
12
|
+
HEAD: route
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { toNextJsHandler };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/integrations/tanstack-start/react/cloudflare/cache-policy.ts
|
|
2
|
+
const EDGE_HEADERS = [
|
|
3
|
+
"Cloudflare-CDN-Cache-Control",
|
|
4
|
+
"CDN-Cache-Control",
|
|
5
|
+
"Cache-Control"
|
|
6
|
+
];
|
|
7
|
+
function validateTags(tags) {
|
|
8
|
+
if (!Array.isArray(tags)) throw new TypeError("CDN tags must be an array of strings.");
|
|
9
|
+
if (tags.length > 1e3) throw new RangeError("At most 1000 explicit CDN tags are supported per response.");
|
|
10
|
+
for (const tag of tags) if (typeof tag !== "string" || !tag.length || tag.length > 1024 || /[^\x21-\x2b\x2d-\x7e]/.test(tag)) throw new TypeError("CDN tags must contain 1-1024 printable ASCII characters without spaces or commas.");
|
|
11
|
+
return [...new Set(tags)];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { EDGE_HEADERS, validateTags };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Duration } from "@kizlo/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/tanstack-start/react/cloudflare/cache.d.ts
|
|
4
|
+
interface CloudflareCacheResult {
|
|
5
|
+
success: boolean;
|
|
6
|
+
errors?: {
|
|
7
|
+
code: number;
|
|
8
|
+
message: string;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
/** Native Workers Cache control surface, not the separate caches.default API. */
|
|
12
|
+
interface CloudflareCacheBinding {
|
|
13
|
+
invalidate?(options: {
|
|
14
|
+
tags?: string[];
|
|
15
|
+
pathPrefixes?: string[];
|
|
16
|
+
}): Promise<CloudflareCacheResult>;
|
|
17
|
+
}
|
|
18
|
+
interface CdnHeadersOptions {
|
|
19
|
+
/** Freshness in seconds at the edge. Browser reuse requires revalidation. */
|
|
20
|
+
maxAge: Duration;
|
|
21
|
+
staleWhileRevalidate?: Duration;
|
|
22
|
+
/** Defaults to zero so a failing origin cannot keep stale pages indefinitely. */
|
|
23
|
+
staleIfError?: Duration;
|
|
24
|
+
tags?: readonly string[];
|
|
25
|
+
/** Request headers that select separate cached responses. No variance is added automatically. */
|
|
26
|
+
vary?: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
declare function createCdnHeaders(options: CdnHeadersOptions): Record<string, string>;
|
|
29
|
+
/** Mark the native pathname prefix stale, including its query variants and longer paths. */
|
|
30
|
+
declare function revalidateUrl(url: string | URL): Promise<void>;
|
|
31
|
+
/** Mark responses carrying this host-scoped tag stale under their stored cache policy. */
|
|
32
|
+
declare function revalidateTag(tag: string): Promise<void>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CdnHeadersOptions, CloudflareCacheBinding, CloudflareCacheResult, createCdnHeaders, revalidateTag, revalidateUrl };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getStartRequestContext } from "../request-context.js";
|
|
2
|
+
import { EDGE_HEADERS, validateTags } from "./cache-policy.js";
|
|
3
|
+
import { seconds } from "@kizlo/shared";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/tanstack-start/react/cloudflare/cache.ts
|
|
7
|
+
function getCacheContext() {
|
|
8
|
+
const context = getStartRequestContext();
|
|
9
|
+
const cache = (context?.values)?.executionCtx?.cache;
|
|
10
|
+
if (!context || !cache) throw new Error("CDN revalidation requires a TanStack Start request with executionCtx.cache. Use withCloudflare at the Worker entrypoint.");
|
|
11
|
+
return {
|
|
12
|
+
url: new URL(context.request.url),
|
|
13
|
+
cache
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const MAX_TAG_HEADER_BYTES = 16384;
|
|
17
|
+
const digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
18
|
+
const resourceTag = (url, tag) => `kizlo:t:${digest(`${url.host}\0${tag}`)}`;
|
|
19
|
+
function seconds$1(value, name) {
|
|
20
|
+
value = typeof value === "number" ? value : seconds(value);
|
|
21
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name} must be a nonnegative integer number of seconds.`);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function createCdnHeaders(options) {
|
|
25
|
+
const directives = [`public`, `max-age=${seconds$1(options.maxAge, "maxAge")}`];
|
|
26
|
+
if (options.staleWhileRevalidate !== void 0) directives.push(`stale-while-revalidate=${seconds$1(options.staleWhileRevalidate, "staleWhileRevalidate")}`);
|
|
27
|
+
directives.push(`stale-if-error=${seconds$1(options.staleIfError ?? 0, "staleIfError")}`);
|
|
28
|
+
const tags = validateTags(options.tags ?? []).join(",");
|
|
29
|
+
const vary = options.vary ?? [];
|
|
30
|
+
if (!Array.isArray(vary) || vary.some((name) => typeof name !== "string" || !name.length || /[^!#$%&'*+.^_`|~0-9a-z-]/i.test(name))) throw new TypeError("Vary must be an array of HTTP header names.");
|
|
31
|
+
const names = [...new Map(vary.map((name) => [name.toLowerCase(), name])).values()];
|
|
32
|
+
return {
|
|
33
|
+
"Cache-Control": "no-cache",
|
|
34
|
+
"Cloudflare-CDN-Cache-Control": directives.join(", "),
|
|
35
|
+
...tags ? { "Cache-Tag": tags } : {},
|
|
36
|
+
...names.length ? { Vary: names.includes("*") ? "*" : names.join(", ") } : {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Mark the native pathname prefix stale, including its query variants and longer paths. */
|
|
40
|
+
async function revalidateUrl(url) {
|
|
41
|
+
const state = getCacheContext();
|
|
42
|
+
const value = url instanceof URL ? url.href : url;
|
|
43
|
+
if (typeof value !== "string" || !/^(?:\/(?!\/)|https?:\/\/)/i.test(value) || /[\s\p{Cc}\\]/u.test(value)) throw new TypeError("CDN URLs must be absolute pathnames or same-origin HTTP(S) URLs without whitespace or backslashes.");
|
|
44
|
+
const target = new URL(value, state.url);
|
|
45
|
+
if (target.origin !== state.url.origin || target.username || target.password) throw new TypeError("CDN URLs must belong to the current origin and cannot contain credentials.");
|
|
46
|
+
await invalidate(state.cache, { pathPrefixes: [target.pathname] });
|
|
47
|
+
}
|
|
48
|
+
/** Mark responses carrying this host-scoped tag stale under their stored cache policy. */
|
|
49
|
+
async function revalidateTag(tag) {
|
|
50
|
+
const state = getCacheContext();
|
|
51
|
+
validateTags([tag]);
|
|
52
|
+
await invalidate(state.cache, { tags: [resourceTag(state.url, tag)] });
|
|
53
|
+
}
|
|
54
|
+
async function invalidate(cache, targets) {
|
|
55
|
+
if (typeof cache.invalidate !== "function") throw new Error("The Worker runtime does not support cache.invalidate().");
|
|
56
|
+
const result = await cache.invalidate(targets);
|
|
57
|
+
if (result?.success !== true) {
|
|
58
|
+
const detail = result?.errors?.map(({ code, message }) => `${code}: ${message}`).join("; ");
|
|
59
|
+
throw new Error(`Cloudflare CDN revalidation failed${detail ? `: ${detail}` : "."}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Default to no caching and encode only authored resource tags. */
|
|
63
|
+
function applyCloudflareHeaders(request, response) {
|
|
64
|
+
if (response.status === 101) return response;
|
|
65
|
+
const result = new Headers(response.headers);
|
|
66
|
+
if (!EDGE_HEADERS.some((name) => result.has(name))) result.set("Cache-Control", "no-store");
|
|
67
|
+
const authoredTags = result.get("Cache-Tag");
|
|
68
|
+
if (authoredTags !== null) {
|
|
69
|
+
const url = new URL(request.url);
|
|
70
|
+
const tagHeader = validateTags(authoredTags.split(",").map((tag) => tag.trim())).map((tag) => resourceTag(url, tag)).join(",");
|
|
71
|
+
if (tagHeader.length > MAX_TAG_HEADER_BYTES) throw new RangeError("Encoded CDN tags exceed Cloudflare's 16 KB header limit.");
|
|
72
|
+
result.set("Cache-Tag", tagHeader);
|
|
73
|
+
}
|
|
74
|
+
return new Response(response.body, {
|
|
75
|
+
status: response.status,
|
|
76
|
+
statusText: response.statusText,
|
|
77
|
+
headers: result
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { applyCloudflareHeaders, createCdnHeaders, revalidateTag, revalidateUrl };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { deleteCookie, getCookies, setCookie } from "@tanstack/react-start/server";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/tanstack-start/react/cookies.ts
|
|
4
|
+
function startCookies() {
|
|
5
|
+
return {
|
|
6
|
+
getAll: () => Object.entries(getCookies()).flatMap(([name, value]) => value === void 0 ? [] : [{
|
|
7
|
+
name,
|
|
8
|
+
value
|
|
9
|
+
}]),
|
|
10
|
+
setAll: (cookies) => {
|
|
11
|
+
for (const { name, value, options } of cookies) setCookie(name, value, options);
|
|
12
|
+
},
|
|
13
|
+
deleteAll: (cookies) => {
|
|
14
|
+
for (const { name, options } of cookies) deleteCookie(name, options);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { startCookies };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CookiesAdapter } from "../../../shared/types.js";
|
|
2
|
+
import { EventHandler } from "../../../webhook/index.js";
|
|
3
|
+
import { EnvSource, IntegrationRequirements } from "../../../shared/integration.js";
|
|
4
|
+
import "../../../index.js";
|
|
5
|
+
import { TanstackStartOptions } from "../integration.js";
|
|
6
|
+
import { getStartRequestContext } from "./request-context.js";
|
|
7
|
+
|
|
8
|
+
//#region src/integrations/tanstack-start/react/integration.d.ts
|
|
9
|
+
/** Add React Start's native request context and cookies to the shared environment mapping. */
|
|
10
|
+
declare function tanstackStart(options?: TanstackStartOptions): {
|
|
11
|
+
adapters: {
|
|
12
|
+
cookies: CookiesAdapter;
|
|
13
|
+
requestContext: {
|
|
14
|
+
get: typeof getStartRequestContext;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
id: "tanstack-start";
|
|
18
|
+
procedures?: Record<never, never> | undefined;
|
|
19
|
+
events?: EventHandler[];
|
|
20
|
+
env?: EnvSource;
|
|
21
|
+
requires?: IntegrationRequirements;
|
|
22
|
+
order?: number;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { tanstackStart };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tanstackStart } from "../integration.js";
|
|
2
|
+
import { startCookies } from "./cookies.js";
|
|
3
|
+
import { getStartRequestContext } from "./request-context.js";
|
|
4
|
+
|
|
5
|
+
//#region src/integrations/tanstack-start/react/integration.ts
|
|
6
|
+
/** Add React Start's native request context and cookies to the shared environment mapping. */
|
|
7
|
+
function tanstackStart$1(options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
...tanstackStart(options),
|
|
10
|
+
adapters: {
|
|
11
|
+
cookies: startCookies(),
|
|
12
|
+
requestContext: { get: getStartRequestContext }
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { tanstackStart$1 as tanstackStart };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _tanstack_react_start0 from "@tanstack/react-start";
|
|
2
|
+
import { AnyRequestMiddleware } from "@tanstack/react-start";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/tanstack-start/react/middleware.d.ts
|
|
5
|
+
type MiddlewareMatcher = string | readonly string[] | ((request: Request) => boolean);
|
|
6
|
+
/** Wrap native request middleware with a path-to-regexp pattern or synchronous request predicate. */
|
|
7
|
+
declare function matchMiddleware<Middleware extends AnyRequestMiddleware>(middleware: Middleware, matcher: MiddlewareMatcher): Pick<_tanstack_react_start0.RequestMiddlewareAfterServer<{}, readonly [Middleware], undefined>, "~types" | "options">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { MiddlewareMatcher, matchMiddleware };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createPathMatcher } from "@kizlo/shared";
|
|
2
|
+
import { getRequest } from "@tanstack/react-start/server";
|
|
3
|
+
import { createIsomorphicFn, createMiddleware } from "@tanstack/react-start";
|
|
4
|
+
|
|
5
|
+
//#region src/integrations/tanstack-start/react/middleware.ts
|
|
6
|
+
const currentRequest = createIsomorphicFn().client(() => void 0).server(() => getRequest());
|
|
7
|
+
/** Wrap native request middleware with a path-to-regexp pattern or synchronous request predicate. */
|
|
8
|
+
function matchMiddleware(middleware, matcher) {
|
|
9
|
+
const patterns = typeof matcher === "function" ? [] : typeof matcher === "string" ? [matcher] : matcher;
|
|
10
|
+
if (patterns.some((pattern) => !pattern.startsWith("/"))) throw new TypeError("Middleware patterns must start with /.");
|
|
11
|
+
const [first, ...rest] = patterns;
|
|
12
|
+
const matches = typeof matcher === "function" ? matcher : first === void 0 ? () => false : createPathMatcher([first, ...rest]);
|
|
13
|
+
const wrapped = createMiddleware().middleware([middleware]).server(({ next }) => next());
|
|
14
|
+
const options = wrapped.options;
|
|
15
|
+
const skipped = { server: options.server };
|
|
16
|
+
const decisions = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
Object.defineProperty(wrapped, "options", { get() {
|
|
18
|
+
const request = currentRequest();
|
|
19
|
+
if (!request) return {};
|
|
20
|
+
let selected = decisions.get(request);
|
|
21
|
+
if (selected === void 0) {
|
|
22
|
+
selected = matches(request);
|
|
23
|
+
if (typeof selected !== "boolean") throw new TypeError("Middleware predicates must return a boolean synchronously.");
|
|
24
|
+
decisions.set(request, selected);
|
|
25
|
+
}
|
|
26
|
+
return selected ? options : skipped;
|
|
27
|
+
} });
|
|
28
|
+
return wrapped;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { matchMiddleware };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/integrations/tanstack-start/react/request-context.d.ts
|
|
2
|
+
/** Read Start's native request scope; no application-owned async storage is needed. */
|
|
3
|
+
declare function getStartRequestContext(): {
|
|
4
|
+
request: Request;
|
|
5
|
+
values: object;
|
|
6
|
+
} | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { getStartRequestContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getRequest } from "@tanstack/react-start/server";
|
|
2
|
+
import { getGlobalStartContext } from "@tanstack/react-start";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/tanstack-start/react/request-context.ts
|
|
5
|
+
/** Read Start's native request scope; no application-owned async storage is needed. */
|
|
6
|
+
function getStartRequestContext() {
|
|
7
|
+
let request;
|
|
8
|
+
try {
|
|
9
|
+
request = getRequest();
|
|
10
|
+
} catch {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let values = {};
|
|
14
|
+
try {
|
|
15
|
+
values = getGlobalStartContext() ?? {};
|
|
16
|
+
} catch {}
|
|
17
|
+
return {
|
|
18
|
+
request,
|
|
19
|
+
values
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getStartRequestContext };
|
package/dist/kizlo.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ActiveWordPressClient, WordPressCredentials } from "./wordpress/types.js";
|
|
2
2
|
import "./wordpress/index.js";
|
|
3
3
|
import { LogLevel } from "./adapters/logger.js";
|
|
4
|
+
import { PlatformRequestCtx } from "./context.js";
|
|
4
5
|
import { CoreProcedures } from "./procedures.js";
|
|
5
6
|
import { AnyIntegration, EnvReader, InferIntegrationProcedures } from "./shared/integration.js";
|
|
6
7
|
import { ResultClient } from "./shared/result.js";
|
|
@@ -26,7 +27,7 @@ declare class Kizlo<TIntegrations extends readonly AnyIntegration[] = []> {
|
|
|
26
27
|
private readonly config;
|
|
27
28
|
constructor(config: KizloConfig<TIntegrations>);
|
|
28
29
|
get wordpress(): ActiveWordPressClient;
|
|
29
|
-
handler(request: Request): Promise<Response>;
|
|
30
|
+
handler(request: Request, values?: PlatformRequestCtx): Promise<Response>;
|
|
30
31
|
private errorInterceptor;
|
|
31
32
|
private checkInvocationScope;
|
|
32
33
|
private registerIntegrations;
|
package/dist/kizlo.js
CHANGED
|
@@ -61,23 +61,31 @@ var Kizlo = class {
|
|
|
61
61
|
get wordpress() {
|
|
62
62
|
return this.context.createServerContext().wordpress;
|
|
63
63
|
}
|
|
64
|
-
async handler(request) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
async handler(request, values) {
|
|
65
|
+
return this.context.withRequestContext(request, values, async () => {
|
|
66
|
+
const serverUrl = new URL(this.config.baseUrl);
|
|
67
|
+
const context = this.context.createRestContext(request, values);
|
|
68
|
+
const result = !(request.headers.get(RPC_PROTOCOL_HEADER) !== null) ? await this.openapiHandler.handle(request, {
|
|
69
|
+
context,
|
|
70
|
+
prefix: serverUrl.pathname
|
|
71
|
+
}) : await this.remoteHandler.handle(request, {
|
|
72
|
+
context,
|
|
73
|
+
prefix: serverUrl.pathname
|
|
74
|
+
});
|
|
75
|
+
const response = result.matched ? result.response : new Response("Not Found", { status: 404 });
|
|
76
|
+
for (const [key, value] of context.headers.entries()) {
|
|
77
|
+
if (key.toLowerCase() === "set-cookie") continue;
|
|
78
|
+
response.headers.set(key, value);
|
|
79
|
+
}
|
|
80
|
+
for (const cookie of context.headers.getSetCookie()) response.headers.append("Set-Cookie", cookie);
|
|
81
|
+
response.headers.set("Cache-Control", "private, no-store");
|
|
82
|
+
for (const name of [
|
|
83
|
+
"Cloudflare-CDN-Cache-Control",
|
|
84
|
+
"CDN-Cache-Control",
|
|
85
|
+
"Cache-Tag"
|
|
86
|
+
]) response.headers.delete(name);
|
|
87
|
+
return response;
|
|
73
88
|
});
|
|
74
|
-
if (!result.matched) return new Response("Not Found", { status: 404 });
|
|
75
|
-
for (const [key, value] of context.headers.entries()) {
|
|
76
|
-
if (key.toLowerCase() === "set-cookie") continue;
|
|
77
|
-
result.response.headers.set(key, value);
|
|
78
|
-
}
|
|
79
|
-
for (const cookie of context.headers.getSetCookie()) result.response.headers.append("Set-Cookie", cookie);
|
|
80
|
-
return result.response;
|
|
81
89
|
}
|
|
82
90
|
errorInterceptor() {
|
|
83
91
|
return async ({ context, next }) => {
|
package/dist/nextjs/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WEB_MANIFEST_ROUTE } from "../brand/manifest.js";
|
|
2
2
|
import { renderJsonLd } from "../seo/utils.js";
|
|
3
3
|
import { createSitemapRedirectRoute } from "../seo/sitemap.js";
|
|
4
|
+
import { toNextJsHandler } from "../integrations/nextjs/api.js";
|
|
4
5
|
import { NextRevalidateOptions, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
5
6
|
import { NextjsOptions, nextjs } from "../integrations/nextjs/integration.js";
|
|
6
7
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
@@ -8,4 +9,4 @@ import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootV
|
|
|
8
9
|
import { ROBOTS_CACHE_TAG, createRobotsRoute } from "../integrations/nextjs/robots.js";
|
|
9
10
|
import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integrations/nextjs/sitemap.js";
|
|
10
11
|
import { createCachedTextRoute, createNextCookiesInterface, getServerBaseUrl } from "../integrations/nextjs/utils.js";
|
|
11
|
-
export { MANIFEST_CACHE_TAG, NextRevalidateOptions, NextjsOptions, ROBOTS_CACHE_TAG, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd };
|
|
12
|
+
export { MANIFEST_CACHE_TAG, NextRevalidateOptions, NextjsOptions, ROBOTS_CACHE_TAG, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd, toNextJsHandler };
|
package/dist/nextjs/server.js
CHANGED
|
@@ -2,6 +2,7 @@ import { WEB_MANIFEST_ROUTE } from "../brand/manifest.js";
|
|
|
2
2
|
import { renderJsonLd } from "../seo/utils.js";
|
|
3
3
|
import { createSitemapRedirectRoute } from "../seo/sitemap.js";
|
|
4
4
|
import { createCachedTextRoute, createNextCookiesInterface, getServerBaseUrl } from "../integrations/nextjs/utils.js";
|
|
5
|
+
import { toNextJsHandler } from "../integrations/nextjs/api.js";
|
|
5
6
|
import { ROBOTS_CACHE_TAG, createRobotsRoute } from "../integrations/nextjs/robots.js";
|
|
6
7
|
import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integrations/nextjs/sitemap.js";
|
|
7
8
|
import { nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
@@ -9,4 +10,4 @@ import { nextjs } from "../integrations/nextjs/integration.js";
|
|
|
9
10
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
10
11
|
import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
11
12
|
|
|
12
|
-
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd };
|
|
13
|
+
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, nextjs, renderJsonLd, toNextJsHandler };
|
package/dist/package.js
CHANGED
package/dist/post/schema.d.ts
CHANGED
|
@@ -26,13 +26,13 @@ declare const Post: z.ZodObject<{
|
|
|
26
26
|
private: "private";
|
|
27
27
|
}>;
|
|
28
28
|
format: z.ZodEnum<{
|
|
29
|
-
image: "image";
|
|
30
29
|
link: "link";
|
|
31
30
|
status: "status";
|
|
32
31
|
standard: "standard";
|
|
33
32
|
aside: "aside";
|
|
34
33
|
chat: "chat";
|
|
35
34
|
gallery: "gallery";
|
|
35
|
+
image: "image";
|
|
36
36
|
quote: "quote";
|
|
37
37
|
video: "video";
|
|
38
38
|
audio: "audio";
|
|
@@ -150,13 +150,13 @@ declare const PostList: z.ZodObject<{
|
|
|
150
150
|
private: "private";
|
|
151
151
|
}>;
|
|
152
152
|
format: z.ZodEnum<{
|
|
153
|
-
image: "image";
|
|
154
153
|
link: "link";
|
|
155
154
|
status: "status";
|
|
156
155
|
standard: "standard";
|
|
157
156
|
aside: "aside";
|
|
158
157
|
chat: "chat";
|
|
159
158
|
gallery: "gallery";
|
|
159
|
+
image: "image";
|
|
160
160
|
quote: "quote";
|
|
161
161
|
video: "video";
|
|
162
162
|
audio: "audio";
|
package/dist/procedures.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ declare const CORE_PROCEDURES: {
|
|
|
44
44
|
include?: string | number | (string | number)[] | undefined;
|
|
45
45
|
offset?: string | number | undefined;
|
|
46
46
|
order?: "asc" | "desc" | undefined;
|
|
47
|
-
orderby?: "id" | "slug" | "parent" | "title" | "author" | "
|
|
47
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
|
|
48
48
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
49
49
|
slug?: string | string[] | undefined;
|
|
50
50
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -99,7 +99,7 @@ declare const CORE_PROCEDURES: {
|
|
|
99
99
|
include?: string | number | (string | number)[] | undefined;
|
|
100
100
|
offset?: string | number | undefined;
|
|
101
101
|
order?: "asc" | "desc" | undefined;
|
|
102
|
-
orderby?: "id" | "slug" | "parent" | "title" | "author" | "
|
|
102
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
103
103
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
104
104
|
slug?: string | string[] | undefined;
|
|
105
105
|
parent?: string | number | (string | number)[] | undefined;
|
|
@@ -136,7 +136,7 @@ declare const CORE_PROCEDURES: {
|
|
|
136
136
|
exclude?: string | number | (string | number)[] | undefined;
|
|
137
137
|
include?: string | number | (string | number)[] | undefined;
|
|
138
138
|
order?: "asc" | "desc" | undefined;
|
|
139
|
-
orderBy?: "
|
|
139
|
+
orderBy?: "description" | "count" | "id" | "slug" | "name" | "include" | "include_slugs" | "term_group" | undefined;
|
|
140
140
|
hideEmpty?: string | boolean | undefined;
|
|
141
141
|
parent?: string | number | undefined;
|
|
142
142
|
post?: string | number | undefined;
|
|
@@ -172,7 +172,7 @@ declare const CORE_PROCEDURES: {
|
|
|
172
172
|
exclude?: string | number | (string | number)[] | undefined;
|
|
173
173
|
include?: string | number | (string | number)[] | undefined;
|
|
174
174
|
order?: "asc" | "desc" | undefined;
|
|
175
|
-
orderBy?: "
|
|
175
|
+
orderBy?: "description" | "count" | "id" | "slug" | "name" | "include" | "include_slugs" | "term_group" | undefined;
|
|
176
176
|
hideEmpty?: string | boolean | undefined;
|
|
177
177
|
post?: string | number | undefined;
|
|
178
178
|
slug?: string | string[] | undefined;
|
|
@@ -241,7 +241,7 @@ declare const CORE_PROCEDURES: {
|
|
|
241
241
|
sitemaps: {
|
|
242
242
|
list: Procedure<"internal", {}, {
|
|
243
243
|
key: string;
|
|
244
|
-
type: "
|
|
244
|
+
type: "post_type" | "taxonomy" | "author";
|
|
245
245
|
pages: number;
|
|
246
246
|
lastmod: string;
|
|
247
247
|
}[], DefinedErrorMapLike>;
|
|
@@ -249,7 +249,7 @@ declare const CORE_PROCEDURES: {
|
|
|
249
249
|
origin: string;
|
|
250
250
|
sitemaps: {
|
|
251
251
|
key: string;
|
|
252
|
-
type: "
|
|
252
|
+
type: "post_type" | "taxonomy" | "author";
|
|
253
253
|
pages: number;
|
|
254
254
|
lastmod: string;
|
|
255
255
|
}[];
|
|
@@ -292,7 +292,7 @@ declare const CORE_PROCEDURES: {
|
|
|
292
292
|
include?: string | number | (string | number)[] | undefined;
|
|
293
293
|
offset?: string | number | undefined;
|
|
294
294
|
order?: "asc" | "desc" | undefined;
|
|
295
|
-
orderby?: "id" | "slug" | "parent" | "title" | "author" | "
|
|
295
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
296
296
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
297
297
|
slug?: string | string[] | undefined;
|
|
298
298
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -371,7 +371,7 @@ declare const CORE_PROCEDURES: {
|
|
|
371
371
|
include?: string | number | (string | number)[] | undefined;
|
|
372
372
|
offset?: string | number | undefined;
|
|
373
373
|
order?: "asc" | "desc" | undefined;
|
|
374
|
-
orderby?: "id" | "slug" | "parent" | "title" | "author" | "
|
|
374
|
+
orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
375
375
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
376
376
|
slug?: string | string[] | undefined;
|
|
377
377
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -507,7 +507,7 @@ declare const CORE_PROCEDURES: {
|
|
|
507
507
|
include?: string | number | (string | number)[] | undefined;
|
|
508
508
|
offset?: string | number | undefined;
|
|
509
509
|
order?: "asc" | "desc" | undefined;
|
|
510
|
-
orderby?: "
|
|
510
|
+
orderby?: "date" | "id" | "parent" | "include" | "post" | undefined;
|
|
511
511
|
parent?: string | number | (string | number)[] | undefined;
|
|
512
512
|
parentExclude?: string | number | (string | number)[] | undefined;
|
|
513
513
|
post?: string | number | (string | number)[] | undefined;
|
|
@@ -635,8 +635,8 @@ declare const CORE_PROCEDURES: {
|
|
|
635
635
|
get: Procedure<"internal", {}, _kizlo_shared11.Settings, DefinedErrorMapLike>;
|
|
636
636
|
site: {
|
|
637
637
|
update: Procedure<"internal", {
|
|
638
|
-
name?: string | null | undefined;
|
|
639
638
|
url?: string | null | undefined;
|
|
639
|
+
name?: string | null | undefined;
|
|
640
640
|
backend_url?: string | null | undefined;
|
|
641
641
|
secret?: string | null | undefined;
|
|
642
642
|
alternate_name?: string | null | undefined;
|
package/dist/seo/schema.d.ts
CHANGED
|
@@ -108,17 +108,17 @@ declare const Seo: z.ZodObject<{
|
|
|
108
108
|
type Seo = z.infer<typeof Seo>;
|
|
109
109
|
declare const CONTENT_TYPES: readonly ["post_type", "taxonomy", "author"];
|
|
110
110
|
declare const ContentType: z.ZodEnum<{
|
|
111
|
-
author: "author";
|
|
112
111
|
post_type: "post_type";
|
|
113
112
|
taxonomy: "taxonomy";
|
|
113
|
+
author: "author";
|
|
114
114
|
}>;
|
|
115
115
|
type ContentType = z.infer<typeof ContentType>;
|
|
116
116
|
declare const Sitemap: z.ZodObject<{
|
|
117
117
|
key: z.ZodString;
|
|
118
118
|
type: z.ZodEnum<{
|
|
119
|
-
author: "author";
|
|
120
119
|
post_type: "post_type";
|
|
121
120
|
taxonomy: "taxonomy";
|
|
121
|
+
author: "author";
|
|
122
122
|
}>;
|
|
123
123
|
pages: z.ZodNumber;
|
|
124
124
|
lastmod: z.ZodString;
|
|
@@ -127,9 +127,9 @@ type Sitemap = z.infer<typeof Sitemap>;
|
|
|
127
127
|
declare const SitemapList: z.ZodArray<z.ZodObject<{
|
|
128
128
|
key: z.ZodString;
|
|
129
129
|
type: z.ZodEnum<{
|
|
130
|
-
author: "author";
|
|
131
130
|
post_type: "post_type";
|
|
132
131
|
taxonomy: "taxonomy";
|
|
132
|
+
author: "author";
|
|
133
133
|
}>;
|
|
134
134
|
pages: z.ZodNumber;
|
|
135
135
|
lastmod: z.ZodString;
|
|
@@ -140,9 +140,9 @@ declare const SitemapIndex: z.ZodObject<{
|
|
|
140
140
|
sitemaps: z.ZodArray<z.ZodObject<{
|
|
141
141
|
key: z.ZodString;
|
|
142
142
|
type: z.ZodEnum<{
|
|
143
|
-
author: "author";
|
|
144
143
|
post_type: "post_type";
|
|
145
144
|
taxonomy: "taxonomy";
|
|
145
|
+
author: "author";
|
|
146
146
|
}>;
|
|
147
147
|
pages: z.ZodNumber;
|
|
148
148
|
lastmod: z.ZodString;
|
|
@@ -174,9 +174,9 @@ declare const SitemapUrlList: z.ZodArray<z.ZodObject<{
|
|
|
174
174
|
type SitemapUrlList = z.infer<typeof SitemapUrlList>;
|
|
175
175
|
declare const ListSitemapUrlInputBase: z.ZodObject<{
|
|
176
176
|
type: z.ZodEnum<{
|
|
177
|
-
author: "author";
|
|
178
177
|
post_type: "post_type";
|
|
179
178
|
taxonomy: "taxonomy";
|
|
179
|
+
author: "author";
|
|
180
180
|
}>;
|
|
181
181
|
page: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
|
|
182
182
|
}, z.core.$strip>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GeoAdapter } from "../../adapters/geo.js";
|
|
2
|
+
import { Integration } from "../../shared/integration.js";
|
|
3
|
+
import "../../index.js";
|
|
4
|
+
import { CdnHeadersOptions, CloudflareCacheBinding, CloudflareCacheResult, createCdnHeaders, revalidateTag, revalidateUrl } from "../../integrations/tanstack-start/react/cloudflare/cache.js";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/tanstack-start/react/cloudflare.d.ts
|
|
7
|
+
interface ExecutionContext {
|
|
8
|
+
cache?: CloudflareCacheBinding;
|
|
9
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
10
|
+
}
|
|
11
|
+
/** Cloudflare connection metadata, using TanStack Start's existing request scope. */
|
|
12
|
+
declare function geoCloudflare(): GeoAdapter;
|
|
13
|
+
/** Add Cloudflare connection metadata; caching remains an explicit response policy. */
|
|
14
|
+
declare function cloudflare(): Integration<"cloudflare", Record<never, never>>;
|
|
15
|
+
/** Forward native Worker values to Start, default to no caching and encode explicit cache tags. */
|
|
16
|
+
declare function withCloudflare<Env, Context extends ExecutionContext = ExecutionContext>(handler: {
|
|
17
|
+
fetch(request: Request, options: {
|
|
18
|
+
context: {
|
|
19
|
+
env: Env;
|
|
20
|
+
executionCtx: Context;
|
|
21
|
+
};
|
|
22
|
+
}): Response | Promise<Response>;
|
|
23
|
+
}): {
|
|
24
|
+
fetch(request: Request, env: Env, executionCtx: Context): Promise<Response>;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type CdnHeadersOptions, type CloudflareCacheBinding, type CloudflareCacheResult, cloudflare, createCdnHeaders, geoCloudflare, revalidateTag, revalidateUrl, withCloudflare };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cloudflareConnInfo } from "../../adapters/cloudflare-connection.js";
|
|
2
|
+
import { FRAMEWORK_INTEGRATION_ORDER } from "../../shared/constants.js";
|
|
3
|
+
import { createIntegration } from "../../shared/integration.js";
|
|
4
|
+
import { getStartRequestContext } from "../../integrations/tanstack-start/react/request-context.js";
|
|
5
|
+
import { applyCloudflareHeaders, createCdnHeaders, revalidateTag, revalidateUrl } from "../../integrations/tanstack-start/react/cloudflare/cache.js";
|
|
6
|
+
|
|
7
|
+
//#region src/integrations/tanstack-start/react/cloudflare.ts
|
|
8
|
+
/** Cloudflare connection metadata, using TanStack Start's existing request scope. */
|
|
9
|
+
function geoCloudflare() {
|
|
10
|
+
return { getConnInfo(request) {
|
|
11
|
+
return cloudflareConnInfo((request ?? getStartRequestContext()?.request)?.headers);
|
|
12
|
+
} };
|
|
13
|
+
}
|
|
14
|
+
/** Add Cloudflare connection metadata; caching remains an explicit response policy. */
|
|
15
|
+
function cloudflare() {
|
|
16
|
+
return createIntegration({
|
|
17
|
+
id: "cloudflare",
|
|
18
|
+
order: FRAMEWORK_INTEGRATION_ORDER,
|
|
19
|
+
adapters: { geo: geoCloudflare() }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Forward native Worker values to Start, default to no caching and encode explicit cache tags. */
|
|
23
|
+
function withCloudflare(handler) {
|
|
24
|
+
return { async fetch(request, env, executionCtx) {
|
|
25
|
+
return applyCloudflareHeaders(request, await handler.fetch(request, { context: {
|
|
26
|
+
env,
|
|
27
|
+
executionCtx
|
|
28
|
+
} }));
|
|
29
|
+
} };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { cloudflare, createCdnHeaders, geoCloudflare, revalidateTag, revalidateUrl, withCloudflare };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WEB_MANIFEST_ROUTE } from "../../brand/manifest.js";
|
|
2
|
+
import { renderJsonLd } from "../../seo/utils.js";
|
|
3
|
+
import { LinkDescriptor, MetaDescriptor, RouteHead, ScriptDescriptor, resolvePageHead } from "../../integrations/tanstack-start/metadata.js";
|
|
4
|
+
import { ServerRoute, ServerRouteContext, getServerBaseUrl } from "../../integrations/tanstack-start/utils.js";
|
|
5
|
+
import { ApiHandlers, KizloHandler, createApiHandlers } from "../../integrations/tanstack-start/api.js";
|
|
6
|
+
import { TanstackStartOptions } from "../../integrations/tanstack-start/integration.js";
|
|
7
|
+
import { createManifestRoute } from "../../integrations/tanstack-start/manifest.js";
|
|
8
|
+
import { createRobotsRoute } from "../../integrations/tanstack-start/robots.js";
|
|
9
|
+
import { resolveRootHead } from "../../integrations/tanstack-start/root-head.js";
|
|
10
|
+
import { createSitemapRedirectRoute, createSitemapRoute } from "../../integrations/tanstack-start/sitemap.js";
|
|
11
|
+
import "../server.js";
|
|
12
|
+
import { tanstackStart } from "../../integrations/tanstack-start/react/integration.js";
|
|
13
|
+
import { MiddlewareMatcher, matchMiddleware } from "../../integrations/tanstack-start/react/middleware.js";
|
|
14
|
+
export { ApiHandlers, KizloHandler, LinkDescriptor, MetaDescriptor, MiddlewareMatcher, RouteHead, ScriptDescriptor, ServerRoute, ServerRouteContext, TanstackStartOptions, WEB_MANIFEST_ROUTE, createApiHandlers, createManifestRoute, createRobotsRoute, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, matchMiddleware, renderJsonLd, resolvePageHead, resolveRootHead, tanstackStart };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WEB_MANIFEST_ROUTE } from "../../brand/manifest.js";
|
|
2
|
+
import { renderJsonLd } from "../../seo/utils.js";
|
|
3
|
+
import { getServerBaseUrl } from "../../integrations/tanstack-start/utils.js";
|
|
4
|
+
import { resolvePageHead } from "../../integrations/tanstack-start/metadata.js";
|
|
5
|
+
import { createApiHandlers } from "../../integrations/tanstack-start/api.js";
|
|
6
|
+
import { createManifestRoute } from "../../integrations/tanstack-start/manifest.js";
|
|
7
|
+
import { createRobotsRoute } from "../../integrations/tanstack-start/robots.js";
|
|
8
|
+
import { resolveRootHead } from "../../integrations/tanstack-start/root-head.js";
|
|
9
|
+
import { createSitemapRedirectRoute, createSitemapRoute } from "../../integrations/tanstack-start/sitemap.js";
|
|
10
|
+
import { tanstackStart } from "../../integrations/tanstack-start/react/integration.js";
|
|
11
|
+
import { matchMiddleware } from "../../integrations/tanstack-start/react/middleware.js";
|
|
12
|
+
|
|
13
|
+
export { WEB_MANIFEST_ROUTE, createApiHandlers, createManifestRoute, createRobotsRoute, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, matchMiddleware, renderJsonLd, resolvePageHead, resolveRootHead, tanstackStart };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizlo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A headless WordPress framework for TypeScript.",
|
|
6
6
|
"keywords": [
|
|
@@ -58,18 +58,6 @@
|
|
|
58
58
|
"default": "./dist/test.js"
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
"./cloudflare": {
|
|
62
|
-
"import": {
|
|
63
|
-
"types": "./dist/cloudflare.d.ts",
|
|
64
|
-
"default": "./dist/cloudflare.js"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"./cloudflare/vinext": {
|
|
68
|
-
"import": {
|
|
69
|
-
"types": "./dist/cloudflare/vinext.d.ts",
|
|
70
|
-
"default": "./dist/cloudflare/vinext.js"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
61
|
"./node": {
|
|
74
62
|
"import": {
|
|
75
63
|
"types": "./dist/node.d.ts",
|
|
@@ -111,6 +99,18 @@
|
|
|
111
99
|
"types": "./dist/tanstack-start/server.d.ts",
|
|
112
100
|
"default": "./dist/tanstack-start/server.js"
|
|
113
101
|
}
|
|
102
|
+
},
|
|
103
|
+
"./tanstack-start/react/server": {
|
|
104
|
+
"import": {
|
|
105
|
+
"types": "./dist/tanstack-start/react/server.d.ts",
|
|
106
|
+
"default": "./dist/tanstack-start/react/server.js"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"./tanstack-start/react/cloudflare": {
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/tanstack-start/react/cloudflare.d.ts",
|
|
112
|
+
"default": "./dist/tanstack-start/react/cloudflare.js"
|
|
113
|
+
}
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"files": [
|
|
@@ -145,14 +145,13 @@
|
|
|
145
145
|
"zod": "^4.3.6"
|
|
146
146
|
},
|
|
147
147
|
"peerDependencies": {
|
|
148
|
-
"@tanstack/react-router": "^1.
|
|
149
|
-
"@tanstack/react-start": "^1.
|
|
148
|
+
"@tanstack/react-router": "^1.170.41",
|
|
149
|
+
"@tanstack/react-start": "^1.168.60",
|
|
150
150
|
"astro": "^7.0.0",
|
|
151
151
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
152
152
|
"react": "^18.0.0 || ^19.0.0",
|
|
153
153
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
154
|
-
"typescript": "^5.0.0"
|
|
155
|
-
"vite": "^8.0.0"
|
|
154
|
+
"typescript": "^5.0.0"
|
|
156
155
|
},
|
|
157
156
|
"peerDependenciesMeta": {
|
|
158
157
|
"@tanstack/react-router": {
|
|
@@ -175,9 +174,6 @@
|
|
|
175
174
|
},
|
|
176
175
|
"typescript": {
|
|
177
176
|
"optional": true
|
|
178
|
-
},
|
|
179
|
-
"vite": {
|
|
180
|
-
"optional": true
|
|
181
177
|
}
|
|
182
178
|
}
|
|
183
179
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "vite";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/cloudflare/vinext.d.ts
|
|
4
|
-
/** Capture Cloudflare context inside each Vinext stage, including cache misses and regeneration. */
|
|
5
|
-
declare function cloudflareVinext(): Plugin;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { cloudflareVinext };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//#region src/integrations/cloudflare/vinext.ts
|
|
2
|
-
const stages = new Map([["vinext/server/request-stage", ["loadVinextRequestStage", "handleRequestStage"]], ["vinext/server/response-stage", ["loadVinextResponseStage", "handleResponseStage"]]]);
|
|
3
|
-
/** Capture Cloudflare context inside each Vinext stage, including cache misses and regeneration. */
|
|
4
|
-
function cloudflareVinext() {
|
|
5
|
-
const modules = /* @__PURE__ */ new Map();
|
|
6
|
-
return {
|
|
7
|
-
name: "kizlo:cloudflare-vinext",
|
|
8
|
-
enforce: "pre",
|
|
9
|
-
async resolveId(source, importer) {
|
|
10
|
-
const stage = stages.get(source);
|
|
11
|
-
if (!stage) return null;
|
|
12
|
-
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
13
|
-
if (!resolved) return this.error(`Cannot resolve ${source}. Use a Vinext release exposing the public stage loaders.`);
|
|
14
|
-
const id = `\0kizlo:cloudflare:${resolved.id}`;
|
|
15
|
-
modules.set(id, {
|
|
16
|
-
original: resolved.id,
|
|
17
|
-
loader: stage[0],
|
|
18
|
-
handler: stage[1]
|
|
19
|
-
});
|
|
20
|
-
return id;
|
|
21
|
-
},
|
|
22
|
-
load(id) {
|
|
23
|
-
const stage = modules.get(id);
|
|
24
|
-
if (!stage) return null;
|
|
25
|
-
return `
|
|
26
|
-
import { withCloudflareRequest } from "kizlo/cloudflare";
|
|
27
|
-
import { ${stage.loader} as loadStage } from ${JSON.stringify(stage.original)};
|
|
28
|
-
export * from ${JSON.stringify(stage.original)};
|
|
29
|
-
export async function ${stage.loader}(...args) {
|
|
30
|
-
const stage = await loadStage(...args);
|
|
31
|
-
return {
|
|
32
|
-
...stage,
|
|
33
|
-
${stage.handler}(request, ...args) {
|
|
34
|
-
return withCloudflareRequest(request, () => stage.${stage.handler}(request, ...args));
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { cloudflareVinext };
|
package/dist/cloudflare.d.ts
DELETED
package/dist/cloudflare.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Integration } from "../../shared/integration.js";
|
|
2
|
-
import "../../index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/cloudflare/integration.d.ts
|
|
5
|
-
/** Supply Cloudflare connection info independently of the frontend framework or WordPress host. */
|
|
6
|
-
declare function cloudflare(): Integration<"cloudflare", Record<never, never>>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { cloudflare };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FRAMEWORK_INTEGRATION_ORDER } from "../../shared/constants.js";
|
|
2
|
-
import { createIntegration } from "../../shared/integration.js";
|
|
3
|
-
import { geoCloudflare } from "./request-context.js";
|
|
4
|
-
|
|
5
|
-
//#region src/integrations/cloudflare/integration.ts
|
|
6
|
-
/** Supply Cloudflare connection info independently of the frontend framework or WordPress host. */
|
|
7
|
-
function cloudflare() {
|
|
8
|
-
return createIntegration({
|
|
9
|
-
id: "cloudflare",
|
|
10
|
-
order: FRAMEWORK_INTEGRATION_ORDER,
|
|
11
|
-
adapters: { geo: geoCloudflare() }
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { cloudflare };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GeoAdapter } from "../../adapters/geo.js";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/cloudflare/request-context.d.ts
|
|
4
|
-
/** Read an explicit Cloudflare request or the active Worker entry context, without framework headers. */
|
|
5
|
-
declare function geoCloudflare(): GeoAdapter;
|
|
6
|
-
/** Wrap the complete Worker fetch handler, including SSR and streamed response production. */
|
|
7
|
-
declare function withCloudflareRequest(request: Request, handle: () => Response | Promise<Response>): Promise<Response>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { geoCloudflare, withCloudflareRequest };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { cloudflareConnInfo } from "../../adapters/cloudflare-connection.js";
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/cloudflare/request-context.ts
|
|
5
|
-
const requests = new AsyncLocalStorage();
|
|
6
|
-
/** Read an explicit Cloudflare request or the active Worker entry context, without framework headers. */
|
|
7
|
-
function geoCloudflare() {
|
|
8
|
-
return { getConnInfo: (request) => request ? cloudflareConnInfo(request.headers) : { ...requests.getStore()?.connection ?? cloudflareConnInfo() } };
|
|
9
|
-
}
|
|
10
|
-
/** Wrap the complete Worker fetch handler, including SSR and streamed response production. */
|
|
11
|
-
function withCloudflareRequest(request, handle) {
|
|
12
|
-
const store = { connection: cloudflareConnInfo(request.headers) };
|
|
13
|
-
return requests.run(store, async () => {
|
|
14
|
-
try {
|
|
15
|
-
const response = await handle();
|
|
16
|
-
if (!response.body || response.status === 101) {
|
|
17
|
-
store.connection = null;
|
|
18
|
-
return response;
|
|
19
|
-
}
|
|
20
|
-
const reader = response.body.getReader();
|
|
21
|
-
const body = new ReadableStream({
|
|
22
|
-
pull(controller) {
|
|
23
|
-
return requests.run(store, async () => {
|
|
24
|
-
try {
|
|
25
|
-
const { value, done } = await reader.read();
|
|
26
|
-
if (done) {
|
|
27
|
-
store.connection = null;
|
|
28
|
-
reader.releaseLock();
|
|
29
|
-
controller.close();
|
|
30
|
-
} else controller.enqueue(value);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
store.connection = null;
|
|
33
|
-
reader.releaseLock();
|
|
34
|
-
controller.error(error);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
cancel(reason) {
|
|
39
|
-
return requests.run(store, async () => {
|
|
40
|
-
try {
|
|
41
|
-
await reader.cancel(reason);
|
|
42
|
-
} finally {
|
|
43
|
-
store.connection = null;
|
|
44
|
-
reader.releaseLock();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}, { highWaterMark: 0 });
|
|
49
|
-
return new Response(body, response);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
store.connection = null;
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { geoCloudflare, withCloudflareRequest };
|