@storystick/next 0.2.0-rc.3 → 0.2.0-rc.5

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/PUBLIC-API.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @storystick/next API contract
2
2
 
3
- Install this candidate explicitly with `@storystick/next@0.2.0-rc.3` after registry bootstrap and publication. This repository alone does not make the candidate or beta channel available on npm.
3
+ Install this candidate explicitly with `@storystick/next@0.2.0-rc.4` after registry bootstrap and publication. This repository alone does not make the candidate or beta channel available on npm.
4
4
 
5
- Version 0.2.0-rc.3, cohort `sdk-0.2.0-rc.3`. ESM distribution; no CommonJS or universal Edge compatibility is promised.
5
+ Version 0.2.0-rc.4, cohort `sdk-0.2.0-rc.4`. ESM distribution; no CommonJS or universal Edge compatibility is promised.
6
6
 
7
7
  This package is a product integration facade. Reserved contracts are required between SDK packages and must be upgraded with the same cohort. Their public export paths do not promise independent stability.
8
8
 
package/README.md CHANGED
@@ -551,3 +551,52 @@ Mount `<Storystick />` from a Server Component so server configuration reaches
551
551
  the browser through the adapter. Explicit transport props remain available for
552
552
  deliberate local/self-hosted integrations; conflicting service configuration
553
553
  fails instead of silently selecting another destination.
554
+
555
+ ## Reactive rendering with a server seed
556
+
557
+ For content that must update locally while it is being edited, use the same
558
+ Query V2 definition in a client component. Server-only components continue to
559
+ update after the confirmed projection and Next refresh.
560
+
561
+ ```tsx
562
+ // Server Component
563
+ import { preloadQuery } from '@storystick/next/server'
564
+ const client = await site.client({ locale: 'en' })
565
+ const initialData = await preloadQuery(client.query('page').selectAll().by({ id }).locale('en'))
566
+ return <PageBody id={id} initialData={initialData} connection={site.browserOptions()} />
567
+ ```
568
+
569
+ ```tsx
570
+ 'use client'
571
+ import { createClient } from '@storystick/next'
572
+ import { useQuery } from '@storystick/next/query'
573
+ import { useMemo } from 'react'
574
+ import { querySchema } from '@/generated/storystick/query'
575
+
576
+ // Add props types from QuerySnapshot and your generated query definition.
577
+ function PageBody({ id, initialData, connection }) {
578
+ const connectionKey = JSON.stringify(connection)
579
+ const client = useMemo(() => createClient({
580
+ ...JSON.parse(connectionKey), schema: querySchema,
581
+ }), [connectionKey])
582
+ const result = useQuery(client.query('page').selectAll().by({ id }).locale('en'), { initialData })
583
+ if (result.status === 'error') throw result.error
584
+ if (!result.data) return null
585
+ return <PageContent page={result.data} />
586
+ }
587
+ ```
588
+
589
+ `browserOptions()` carries the selected public service and publishable key, never
590
+ a server API key or a session token. `preloadQuery` returns plain JSON with query,
591
+ project, schema, service and Preview context identities. It does not serialize a
592
+ query receipt as browser authority. The first mounted query obtains its own read
593
+ and receipt; a private seed never starts a public read while Preview authenticates.
594
+ Use stable components and keys so content changes do not reset local UI state.
595
+
596
+ The local editing projection remains an internal, bilateral qualification gate
597
+ (`STORYSTICK_PREVIEW_LIVE_QUERY_OVERLAY` on the Next server and the corresponding
598
+ Studio build gate). Installing this API alone does not activate it. It projects
599
+ bounded fields of already-authorized query results; filtered/sorted results,
600
+ new memberships and server-only components retain the confirmed refresh path.
601
+ A locally rendered edit is not a persistence acknowledgement. Navigation, save
602
+ errors and published delivery retain their existing authority checks.
package/dist/.source-hash CHANGED
@@ -1 +1 @@
1
- 0e9cc2f9becc7a5e253621d032bfaa2864dac49eb6aedf65d3d3c57c11cd8a89
1
+ 4ced3e6c171faffecd7beaf6850c7f41529aa6f6b00fdf8a1b0173c85b109792
@@ -31,3 +31,5 @@ export { Storystick } from './storystick.js';
31
31
  export { StorystickErrorRecovery } from './storystick-error-recovery.js';
32
32
  export type { StorystickProps } from './storystick.js';
33
33
  export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
34
+ export { preloadQuery } from '@storystick/client';
35
+ export type { QuerySnapshot } from '@storystick/client';
package/dist/rendering.js CHANGED
@@ -40,3 +40,4 @@ export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
40
40
  // import { useStorystickPreviewNavigation } from '@storystick/next/preview-nav'
41
41
  //
42
42
  // See `README.md` "Preview navigation" section for usage.
43
+ export { preloadQuery } from '@storystick/client';
@@ -180,6 +180,23 @@ export declare function createSite<const TSchema extends QuerySchemaDefinition,
180
180
  client: (input?: {
181
181
  locale?: string;
182
182
  }) => Promise<Client<TSchema>>;
183
+ /** Public browser configuration from the same server-selected service.
184
+ * Request credentials and private operator configuration never cross RSC. */
185
+ browserOptions(): {
186
+ deliveryEndpoint?: string | undefined;
187
+ service: import("@storystick/types/public-endpoints").ServiceConnection;
188
+ projectId: string;
189
+ publishableKey: string;
190
+ } | {
191
+ deliveryEndpoint?: string | undefined;
192
+ endpoint: string;
193
+ projectId: string;
194
+ publishableKey: string;
195
+ } | {
196
+ deliveryEndpoint?: string | undefined;
197
+ projectId: string;
198
+ publishableKey: string;
199
+ };
183
200
  renderReceipt(input: {
184
201
  pathname: string;
185
202
  results: readonly object[];
@@ -390,6 +390,7 @@ async function createNextServerClient(input) {
390
390
  projectId: input.projectId,
391
391
  apiKey: input.apiKey,
392
392
  endpoint: input.endpoint,
393
+ deliveryEndpoint: process.env.STORYSTICK_DELIVERY_ENDPOINT,
393
394
  defaults: input.locale ? { locale: input.locale } : undefined,
394
395
  requestContext,
395
396
  transport: withNextQueryOptions(input.projectId, localeGuardTransport(previewRuntimeForSchema(input.querySchema) ? undefined : input.locale, createPreviewReadIdentityTransport(createNextHttpTransport({
@@ -1494,6 +1495,19 @@ export function createSite(options) {
1494
1495
  };
1495
1496
  return Object.freeze({
1496
1497
  client,
1498
+ /** Public browser configuration from the same server-selected service.
1499
+ * Request credentials and private operator configuration never cross RSC. */
1500
+ browserOptions() {
1501
+ const { service, endpoint } = serverInfraOptions();
1502
+ const publishableKey = readRequiredEnv('NEXT_PUBLIC_STORYSTICK_PUBLISHABLE_KEY', 'Run storystick connect from the website repository.');
1503
+ return {
1504
+ projectId: readProjectId(),
1505
+ publishableKey,
1506
+ ...(service ? { service } : endpoint ? { endpoint } : {}),
1507
+ ...(!service && process.env.STORYSTICK_DELIVERY_ENDPOINT
1508
+ ? { deliveryEndpoint: process.env.STORYSTICK_DELIVERY_ENDPOINT } : {}),
1509
+ };
1510
+ },
1497
1511
  async renderReceipt(input) {
1498
1512
  if ((await draftMode()).isEnabled)
1499
1513
  return null;
package/dist/server.d.ts CHANGED
@@ -6,3 +6,5 @@ export { stripPreviewProvenance } from './clean.js';
6
6
  export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
7
7
  export { createSite, createServerClient, resolvePage, buildStorystickSitemap, buildStorystickSitemapShards, STORYSTICK_SITEMAP_MAX_URLS, storystickAlternates, } from './server-runtime.js';
8
8
  export type { SiteDefinition, CreateSiteOptions, StorystickSitemapBuildOptions, ResolvePageDataCondition, ResolvePageDataDeclaration, ResolvePageDataDeclarations, ResolvedPageData, ResolvePageRouteInput, ResolvePageInput, ResolvedRouteForSchema, ResolvedRouteWithPageData, TypedResolvePageInput, ResolvedDocumentRoute, StorystickAlternatesOptions, StorystickPublishedLocaleRoute, StorystickSitemapOptions, } from './server-runtime.js';
9
+ export { preloadQuery } from '@storystick/client';
10
+ export type { QuerySnapshot } from '@storystick/client';
package/dist/server.js CHANGED
@@ -4,3 +4,4 @@ export { StorystickError } from '@storystick/client';
4
4
  export { stripPreviewProvenance } from './clean.js';
5
5
  export { STORYSTICK_PREVIEW_ROBOTS } from './preview-metadata.js';
6
6
  export { createSite, createServerClient, resolvePage, buildStorystickSitemap, buildStorystickSitemapShards, STORYSTICK_SITEMAP_MAX_URLS, storystickAlternates, } from './server-runtime.js';
7
+ export { preloadQuery } from '@storystick/client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storystick/next",
3
- "version": "0.2.0-rc.3",
3
+ "version": "0.2.0-rc.5",
4
4
  "license": "FSL-1.1-MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -88,11 +88,11 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "server-only": "^0.0.1",
91
- "@storystick/client": "0.2.0-rc.3",
91
+ "@storystick/client": "0.2.0-rc.4",
92
92
  "@storystick/media": "0.2.0-rc.3",
93
- "@storystick/react": "0.2.0-rc.3",
94
- "@storystick/types": "0.1.0-rc.3",
95
- "@storystick/preview": "0.2.0-rc.3"
93
+ "@storystick/preview": "0.2.0-rc.4",
94
+ "@storystick/react": "0.2.0-rc.5",
95
+ "@storystick/types": "0.1.0-rc.3"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@testing-library/react": "^16.3.2",