@nextblock-cms/cortex 0.21.1 → 0.21.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./zod-config.cjs");let e=require("zod");var t=[`text`,`heading`,`image`,`button`,`posts_grid`,`video_embed`,`section`,`form`,`testimonial`,`product_grid`,`featured_product`,`cart`,`checkout`,`product_details`],n=e.z.enum(t),r=e.z.object({direction:e.z.string().optional(),stops:e.z.array(e.z.object({color:e.z.string(),position:e.z.number()})),type:e.z.enum([`linear`,`radial`])}),i=e.z.object({gradient:r.optional(),image:e.z.object({alt_text:e.z.string().optional(),blur_data_url:e.z.string().optional(),external_url:e.z.string().optional(),height:e.z.number().optional(),media_id:e.z.string().optional(),object_key:e.z.string().optional(),overlay:e.z.object({gradient:r,type:e.z.literal(`gradient`)}).optional(),position:e.z.enum([`center`,`top`,`bottom`,`left`,`right`]),quality:e.z.number().nullable().optional(),size:e.z.enum([`cover`,`contain`]),width:e.z.number().optional()}).optional(),min_height:e.z.string().optional(),solid_color:e.z.string().optional(),theme:e.z.enum([`primary`,`secondary`,`muted`,`accent`,`destructive`]).optional(),type:e.z.enum([`none`,`theme`,`solid`,`gradient`,`image`])}),a=e.z.string().regex(/^[a-z][a-z0-9-]*$/),o=e.z.object({block_type:e.z.union([n,a]),content:e.z.record(e.z.string(),e.z.any()),temp_id:e.z.string().optional()}),s=e.z.object({background:i,column_blocks:e.z.array(e.z.array(o))}),c=e.z.object({autoplay:e.z.boolean().optional(),background:i,column_blocks:e.z.array(e.z.array(o)),column_gap:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`]),container_type:e.z.enum([`full-width`,`container`,`container-sm`,`container-lg`,`container-xl`]),is_hero:e.z.boolean().optional(),padding:e.z.object({bottom:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`]),top:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`])}),responsive_columns:e.z.object({desktop:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3),e.z.literal(4)]),mobile:e.z.union([e.z.literal(1),e.z.literal(2)]),tablet:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3)])}),slider:e.z.boolean().optional(),slides:e.z.array(s).optional(),timeframe:e.z.number().optional(),vertical_alignment:e.z.enum([`start`,`center`,`end`,`stretch`]).optional()}),l={button:e.z.object({position:e.z.enum([`left`,`center`,`right`]).optional(),size:e.z.enum([`default`,`sm`,`lg`,`full`]).optional(),text:e.z.string(),url:e.z.string(),variant:e.z.enum([`default`,`outline`,`secondary`,`ghost`,`link`]).optional()}),cart:e.z.object({}),checkout:e.z.object({}),featured_product:e.z.object({imagePosition:e.z.enum([`left`,`right`]).default(`left`),productId:e.z.string().min(1),showBackground:e.z.boolean().default(!1)}),form:e.z.object({fields:e.z.array(e.z.object({field_type:e.z.enum([`text`,`email`,`tel`,`url`,`number`,`textarea`,`select`,`radio`,`checkbox`]),is_required:e.z.boolean(),label:e.z.string(),options:e.z.array(e.z.object({label:e.z.string(),value:e.z.string()})).optional(),placeholder:e.z.string().optional(),temp_id:e.z.string()})),form_key:e.z.string().optional(),recipient_email:e.z.string().email().optional(),submit_button_text:e.z.string(),success_message:e.z.string()}),heading:e.z.object({level:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3),e.z.literal(4),e.z.literal(5),e.z.literal(6)]),textAlign:e.z.enum([`left`,`center`,`right`,`justify`]).optional(),textColor:e.z.union([e.z.enum([`foreground`,`primary`,`secondary`,`accent`,`muted`,`destructive`,`background`]),e.z.string().regex(/^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^)]+\)|hsla?\([^)]+\))$/i,`Must be a hex, rgb(a) or hsl(a) colour`)]).optional().describe(`Prefer a theme token so the heading adapts to dark mode; use a CSS colour only when the brand requires an exact value`),text_content:e.z.string()}),image:e.z.object({alt_text:e.z.string().optional(),caption:e.z.string().optional(),external_url:e.z.string().nullable().optional(),height:e.z.number().nullable().optional(),media_id:e.z.string().nullable().optional(),object_key:e.z.string().nullable().optional(),width:e.z.number().nullable().optional()}),posts_grid:e.z.object({columns:e.z.number().min(1).max(6),postsPerPage:e.z.number().min(1).max(50),showPagination:e.z.boolean(),title:e.z.string().optional()}),product_details:e.z.object({}),product_grid:e.z.object({categoryId:e.z.string().optional(),categoryIds:e.z.array(e.z.string()).max(20).optional(),limit:e.z.number().min(0).max(48).default(6),productIds:e.z.array(e.z.string()).max(24).optional(),showPagination:e.z.boolean().default(!1),title:e.z.string().optional(),type:e.z.enum([`latest`,`category`,`manual`]).default(`latest`)}),section:c,testimonial:e.z.object({author_name:e.z.string().min(1),author_title:e.z.string().optional(),image_url:e.z.string().url().optional().or(e.z.literal(``)),quote:e.z.string().min(1)}),text:e.z.object({html_content:e.z.string()}),video_embed:e.z.object({autoplay:e.z.boolean().optional(),controls:e.z.boolean().optional(),title:e.z.string().optional(),url:e.z.string()})};function u(e){return t.includes(e)}function d(e){return typeof e?.validateBlockContent==`function`?e.validateBlockContent:null}function f(e,t,n){let r=d(n);if(r)return r(e,t);let i=l[e].safeParse(t);return i.success?{errors:[],isValid:!0,warnings:[]}:{errors:i.error.issues.map(e=>{let t=e.path.join(`.`);return t?`${t}: ${e.message}`:e.message}),isValid:!1,warnings:[]}}function p(e){return Array.isArray(e.fields)?e.fields.filter(e=>!!e&&typeof e==`object`&&typeof e.key==`string`&&typeof e.type==`string`):[]}function m(e){return e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0}function h(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return{errors:[`content must be a JSON object of { field_key: value } pairs.`],isValid:!1,warnings:[]};let n=p(e),r=new Set(n.map(e=>e.key)),i=[],a=[];for(let n of Object.keys(t))r.has(n)||i.push(`Unknown field "${n}" for custom block "${e.slug}". Known fields: ${[...r].join(`, `)||`(none)`}.`);for(let e of n){let n=t[e.key];if(m(n)){e.required&&i.push(`Field "${e.key}" is required.`);continue}if(e.type===`text`||e.type===`rich-text`){if(typeof n!=`string`){i.push(`Field "${e.key}" must be a string${e.type===`rich-text`?` of HTML`:``}.`);continue}typeof e.max_length==`number`&&n.length>e.max_length&&i.push(`Field "${e.key}" exceeds its ${e.max_length}-character limit.`),typeof e.min_length==`number`&&n.length<e.min_length&&i.push(`Field "${e.key}" is shorter than its ${e.min_length}-character minimum.`);continue}if(e.type===`image_r2`){let t=n;(typeof n!=`object`||Array.isArray(n)||typeof t.object_key!=`string`||typeof t.url!=`string`)&&i.push(`Field "${e.key}" must be an uploaded image object with object_key and url (upload it with upload_media first) or null.`);continue}if(e.type===`db_relation`){let t=e=>typeof e==`string`||typeof e==`number`;e.multiple?(!Array.isArray(n)||!n.every(t))&&i.push(`Field "${e.key}" must be an array of related record ids.`):t(n)||i.push(`Field "${e.key}" must be a single related record id.`);continue}a.push(`Field "${e.key}" has an unrecognised type "${String(e.type)}"; it was not validated.`)}return{errors:i,isValid:i.length===0,warnings:a}}async function g(e){let{data:t,error:n}=await e.from(`custom_block_definitions`).select(`slug, name, fields`);if(n)throw Error(`Could not read the custom block definitions: ${typeof n==`object`&&n&&`message`in n?String(n.message):String(n)}`);return(Array.isArray(t)?t:[]).filter(e=>!!e&&typeof e.slug==`string`)}exports.availableCortexAiBlockTypes=t,exports.cortexAiBlockTypeSchema=n,exports.customBlockSlugPatternSchema=a,exports.fallbackBlockSchemas=l,exports.isValidBlockType=u,exports.loadCustomBlockDefinitions=g,exports.readCustomBlockFields=p,exports.sectionBlockFallbackSchema=c,exports.validateCortexBlockContent=f,exports.validateCustomBlockInstanceContent=h;
|
|
1
|
+
require("./zod-config.cjs");let e=require("zod");var t=[`text`,`heading`,`image`,`button`,`posts_grid`,`video_embed`,`section`,`form`,`testimonial`,`product_grid`,`featured_product`,`cart`,`checkout`,`product_details`],n=e.z.enum(t),r=e.z.object({direction:e.z.string().optional(),stops:e.z.array(e.z.object({color:e.z.string(),position:e.z.number()})),type:e.z.enum([`linear`,`radial`])}),i=e.z.object({gradient:r.optional(),image:e.z.object({alt_text:e.z.string().optional(),blur_data_url:e.z.string().optional(),external_url:e.z.string().optional(),height:e.z.number().optional(),media_id:e.z.string().optional(),object_key:e.z.string().optional(),overlay:e.z.object({gradient:r,type:e.z.literal(`gradient`)}).optional(),position:e.z.enum([`center`,`top`,`bottom`,`left`,`right`]),quality:e.z.number().nullable().optional(),size:e.z.enum([`cover`,`contain`]),width:e.z.number().optional()}).optional(),min_height:e.z.string().optional(),solid_color:e.z.string().optional(),theme:e.z.enum([`primary`,`secondary`,`muted`,`accent`,`destructive`]).optional(),type:e.z.enum([`none`,`theme`,`solid`,`gradient`,`image`])}),a=e.z.string().regex(/^[a-z][a-z0-9-]*$/),o=e.z.object({block_type:e.z.union([n,a]),content:e.z.record(e.z.string(),e.z.any()),temp_id:e.z.string().optional()}),s=e.z.object({background:i,column_blocks:e.z.array(e.z.array(o))}),c=e.z.object({autoplay:e.z.boolean().optional(),background:i,column_blocks:e.z.array(e.z.array(o)),column_gap:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`]),container_type:e.z.enum([`full-width`,`container`,`container-sm`,`container-lg`,`container-xl`]),is_hero:e.z.boolean().optional(),padding:e.z.object({bottom:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`]),top:e.z.enum([`none`,`sm`,`md`,`lg`,`xl`])}),responsive_columns:e.z.object({desktop:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3),e.z.literal(4)]),mobile:e.z.union([e.z.literal(1),e.z.literal(2)]),tablet:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3)])}),slider:e.z.boolean().optional(),slides:e.z.array(s).optional(),timeframe:e.z.number().optional(),vertical_alignment:e.z.enum([`start`,`center`,`end`,`stretch`]).optional()}),l={button:e.z.object({position:e.z.enum([`left`,`center`,`right`]).optional(),size:e.z.enum([`default`,`sm`,`lg`,`full`]).optional(),text:e.z.string(),url:e.z.string(),variant:e.z.enum([`default`,`outline`,`secondary`,`ghost`,`link`]).optional()}),cart:e.z.object({}),checkout:e.z.object({}),featured_product:e.z.object({imagePosition:e.z.enum([`left`,`right`]).default(`left`),productId:e.z.string().min(1),showBackground:e.z.boolean().default(!1)}),form:e.z.object({fields:e.z.array(e.z.object({field_type:e.z.enum([`text`,`email`,`tel`,`url`,`number`,`textarea`,`select`,`radio`,`checkbox`]),is_required:e.z.boolean(),label:e.z.string(),options:e.z.array(e.z.object({label:e.z.string(),value:e.z.string()})).optional(),placeholder:e.z.string().optional(),temp_id:e.z.string()})),form_key:e.z.string().optional(),recipient_email:e.z.string().email().optional(),submit_button_text:e.z.string(),success_message:e.z.string()}),heading:e.z.object({level:e.z.union([e.z.literal(1),e.z.literal(2),e.z.literal(3),e.z.literal(4),e.z.literal(5),e.z.literal(6)]),textAlign:e.z.enum([`left`,`center`,`right`,`justify`]).optional(),textColor:e.z.union([e.z.enum([`foreground`,`primary`,`secondary`,`accent`,`muted`,`destructive`,`background`]),e.z.string().regex(/^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^)]+\)|hsla?\([^)]+\))$/i,`Must be a hex, rgb(a) or hsl(a) colour`)]).optional().describe(`Prefer a theme token so the heading adapts to dark mode; use a CSS colour only when the brand requires an exact value`),text_content:e.z.string()}),image:e.z.object({alt_text:e.z.string().optional(),caption:e.z.string().optional(),external_url:e.z.string().nullable().optional(),height:e.z.number().nullable().optional(),media_id:e.z.string().nullable().optional(),object_key:e.z.string().nullable().optional(),width:e.z.number().nullable().optional()}),posts_grid:e.z.object({anchor:e.z.string().regex(/^([a-z][a-z0-9-]{0,63})?$/).optional(),columns:e.z.number().min(1).max(6),postsPerPage:e.z.number().min(1).max(50),showPagination:e.z.boolean(),title:e.z.string().optional()}),product_details:e.z.object({}),product_grid:e.z.object({categoryId:e.z.string().optional(),categoryIds:e.z.array(e.z.string()).max(20).optional(),limit:e.z.number().min(0).max(48).default(6),productIds:e.z.array(e.z.string()).max(24).optional(),showPagination:e.z.boolean().default(!1),title:e.z.string().optional(),type:e.z.enum([`latest`,`category`,`manual`]).default(`latest`)}),section:c,testimonial:e.z.object({author_name:e.z.string().min(1),author_title:e.z.string().optional(),image_url:e.z.string().url().optional().or(e.z.literal(``)),quote:e.z.string().min(1)}),text:e.z.object({html_content:e.z.string()}),video_embed:e.z.object({autoplay:e.z.boolean().optional(),controls:e.z.boolean().optional(),title:e.z.string().optional(),url:e.z.string()})};function u(e){return t.includes(e)}function d(e){return typeof e?.validateBlockContent==`function`?e.validateBlockContent:null}function f(e,t,n){let r=d(n);if(r)return r(e,t);let i=l[e].safeParse(t);return i.success?{errors:[],isValid:!0,warnings:[]}:{errors:i.error.issues.map(e=>{let t=e.path.join(`.`);return t?`${t}: ${e.message}`:e.message}),isValid:!1,warnings:[]}}function p(e){return Array.isArray(e.fields)?e.fields.filter(e=>!!e&&typeof e==`object`&&typeof e.key==`string`&&typeof e.type==`string`):[]}function m(e){return e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0}function h(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return{errors:[`content must be a JSON object of { field_key: value } pairs.`],isValid:!1,warnings:[]};let n=p(e),r=new Set(n.map(e=>e.key)),i=[],a=[];for(let n of Object.keys(t))r.has(n)||i.push(`Unknown field "${n}" for custom block "${e.slug}". Known fields: ${[...r].join(`, `)||`(none)`}.`);for(let e of n){let n=t[e.key];if(m(n)){e.required&&i.push(`Field "${e.key}" is required.`);continue}if(e.type===`text`||e.type===`rich-text`){if(typeof n!=`string`){i.push(`Field "${e.key}" must be a string${e.type===`rich-text`?` of HTML`:``}.`);continue}typeof e.max_length==`number`&&n.length>e.max_length&&i.push(`Field "${e.key}" exceeds its ${e.max_length}-character limit.`),typeof e.min_length==`number`&&n.length<e.min_length&&i.push(`Field "${e.key}" is shorter than its ${e.min_length}-character minimum.`);continue}if(e.type===`image_r2`){let t=n;(typeof n!=`object`||Array.isArray(n)||typeof t.object_key!=`string`||typeof t.url!=`string`)&&i.push(`Field "${e.key}" must be an uploaded image object with object_key and url (upload it with upload_media first) or null.`);continue}if(e.type===`db_relation`){let t=e=>typeof e==`string`||typeof e==`number`;e.multiple?(!Array.isArray(n)||!n.every(t))&&i.push(`Field "${e.key}" must be an array of related record ids.`):t(n)||i.push(`Field "${e.key}" must be a single related record id.`);continue}a.push(`Field "${e.key}" has an unrecognised type "${String(e.type)}"; it was not validated.`)}return{errors:i,isValid:i.length===0,warnings:a}}async function g(e){let{data:t,error:n}=await e.from(`custom_block_definitions`).select(`slug, name, fields`);if(n)throw Error(`Could not read the custom block definitions: ${typeof n==`object`&&n&&`message`in n?String(n.message):String(n)}`);return(Array.isArray(t)?t:[]).filter(e=>!!e&&typeof e.slug==`string`)}exports.availableCortexAiBlockTypes=t,exports.cortexAiBlockTypeSchema=n,exports.customBlockSlugPatternSchema=a,exports.fallbackBlockSchemas=l,exports.isValidBlockType=u,exports.loadCustomBlockDefinitions=g,exports.readCustomBlockFields=p,exports.sectionBlockFallbackSchema=c,exports.validateCortexBlockContent=f,exports.validateCustomBlockInstanceContent=h;
|
|
@@ -220,6 +220,7 @@ var t = [
|
|
|
220
220
|
width: e.number().nullable().optional()
|
|
221
221
|
}),
|
|
222
222
|
posts_grid: e.object({
|
|
223
|
+
anchor: e.string().regex(/^([a-z][a-z0-9-]{0,63})?$/).optional(),
|
|
223
224
|
columns: e.number().min(1).max(6),
|
|
224
225
|
postsPerPage: e.number().min(1).max(50),
|
|
225
226
|
showPagination: e.boolean(),
|
|
@@ -12,7 +12,7 @@ import { CortexAiMcpScope } from './mcp-tokens';
|
|
|
12
12
|
*
|
|
13
13
|
* 1. JSON Schema. MCP `tools/list` transmits raw JSON Schema; the registry stores Zod.
|
|
14
14
|
* 2. Scopes. A read-only token must not even *see* the mutating tools.
|
|
15
|
-
* 3. Aliases. The MCP contract names
|
|
15
|
+
* 3. Aliases. The MCP contract names six tools that already exist here under
|
|
16
16
|
* different names (see CORTEX_MCP_TOOL_ALIASES).
|
|
17
17
|
* 4. MCP result envelopes (`content` / `isError` / `structuredContent`).
|
|
18
18
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/cortex",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.3",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ai-sdk/openai-compatible": "^3.0.53",
|
|
32
|
-
"@nextblock-cms/db": "^0.21.
|
|
33
|
-
"@nextblock-cms/ecommerce": "npm:@nextblock-cms/ecom@^0.21.
|
|
34
|
-
"@nextblock-cms/utils": "^0.21.
|
|
32
|
+
"@nextblock-cms/db": "^0.21.3",
|
|
33
|
+
"@nextblock-cms/ecommerce": "npm:@nextblock-cms/ecom@^0.21.3",
|
|
34
|
+
"@nextblock-cms/utils": "^0.21.3",
|
|
35
35
|
"ai": "^7.0.107",
|
|
36
36
|
"zod": "^4.6.5"
|
|
37
37
|
},
|