@storystick/next 0.0.0-stage → 0.2.0-rc.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/LICENSE +112 -0
- package/PUBLIC-API.md +31 -0
- package/README.md +522 -2
- package/dist/.source-hash +1 -0
- package/dist/cache-tags.d.ts +2 -0
- package/dist/cache-tags.js +12 -0
- package/dist/clean.d.ts +1 -0
- package/dist/clean.js +1 -0
- package/dist/code-version.d.ts +29 -0
- package/dist/code-version.js +48 -0
- package/dist/file.d.ts +1 -0
- package/dist/file.js +1 -0
- package/dist/i18n-seo.d.ts +1 -0
- package/dist/i18n-seo.js +1 -0
- package/dist/image.d.ts +11 -0
- package/dist/image.js +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.react-server.d.ts +3 -0
- package/dist/index.react-server.js +12 -0
- package/dist/link.d.ts +10 -0
- package/dist/link.js +8 -0
- package/dist/preview/index.d.ts +29 -0
- package/dist/preview/index.js +24 -0
- package/dist/preview/internal.d.ts +61 -0
- package/dist/preview/internal.js +97 -0
- package/dist/preview/preview-request-identity.d.ts +4 -0
- package/dist/preview/preview-request-identity.js +63 -0
- package/dist/preview/provenance-config.d.ts +42 -0
- package/dist/preview/provenance-config.js +132 -0
- package/dist/preview/provenance-frame-builder.d.ts +6 -0
- package/dist/preview/provenance-frame-builder.js +10 -0
- package/dist/preview/provenance-response.d.ts +5 -0
- package/dist/preview/provenance-response.js +9 -0
- package/dist/preview/provenance-runtime-adapter.d.ts +9 -0
- package/dist/preview/provenance-runtime-adapter.js +42 -0
- package/dist/preview/render-frame-provenance.d.ts +23 -0
- package/dist/preview/render-frame-provenance.js +47 -0
- package/dist/preview/route-authoring.d.ts +3 -0
- package/dist/preview/route-authoring.js +80 -0
- package/dist/preview/route-context.d.ts +3 -0
- package/dist/preview/route-context.js +38 -0
- package/dist/preview/route-disable.d.ts +7 -0
- package/dist/preview/route-disable.js +63 -0
- package/dist/preview/route-document-provenance.d.ts +23 -0
- package/dist/preview/route-document-provenance.js +46 -0
- package/dist/preview/route-errors.d.ts +1 -0
- package/dist/preview/route-errors.js +1 -0
- package/dist/preview/route-handler.d.ts +36 -0
- package/dist/preview/route-handler.js +139 -0
- package/dist/preview/route-initial.d.ts +9 -0
- package/dist/preview/route-initial.js +141 -0
- package/dist/preview/route-provenance-runtime.d.ts +34 -0
- package/dist/preview/route-provenance-runtime.js +90 -0
- package/dist/preview/route-token.d.ts +6 -0
- package/dist/preview/route-token.js +46 -0
- package/dist/preview/server-preview-internals.d.ts +3 -0
- package/dist/preview/server-preview-internals.js +3 -0
- package/dist/preview/slice-locale.d.ts +5 -0
- package/dist/preview/slice-locale.js +15 -0
- package/dist/preview-error-surface.d.ts +7 -0
- package/dist/preview-error-surface.js +24 -0
- package/dist/preview-exit.d.ts +7 -0
- package/dist/preview-exit.js +71 -0
- package/dist/preview-metadata.d.ts +15 -0
- package/dist/preview-metadata.js +13 -0
- package/dist/preview-mode-latch.d.ts +133 -0
- package/dist/preview-mode-latch.js +231 -0
- package/dist/preview-nav-location.d.ts +12 -0
- package/dist/preview-nav-location.js +149 -0
- package/dist/preview-nav.d.ts +94 -0
- package/dist/preview-nav.js +523 -0
- package/dist/preview-refresh-coordinator.d.ts +26 -0
- package/dist/preview-refresh-coordinator.js +93 -0
- package/dist/preview-render-error.d.ts +11 -0
- package/dist/preview-render-error.js +36 -0
- package/dist/preview-render-recovery.d.ts +9 -0
- package/dist/preview-render-recovery.js +42 -0
- package/dist/preview-session-recovery.d.ts +1 -0
- package/dist/preview-session-recovery.js +1 -0
- package/dist/preview-standalone-host.d.ts +3 -0
- package/dist/preview-standalone-host.js +55 -0
- package/dist/preview-text.d.ts +2 -0
- package/dist/preview-text.js +1 -0
- package/dist/preview-view-bootstrap.d.ts +5 -0
- package/dist/preview-view-bootstrap.js +13 -0
- package/dist/public-delivery.d.ts +6 -0
- package/dist/public-delivery.js +7 -0
- package/dist/query-fetch-options.d.ts +7 -0
- package/dist/query-fetch-options.js +193 -0
- package/dist/query.d.ts +2 -0
- package/dist/query.js +1 -0
- package/dist/rendering.d.ts +33 -0
- package/dist/rendering.js +42 -0
- package/dist/revalidate.d.ts +12 -0
- package/dist/revalidate.js +33 -0
- package/dist/rich-text.d.ts +2 -0
- package/dist/rich-text.js +1 -0
- package/dist/server-runtime.d.ts +208 -0
- package/dist/server-runtime.js +1584 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +6 -0
- package/dist/slice-zone.d.ts +2 -0
- package/dist/slice-zone.js +1 -0
- package/dist/storystick-component-types.d.ts +26 -0
- package/dist/storystick-component-types.js +1 -0
- package/dist/storystick-component.d.ts +10 -0
- package/dist/storystick-component.js +45 -0
- package/dist/storystick-error-recovery.d.ts +12 -0
- package/dist/storystick-error-recovery.js +11 -0
- package/dist/storystick-preview-runtime.d.ts +30 -0
- package/dist/storystick-preview-runtime.js +561 -0
- package/dist/storystick.d.ts +24 -0
- package/dist/storystick.js +23 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.js +40 -0
- package/dist/video.d.ts +1 -0
- package/dist/video.js +1 -0
- package/package.json +128 -3
- package/recipes/README.md +91 -0
- package/recipes/resource-mirror.ts +49 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { SchemaStoryName, ResolvedRouteForSchema } from '@storystick/client';
|
|
2
|
+
export type { ResolvedRouteForSchema } from '@storystick/client';
|
|
3
|
+
/** Next server reads, optional CMS routing, and static route inventory. */
|
|
4
|
+
import 'server-only';
|
|
5
|
+
import { type PublicLocaleOrigins } from '@storystick/client/locale-routing';
|
|
6
|
+
import type { Metadata } from 'next';
|
|
7
|
+
import type { PreviewProvenanceEditableTextPathManifest } from '@storystick/preview/provenance';
|
|
8
|
+
import { type RouteHandlerOptions } from './preview/route-handler.js';
|
|
9
|
+
import { type PreviewReadContext } from '@storystick/types/preview-query-targeting';
|
|
10
|
+
import { type QueryResult, StorystickError, type Client, type QuerySchemaDefinition, type QueryStoriesOf, type SelectedDocument } from '@storystick/client';
|
|
11
|
+
import { type StorystickSitemapOptions } from './i18n-seo.js';
|
|
12
|
+
export { buildStorystickSitemap, buildStorystickSitemapShards, STORYSTICK_SITEMAP_MAX_URLS, storystickAlternates, type ResolvedDocumentRoute, type StorystickAlternatesOptions, type StorystickPublishedLocaleRoute, type StorystickSitemapOptions, } from './i18n-seo.js';
|
|
13
|
+
export { appendSearchParamsToRedirect, } from './preview-session-recovery.js';
|
|
14
|
+
export { StorystickError } from '@storystick/client';
|
|
15
|
+
export type { StorystickErrorCategory, StorystickErrorOptions, } from '@storystick/client';
|
|
16
|
+
/**
|
|
17
|
+
* Natural cookie expiry can arrive as EXPIRED while the cookie is still in
|
|
18
|
+
* the request jar, or MISSING after the browser evicts it while Draft Mode
|
|
19
|
+
* remains enabled. Both are the same user-visible ended-session state.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isPreviewSessionEndedError(error: unknown): boolean;
|
|
22
|
+
export { buildPreviewProvenanceFrame, type BuildPreviewProvenanceFrameOptions, type BuildPreviewProvenanceFrameResult, type PreviewProvenanceAttrs, type PreviewProvenanceAttrsByKey, } from './preview/provenance-frame-builder.js';
|
|
23
|
+
export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
|
|
24
|
+
export { readPreviewProvenanceSessionId, resolvePreviewProvenanceRouteIdentity, } from './preview/preview-request-identity.js';
|
|
25
|
+
export { stripPreviewProvenance } from './clean.js';
|
|
26
|
+
export type { PreviewProvenanceRouteIdentity, ReadPreviewProvenanceSessionOptions, ResolvePreviewProvenanceRouteIdentityOptions, } from './preview/preview-request-identity.js';
|
|
27
|
+
export declare function createServerClient<const TSchema extends QuerySchemaDefinition>(querySchema: TSchema): Promise<Client<TSchema>>;
|
|
28
|
+
export interface StorystickSitemapBuildOptions extends StorystickSitemapOptions {
|
|
29
|
+
readonly storyTypes: readonly string[];
|
|
30
|
+
readonly id?: number;
|
|
31
|
+
readonly shardSize?: number;
|
|
32
|
+
readonly locale?: string;
|
|
33
|
+
}
|
|
34
|
+
import type { ResolveRouteInput, ResolvedRoute } from '@storystick/client';
|
|
35
|
+
export type { ResolveRouteInput, ResolvedRoute } from '@storystick/client';
|
|
36
|
+
export type ResolvePageDataCondition = string | {
|
|
37
|
+
readonly storyType: string;
|
|
38
|
+
};
|
|
39
|
+
export interface ResolvePageDataDeclaration<StoryName extends string = string> {
|
|
40
|
+
readonly query: StoryName;
|
|
41
|
+
readonly for?: readonly ResolvePageDataCondition[];
|
|
42
|
+
readonly first?: number;
|
|
43
|
+
}
|
|
44
|
+
export type ResolvePageDataDeclarations<StoryName extends string = string> = Readonly<Record<string, ResolvePageDataDeclaration<StoryName>>>;
|
|
45
|
+
export type ResolvedPageData<TData extends ResolvePageDataDeclarations, TSchema extends QuerySchemaDefinition = QuerySchemaDefinition> = {
|
|
46
|
+
readonly [K in keyof TData]: TData[K]['query'] extends keyof QueryStoriesOf<TSchema> ? readonly SelectedDocument<QueryStoriesOf<TSchema>[TData[K]['query']], 'all'>[] : QueryResult[];
|
|
47
|
+
};
|
|
48
|
+
type ResolvePageSearchParamValue = string | readonly string[] | undefined;
|
|
49
|
+
export type ResolvePageRouteInput = ResolveRouteInput & {
|
|
50
|
+
readonly publicOrigins?: PublicLocaleOrigins;
|
|
51
|
+
readonly searchParams?: Readonly<Record<string, ResolvePageSearchParamValue>>;
|
|
52
|
+
};
|
|
53
|
+
export type ResolvePageInput<TData extends ResolvePageDataDeclarations | undefined = undefined> = ResolvePageRouteInput & {
|
|
54
|
+
readonly data?: TData;
|
|
55
|
+
readonly querySchema?: QuerySchemaDefinition;
|
|
56
|
+
};
|
|
57
|
+
export type ResolvedRouteWithPageData<TData extends ResolvePageDataDeclarations, TSchema extends QuerySchemaDefinition = QuerySchemaDefinition, TStoryTypes extends readonly SchemaStoryName<TSchema>[] | undefined = undefined> = (Extract<ResolvedRouteForSchema<TSchema, TStoryTypes>, {
|
|
58
|
+
type: 'document';
|
|
59
|
+
}> & {
|
|
60
|
+
readonly data: ResolvedPageData<TData, TSchema>;
|
|
61
|
+
}) | Exclude<ResolvedRouteForSchema<TSchema, TStoryTypes>, {
|
|
62
|
+
type: 'document';
|
|
63
|
+
}>;
|
|
64
|
+
export type TypedResolvePageInput<TSchema extends QuerySchemaDefinition, TStoryTypes extends readonly SchemaStoryName<TSchema>[] | undefined = undefined, TData extends ResolvePageDataDeclarations<SchemaStoryName<TSchema>> | undefined = undefined> = Omit<ResolvePageRouteInput, 'storyTypes'> & {
|
|
65
|
+
readonly querySchema: TSchema;
|
|
66
|
+
readonly storyTypes?: TStoryTypes;
|
|
67
|
+
readonly data?: TData;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Next.js façade for `resolveStorystickPage` (ADR-094 §1).
|
|
71
|
+
*
|
|
72
|
+
* Automatically inherits Draft Mode + preview cookie handling from
|
|
73
|
+
* `createServerClient()`. Customer code:
|
|
74
|
+
*
|
|
75
|
+
* // app/[[...pathname]]/page.tsx
|
|
76
|
+
* export default async function Page({
|
|
77
|
+
* params,
|
|
78
|
+
* }: { params: Promise<{ pathname: string[] | undefined }> }) {
|
|
79
|
+
* const { pathname } = await params
|
|
80
|
+
* const route = await resolvePage({ pathname })
|
|
81
|
+
* if (route.type === 'notFound') notFound()
|
|
82
|
+
* return <Renderer document={route.document} storyType={route.storyType} />
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* Returns a `ResolvedRoute` discriminated union (`document` / `notFound`
|
|
86
|
+
* / future `redirect`). Infrastructure failures (network/auth) throw
|
|
87
|
+
* `StorystickError` — NOT swallowed into `notFound`. Customers handle
|
|
88
|
+
* those via Next-native `error.tsx` boundaries (ADR §1 error strategy).
|
|
89
|
+
*
|
|
90
|
+
* Single backend call: dispatches `queries:getRouteByPathname` (cross-
|
|
91
|
+
* storytype, indexed via ADR-086 `by_projectId_resolvedPathname`). No
|
|
92
|
+
* SDK-side fan-out. The optional `storyTypes` argument filters the
|
|
93
|
+
* backend lookup to specific types.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolvePage<const TSchema extends QuerySchemaDefinition, const TStoryTypes extends readonly SchemaStoryName<TSchema>[] | undefined = undefined, const TData extends ResolvePageDataDeclarations<SchemaStoryName<TSchema>> | undefined = undefined>(input: TypedResolvePageInput<TSchema, TStoryTypes, TData>): Promise<TData extends ResolvePageDataDeclarations ? ResolvedRouteWithPageData<TData, TSchema, TStoryTypes> : ResolvedRouteForSchema<TSchema, TStoryTypes>>;
|
|
96
|
+
export declare function resolvePage<const TData extends ResolvePageDataDeclarations>(input: ResolvePageInput<TData>): Promise<ResolvedRouteWithPageData<TData>>;
|
|
97
|
+
export declare function resolvePage(input: ResolvePageRouteInput): Promise<ResolvedRoute>;
|
|
98
|
+
type PreviewRouteRenderDocument = {
|
|
99
|
+
readonly documentId: string;
|
|
100
|
+
readonly storyType?: string;
|
|
101
|
+
readonly fields?: unknown;
|
|
102
|
+
};
|
|
103
|
+
export interface ResolveStorystickRouteRenderInput<TDocument extends PreviewRouteRenderDocument, TContext = unknown> {
|
|
104
|
+
readonly document: TDocument;
|
|
105
|
+
readonly context?: TContext;
|
|
106
|
+
readonly pathname?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface ResolvedStorystickRouteRender<TDocument extends PreviewRouteRenderDocument, TContext = unknown> {
|
|
109
|
+
readonly document: TDocument;
|
|
110
|
+
readonly context: TContext | undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve the render-time Source Graph closure for a route body.
|
|
114
|
+
*
|
|
115
|
+
* `resolvePage()` can attach identity for the route document itself, but app
|
|
116
|
+
* renderers often load additional QueryResults afterwards (related posts,
|
|
117
|
+
* customers, authors, tags, etc.). This helper is the server-side seam that
|
|
118
|
+
* combines the route document and the actual render context before rendering.
|
|
119
|
+
* It is a no-op outside Preview V2.
|
|
120
|
+
*/
|
|
121
|
+
export declare function resolveStorystickRouteRender<TDocument extends PreviewRouteRenderDocument, TContext = unknown>({ document, context, pathname, }: ResolveStorystickRouteRenderInput<TDocument, TContext>): Promise<ResolvedStorystickRouteRender<TDocument, TContext>>;
|
|
122
|
+
/**
|
|
123
|
+
* Visible-failure subclass for preview-draft resolution failures
|
|
124
|
+
* (CSO-PREVIEW-1 invariant — never silent prod fallback when the editor
|
|
125
|
+
* is targeting a draft). Categorized as `'system'` to flow through the
|
|
126
|
+
* existing canonical category union; the subclass identity (via
|
|
127
|
+
* `instanceof`) is the discriminator for customer error.tsx handlers
|
|
128
|
+
* that want to render a draft-specific message.
|
|
129
|
+
*/
|
|
130
|
+
export declare class StorystickPreviewDraftError extends StorystickError {
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
133
|
+
/** @internal The existing server mount attests the same request as its page.
|
|
134
|
+
* No cookies or infrastructure reads are added to public production renders. */
|
|
135
|
+
export declare const readPreviewServerRenderReceipt: (projectOverride?: string) => Promise<{
|
|
136
|
+
projectionCheckpoint?: {
|
|
137
|
+
lensHash?: string | undefined;
|
|
138
|
+
projectionHash?: string | undefined;
|
|
139
|
+
projectedThroughSeq?: number | undefined;
|
|
140
|
+
generation: number;
|
|
141
|
+
status: "error" | "ready" | "stale" | "rebuilding";
|
|
142
|
+
} | undefined;
|
|
143
|
+
readContext: PreviewReadContext;
|
|
144
|
+
renderId: string;
|
|
145
|
+
} | null>;
|
|
146
|
+
export interface PreviewDraftResolveOptions {
|
|
147
|
+
/** Explicit view selector from the native page request; never inferred by a layout. */
|
|
148
|
+
readonly sessionId: string | null;
|
|
149
|
+
readonly locale?: string;
|
|
150
|
+
}
|
|
151
|
+
export declare function resolvePreviewDraft(options: PreviewDraftResolveOptions): Promise<QueryResult | null>;
|
|
152
|
+
/** Advanced draft guard for an explicitly selected view. Prefer site.resolvePage for CMS routes. */
|
|
153
|
+
export declare const isPreviewDraftActive: (sessionId: string | null) => Promise<boolean>;
|
|
154
|
+
/** Generated, framework-neutral content definition, imported once per site. */
|
|
155
|
+
export interface SiteDefinition<TSchema extends QuerySchemaDefinition = QuerySchemaDefinition> {
|
|
156
|
+
readonly querySchema: TSchema;
|
|
157
|
+
readonly previewProvenanceEditableTextPathManifest: PreviewProvenanceEditableTextPathManifest;
|
|
158
|
+
}
|
|
159
|
+
export interface CreateSiteOptions<TSchema extends QuerySchemaDefinition, TStoryTypes extends readonly SchemaStoryName<TSchema>[] | undefined = undefined> {
|
|
160
|
+
readonly definition: SiteDefinition<TSchema>;
|
|
161
|
+
readonly storyTypes?: TStoryTypes;
|
|
162
|
+
readonly siteUrl?: string | URL;
|
|
163
|
+
/** Default for independent readers. Otherwise use the project's default. */
|
|
164
|
+
readonly locale?: string;
|
|
165
|
+
readonly routes?: RouteHandlerOptions;
|
|
166
|
+
/** Language origins share canonical, unprefixed content paths. */
|
|
167
|
+
readonly publicOrigins?: PublicLocaleOrigins;
|
|
168
|
+
/** Locale served by this deployment. Explicit, so static generation needs no Host read. */
|
|
169
|
+
readonly domainLocale?: string;
|
|
170
|
+
/** Static requires a unique deployment ID per compilation; request supports live render receipts. */
|
|
171
|
+
readonly publicRendering?: 'request' | 'static';
|
|
172
|
+
}
|
|
173
|
+
type SiteNativeParams = Record<string, string | string[] | undefined>;
|
|
174
|
+
type SiteNativeProps<TParams extends SiteNativeParams> = {
|
|
175
|
+
params: Promise<TParams>;
|
|
176
|
+
searchParams?: Promise<ResolvePageRouteInput['searchParams']>;
|
|
177
|
+
};
|
|
178
|
+
/** Immutable configuration; sessions and request data are resolved per render. */
|
|
179
|
+
export declare function createSite<const TSchema extends QuerySchemaDefinition, const TStoryTypes extends readonly SchemaStoryName<TSchema>[] | undefined = undefined>(options: CreateSiteOptions<TSchema, TStoryTypes>): Readonly<{
|
|
180
|
+
client: (input?: {
|
|
181
|
+
locale?: string;
|
|
182
|
+
}) => Promise<Client<TSchema>>;
|
|
183
|
+
renderReceipt(input: {
|
|
184
|
+
pathname: string;
|
|
185
|
+
results: readonly object[];
|
|
186
|
+
deploymentId?: string;
|
|
187
|
+
}): Promise<import("@storystick/client").PublicRenderReceiptV1 | null>;
|
|
188
|
+
publicationManifest(input?: {
|
|
189
|
+
deploymentId?: string;
|
|
190
|
+
sitemapPath?: string;
|
|
191
|
+
}): Promise<import("@storystick/client").PublicSiteManifestV1>;
|
|
192
|
+
/** Project default locale, or the explicit locale configured for this site. */
|
|
193
|
+
locale(): Promise<string>;
|
|
194
|
+
resolvePage(input: Omit<ResolvePageRouteInput, "storyTypes"> | SiteNativeProps<SiteNativeParams>): Promise<ResolvedRouteForSchema<TSchema, TStoryTypes>>;
|
|
195
|
+
params: () => Promise<{
|
|
196
|
+
pathname: string[] | undefined;
|
|
197
|
+
}[] | {
|
|
198
|
+
pathname: string[] | undefined;
|
|
199
|
+
}[]>;
|
|
200
|
+
/** Only real published translations; no prefix substitution in language switches. */
|
|
201
|
+
alternates(route: ResolvedRouteForSchema<TSchema, TStoryTypes>): Readonly<Record<string, string>>;
|
|
202
|
+
metadata(route: ResolvedRouteForSchema<TSchema, TStoryTypes>, metadata?: Metadata): Promise<Metadata>;
|
|
203
|
+
handlers: Readonly<import("./preview/route-handler.js").RouteHandlers>;
|
|
204
|
+
sitemap: (input?: Omit<StorystickSitemapBuildOptions, "storyTypes" | "siteUrl">) => Promise<import("@storystick/client/seo").StorystickSitemapEntry[]>;
|
|
205
|
+
sitemapIds: (input?: Omit<StorystickSitemapBuildOptions, "storyTypes" | "siteUrl" | "id">) => Promise<{
|
|
206
|
+
id: number;
|
|
207
|
+
}[]>;
|
|
208
|
+
}>;
|