@jay-framework/fullstack-component 0.17.3 → 0.17.4
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/index.d.ts +48 -2
- package/dist/index.js +28 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ interface PageProps {
|
|
|
67
67
|
interface RequestQuery {
|
|
68
68
|
query: Record<string, string>;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* HTTP cookies parsed from the request Cookie header.
|
|
72
|
+
* Available in the fast phase only — not in the slow phase.
|
|
73
|
+
*/
|
|
74
|
+
interface RequestCookies {
|
|
75
|
+
cookies: Record<string, string>;
|
|
76
|
+
}
|
|
70
77
|
type UrlParams = Record<string, string>;
|
|
71
78
|
interface ServerError5xx {
|
|
72
79
|
kind: 'ServerError';
|
|
@@ -111,6 +118,8 @@ interface PhaseOutput<ViewState extends object, CarryForward = {}> {
|
|
|
111
118
|
carryForward: CarryForward;
|
|
112
119
|
/** Tags to inject into <head> during SSR (Design Log #127). */
|
|
113
120
|
headTags?: HeadTag[];
|
|
121
|
+
/** HTTP response headers to set on the page response (Design Log #141). */
|
|
122
|
+
responseHeaders?: Record<string, string>;
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* @deprecated Use PhaseOutput instead. PartialRender is kept for backwards compatibility.
|
|
@@ -126,7 +135,7 @@ type FastRenderResult<ViewState extends object, CarryForward = {}> = RenderOutco
|
|
|
126
135
|
type AnyFastRenderResult = FastRenderResult<object, object>;
|
|
127
136
|
type LoadParams<Services, Params extends UrlParams> = (contexts: Services) => AsyncIterable<Params[]>;
|
|
128
137
|
type RenderSlowly<Services extends Array<object>, PropsT extends object, SlowViewState extends object, SlowlyCarryForward> = (props: PropsT, ...services: Services) => Promise<SlowlyRenderResult<SlowViewState, SlowlyCarryForward>>;
|
|
129
|
-
type RenderFast<Services extends Array<object>, PropsT extends object, FastViewState extends object, FastCarryForward> = (props: PropsT & RequestQuery, ...services: Services) => Promise<FastRenderResult<FastViewState, FastCarryForward>>;
|
|
138
|
+
type RenderFast<Services extends Array<object>, PropsT extends object, FastViewState extends object, FastCarryForward> = (props: PropsT & RequestQuery & RequestCookies, ...services: Services) => Promise<FastRenderResult<FastViewState, FastCarryForward>>;
|
|
130
139
|
interface JayStackComponentDefinition<Refs extends object, SlowVS extends object, FastVS extends object, InteractiveVS extends object, Services extends Array<any>, Contexts extends Array<any>, PropsT extends object, Params extends UrlParams, CompCore extends JayComponentCore<PropsT, InteractiveVS>> {
|
|
131
140
|
services: ServiceMarkers<Services>;
|
|
132
141
|
contexts: ContextMarkers<Contexts>;
|
|
@@ -202,6 +211,7 @@ declare function redirect3xx(status: number, location: string, message?: string)
|
|
|
202
211
|
*/
|
|
203
212
|
declare function phaseOutput<ViewState extends object, CarryForward = {}>(rendered: ViewState, carryForward: CarryForward, options?: {
|
|
204
213
|
headTags?: HeadTag[];
|
|
214
|
+
responseHeaders?: Record<string, string>;
|
|
205
215
|
}): PhaseOutput<ViewState, CarryForward>;
|
|
206
216
|
/**
|
|
207
217
|
* @deprecated Use phaseOutput instead. Kept for backwards compatibility.
|
|
@@ -681,6 +691,42 @@ declare function isJayStreamAction(value: unknown): value is JayStreamAction<unk
|
|
|
681
691
|
*/
|
|
682
692
|
type StreamChunk<T> = T extends JayStreamAction<any, infer C> ? C : never;
|
|
683
693
|
|
|
694
|
+
interface WebhookEvent {
|
|
695
|
+
type: string;
|
|
696
|
+
payload: unknown;
|
|
697
|
+
headers: Record<string, string | undefined>;
|
|
698
|
+
}
|
|
699
|
+
interface InvalidateContract {
|
|
700
|
+
(contractName: string, params?: Record<string, string>): Promise<void>;
|
|
701
|
+
}
|
|
702
|
+
interface JayWebhook<Services extends any[] = any[]> {
|
|
703
|
+
readonly webhookName: string;
|
|
704
|
+
readonly services: ServiceMarkers<Services>;
|
|
705
|
+
readonly handler: (event: WebhookEvent, invalidate: InvalidateContract, ...services: Services) => Promise<void>;
|
|
706
|
+
readonly _brand: 'JayWebhook';
|
|
707
|
+
}
|
|
708
|
+
interface JayWebhookBuilder<Services extends any[]> {
|
|
709
|
+
withServices<NewServices extends any[]>(...services: ServiceMarkers<NewServices>): JayWebhookBuilder<NewServices>;
|
|
710
|
+
withHandler(handler: (event: WebhookEvent, invalidate: InvalidateContract, ...services: Services) => Promise<void>): JayWebhook<Services>;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Create a webhook handler for data change invalidation.
|
|
714
|
+
*
|
|
715
|
+
* @param name - Unique webhook name (e.g., 'wix-stores.product-change')
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* export const onProductChange = makeWebhook('wix-stores.product-change')
|
|
720
|
+
* .withServices(PRODUCTS_SERVICE)
|
|
721
|
+
* .withHandler(async (event, invalidate, productsService) => {
|
|
722
|
+
* const slug = await productsService.resolveSlug(event.payload.itemId);
|
|
723
|
+
* await invalidate('product-page', { slug });
|
|
724
|
+
* });
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
declare function makeWebhook(name: string): JayWebhookBuilder<[]>;
|
|
728
|
+
declare function isJayWebhook(value: unknown): value is JayWebhook;
|
|
729
|
+
|
|
684
730
|
/**
|
|
685
731
|
* Builder for plugin/project initialization with type-safe server-to-client data flow.
|
|
686
732
|
*
|
|
@@ -783,4 +829,4 @@ declare function makeJayInit(key?: string): JayInitBuilder<void>;
|
|
|
783
829
|
*/
|
|
784
830
|
declare function isJayInit(obj: unknown): obj is JayInit<any>;
|
|
785
831
|
|
|
786
|
-
export { ActionError, type ActionInput, type ActionOutput, type AnyFastRenderResult, type AnyJayStackComponentDefinition, type AnySlowlyRenderResult, type Builder, type CacheOptions, type ClientError4xx, type ContractGeneratorFunction, type DynamicContractGenerator, type DynamicContractProps, type FastRenderResult, type FileUploadOptions, type GeneratedContractYaml, type HeadTag, type HttpMethod, type JayAction, type JayActionBuilder, type JayActionDefinition, type JayFile, type JayInit, type JayInitBuilder, type JayInitBuilderWithServer, type JayStackComponentDefinition, type JayStreamAction, type JayStreamActionDefinition, type JayStreamBuilder, type LoadParams, type PageProps, type PartialRender, type PhaseOutput, type PipelineFactory, type Redirect3xx, type RenderFast, type RenderOutcome, RenderPipeline, type RenderSlowly, type RequestQuery, type ServerError5xx, type ServiceInstances, type ServiceMarker, type ServiceMarkers, type Signals, type SlowlyRenderResult, type StreamChunk, type UrlParams, badRequest, clientError4xx, createJayService, forbidden, isJayAction, isJayInit, isJayStreamAction, makeContractGenerator, makeJayAction, makeJayInit, makeJayQuery, makeJayStackComponent, makeJayStream, notFound, partialRender, phaseOutput, redirect3xx, serverError5xx, unauthorized };
|
|
832
|
+
export { ActionError, type ActionInput, type ActionOutput, type AnyFastRenderResult, type AnyJayStackComponentDefinition, type AnySlowlyRenderResult, type Builder, type CacheOptions, type ClientError4xx, type ContractGeneratorFunction, type DynamicContractGenerator, type DynamicContractProps, type FastRenderResult, type FileUploadOptions, type GeneratedContractYaml, type HeadTag, type HttpMethod, type InvalidateContract, type JayAction, type JayActionBuilder, type JayActionDefinition, type JayFile, type JayInit, type JayInitBuilder, type JayInitBuilderWithServer, type JayStackComponentDefinition, type JayStreamAction, type JayStreamActionDefinition, type JayStreamBuilder, type JayWebhook, type JayWebhookBuilder, type LoadParams, type PageProps, type PartialRender, type PhaseOutput, type PipelineFactory, type Redirect3xx, type RenderFast, type RenderOutcome, RenderPipeline, type RenderSlowly, type RequestCookies, type RequestQuery, type ServerError5xx, type ServiceInstances, type ServiceMarker, type ServiceMarkers, type Signals, type SlowlyRenderResult, type StreamChunk, type UrlParams, type WebhookEvent, badRequest, clientError4xx, createJayService, forbidden, isJayAction, isJayInit, isJayStreamAction, isJayWebhook, makeContractGenerator, makeJayAction, makeJayInit, makeJayQuery, makeJayStackComponent, makeJayStream, makeWebhook, notFound, partialRender, phaseOutput, redirect3xx, serverError5xx, unauthorized };
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,8 @@ function phaseOutput(rendered, carryForward, options) {
|
|
|
45
45
|
kind: "PhaseOutput",
|
|
46
46
|
rendered,
|
|
47
47
|
carryForward,
|
|
48
|
-
...options?.headTags && { headTags: options.headTags }
|
|
48
|
+
...options?.headTags && { headTags: options.headTags },
|
|
49
|
+
...options?.responseHeaders && { responseHeaders: options.responseHeaders }
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
function partialRender(rendered, carryForward) {
|
|
@@ -472,6 +473,30 @@ function makeJayStream(name) {
|
|
|
472
473
|
function isJayStreamAction(value) {
|
|
473
474
|
return typeof value === "function" && value._brand === "JayStreamAction" && typeof value.actionName === "string";
|
|
474
475
|
}
|
|
476
|
+
class JayWebhookBuilderImpl {
|
|
477
|
+
constructor(_webhookName) {
|
|
478
|
+
__publicField(this, "_services", []);
|
|
479
|
+
this._webhookName = _webhookName;
|
|
480
|
+
}
|
|
481
|
+
withServices(...services) {
|
|
482
|
+
this._services = services;
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
withHandler(handler) {
|
|
486
|
+
return {
|
|
487
|
+
webhookName: this._webhookName,
|
|
488
|
+
services: this._services,
|
|
489
|
+
handler,
|
|
490
|
+
_brand: "JayWebhook"
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function makeWebhook(name) {
|
|
495
|
+
return new JayWebhookBuilderImpl(name);
|
|
496
|
+
}
|
|
497
|
+
function isJayWebhook(value) {
|
|
498
|
+
return typeof value === "object" && value !== null && value._brand === "JayWebhook" && typeof value.webhookName === "string";
|
|
499
|
+
}
|
|
475
500
|
function makeJayInit(key) {
|
|
476
501
|
const resolvedKey = key ?? "__JAY_INIT_KEY__";
|
|
477
502
|
return {
|
|
@@ -517,12 +542,14 @@ export {
|
|
|
517
542
|
isJayAction,
|
|
518
543
|
isJayInit,
|
|
519
544
|
isJayStreamAction,
|
|
545
|
+
isJayWebhook,
|
|
520
546
|
makeContractGenerator,
|
|
521
547
|
makeJayAction,
|
|
522
548
|
makeJayInit,
|
|
523
549
|
makeJayQuery,
|
|
524
550
|
makeJayStackComponent,
|
|
525
551
|
makeJayStream,
|
|
552
|
+
makeWebhook,
|
|
526
553
|
notFound,
|
|
527
554
|
partialRender,
|
|
528
555
|
phaseOutput,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/fullstack-component",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"test:watch": "vitest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@jay-framework/component": "^0.17.
|
|
30
|
-
"@jay-framework/runtime": "^0.17.
|
|
29
|
+
"@jay-framework/component": "^0.17.4",
|
|
30
|
+
"@jay-framework/runtime": "^0.17.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@jay-framework/dev-environment": "^0.17.
|
|
34
|
-
"@jay-framework/jay-cli": "^0.17.
|
|
33
|
+
"@jay-framework/dev-environment": "^0.17.4",
|
|
34
|
+
"@jay-framework/jay-cli": "^0.17.4",
|
|
35
35
|
"@types/express": "^5.0.2",
|
|
36
36
|
"@types/node": "^22.15.21",
|
|
37
37
|
"nodemon": "^3.0.3",
|