@webstir-io/module-contract 0.5.0 → 0.7.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/index.d.ts +20 -0
- package/dist/index.js +4 -0
- package/dist/render-execute.js +21 -0
- package/dist/render-program.d.ts +5 -3
- package/dist/render-program.js +1 -0
- package/dist/render-version.d.ts +1 -1
- package/dist/render-version.js +1 -1
- package/package.json +1 -1
- package/schema/module-manifest.schema.json +12 -0
- package/schema/route-definition.schema.json +6 -0
- package/schema/view-definition.schema.json +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -1608,6 +1608,8 @@ export declare const routeDefinitionSchema: z.ZodObject<{
|
|
|
1608
1608
|
mode?: "optional" | "required" | undefined;
|
|
1609
1609
|
write?: boolean | undefined;
|
|
1610
1610
|
}>>;
|
|
1611
|
+
/** `required`: only a signed-in user reaches the route; others are sent to sign in. */
|
|
1612
|
+
auth: z.ZodOptional<z.ZodEnum<["required"]>>;
|
|
1611
1613
|
flash: z.ZodOptional<z.ZodObject<{
|
|
1612
1614
|
consume: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1613
1615
|
publish: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -2311,6 +2313,7 @@ export declare const routeDefinitionSchema: z.ZodObject<{
|
|
|
2311
2313
|
mode?: "optional" | "required" | undefined;
|
|
2312
2314
|
write?: boolean | undefined;
|
|
2313
2315
|
} | undefined;
|
|
2316
|
+
auth?: "required" | undefined;
|
|
2314
2317
|
flash?: {
|
|
2315
2318
|
consume?: string[] | undefined;
|
|
2316
2319
|
publish?: {
|
|
@@ -2474,6 +2477,7 @@ export declare const routeDefinitionSchema: z.ZodObject<{
|
|
|
2474
2477
|
mode?: "optional" | "required" | undefined;
|
|
2475
2478
|
write?: boolean | undefined;
|
|
2476
2479
|
} | undefined;
|
|
2480
|
+
auth?: "required" | undefined;
|
|
2477
2481
|
flash?: {
|
|
2478
2482
|
consume?: string[] | undefined;
|
|
2479
2483
|
publish?: {
|
|
@@ -2704,6 +2708,8 @@ export declare const viewDefinitionSchema: z.ZodObject<{
|
|
|
2704
2708
|
summary: z.ZodOptional<z.ZodString>;
|
|
2705
2709
|
description: z.ZodOptional<z.ZodString>;
|
|
2706
2710
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2711
|
+
/** `required`: only a signed-in user sees the page; others are sent to sign in. */
|
|
2712
|
+
auth: z.ZodOptional<z.ZodEnum<["required"]>>;
|
|
2707
2713
|
params: z.ZodOptional<z.ZodObject<{
|
|
2708
2714
|
kind: z.ZodDefault<z.ZodEnum<["zod", "json-schema", "ts-rest"]>>;
|
|
2709
2715
|
name: z.ZodString;
|
|
@@ -2746,6 +2752,7 @@ export declare const viewDefinitionSchema: z.ZodObject<{
|
|
|
2746
2752
|
summary?: string | undefined;
|
|
2747
2753
|
description?: string | undefined;
|
|
2748
2754
|
tags?: string[] | undefined;
|
|
2755
|
+
auth?: "required" | undefined;
|
|
2749
2756
|
params?: {
|
|
2750
2757
|
kind: "json-schema" | "ts-rest" | "zod";
|
|
2751
2758
|
name: string;
|
|
@@ -2768,6 +2775,7 @@ export declare const viewDefinitionSchema: z.ZodObject<{
|
|
|
2768
2775
|
summary?: string | undefined;
|
|
2769
2776
|
description?: string | undefined;
|
|
2770
2777
|
tags?: string[] | undefined;
|
|
2778
|
+
auth?: "required" | undefined;
|
|
2771
2779
|
params?: {
|
|
2772
2780
|
kind?: "json-schema" | "ts-rest" | "zod" | undefined;
|
|
2773
2781
|
name: string;
|
|
@@ -2909,6 +2917,8 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
2909
2917
|
mode?: "optional" | "required" | undefined;
|
|
2910
2918
|
write?: boolean | undefined;
|
|
2911
2919
|
}>>;
|
|
2920
|
+
/** `required`: only a signed-in user reaches the route; others are sent to sign in. */
|
|
2921
|
+
auth: z.ZodOptional<z.ZodEnum<["required"]>>;
|
|
2912
2922
|
flash: z.ZodOptional<z.ZodObject<{
|
|
2913
2923
|
consume: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2914
2924
|
publish: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -3612,6 +3622,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
3612
3622
|
mode?: "optional" | "required" | undefined;
|
|
3613
3623
|
write?: boolean | undefined;
|
|
3614
3624
|
} | undefined;
|
|
3625
|
+
auth?: "required" | undefined;
|
|
3615
3626
|
flash?: {
|
|
3616
3627
|
consume?: string[] | undefined;
|
|
3617
3628
|
publish?: {
|
|
@@ -3775,6 +3786,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
3775
3786
|
mode?: "optional" | "required" | undefined;
|
|
3776
3787
|
write?: boolean | undefined;
|
|
3777
3788
|
} | undefined;
|
|
3789
|
+
auth?: "required" | undefined;
|
|
3778
3790
|
flash?: {
|
|
3779
3791
|
consume?: string[] | undefined;
|
|
3780
3792
|
publish?: {
|
|
@@ -3931,6 +3943,8 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
3931
3943
|
summary: z.ZodOptional<z.ZodString>;
|
|
3932
3944
|
description: z.ZodOptional<z.ZodString>;
|
|
3933
3945
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3946
|
+
/** `required`: only a signed-in user sees the page; others are sent to sign in. */
|
|
3947
|
+
auth: z.ZodOptional<z.ZodEnum<["required"]>>;
|
|
3934
3948
|
params: z.ZodOptional<z.ZodObject<{
|
|
3935
3949
|
kind: z.ZodDefault<z.ZodEnum<["zod", "json-schema", "ts-rest"]>>;
|
|
3936
3950
|
name: z.ZodString;
|
|
@@ -3973,6 +3987,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
3973
3987
|
summary?: string | undefined;
|
|
3974
3988
|
description?: string | undefined;
|
|
3975
3989
|
tags?: string[] | undefined;
|
|
3990
|
+
auth?: "required" | undefined;
|
|
3976
3991
|
params?: {
|
|
3977
3992
|
kind: "json-schema" | "ts-rest" | "zod";
|
|
3978
3993
|
name: string;
|
|
@@ -3995,6 +4010,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
3995
4010
|
summary?: string | undefined;
|
|
3996
4011
|
description?: string | undefined;
|
|
3997
4012
|
tags?: string[] | undefined;
|
|
4013
|
+
auth?: "required" | undefined;
|
|
3998
4014
|
params?: {
|
|
3999
4015
|
kind?: "json-schema" | "ts-rest" | "zod" | undefined;
|
|
4000
4016
|
name: string;
|
|
@@ -4101,6 +4117,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
4101
4117
|
mode?: "optional" | "required" | undefined;
|
|
4102
4118
|
write?: boolean | undefined;
|
|
4103
4119
|
} | undefined;
|
|
4120
|
+
auth?: "required" | undefined;
|
|
4104
4121
|
flash?: {
|
|
4105
4122
|
consume?: string[] | undefined;
|
|
4106
4123
|
publish?: {
|
|
@@ -4257,6 +4274,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
4257
4274
|
summary?: string | undefined;
|
|
4258
4275
|
description?: string | undefined;
|
|
4259
4276
|
tags?: string[] | undefined;
|
|
4277
|
+
auth?: "required" | undefined;
|
|
4260
4278
|
params?: {
|
|
4261
4279
|
kind: "json-schema" | "ts-rest" | "zod";
|
|
4262
4280
|
name: string;
|
|
@@ -4323,6 +4341,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
4323
4341
|
mode?: "optional" | "required" | undefined;
|
|
4324
4342
|
write?: boolean | undefined;
|
|
4325
4343
|
} | undefined;
|
|
4344
|
+
auth?: "required" | undefined;
|
|
4326
4345
|
flash?: {
|
|
4327
4346
|
consume?: string[] | undefined;
|
|
4328
4347
|
publish?: {
|
|
@@ -4479,6 +4498,7 @@ export declare const moduleManifestSchema: z.ZodObject<{
|
|
|
4479
4498
|
summary?: string | undefined;
|
|
4480
4499
|
description?: string | undefined;
|
|
4481
4500
|
tags?: string[] | undefined;
|
|
4501
|
+
auth?: "required" | undefined;
|
|
4482
4502
|
params?: {
|
|
4483
4503
|
kind?: "json-schema" | "ts-rest" | "zod" | undefined;
|
|
4484
4504
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -159,6 +159,8 @@ export const routeDefinitionSchema = z.object({
|
|
|
159
159
|
interaction: routeInteractionKindSchema.optional(),
|
|
160
160
|
requestHooks: z.array(requestHookReferenceSchema).optional(),
|
|
161
161
|
session: routeSessionSchema.optional(),
|
|
162
|
+
/** `required`: only a signed-in user reaches the route; others are sent to sign in. */
|
|
163
|
+
auth: z.enum(['required']).optional(),
|
|
162
164
|
flash: routeFlashSchema.optional(),
|
|
163
165
|
form: routeFormSchema.optional(),
|
|
164
166
|
fragment: routeFragmentSchema.optional(),
|
|
@@ -180,6 +182,8 @@ export const viewDefinitionSchema = z.object({
|
|
|
180
182
|
summary: z.string().optional(),
|
|
181
183
|
description: z.string().optional(),
|
|
182
184
|
tags: z.array(z.string()).optional(),
|
|
185
|
+
/** `required`: only a signed-in user sees the page; others are sent to sign in. */
|
|
186
|
+
auth: z.enum(['required']).optional(),
|
|
183
187
|
params: schemaReferenceSchema.optional(),
|
|
184
188
|
data: schemaReferenceSchema.optional(),
|
|
185
189
|
renderMode: z.enum(['ssg', 'ssr', 'spa']).optional(),
|
package/dist/render-execute.js
CHANGED
|
@@ -73,6 +73,14 @@ function run(nodes, data, scopes, options, out) {
|
|
|
73
73
|
}
|
|
74
74
|
case 'attr': {
|
|
75
75
|
const value = read(node.path, data, scopes);
|
|
76
|
+
if (node.json) {
|
|
77
|
+
// An island's props: the value as JSON, escaped like any attribute.
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
const json = toJson(value, node.loc, `data-props="${node.path.source}"`);
|
|
80
|
+
out.push(` ${node.name}="${escapeAttribute(json)}"`);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
76
84
|
// ARIA states are the words "true" and "false", not an attribute's presence.
|
|
77
85
|
if (typeof value === 'boolean' && ARIA_TRUE_FALSE.has(node.name.toLowerCase())) {
|
|
78
86
|
out.push(` ${node.name}="${value}"`);
|
|
@@ -133,6 +141,19 @@ function toText(value, loc, label) {
|
|
|
133
141
|
}
|
|
134
142
|
throw new RenderProgramError(loc, `${label} needs a string or number, got ${describe(value)}`);
|
|
135
143
|
}
|
|
144
|
+
function toJson(value, loc, label) {
|
|
145
|
+
let json;
|
|
146
|
+
try {
|
|
147
|
+
json = JSON.stringify(value);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw new RenderProgramError(loc, `${label} needs JSON data: ${error.message}`);
|
|
151
|
+
}
|
|
152
|
+
if (json === undefined) {
|
|
153
|
+
throw new RenderProgramError(loc, `${label} needs JSON data, got ${describe(value)}`);
|
|
154
|
+
}
|
|
155
|
+
return json;
|
|
156
|
+
}
|
|
136
157
|
/** Every URL in the value is checked: `srcset` lists candidates, `ping` lists URLs. */
|
|
137
158
|
function safeAttributeUrl(name, value) {
|
|
138
159
|
if (name === 'srcset' || name === 'imagesrcset') {
|
package/dist/render-program.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export type RenderNode = string | {
|
|
|
33
33
|
readonly op: 'attr';
|
|
34
34
|
readonly name: string;
|
|
35
35
|
readonly url: boolean;
|
|
36
|
+
/** Writes the value as JSON (an island's `data-props`) rather than as text. */
|
|
37
|
+
readonly json?: boolean;
|
|
36
38
|
readonly path: RenderPath;
|
|
37
39
|
readonly loc: RenderSourceLocation;
|
|
38
40
|
} | {
|
|
@@ -52,19 +54,19 @@ export type RenderNode = string | {
|
|
|
52
54
|
};
|
|
53
55
|
export declare const renderNodeSchema: z.ZodType<RenderNode>;
|
|
54
56
|
export declare const renderProgramSchema: z.ZodObject<{
|
|
55
|
-
version: z.ZodLiteral<
|
|
57
|
+
version: z.ZodLiteral<2>;
|
|
56
58
|
page: z.ZodString;
|
|
57
59
|
source: z.ZodString;
|
|
58
60
|
bindings: z.ZodNumber;
|
|
59
61
|
nodes: z.ZodArray<z.ZodType<RenderNode, z.ZodTypeDef, RenderNode>, "many">;
|
|
60
62
|
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
version:
|
|
63
|
+
version: 2;
|
|
62
64
|
page: string;
|
|
63
65
|
source: string;
|
|
64
66
|
bindings: number;
|
|
65
67
|
nodes: RenderNode[];
|
|
66
68
|
}, {
|
|
67
|
-
version:
|
|
69
|
+
version: 2;
|
|
68
70
|
page: string;
|
|
69
71
|
source: string;
|
|
70
72
|
bindings: number;
|
package/dist/render-program.js
CHANGED
package/dist/render-version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const RENDER_PROGRAM_VERSION =
|
|
1
|
+
export declare const RENDER_PROGRAM_VERSION = 2;
|
|
2
2
|
export declare const RENDER_PROGRAM_FILE = "index.program.json";
|
package/dist/render-version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const RENDER_PROGRAM_VERSION =
|
|
1
|
+
export const RENDER_PROGRAM_VERSION = 2;
|
|
2
2
|
export const RENDER_PROGRAM_FILE = 'index.program.json';
|
package/package.json
CHANGED
|
@@ -146,6 +146,12 @@
|
|
|
146
146
|
},
|
|
147
147
|
"additionalProperties": false
|
|
148
148
|
},
|
|
149
|
+
"auth": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"enum": [
|
|
152
|
+
"required"
|
|
153
|
+
]
|
|
154
|
+
},
|
|
149
155
|
"flash": {
|
|
150
156
|
"type": "object",
|
|
151
157
|
"properties": {
|
|
@@ -479,6 +485,12 @@
|
|
|
479
485
|
"type": "string"
|
|
480
486
|
}
|
|
481
487
|
},
|
|
488
|
+
"auth": {
|
|
489
|
+
"type": "string",
|
|
490
|
+
"enum": [
|
|
491
|
+
"required"
|
|
492
|
+
]
|
|
493
|
+
},
|
|
482
494
|
"params": {
|
|
483
495
|
"$ref": "#/definitions/module-manifest/properties/routes/items/properties/input/properties/params"
|
|
484
496
|
},
|