@opencloudcms/schema 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +4 -2
- package/dist/__typecheck__/define-messages.d.ts +20 -0
- package/dist/__typecheck__/define-messages.js +16 -0
- package/dist/__typecheck__/define-messages.js.map +1 -0
- package/dist/actions.d.ts +86 -0
- package/dist/actions.js +158 -0
- package/dist/actions.js.map +1 -0
- package/dist/composed-block.d.ts +205 -0
- package/dist/composed-block.js +897 -0
- package/dist/composed-block.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/define.d.ts +31 -0
- package/dist/define.js +113 -0
- package/dist/define.js.map +1 -0
- package/dist/form-controls.d.ts +18 -0
- package/dist/form-controls.js +52 -0
- package/dist/form-controls.js.map +1 -0
- package/dist/groups.d.ts +12 -0
- package/dist/groups.js +55 -0
- package/dist/groups.js.map +1 -0
- package/dist/i18n.d.ts +43 -0
- package/dist/i18n.js +93 -0
- package/dist/i18n.js.map +1 -0
- package/dist/icons.d.ts +3 -0
- package/dist/icons.js +28 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/locales.d.ts +11 -0
- package/dist/locales.js +38 -0
- package/dist/locales.js.map +1 -0
- package/dist/pages.d.ts +78 -0
- package/dist/pages.js +139 -0
- package/dist/pages.js.map +1 -0
- package/dist/permissions.d.ts +7 -0
- package/dist/permissions.js +29 -0
- package/dist/permissions.js.map +1 -0
- package/dist/physical.d.ts +72 -0
- package/dist/physical.js +195 -0
- package/dist/physical.js.map +1 -0
- package/dist/search.d.ts +5 -0
- package/dist/search.js +15 -0
- package/dist/search.js.map +1 -0
- package/dist/slug.d.ts +65 -0
- package/dist/slug.js +238 -0
- package/dist/slug.js.map +1 -0
- package/dist/style.d.ts +71 -0
- package/dist/style.js +211 -0
- package/dist/style.js.map +1 -0
- package/dist/theme.d.ts +15 -0
- package/dist/theme.js +64 -0
- package/dist/theme.js.map +1 -0
- package/dist/types.d.ts +140 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +11 -0
- package/dist/validate.js +191 -0
- package/dist/validate.js.map +1 -0
- package/dist/validator.d.ts +25 -0
- package/dist/validator.js +80 -0
- package/dist/validator.js.map +1 -0
- package/package.json +30 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ánh Nguyễn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @opencloudcms/schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Content type definition DSL, field registry and physical storage mapping for OpenCloudCMS.
|
|
4
|
+
|
|
5
|
+
Part of [OpenCloudCMS](https://github.com/anhdev97/Open-CMS): see the [main README](https://github.com/anhdev97/Open-CMS#readme) for setup and documentation.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const ok: {
|
|
2
|
+
'en-US': {
|
|
3
|
+
hello: string;
|
|
4
|
+
nested: {
|
|
5
|
+
a: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
} & Partial<Record<"vi-VN" | "fr-FR" | "id-ID", {
|
|
9
|
+
hello?: string | undefined;
|
|
10
|
+
nested?: {
|
|
11
|
+
a?: string | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}>>;
|
|
14
|
+
export declare const extraKey: {
|
|
15
|
+
'en-US': {
|
|
16
|
+
hello: string;
|
|
17
|
+
};
|
|
18
|
+
} & Partial<Record<"vi-VN" | "fr-FR" | "id-ID", {
|
|
19
|
+
hello?: string | undefined;
|
|
20
|
+
}>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extraKey = exports.ok = void 0;
|
|
4
|
+
// Compile-time guard for defineMessages (checked by `tsc --noEmit`; not exported from index).
|
|
5
|
+
const i18n_1 = require("../i18n");
|
|
6
|
+
exports.ok = (0, i18n_1.defineMessages)({
|
|
7
|
+
'en-US': { hello: 'Hello {name}', nested: { a: 'A' } },
|
|
8
|
+
'vi-VN': { hello: 'Xin chào {name}', nested: { a: 'Một' } },
|
|
9
|
+
'fr-FR': { hello: 'Bonjour {name}' },
|
|
10
|
+
});
|
|
11
|
+
exports.extraKey = (0, i18n_1.defineMessages)({
|
|
12
|
+
'en-US': { hello: 'Hello' },
|
|
13
|
+
// @ts-expect-error key missing from en-US
|
|
14
|
+
'vi-VN': { hello: 'Xin chào', bogus: 'x' },
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=define-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-messages.js","sourceRoot":"","sources":["../../src/__typecheck__/define-messages.ts"],"names":[],"mappings":";;;AAAA,8FAA8F;AAC9F,kCAAyC;AAE5B,QAAA,EAAE,GAAG,IAAA,qBAAc,EAAC;IAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;IACtD,OAAO,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;IAC3D,OAAO,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;CACrC,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG,IAAA,qBAAc,EAAC;IACrC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;IAC3B,0CAA0C;IAC1C,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;CAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ComposedIssue } from './composed-block';
|
|
2
|
+
/** Region, overlay and overlay-action target names. */
|
|
3
|
+
export declare const OVERLAY_NAME_RE: RegExp;
|
|
4
|
+
/** `anchorId` prop values and scroll-action targets (an element id on the page). */
|
|
5
|
+
export declare const ANCHOR_ID_RE: RegExp;
|
|
6
|
+
export type ButtonAction = {
|
|
7
|
+
type: 'overlay';
|
|
8
|
+
op: 'open' | 'close' | 'toggle';
|
|
9
|
+
target?: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'scroll';
|
|
12
|
+
target: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'run';
|
|
15
|
+
name: string;
|
|
16
|
+
params?: Record<string, string | number | boolean | null>;
|
|
17
|
+
};
|
|
18
|
+
/** Server action names (same pattern the core registry enforces). */
|
|
19
|
+
export declare const ACTION_NAME_RE: RegExp;
|
|
20
|
+
/** Built-in client-side actions: valid `run` names, never in the server manifest, take no params. */
|
|
21
|
+
export declare const BUILTIN_ACTIONS: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Manifest of server actions (`GET /api/actions/manifest`). Structurally compatible with core's `ParamDescriptor`;
|
|
24
|
+
* defined here because schema must not import core.
|
|
25
|
+
*/
|
|
26
|
+
export type ManifestParam = {
|
|
27
|
+
name: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
label?: unknown;
|
|
30
|
+
} & ({
|
|
31
|
+
kind: 'text';
|
|
32
|
+
max?: number;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'number';
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
default?: number;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'boolean';
|
|
40
|
+
default?: boolean;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'select';
|
|
43
|
+
options: string[];
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'entryRef';
|
|
46
|
+
apiId: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'overlay';
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'url';
|
|
51
|
+
});
|
|
52
|
+
export type ActionManifest = {
|
|
53
|
+
actions: {
|
|
54
|
+
name: string;
|
|
55
|
+
label?: unknown;
|
|
56
|
+
params: ManifestParam[];
|
|
57
|
+
hasInput?: boolean;
|
|
58
|
+
requireCustomer?: boolean;
|
|
59
|
+
previewSafe?: boolean;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Stored value of an `entryRef` param bound to the current entry (the block's entry or the CollectionList item where
|
|
64
|
+
* the trigger sits, or a detail template's entry): replaced by that entry's `documentId` at render
|
|
65
|
+
* (`resolveActionEntry`), so the browser always sends an id.
|
|
66
|
+
*/
|
|
67
|
+
export declare const CURRENT_ENTRY = "@entry";
|
|
68
|
+
/** `p.url` rule (same as core `isSafeUrlParam`): a same-site path (no `//`, `\`, control characters) or an `https:` URL. */
|
|
69
|
+
export declare function isSafeUrlParam(v: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* `action` with its `CURRENT_ENTRY` params replaced by `entryId` (dropped when there is none, so the server reports a
|
|
72
|
+
* required one). Other actions, and run actions without the binding, are returned as they are.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveActionEntry<A extends ButtonAction | undefined | null>(action: A, entryId: string | null | undefined): A;
|
|
75
|
+
export interface ButtonActionCheck {
|
|
76
|
+
/**
|
|
77
|
+
* Where the trigger sits, when known: the content type of its current entry (`null`: none). A `CURRENT_ENTRY`
|
|
78
|
+
* param is then valid only for an `entryRef` of that type. Absent: not checked.
|
|
79
|
+
*/
|
|
80
|
+
entry?: {
|
|
81
|
+
apiId: string | null;
|
|
82
|
+
};
|
|
83
|
+
/** Leave out missing required params (a composed block's save: they are reported where it runs). */
|
|
84
|
+
skipRequired?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export declare function validateButtonAction(v: unknown, path: (string | number)[], manifest?: ActionManifest, check?: ButtonActionCheck): ComposedIssue[];
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURRENT_ENTRY = exports.BUILTIN_ACTIONS = exports.ACTION_NAME_RE = exports.ANCHOR_ID_RE = exports.OVERLAY_NAME_RE = void 0;
|
|
4
|
+
exports.isSafeUrlParam = isSafeUrlParam;
|
|
5
|
+
exports.resolveActionEntry = resolveActionEntry;
|
|
6
|
+
exports.validateButtonAction = validateButtonAction;
|
|
7
|
+
/** Region, overlay and overlay-action target names. */
|
|
8
|
+
exports.OVERLAY_NAME_RE = /^[a-z][a-z0-9-]{0,31}$/;
|
|
9
|
+
/** `anchorId` prop values and scroll-action targets (an element id on the page). */
|
|
10
|
+
exports.ANCHOR_ID_RE = /^[A-Za-z][\w-]{0,63}$/;
|
|
11
|
+
/** Server action names (same pattern the core registry enforces). */
|
|
12
|
+
exports.ACTION_NAME_RE = /^[a-z][a-z0-9-]{1,47}$/;
|
|
13
|
+
/** Built-in client-side actions: valid `run` names, never in the server manifest, take no params. */
|
|
14
|
+
exports.BUILTIN_ACTIONS = ['sign-in', 'sign-out', 'navigate-back'];
|
|
15
|
+
const OPS = ['open', 'close', 'toggle'];
|
|
16
|
+
/**
|
|
17
|
+
* Stored value of an `entryRef` param bound to the current entry (the block's entry or the CollectionList item where
|
|
18
|
+
* the trigger sits, or a detail template's entry): replaced by that entry's `documentId` at render
|
|
19
|
+
* (`resolveActionEntry`), so the browser always sends an id.
|
|
20
|
+
*/
|
|
21
|
+
exports.CURRENT_ENTRY = '@entry';
|
|
22
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
23
|
+
// eslint-disable-next-line no-control-regex
|
|
24
|
+
const CONTROL_RE = /[\u0000-\u001f\u007f]/;
|
|
25
|
+
/** `p.url` rule (same as core `isSafeUrlParam`): a same-site path (no `//`, `\`, control characters) or an `https:` URL. */
|
|
26
|
+
function isSafeUrlParam(v) {
|
|
27
|
+
if (CONTROL_RE.test(v) || v.length > 2048)
|
|
28
|
+
return false;
|
|
29
|
+
if (v.startsWith('/'))
|
|
30
|
+
return !v.startsWith('//') && !v.includes('\\');
|
|
31
|
+
try {
|
|
32
|
+
const u = new URL(v);
|
|
33
|
+
return u.protocol === 'https:' && !!u.hostname && !v.includes('\\');
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function paramTypeIssue(p, v) {
|
|
40
|
+
switch (p.kind) {
|
|
41
|
+
case 'number':
|
|
42
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
43
|
+
return 'must be a number';
|
|
44
|
+
if (p.min !== undefined && v < p.min)
|
|
45
|
+
return `must be at least ${p.min}`;
|
|
46
|
+
if (p.max !== undefined && v > p.max)
|
|
47
|
+
return `must be at most ${p.max}`;
|
|
48
|
+
return undefined;
|
|
49
|
+
case 'boolean': return typeof v === 'boolean' ? undefined : 'must be a boolean';
|
|
50
|
+
case 'select': return typeof v === 'string' && p.options.includes(v) ? undefined : `must be one of ${p.options.join(', ')}`;
|
|
51
|
+
case 'overlay': return typeof v === 'string' && exports.OVERLAY_NAME_RE.test(v) ? undefined : 'must be an overlay name';
|
|
52
|
+
case 'entryRef': return v === exports.CURRENT_ENTRY || (typeof v === 'string' && UUID_RE.test(v)) ? undefined : 'must be an entry id';
|
|
53
|
+
case 'url': return typeof v === 'string' && isSafeUrlParam(v) ? undefined : 'must be a path or an https URL';
|
|
54
|
+
case 'text':
|
|
55
|
+
if (typeof v !== 'string')
|
|
56
|
+
return 'must be a string';
|
|
57
|
+
return p.max !== undefined && v.length > p.max ? `must be at most ${p.max} characters` : undefined;
|
|
58
|
+
default: return typeof v === 'string' ? undefined : 'must be a string';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `action` with its `CURRENT_ENTRY` params replaced by `entryId` (dropped when there is none, so the server reports a
|
|
63
|
+
* required one). Other actions, and run actions without the binding, are returned as they are.
|
|
64
|
+
*/
|
|
65
|
+
function resolveActionEntry(action, entryId) {
|
|
66
|
+
if (!action || action.type !== 'run' || !action.params)
|
|
67
|
+
return action;
|
|
68
|
+
if (!Object.values(action.params).includes(exports.CURRENT_ENTRY))
|
|
69
|
+
return action;
|
|
70
|
+
const params = {};
|
|
71
|
+
for (const [k, v] of Object.entries(action.params)) {
|
|
72
|
+
if (v !== exports.CURRENT_ENTRY)
|
|
73
|
+
params[k] = v;
|
|
74
|
+
else if (entryId)
|
|
75
|
+
params[k] = entryId;
|
|
76
|
+
}
|
|
77
|
+
return { ...action, params };
|
|
78
|
+
}
|
|
79
|
+
function validateButtonAction(v, path, manifest, check = {}) {
|
|
80
|
+
const issues = [];
|
|
81
|
+
const add = (p, message) => issues.push({ path: p, message });
|
|
82
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
83
|
+
return [{ path, message: 'action must be an object' }];
|
|
84
|
+
const a = v;
|
|
85
|
+
if (a.type === 'overlay') {
|
|
86
|
+
if (typeof a.op !== 'string' || !OPS.includes(a.op))
|
|
87
|
+
add([...path, 'op'], `op must be one of ${OPS.join(', ')}`);
|
|
88
|
+
if (a.target === undefined) {
|
|
89
|
+
if (a.op === 'open' || a.op === 'toggle')
|
|
90
|
+
add([...path, 'target'], `${a.op} requires a target overlay name`);
|
|
91
|
+
}
|
|
92
|
+
else if (typeof a.target !== 'string' || !exports.OVERLAY_NAME_RE.test(a.target)) {
|
|
93
|
+
add([...path, 'target'], 'target must match ^[a-z][a-z0-9-]{0,31}$');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (a.type === 'scroll') {
|
|
97
|
+
if (typeof a.target !== 'string' || !exports.ANCHOR_ID_RE.test(a.target))
|
|
98
|
+
add([...path, 'target'], 'target must match ^[A-Za-z][\\w-]{0,63}$');
|
|
99
|
+
}
|
|
100
|
+
else if (a.type === 'run') {
|
|
101
|
+
const nameOk = typeof a.name === 'string' && exports.ACTION_NAME_RE.test(a.name);
|
|
102
|
+
if (!nameOk)
|
|
103
|
+
add([...path, 'name'], 'name must match ^[a-z][a-z0-9-]{1,47}$');
|
|
104
|
+
const params = a.params;
|
|
105
|
+
let flat = true;
|
|
106
|
+
if (params !== undefined) {
|
|
107
|
+
if (!params || typeof params !== 'object' || Array.isArray(params)) {
|
|
108
|
+
add([...path, 'params'], 'params must be an object');
|
|
109
|
+
flat = false;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
for (const [k, pv] of Object.entries(params)) {
|
|
113
|
+
if (pv !== null && typeof pv !== 'string' && typeof pv !== 'number' && typeof pv !== 'boolean') {
|
|
114
|
+
add([...path, 'params', k], 'param values must be strings, numbers, booleans or null');
|
|
115
|
+
flat = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (manifest && nameOk && flat) {
|
|
121
|
+
const name = a.name;
|
|
122
|
+
const given = (params ?? {});
|
|
123
|
+
const def = manifest.actions.find((x) => x.name === name);
|
|
124
|
+
if (def) {
|
|
125
|
+
for (const p of def.params) {
|
|
126
|
+
const pv = given[p.name];
|
|
127
|
+
if (pv === undefined || pv === null || pv === '') {
|
|
128
|
+
if (p.required && !check.skipRequired)
|
|
129
|
+
add([...path, 'params', p.name], `${p.name} is required`);
|
|
130
|
+
}
|
|
131
|
+
else if (pv === exports.CURRENT_ENTRY && p.kind === 'entryRef' && check.entry && check.entry.apiId !== p.apiId) {
|
|
132
|
+
add([...path, 'params', p.name], `${p.name}: no current ${p.apiId} entry here`);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const m = paramTypeIssue(p, pv);
|
|
136
|
+
if (m)
|
|
137
|
+
add([...path, 'params', p.name], `${p.name} ${m}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const k of Object.keys(given))
|
|
141
|
+
if (!def.params.some((p) => p.name === k))
|
|
142
|
+
add([...path, 'params', k], `unknown param "${k}"`);
|
|
143
|
+
}
|
|
144
|
+
else if (exports.BUILTIN_ACTIONS.includes(name)) {
|
|
145
|
+
for (const k of Object.keys(given))
|
|
146
|
+
add([...path, 'params', k], `${name} takes no params`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
add([...path, 'name'], 'unknown_action');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
add([...path, 'type'], "type must be 'overlay', 'scroll' or 'run'");
|
|
155
|
+
}
|
|
156
|
+
return issues;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=actions.js.map
|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4BAAE,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;oBAC5D,CAAC;gBACH,CAAC;gBACD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;oBAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;wBAAE,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;YACrI,CAAC;iBAAM,IAAI,uBAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;oBAAE,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,kBAAkB,CAAC,CAAC;YAC7F,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,2CAA2C,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { type ActionManifest } from './actions';
|
|
2
|
+
import type { LocalizedText } from './i18n';
|
|
3
|
+
import { type NodeStyle } from './style';
|
|
4
|
+
export type FormControlElement = 'Input' | 'Textarea' | 'Select' | 'Combobox' | 'Radio' | 'Checkbox' | 'Switch';
|
|
5
|
+
export type ComposedElement = 'Box' | 'Stack' | 'Columns' | 'Grid' | 'Card' | 'Slot' | 'Heading' | 'Text' | 'Image' | 'Button' | 'Badge' | 'Price' | 'Date' | 'Divider' | 'Spacer' | 'Region' | 'PageContent' | 'Overlay' | 'Dropdown' | 'Tooltip' | 'Accordion' | 'AccordionItem' | 'Tabs' | 'TabPanel' | 'Carousel' | 'Icon' | 'CollectionList' | 'Form' | FormControlElement;
|
|
6
|
+
export declare const FORM_CONTROL_ELEMENTS: readonly FormControlElement[];
|
|
7
|
+
export declare const COMPOSED_ELEMENTS: readonly ComposedElement[];
|
|
8
|
+
/** Props of each element that may be bound to data (everything else takes design tokens only). */
|
|
9
|
+
export declare const ELEMENT_BINDABLE: Record<ComposedElement, readonly string[]>;
|
|
10
|
+
/** Interactive containers: not the root of an overlay frame. */
|
|
11
|
+
export declare const INTERACTIVE_CONTAINERS: readonly ComposedElement[];
|
|
12
|
+
/** Elements that render interactive content (not allowed inside a clickable Box/Card, at any depth). */
|
|
13
|
+
export declare const INTERACTIVE_ELEMENTS: readonly ComposedElement[];
|
|
14
|
+
/** Elements that become a link or button with a bound `href` or a valid `action`. */
|
|
15
|
+
export declare const CLICKABLE_ELEMENTS: readonly ComposedElement[];
|
|
16
|
+
/** Max length of a Tooltip `text` bound to a constant. */
|
|
17
|
+
export declare const TOOLTIP_TEXT_MAX = 200;
|
|
18
|
+
export declare const COMPOSED_FIELD_KINDS: readonly ["text", "longText", "richText", "number", "boolean", "select", "image", "link"];
|
|
19
|
+
export type ComposedFieldKind = (typeof COMPOSED_FIELD_KINDS)[number];
|
|
20
|
+
export type BindSource = {
|
|
21
|
+
from: 'entry';
|
|
22
|
+
path: string;
|
|
23
|
+
} | {
|
|
24
|
+
from: 'entryUrl';
|
|
25
|
+
} | {
|
|
26
|
+
from: 'field';
|
|
27
|
+
name: string;
|
|
28
|
+
} | {
|
|
29
|
+
from: 'const';
|
|
30
|
+
value: unknown;
|
|
31
|
+
};
|
|
32
|
+
export interface ComposedNode {
|
|
33
|
+
el: ComposedElement;
|
|
34
|
+
props?: Record<string, unknown>;
|
|
35
|
+
bind?: Record<string, BindSource>;
|
|
36
|
+
showIf?: {
|
|
37
|
+
from: 'entry' | 'field';
|
|
38
|
+
path?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
is: 'present' | 'absent';
|
|
41
|
+
};
|
|
42
|
+
children?: ComposedNode[];
|
|
43
|
+
style?: NodeStyle;
|
|
44
|
+
}
|
|
45
|
+
export interface ComposedField {
|
|
46
|
+
kind: ComposedFieldKind;
|
|
47
|
+
label?: LocalizedText | string;
|
|
48
|
+
default?: unknown;
|
|
49
|
+
/** Required for `select`, not allowed on other kinds. */
|
|
50
|
+
options?: (string | number)[];
|
|
51
|
+
}
|
|
52
|
+
export interface ComposedBinding {
|
|
53
|
+
apiId: string;
|
|
54
|
+
mode: 'single' | 'collection';
|
|
55
|
+
filter?: {
|
|
56
|
+
field: string;
|
|
57
|
+
value: unknown;
|
|
58
|
+
}[];
|
|
59
|
+
sort?: {
|
|
60
|
+
field: string;
|
|
61
|
+
direction: 'asc' | 'desc';
|
|
62
|
+
};
|
|
63
|
+
limit?: number;
|
|
64
|
+
/** `columns`: 2-6 for grid, the desktop per-view count 1-6 for carousel. */
|
|
65
|
+
layout?: {
|
|
66
|
+
kind: 'grid' | 'list' | 'carousel';
|
|
67
|
+
columns?: number;
|
|
68
|
+
};
|
|
69
|
+
urlPattern?: string;
|
|
70
|
+
options?: {
|
|
71
|
+
editorFilter?: boolean;
|
|
72
|
+
editorSort?: boolean;
|
|
73
|
+
editorLimit?: boolean;
|
|
74
|
+
editorLayout?: boolean;
|
|
75
|
+
emptyText?: LocalizedText;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface ComposedBlockSpec {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
label: LocalizedText;
|
|
82
|
+
category: string;
|
|
83
|
+
icon?: string;
|
|
84
|
+
version: number;
|
|
85
|
+
binding?: ComposedBinding;
|
|
86
|
+
fields: Record<string, ComposedField>;
|
|
87
|
+
tree: ComposedNode;
|
|
88
|
+
}
|
|
89
|
+
export type ComposedBlockKind = 'block' | 'layout' | 'overlay';
|
|
90
|
+
export type ComposedIssue = {
|
|
91
|
+
path: (string | number)[];
|
|
92
|
+
message: string;
|
|
93
|
+
};
|
|
94
|
+
/** Block field names `defineBlocks` accepts. */
|
|
95
|
+
export declare const BLOCK_FIELD_KEY_RE: RegExp;
|
|
96
|
+
/** Prop names used by core or Puck on every block item (`defineBlocks` rejects them as field names). */
|
|
97
|
+
export declare const RESERVED_BLOCK_PROPS: readonly string[];
|
|
98
|
+
/** Reserved props stamped on composed (and `usesLocale`) block items. */
|
|
99
|
+
export declare const COMPOSED_RESERVED_PROPS: readonly string[];
|
|
100
|
+
/**
|
|
101
|
+
* Field names `defineComposedBlock` may generate (`entry`, `entries`, `layout`, `slot`, `slot2`, …). Manual fields
|
|
102
|
+
* never use them, whatever the binding and tree, so a later binding or Slot cannot clash with stored content.
|
|
103
|
+
*/
|
|
104
|
+
export declare const COMPOSED_GENERATED_FIELD_RE: RegExp;
|
|
105
|
+
/** `key` of a `CollectionList` (its generated block field name). */
|
|
106
|
+
export declare const COLLECTION_LIST_KEY_RE: RegExp;
|
|
107
|
+
/** Max `CollectionList`s per block. */
|
|
108
|
+
export declare const MAX_COLLECTION_LISTS = 4;
|
|
109
|
+
/** Max `limit` of a `CollectionList`. */
|
|
110
|
+
export declare const COLLECTION_LIST_MAX_LIMIT = 50;
|
|
111
|
+
/** Default `limit` of a `CollectionList`. */
|
|
112
|
+
export declare const COLLECTION_LIST_DEFAULT_LIMIT = 12;
|
|
113
|
+
/** Props of a `CollectionList` node (its children are the item template). */
|
|
114
|
+
export interface CollectionListProps {
|
|
115
|
+
key: string;
|
|
116
|
+
apiId: string;
|
|
117
|
+
filter?: {
|
|
118
|
+
field: string;
|
|
119
|
+
value: unknown;
|
|
120
|
+
}[];
|
|
121
|
+
sort?: {
|
|
122
|
+
field: string;
|
|
123
|
+
direction: 'asc' | 'desc';
|
|
124
|
+
};
|
|
125
|
+
/** 1-50, default 12. */
|
|
126
|
+
limit?: number;
|
|
127
|
+
/** `columns`: 2-6 for grid, the desktop per-view count 1-6 for carousel. Default `{ kind: 'grid', columns: 3 }`. */
|
|
128
|
+
layout?: {
|
|
129
|
+
kind: 'grid' | 'list' | 'carousel';
|
|
130
|
+
columns?: number;
|
|
131
|
+
};
|
|
132
|
+
emptyText?: LocalizedText;
|
|
133
|
+
urlPattern?: string;
|
|
134
|
+
/** Options page editors may change. */
|
|
135
|
+
editor?: {
|
|
136
|
+
filter?: boolean;
|
|
137
|
+
sort?: boolean;
|
|
138
|
+
limit?: boolean;
|
|
139
|
+
layout?: boolean;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Why `name` cannot be a manual field of a composed block (null when it can). */
|
|
143
|
+
export declare function composedFieldNameIssue(name: string): string | null;
|
|
144
|
+
/** Image, Box or Card with a bound `href` or a valid `action` (renders as a link or button). */
|
|
145
|
+
export declare function isClickable(node: unknown): boolean;
|
|
146
|
+
export interface ValidateComposedOptions {
|
|
147
|
+
/**
|
|
148
|
+
* apiIds of the content types with a detail page. When given, `entryUrl` without a `urlPattern` is an issue unless
|
|
149
|
+
* the bound type is in the set; when absent (no type context), such an `entryUrl` is accepted.
|
|
150
|
+
*/
|
|
151
|
+
detailTypes?: ReadonlySet<string>;
|
|
152
|
+
/**
|
|
153
|
+
* The server's action manifest. When given, `run` actions must name one of its actions or a built-in, with valid
|
|
154
|
+
* params; when absent only their shape is checked.
|
|
155
|
+
*/
|
|
156
|
+
actions?: ActionManifest;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* True when `key` is reserved for a CollectionList of a spec of `kind`: generated field names (`entry`, `entries`,
|
|
160
|
+
* `layout`, `slot…`, `region`), core block props, `Object.prototype` names, `name` in an overlay and `pageContent`
|
|
161
|
+
* in a layout. Manual field names and the other lists' keys are checked separately.
|
|
162
|
+
*/
|
|
163
|
+
export declare function isReservedListKey(key: string, kind?: ComposedBlockKind): boolean;
|
|
164
|
+
/** Suffix of a CollectionList's generated editor layout field: `<key>__layout`. */
|
|
165
|
+
export declare const LIST_LAYOUT_SUFFIX = "__layout";
|
|
166
|
+
/**
|
|
167
|
+
* apiIds whose detail path an `entryUrl` of the tree uses: inside a CollectionList without its own `urlPattern` the
|
|
168
|
+
* list's type; elsewhere the binding's type when the binding has no `urlPattern` (decisions 6, 9).
|
|
169
|
+
*/
|
|
170
|
+
export declare function composedDetailLinks(spec: Pick<ComposedBlockSpec, 'tree' | 'binding'>): string[];
|
|
171
|
+
export declare function validateComposedSpec(spec: unknown, opts?: ValidateComposedOptions): ComposedIssue[];
|
|
172
|
+
export declare function composedManifestEntry(spec: ComposedBlockSpec): {
|
|
173
|
+
name: string;
|
|
174
|
+
version: number;
|
|
175
|
+
richText?: string[];
|
|
176
|
+
kind?: ComposedBlockKind;
|
|
177
|
+
};
|
|
178
|
+
/** `ProductCard` → `product-card` (block folders and file names, default overlay names). */
|
|
179
|
+
export declare function kebabName(name: string): string;
|
|
180
|
+
/** Default `name` of an overlay block placement: the block name in kebab case, cut to the overlay name length. */
|
|
181
|
+
export declare function overlayDefaultName(blockName: string): string;
|
|
182
|
+
/**
|
|
183
|
+
* Identity of each `Slot` of `tree`, in tree order (the order `defineComposedBlock` names them `slot`, `slot2`, …):
|
|
184
|
+
* its position path (child indices) and its sorted `allow` list (`*` = any block).
|
|
185
|
+
*/
|
|
186
|
+
export declare function slotSignature(tree: ComposedNode | undefined): string[];
|
|
187
|
+
/**
|
|
188
|
+
* True when stored content of a slot would land in another slot or be dropped: fewer slots, or any existing slot
|
|
189
|
+
* moved or given another `allow`. A slot added after the existing ones is not breaking.
|
|
190
|
+
*/
|
|
191
|
+
export declare function slotsChanged(prev: ComposedBlockSpec, next: ComposedBlockSpec): boolean;
|
|
192
|
+
/** `overlay` when the tree root is an `Overlay`, `layout` when it holds a `Region` or `PageContent`, else `block`. */
|
|
193
|
+
export declare function composedKind(spec: Pick<ComposedBlockSpec, 'tree'> | undefined): ComposedBlockKind;
|
|
194
|
+
/** Names of the valid, first-seen `Region`s of `spec`, in tree order. */
|
|
195
|
+
export declare function regionNames(spec: Pick<ComposedBlockSpec, 'tree'> | undefined): string[];
|
|
196
|
+
/**
|
|
197
|
+
* The `CollectionList`s of `spec` with a valid, first-seen `key`, in tree order (each one's key is its generated
|
|
198
|
+
* `b.entries` block field).
|
|
199
|
+
*/
|
|
200
|
+
export declare function collectionListsOf(spec: Pick<ComposedBlockSpec, 'tree'> | undefined): {
|
|
201
|
+
key: string;
|
|
202
|
+
node: ComposedNode;
|
|
203
|
+
}[];
|
|
204
|
+
export declare function isBreakingChange(prev: ComposedBlockSpec, next: ComposedBlockSpec): boolean;
|
|
205
|
+
export declare function withAutoVersion(prev: ComposedBlockSpec | null, next: ComposedBlockSpec): ComposedBlockSpec;
|