nextjs-cms 0.9.41 → 0.10.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/api/actions/pages.d.ts +4 -3
- package/dist/api/actions/pages.d.ts.map +1 -1
- package/dist/api/actions/pages.js +11 -4
- package/dist/api/trpc/root.d.ts +4 -3
- package/dist/api/trpc/root.d.ts.map +1 -1
- package/dist/api/trpc/routers/config.d.ts.map +1 -1
- package/dist/api/trpc/routers/hasItemsSection.d.ts +1 -0
- package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/trpc/routers/navigation.d.ts +3 -3
- package/dist/api/trpc/server.d.ts +12 -9
- package/dist/api/trpc/server.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +19 -0
- package/dist/core/config/config-loader.d.ts +25 -6
- package/dist/core/config/config-loader.d.ts.map +1 -1
- package/dist/core/config/config-loader.js +9 -13
- package/dist/core/fields/photo.d.ts +80 -8
- package/dist/core/fields/photo.d.ts.map +1 -1
- package/dist/core/fields/photo.js +120 -31
- package/dist/core/fields/richText.d.ts +162 -42
- package/dist/core/fields/richText.d.ts.map +1 -1
- package/dist/core/fields/richText.js +135 -35
- package/dist/core/fields/select.d.ts +1 -1
- package/dist/core/fields/select.d.ts.map +1 -1
- package/dist/core/fields/select.js +18 -2
- package/dist/core/fields/selectMultiple.d.ts.map +1 -1
- package/dist/core/fields/selectMultiple.js +9 -0
- package/dist/core/helpers/background.d.ts +18 -0
- package/dist/core/helpers/background.d.ts.map +1 -0
- package/dist/core/helpers/background.js +18 -0
- package/dist/core/helpers/index.d.ts +5 -1
- package/dist/core/helpers/index.d.ts.map +1 -1
- package/dist/core/helpers/index.js +3 -1
- package/dist/core/helpers/watermark.d.ts +96 -0
- package/dist/core/helpers/watermark.d.ts.map +1 -0
- package/dist/core/helpers/watermark.js +61 -0
- package/dist/core/sections/category.d.ts +78 -42
- package/dist/core/sections/category.d.ts.map +1 -1
- package/dist/core/sections/hasItems.d.ts +132 -48
- package/dist/core/sections/hasItems.d.ts.map +1 -1
- package/dist/core/sections/section.d.ts +62 -25
- package/dist/core/sections/section.d.ts.map +1 -1
- package/dist/core/sections/section.js +2 -2
- package/dist/core/sections/simple.d.ts +44 -8
- package/dist/core/sections/simple.d.ts.map +1 -1
- package/dist/core/submit/gallery-order.d.ts +34 -0
- package/dist/core/submit/gallery-order.d.ts.map +1 -0
- package/dist/core/submit/gallery-order.js +50 -0
- package/dist/core/submit/submit.d.ts +8 -0
- package/dist/core/submit/submit.d.ts.map +1 -1
- package/dist/core/submit/submit.js +63 -3
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/translations/client.d.ts +4 -4
- package/dist/translations/server.d.ts +4 -4
- package/package.json +3 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Padding colour schema — shared by every field that resizes images, so the shape stays
|
|
4
|
+
* identical across them. Only meaningful alongside `fit: 'contain'`, where the image is padded
|
|
5
|
+
* out to the full box; fields fall back to `media.images.background` from the CMS config when
|
|
6
|
+
* it is omitted.
|
|
7
|
+
*
|
|
8
|
+
* `alpha: 0` only survives in formats with an alpha channel (webp, png). Encoding transparent
|
|
9
|
+
* padding to jpeg flattens it to black, so pick an opaque colour for jpeg output.
|
|
10
|
+
*/
|
|
11
|
+
export const backgroundSchema = z
|
|
12
|
+
.strictObject({
|
|
13
|
+
r: z.number().min(0).max(255).describe('Red channel (0-255)'),
|
|
14
|
+
g: z.number().min(0).max(255).describe('Green channel (0-255)'),
|
|
15
|
+
b: z.number().min(0).max(255).describe('Blue channel (0-255)'),
|
|
16
|
+
alpha: z.number().min(0).max(1).describe('Alpha channel (0-1)'),
|
|
17
|
+
})
|
|
18
|
+
.describe('Background color for image padding (used with fit: contain)');
|
|
@@ -2,5 +2,9 @@ export { is } from './entity.js';
|
|
|
2
2
|
export { entityKind } from './entity.js';
|
|
3
3
|
export type { LZEntity } from './entity.js';
|
|
4
4
|
export { hasOwnEntityKind } from './entity.js';
|
|
5
|
-
export { evaluateConditionalRule, evaluateConditionalRuleGroup, normalizeConditionalRules } from './conditional-rules.js';
|
|
5
|
+
export { evaluateConditionalRule, evaluateConditionalRuleGroup, normalizeConditionalRules, } from './conditional-rules.js';
|
|
6
|
+
export { backgroundSchema } from './background.js';
|
|
7
|
+
export type { Background } from './background.js';
|
|
8
|
+
export { watermarkPositionEnum, watermarkObjectSchema, watermarkConfigSchema, WATERMARK_DEFAULTS, resolveWatermark, } from './watermark.js';
|
|
9
|
+
export type { WatermarkPosition, WatermarkObject, WatermarkConfig, ResolvedWatermark } from './watermark.js';
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAI9C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAI9C,OAAO,EACH,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,GAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -4,4 +4,6 @@ export { hasOwnEntityKind } from './entity.js';
|
|
|
4
4
|
// Note: the `and` / `or` authoring wrappers are re-exported from `core/fields` (alongside the field
|
|
5
5
|
// factories that section configs use), so they are intentionally not re-exported here to avoid a
|
|
6
6
|
// duplicate export when `core/index` merges both barrels.
|
|
7
|
-
export { evaluateConditionalRule, evaluateConditionalRuleGroup, normalizeConditionalRules } from './conditional-rules.js';
|
|
7
|
+
export { evaluateConditionalRule, evaluateConditionalRuleGroup, normalizeConditionalRules, } from './conditional-rules.js';
|
|
8
|
+
export { backgroundSchema } from './background.js';
|
|
9
|
+
export { watermarkPositionEnum, watermarkObjectSchema, watermarkConfigSchema, WATERMARK_DEFAULTS, resolveWatermark, } from './watermark.js';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const watermarkPositionEnum: z.ZodEnum<{
|
|
3
|
+
"top-left": "top-left";
|
|
4
|
+
top: "top";
|
|
5
|
+
"top-right": "top-right";
|
|
6
|
+
left: "left";
|
|
7
|
+
center: "center";
|
|
8
|
+
right: "right";
|
|
9
|
+
"bottom-left": "bottom-left";
|
|
10
|
+
bottom: "bottom";
|
|
11
|
+
"bottom-right": "bottom-right";
|
|
12
|
+
}>;
|
|
13
|
+
export type WatermarkPosition = z.infer<typeof watermarkPositionEnum>;
|
|
14
|
+
/**
|
|
15
|
+
* Watermark object schema — shared by the global, gallery, and field config sites.
|
|
16
|
+
* `imagePath` is required; everything else falls back to WATERMARK_DEFAULTS.
|
|
17
|
+
*/
|
|
18
|
+
export declare const watermarkObjectSchema: z.ZodObject<{
|
|
19
|
+
/** Path to the watermark image, resolved relative to process.cwd() unless absolute. PNG w/ alpha recommended. */
|
|
20
|
+
imagePath: z.ZodString;
|
|
21
|
+
/** Placement, mapped to a sharp gravity. Default 'center'. */
|
|
22
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
"top-left": "top-left";
|
|
24
|
+
top: "top";
|
|
25
|
+
"top-right": "top-right";
|
|
26
|
+
left: "left";
|
|
27
|
+
center: "center";
|
|
28
|
+
right: "right";
|
|
29
|
+
"bottom-left": "bottom-left";
|
|
30
|
+
bottom: "bottom";
|
|
31
|
+
"bottom-right": "bottom-right";
|
|
32
|
+
}>>;
|
|
33
|
+
/** Watermark width as a fraction (0–1) of the output image width. Default 0.2. */
|
|
34
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
/** Overlay opacity (0–1). Default 0.5. */
|
|
36
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
/** Inset in px from the chosen edge/corner. Ignored for 'center' and when tiling. Default 0. */
|
|
38
|
+
margin: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
/** Repeat the mark across the whole image (ignores position + margin). Default false. */
|
|
40
|
+
tile: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
/** Also composite the mark onto the generated thumbnail. Default false. */
|
|
42
|
+
applyToThumbnail: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export declare const watermarkConfigSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
|
|
45
|
+
/** Path to the watermark image, resolved relative to process.cwd() unless absolute. PNG w/ alpha recommended. */
|
|
46
|
+
imagePath: z.ZodString;
|
|
47
|
+
/** Placement, mapped to a sharp gravity. Default 'center'. */
|
|
48
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
"top-left": "top-left";
|
|
50
|
+
top: "top";
|
|
51
|
+
"top-right": "top-right";
|
|
52
|
+
left: "left";
|
|
53
|
+
center: "center";
|
|
54
|
+
right: "right";
|
|
55
|
+
"bottom-left": "bottom-left";
|
|
56
|
+
bottom: "bottom";
|
|
57
|
+
"bottom-right": "bottom-right";
|
|
58
|
+
}>>;
|
|
59
|
+
/** Watermark width as a fraction (0–1) of the output image width. Default 0.2. */
|
|
60
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
/** Overlay opacity (0–1). Default 0.5. */
|
|
62
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
/** Inset in px from the chosen edge/corner. Ignored for 'center' and when tiling. Default 0. */
|
|
64
|
+
margin: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
/** Repeat the mark across the whole image (ignores position + margin). Default false. */
|
|
66
|
+
tile: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
/** Also composite the mark onto the generated thumbnail. Default false. */
|
|
68
|
+
applyToThumbnail: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
}, z.core.$strict>]>;
|
|
70
|
+
export type WatermarkObject = z.infer<typeof watermarkObjectSchema>;
|
|
71
|
+
export type WatermarkConfig = z.infer<typeof watermarkConfigSchema>;
|
|
72
|
+
export type ResolvedWatermark = {
|
|
73
|
+
imagePath: string;
|
|
74
|
+
position: WatermarkPosition;
|
|
75
|
+
size: number;
|
|
76
|
+
opacity: number;
|
|
77
|
+
margin: number;
|
|
78
|
+
tile: boolean;
|
|
79
|
+
applyToThumbnail: boolean;
|
|
80
|
+
};
|
|
81
|
+
export declare const WATERMARK_DEFAULTS: {
|
|
82
|
+
position: WatermarkPosition;
|
|
83
|
+
size: number;
|
|
84
|
+
opacity: number;
|
|
85
|
+
margin: number;
|
|
86
|
+
tile: boolean;
|
|
87
|
+
applyToThumbnail: boolean;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Resolve a watermark config for one level against the global config.
|
|
91
|
+
* - undefined -> inherit `global`
|
|
92
|
+
* - false -> off (returns null)
|
|
93
|
+
* - object -> full replacement (imagePath required)
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveWatermark(level: WatermarkConfig | undefined, global: WatermarkConfig): ResolvedWatermark | null;
|
|
96
|
+
//# sourceMappingURL=watermark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/watermark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,qBAAqB;;;;;;;;;;EAUhC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAC9B,iHAAiH;;IAEjH,8DAA8D;;;;;;;;;;;;IAE9D,kFAAkF;;IAElF,0CAA0C;;IAE1C,gGAAgG;;IAEhG,yFAAyF;;IAEzF,2EAA2E;;kBAE7E,CAAA;AAEF,eAAO,MAAM,qBAAqB;IAhB9B,iHAAiH;;IAEjH,8DAA8D;;;;;;;;;;;;IAE9D,kFAAkF;;IAElF,0CAA0C;;IAE1C,gGAAgG;;IAEhG,yFAAyF;;IAEzF,2EAA2E;;oBAIQ,CAAA;AAEvF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACnE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,gBAAgB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB;cACL,iBAAiB;;;;;;CAM1C,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,MAAM,EAAE,eAAe,GACxB,iBAAiB,GAAG,IAAI,CAY1B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export const watermarkPositionEnum = z.enum([
|
|
3
|
+
'top-left',
|
|
4
|
+
'top',
|
|
5
|
+
'top-right',
|
|
6
|
+
'left',
|
|
7
|
+
'center',
|
|
8
|
+
'right',
|
|
9
|
+
'bottom-left',
|
|
10
|
+
'bottom',
|
|
11
|
+
'bottom-right',
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* Watermark object schema — shared by the global, gallery, and field config sites.
|
|
15
|
+
* `imagePath` is required; everything else falls back to WATERMARK_DEFAULTS.
|
|
16
|
+
*/
|
|
17
|
+
export const watermarkObjectSchema = z.strictObject({
|
|
18
|
+
/** Path to the watermark image, resolved relative to process.cwd() unless absolute. PNG w/ alpha recommended. */
|
|
19
|
+
imagePath: z.string(),
|
|
20
|
+
/** Placement, mapped to a sharp gravity. Default 'center'. */
|
|
21
|
+
position: watermarkPositionEnum.optional(),
|
|
22
|
+
/** Watermark width as a fraction (0–1) of the output image width. Default 0.2. */
|
|
23
|
+
size: z.number().min(0).max(1).optional(),
|
|
24
|
+
/** Overlay opacity (0–1). Default 0.5. */
|
|
25
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
26
|
+
/** Inset in px from the chosen edge/corner. Ignored for 'center' and when tiling. Default 0. */
|
|
27
|
+
margin: z.number().min(0).optional(),
|
|
28
|
+
/** Repeat the mark across the whole image (ignores position + margin). Default false. */
|
|
29
|
+
tile: z.boolean().optional(),
|
|
30
|
+
/** Also composite the mark onto the generated thumbnail. Default false. */
|
|
31
|
+
applyToThumbnail: z.boolean().optional(),
|
|
32
|
+
});
|
|
33
|
+
export const watermarkConfigSchema = z.union([z.literal(false), watermarkObjectSchema]);
|
|
34
|
+
export const WATERMARK_DEFAULTS = {
|
|
35
|
+
position: 'center',
|
|
36
|
+
size: 0.2,
|
|
37
|
+
opacity: 0.5,
|
|
38
|
+
margin: 0,
|
|
39
|
+
tile: false,
|
|
40
|
+
applyToThumbnail: false,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a watermark config for one level against the global config.
|
|
44
|
+
* - undefined -> inherit `global`
|
|
45
|
+
* - false -> off (returns null)
|
|
46
|
+
* - object -> full replacement (imagePath required)
|
|
47
|
+
*/
|
|
48
|
+
export function resolveWatermark(level, global) {
|
|
49
|
+
const chosen = level ?? global;
|
|
50
|
+
if (chosen === false)
|
|
51
|
+
return null;
|
|
52
|
+
return {
|
|
53
|
+
imagePath: chosen.imagePath,
|
|
54
|
+
position: chosen.position ?? WATERMARK_DEFAULTS.position,
|
|
55
|
+
size: chosen.size ?? WATERMARK_DEFAULTS.size,
|
|
56
|
+
opacity: chosen.opacity ?? WATERMARK_DEFAULTS.opacity,
|
|
57
|
+
margin: chosen.margin ?? WATERMARK_DEFAULTS.margin,
|
|
58
|
+
tile: chosen.tile ?? WATERMARK_DEFAULTS.tile,
|
|
59
|
+
applyToThumbnail: chosen.applyToThumbnail ?? WATERMARK_DEFAULTS.applyToThumbnail,
|
|
60
|
+
};
|
|
61
|
+
}
|